mod: 推荐视频标签展示、页面跳转
This commit is contained in:
@ -1,22 +1,27 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class UpTag extends StatelessWidget {
|
class UpTag extends StatelessWidget {
|
||||||
const UpTag({super.key});
|
final String? tagText;
|
||||||
|
const UpTag({super.key, this.tagText = 'UP'});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
return Container(
|
return Container(
|
||||||
width: 14,
|
padding: const EdgeInsets.fromLTRB(3, 1, 3, 1),
|
||||||
height: 10,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(2),
|
borderRadius: BorderRadius.circular(3),
|
||||||
border: Border.all(color: Theme.of(context).colorScheme.outline)),
|
color: tagText == 'UP' ? primary : null,
|
||||||
margin: const EdgeInsets.only(right: 4),
|
border: Border.all(color: primary)),
|
||||||
|
margin: const EdgeInsets.only(right: 5),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'UP',
|
tagText!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 6, color: Theme.of(context).colorScheme.outline),
|
fontSize: 9,
|
||||||
|
color: tagText == 'UP'
|
||||||
|
? Theme.of(context).colorScheme.onPrimary
|
||||||
|
: primary,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
|
import 'package:pilipala/common/widgets/badge.dart';
|
||||||
import 'package:pilipala/common/widgets/stat/danmu.dart';
|
import 'package:pilipala/common/widgets/stat/danmu.dart';
|
||||||
|
import 'package:pilipala/common/widgets/stat/up.dart';
|
||||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||||
|
import 'package:pilipala/http/search.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
|
import 'package:pilipala/models/common/search_type.dart';
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
@ -23,6 +29,44 @@ class VideoCardV extends StatelessWidget {
|
|||||||
this.longPressEnd,
|
this.longPressEnd,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
void onPushDetail(heroTag) async {
|
||||||
|
String goto = videoItem.goto;
|
||||||
|
switch (goto) {
|
||||||
|
case 'bangumi':
|
||||||
|
if (videoItem.bangumiBadge == '电影') {
|
||||||
|
SmartDialog.showToast('暂不支持电影观看');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int epId = videoItem.param;
|
||||||
|
SmartDialog.showLoading(msg: '资源获取中');
|
||||||
|
var result = await SearchHttp.bangumiInfo(seasonId: null, epId: epId);
|
||||||
|
if (result['status']) {
|
||||||
|
var bangumiDetail = result['data'];
|
||||||
|
int cid = bangumiDetail.episodes!.first.cid;
|
||||||
|
String bvid = IdUtils.av2bv(bangumiDetail.episodes!.first.aid);
|
||||||
|
SmartDialog.dismiss().then(
|
||||||
|
(value) => Get.toNamed(
|
||||||
|
'/video?bvid=$bvid&cid=$cid&epId=$epId',
|
||||||
|
arguments: {
|
||||||
|
'pic': videoItem.pic,
|
||||||
|
'heroTag': heroTag,
|
||||||
|
'videoType': SearchType.media_bangumi,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'av':
|
||||||
|
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
|
||||||
|
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}', arguments: {
|
||||||
|
// 'videoItem': videoItem,
|
||||||
|
'pic': videoItem.pic,
|
||||||
|
'heroTag': heroTag,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String heroTag = Utils.makeHeroTag(videoItem.id);
|
String heroTag = Utils.makeHeroTag(videoItem.id);
|
||||||
@ -45,11 +89,7 @@ class VideoCardV extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async => onPushDetail(heroTag),
|
||||||
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
|
|
||||||
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
|
|
||||||
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
|
|
||||||
},
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
@ -126,11 +166,15 @@ class VideoContent extends StatelessWidget {
|
|||||||
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
if (videoItem.goto == 'bangumi') ...[
|
||||||
|
UpTag(
|
||||||
|
tagText: videoItem.bangumiBadge,
|
||||||
|
),
|
||||||
|
],
|
||||||
if (videoItem.rcmdReason != null &&
|
if (videoItem.rcmdReason != null &&
|
||||||
videoItem.rcmdReason.content != '' ||
|
videoItem.rcmdReason.content != '') ...[
|
||||||
videoItem.isFollowed == 1) ...[
|
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.fromLTRB(3, 0, 3, 0),
|
padding: const EdgeInsets.fromLTRB(3, 1, 3, 1),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
@ -139,21 +183,19 @@ class VideoContent extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(3)),
|
borderRadius: BorderRadius.circular(3)),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
videoItem.rcmdReason != null &&
|
videoItem.rcmdReason.content,
|
||||||
videoItem.rcmdReason.content != ''
|
|
||||||
? videoItem.rcmdReason.content
|
|
||||||
: '已关注',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: 11,
|
||||||
.textTheme
|
|
||||||
.labelSmall!
|
|
||||||
.fontSize,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
const SizedBox(width: 4)
|
const SizedBox(width: 4)
|
||||||
],
|
],
|
||||||
|
if (videoItem.adInfo != null)
|
||||||
|
const UpTag(
|
||||||
|
tagText: '推广',
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: LayoutBuilder(builder:
|
child: LayoutBuilder(builder:
|
||||||
(BuildContext context, BoxConstraints constraints) {
|
(BuildContext context, BoxConstraints constraints) {
|
||||||
|
@ -47,8 +47,7 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future rcmdVideoListApp(
|
static Future rcmdVideoListApp({int? ps, required int freshIdx}) async {
|
||||||
{required int ps, required int freshIdx}) async {
|
|
||||||
try {
|
try {
|
||||||
var res = await Request().get(
|
var res = await Request().get(
|
||||||
Api.recommendListApp,
|
Api.recommendListApp,
|
||||||
|
@ -20,6 +20,8 @@ class RecVideoItemAppModel {
|
|||||||
this.bangumiView,
|
this.bangumiView,
|
||||||
this.bangumiFollow,
|
this.bangumiFollow,
|
||||||
this.bangumiBadge,
|
this.bangumiBadge,
|
||||||
|
this.cardType,
|
||||||
|
this.adInfo,
|
||||||
});
|
});
|
||||||
|
|
||||||
int? id;
|
int? id;
|
||||||
@ -34,7 +36,7 @@ class RecVideoItemAppModel {
|
|||||||
Owner? owner;
|
Owner? owner;
|
||||||
RcmdReason? rcmdReason;
|
RcmdReason? rcmdReason;
|
||||||
String? goto;
|
String? goto;
|
||||||
String? param;
|
int? param;
|
||||||
String? uri;
|
String? uri;
|
||||||
String? talkBack;
|
String? talkBack;
|
||||||
// 番剧
|
// 番剧
|
||||||
@ -42,6 +44,9 @@ class RecVideoItemAppModel {
|
|||||||
String? bangumiFollow;
|
String? bangumiFollow;
|
||||||
String? bangumiBadge;
|
String? bangumiBadge;
|
||||||
|
|
||||||
|
String? cardType;
|
||||||
|
Map? adInfo;
|
||||||
|
|
||||||
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
||||||
id = json['player_args'] != null
|
id = json['player_args'] != null
|
||||||
? json['player_args']['aid']
|
? json['player_args']['aid']
|
||||||
@ -58,7 +63,7 @@ class RecVideoItemAppModel {
|
|||||||
? RcmdReason.fromJson(json['rcmd_reason_style'])
|
? RcmdReason.fromJson(json['rcmd_reason_style'])
|
||||||
: null;
|
: null;
|
||||||
goto = json['goto'];
|
goto = json['goto'];
|
||||||
param = json['param'];
|
param = int.parse(json['param']);
|
||||||
uri = json['uri'];
|
uri = json['uri'];
|
||||||
talkBack = json['talk_back'];
|
talkBack = json['talk_back'];
|
||||||
|
|
||||||
@ -67,6 +72,9 @@ class RecVideoItemAppModel {
|
|||||||
bangumiFollow = json['cover_left_text_2'];
|
bangumiFollow = json['cover_left_text_2'];
|
||||||
bangumiBadge = json['badge'];
|
bangumiBadge = json['badge'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cardType = json['card_type'];
|
||||||
|
adInfo = json['ad_info'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +121,6 @@ class RcmdReason {
|
|||||||
String? content;
|
String? content;
|
||||||
|
|
||||||
RcmdReason.fromJson(Map<String, dynamic> json) {
|
RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||||
content = json["title"] ?? '';
|
content = json["text"] ?? '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,14 @@ import 'package:get/get.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/video.dart';
|
import 'package:pilipala/http/video.dart';
|
||||||
import 'package:pilipala/models/home/rcmd/result.dart';
|
import 'package:pilipala/models/home/rcmd/result.dart';
|
||||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
class RcmdController extends GetxController {
|
class RcmdController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
int count = 12;
|
|
||||||
int _currentPage = 0;
|
int _currentPage = 0;
|
||||||
int crossAxisCount = 2;
|
int crossAxisCount = 2;
|
||||||
RxList<RecVideoItemAppModel> videoList = [RecVideoItemAppModel()].obs;
|
RxList<RecVideoItemAppModel> videoList = [RecVideoItemAppModel()].obs;
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
bool flag = false;
|
|
||||||
OverlayEntry? popupDialog;
|
OverlayEntry? popupDialog;
|
||||||
Box recVideo = GStrorage.recVideo;
|
Box recVideo = GStrorage.recVideo;
|
||||||
|
|
||||||
@ -36,7 +33,6 @@ class RcmdController extends GetxController {
|
|||||||
_currentPage = 0;
|
_currentPage = 0;
|
||||||
}
|
}
|
||||||
var res = await VideoHttp.rcmdVideoListApp(
|
var res = await VideoHttp.rcmdVideoListApp(
|
||||||
ps: count,
|
|
||||||
freshIdx: _currentPage,
|
freshIdx: _currentPage,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
|
Reference in New Issue
Block a user