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