Merge branch 'main' into feature-updateVideoDetailStructure

This commit is contained in:
guozhigq
2024-04-30 15:52:01 +08:00
42 changed files with 1084 additions and 766 deletions

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../models/common/video_episode_type.dart';
@ -44,27 +45,52 @@ class EpisodeBottomSheet {
title = '${episode.title}${episode.longTitle!}';
break;
}
return ListTile(
onTap: () {
SmartDialog.showToast('切换至「$title');
changeFucCall.call(episode, index);
},
dense: false,
leading: isCurrentIndex
? Image.asset(
'assets/images/live.gif',
color: primary,
height: 12,
)
: null,
title: Text(
title,
style: TextStyle(
fontSize: 14,
color: isCurrentIndex ? primary : onSurface,
),
),
);
return isFullScreen || episode?.cover == null || episode?.cover == ''
? ListTile(
onTap: () {
SmartDialog.showToast('切换至「$title');
changeFucCall.call(episode, index);
},
dense: false,
leading: isCurrentIndex
? Image.asset(
'assets/images/live.gif',
color: primary,
height: 12,
)
: null,
title: Text(title,
style: TextStyle(
fontSize: 14,
color: isCurrentIndex ? primary : onSurface,
)))
: InkWell(
onTap: () {
SmartDialog.showToast('切换至「$title');
changeFucCall.call(episode, index);
},
child: Padding(
padding:
const EdgeInsets.only(left: 14, right: 14, top: 8, bottom: 8),
child: Row(
children: [
NetworkImgLayer(
width: 130, height: 75, src: episode?.cover ?? ''),
const SizedBox(width: 10),
Expanded(
child: Text(
title,
maxLines: 2,
style: TextStyle(
fontSize: 14,
color: isCurrentIndex ? primary : onSurface,
),
),
),
],
),
),
);
}
Widget buildTitle() {

View File

@ -36,7 +36,6 @@ class NetworkImgLayer extends StatelessWidget {
final int defaultImgQuality = GlobalData().imgQuality;
final String imageUrl =
'${src!.startsWith('//') ? 'https:${src!}' : src!}@${quality ?? defaultImgQuality}q.webp';
// print(imageUrl);
int? memCacheWidth, memCacheHeight;
double aspectRatio = (width / height).toDouble();

View File

@ -62,6 +62,7 @@ class OverlayPop extends StatelessWidget {
Expanded(
child: Text(
videoItem.title! as String,
style: Theme.of(context).textTheme.titleSmall,
),
),
const SizedBox(width: 4),

View File

@ -23,6 +23,7 @@ class VideoCardH extends StatelessWidget {
this.showView = true,
this.showDanmaku = true,
this.showPubdate = false,
this.showCharge = false,
});
// ignore: prefer_typing_uninitialized_variables
final videoItem;
@ -33,6 +34,7 @@ class VideoCardH extends StatelessWidget {
final bool showView;
final bool showDanmaku;
final bool showPubdate;
final bool showCharge;
@override
Widget build(BuildContext context) {
@ -121,6 +123,13 @@ class VideoCardH extends StatelessWidget {
// videoItem.rcmdReason.content != '')
// pBadge(videoItem.rcmdReason.content, context,
// 6.0, 6.0, null, null),
if (showCharge && videoItem?.isChargingSrc)
const PBadge(
text: '充电专属',
right: 6.0,
top: 6.0,
type: 'primary',
),
],
);
},

View File

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/utils/feed_back.dart';
import '../../models/model_rec_video_item.dart';
import 'overlay_pop.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
import '../../http/dynamics.dart';
@ -19,15 +21,11 @@ import 'network_img_layer.dart';
class VideoCardV extends StatelessWidget {
final dynamic videoItem;
final int crossAxisCount;
final Function()? longPress;
final Function()? longPressEnd;
const VideoCardV({
Key? key,
required this.videoItem,
required this.crossAxisCount,
this.longPress,
this.longPressEnd,
}) : super(key: key);
bool isStringNumeric(String str) {
@ -127,64 +125,56 @@ class VideoCardV extends StatelessWidget {
@override
Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(videoItem.id);
return Card(
elevation: 0,
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.zero,
child: GestureDetector(
onLongPress: () {
if (longPress != null) {
longPress!();
}
},
// onLongPressEnd: (details) {
// if (longPressEnd != null) {
// longPressEnd!();
// }
// },
child: InkWell(
onTap: () async => onPushDetail(heroTag),
child: Column(
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
src: videoItem.pic,
width: maxWidth,
height: maxHeight,
),
),
if (videoItem.duration > 0)
if (crossAxisCount == 1) ...[
PBadge(
bottom: 10,
right: 10,
text: Utils.timeFormat(videoItem.duration),
)
] else ...[
PBadge(
bottom: 6,
right: 7,
size: 'small',
type: 'gray',
text: Utils.timeFormat(videoItem.duration),
)
],
],
);
}),
),
VideoContent(videoItem: videoItem, crossAxisCount: crossAxisCount)
],
return InkWell(
onTap: () async => onPushDetail(heroTag),
onLongPress: () {
SmartDialog.show(
builder: (context) => OverlayPop(
videoItem: videoItem,
closeFn: () => SmartDialog.dismiss(),
),
),
);
},
borderRadius: BorderRadius.circular(16),
child: Column(
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
src: videoItem.pic,
width: maxWidth,
height: maxHeight,
),
),
if (videoItem.duration > 0)
if (crossAxisCount == 1) ...[
PBadge(
bottom: 10,
right: 10,
text: Utils.timeFormat(videoItem.duration),
)
] else ...[
PBadge(
bottom: 6,
right: 7,
size: 'small',
type: 'gray',
text: Utils.timeFormat(videoItem.duration),
)
],
],
);
}),
),
VideoContent(videoItem: videoItem, crossAxisCount: crossAxisCount)
],
),
);
}
@ -196,122 +186,90 @@ class VideoContent extends StatelessWidget {
const VideoContent(
{Key? key, required this.videoItem, required this.crossAxisCount})
: super(key: key);
Widget _buildBadge(String text, String type, [double fs = 12]) {
return PBadge(
text: text,
stack: 'normal',
size: 'small',
type: type,
fs: fs,
);
}
@override
Widget build(BuildContext context) {
return Expanded(
flex: crossAxisCount == 1 ? 0 : 1,
child: Padding(
padding: crossAxisCount == 1
? const EdgeInsets.fromLTRB(9, 9, 9, 4)
: const EdgeInsets.fromLTRB(5, 8, 5, 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Expanded(
child: Text(
videoItem.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
if (videoItem.goto == 'av' && crossAxisCount == 1) ...[
const SizedBox(width: 10),
VideoPopupMenu(
size: 32,
iconSize: 18,
videoItem: videoItem,
),
],
],
),
if (crossAxisCount > 1) ...[
const SizedBox(height: 2),
VideoStat(
videoItem: videoItem,
crossAxisCount: crossAxisCount,
),
],
if (crossAxisCount == 1) const SizedBox(height: 4),
Row(
children: [
if (videoItem.goto == 'bangumi') ...[
PBadge(
text: videoItem.bangumiBadge,
stack: 'normal',
size: 'small',
type: 'line',
fs: 9,
)
],
if (videoItem.rcmdReason != null &&
videoItem.rcmdReason.content != '') ...[
PBadge(
text: videoItem.rcmdReason.content,
stack: 'normal',
size: 'small',
type: 'color',
)
],
if (videoItem.goto == 'picture') ...[
const PBadge(
text: '动态',
stack: 'normal',
size: 'small',
type: 'line',
fs: 9,
)
],
if (videoItem.isFollowed == 1) ...[
const PBadge(
text: '已关注',
stack: 'normal',
size: 'small',
type: 'color',
)
],
Expanded(
flex: crossAxisCount == 1 ? 0 : 1,
child: Text(
videoItem.owner.name,
maxLines: 1,
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
),
if (crossAxisCount == 1) ...[
Text(
'',
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
VideoStat(
videoItem: videoItem,
crossAxisCount: crossAxisCount,
),
const Spacer(),
],
if (videoItem.goto == 'av' && crossAxisCount != 1) ...[
VideoPopupMenu(
size: 24,
iconSize: 14,
videoItem: videoItem,
),
] else ...[
const SizedBox(height: 24)
]
],
),
return Padding(
padding: crossAxisCount == 1
? const EdgeInsets.fromLTRB(9, 9, 9, 4)
: const EdgeInsets.fromLTRB(5, 8, 5, 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
videoItem.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
if (crossAxisCount > 1) ...[
const SizedBox(height: 2),
VideoStat(videoItem: videoItem, crossAxisCount: crossAxisCount),
],
),
if (crossAxisCount == 1) const SizedBox(height: 4),
Row(
children: [
if (videoItem.goto == 'bangumi')
_buildBadge(videoItem.bangumiBadge, 'line', 9),
if (videoItem.rcmdReason?.content != null &&
videoItem.rcmdReason.content != '')
_buildBadge(videoItem.rcmdReason.content, 'color'),
if (videoItem.goto == 'picture') _buildBadge('动态', 'line', 9),
if (videoItem.isFollowed == 1) _buildBadge('已关注', 'color'),
Expanded(
flex: crossAxisCount == 1 ? 0 : 1,
child: Text(
videoItem.owner.name,
maxLines: 1,
style: TextStyle(
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
),
if (crossAxisCount == 1) ...[
const SizedBox(width: 10),
VideoStat(
videoItem: videoItem,
crossAxisCount: crossAxisCount,
),
const Spacer(),
],
if (videoItem.goto == 'av')
SizedBox(
width: 24,
height: 24,
child: IconButton(
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
useRootNavigator: true,
isScrollControlled: true,
builder: (context) {
return MorePanel(videoItem: videoItem);
},
);
},
icon: Icon(
Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline,
size: 14,
),
),
)
],
),
],
),
);
}
@ -331,15 +289,9 @@ class VideoStat extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
children: [
StatView(
theme: 'gray',
view: videoItem.stat.view,
),
StatView(theme: 'gray', view: videoItem.stat.view),
const SizedBox(width: 8),
StatDanMu(
theme: 'gray',
danmu: videoItem.stat.danmu,
),
StatDanMu(theme: 'gray', danmu: videoItem.stat.danmu),
if (videoItem is RecVideoItemModel) ...<Widget>[
crossAxisCount > 1 ? const Spacer() : const SizedBox(width: 8),
RichText(
@ -358,99 +310,98 @@ class VideoStat extends StatelessWidget {
}
}
class VideoPopupMenu extends StatelessWidget {
final double? size;
final double? iconSize;
class MorePanel extends StatelessWidget {
final dynamic videoItem;
const MorePanel({super.key, required this.videoItem});
const VideoPopupMenu({
Key? key,
required this.size,
required this.iconSize,
required this.videoItem,
}) : super(key: key);
Future<dynamic> menuActionHandler(String type) async {
switch (type) {
case 'block':
blockUser();
break;
case 'watchLater':
var res = await UserHttp.toViewLater(bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg']);
Get.back();
break;
default:
}
}
void blockUser() async {
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text('确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?'
'\n\n被拉黑的Up可以在隐私设置-黑名单管理中解除'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'点错了',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await VideoHttp.relationMod(
mid: videoItem.owner.mid,
act: 5,
reSrc: 11,
);
SmartDialog.dismiss();
SmartDialog.showToast(res['msg'] ?? '成功');
},
child: const Text('确认'),
)
],
);
},
);
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: size,
height: size,
child: PopupMenuButton<String>(
padding: EdgeInsets.zero,
icon: Icon(
Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline,
size: iconSize,
),
position: PopupMenuPosition.under,
// constraints: const BoxConstraints(maxHeight: 35),
onSelected: (String type) {},
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
PopupMenuItem<String>(
onTap: () async {
var res =
await UserHttp.toViewLater(bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg']);
},
value: 'pause',
height: 40,
child: const Row(
children: [
Icon(Icons.watch_later_outlined, size: 16),
SizedBox(width: 6),
Text('稍后再看', style: TextStyle(fontSize: 13))
],
return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
),
),
const PopupMenuDivider(),
PopupMenuItem<String>(
onTap: () async {
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text(
'确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?'
'\n\n被拉黑的Up可以在隐私设置-黑名单管理中解除'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'点错了',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await VideoHttp.relationMod(
mid: videoItem.owner.mid,
act: 5,
reSrc: 11,
);
SmartDialog.dismiss();
SmartDialog.showToast(res['msg'] ?? '成功');
},
child: const Text('确认'),
)
],
);
},
);
},
value: 'pause',
height: 40,
child: Row(
children: [
const Icon(Icons.block, size: 16),
const SizedBox(width: 6),
Text('拉黑:${videoItem.owner.name}',
style: const TextStyle(fontSize: 13))
],
ListTile(
onTap: () async => await menuActionHandler('block'),
minLeadingWidth: 0,
leading: const Icon(Icons.block, size: 19),
title: Text(
'拉黑up主 「${videoItem.owner.name}',
style: Theme.of(context).textTheme.titleSmall,
),
),
ListTile(
onTap: () async => await menuActionHandler('watchLater'),
minLeadingWidth: 0,
leading: const Icon(Icons.watch_later_outlined, size: 19),
title:
Text('添加至稍后再看', style: Theme.of(context).textTheme.titleSmall),
),
],
),
);

View File

@ -22,19 +22,14 @@ class ReplyHttp {
return {
'status': true,
'data': ReplyData.fromJson(res.data['data']),
'code': 200,
};
} else {
Map errMap = {
-400: '请求错误',
-404: '无此项',
12002: '当前页面评论功能已关闭',
12009: '评论主体的type不合法',
12061: 'UP主已关闭评论区',
};
return {
'status': false,
'date': [],
'msg': errMap[res.data['code']] ?? res.data['message'],
'code': res.data['code'],
'msg': res.data['message'],
};
}
}

View File

@ -35,7 +35,7 @@ class VideoHttp {
Api.recommendListWeb,
data: {
'version': 1,
'feed_version': 'V8',
'feed_version': 'V3',
'homepage_ver': 1,
'ps': ps,
'fresh_idx': freshIdx,
@ -192,22 +192,15 @@ class VideoHttp {
// 视频信息 标题、简介
static Future videoIntro({required String bvid}) async {
var res = await Request().get(Api.videoIntro, data: {'bvid': bvid});
VideoDetailResponse result = VideoDetailResponse.fromJson(res.data);
if (result.code == 0) {
if (res.data['code'] == 0) {
VideoDetailResponse result = VideoDetailResponse.fromJson(res.data);
return {'status': true, 'data': result.data!};
} else {
Map errMap = {
-400: '请求错误',
-403: '权限不足',
-404: '视频资源失效',
62002: '稿件不可见',
62004: '稿件审核中',
};
return {
'status': false,
'data': null,
'code': result.code,
'msg': errMap[result.code] ?? '请求异常',
'code': res.data['code'],
'msg': res.data['message'],
};
}
}

View File

@ -65,6 +65,20 @@ void main() async {
},
);
// 小白条、导航栏沉浸
if (Platform.isAndroid) {
List<String> versionParts = Platform.version.split('.');
int androidVersion = int.parse(versionParts[0]);
if (androidVersion >= 29) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
}
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: Colors.transparent,
statusBarColor: Colors.transparent,
));
}
Data.init();
GlobalData();
PiliSchame.init();
@ -130,26 +144,33 @@ class MyApp extends StatelessWidget {
);
}
ThemeData themeData = ThemeData(
colorScheme: currentThemeValue == ThemeType.dark
? darkColorScheme
: lightColorScheme,
);
// ThemeData themeData = ThemeData(
// colorScheme: currentThemeValue == ThemeType.dark
// ? darkColorScheme
// : lightColorScheme,
// );
// 小白条、导航栏沉浸
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
systemNavigationBarColor: GlobalData().enableMYBar
? const Color(0x00010000)
: themeData.canvasColor,
systemNavigationBarDividerColor: GlobalData().enableMYBar
? const Color(0x00010000)
: themeData.canvasColor,
systemNavigationBarIconBrightness: currentThemeValue == ThemeType.dark
? Brightness.light
: Brightness.dark,
statusBarColor: Colors.transparent,
));
// // 小白条、导航栏沉浸
// if (Platform.isAndroid) {
// List<String> versionParts = Platform.version.split('.');
// int androidVersion = int.parse(versionParts[0]);
// if (androidVersion >= 29) {
// SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
// }
// SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
// systemNavigationBarColor: GlobalData().enableMYBar
// ? const Color(0x00010000)
// : themeData.canvasColor,
// systemNavigationBarDividerColor: GlobalData().enableMYBar
// ? const Color(0x00010000)
// : themeData.canvasColor,
// systemNavigationBarIconBrightness:
// currentThemeValue == ThemeType.dark
// ? Brightness.light
// : Brightness.dark,
// statusBarColor: Colors.transparent,
// ));
// }
// 图片缓存
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;

View File

@ -414,6 +414,7 @@ class DynamicMajorModel {
this.none,
this.type,
this.courses,
this.common,
});
DynamicArchiveModel? archive;
@ -429,6 +430,7 @@ class DynamicMajorModel {
// MAJOR_TYPE_OPUS 图文/文章
String? type;
Map? courses;
Map? common;
DynamicMajorModel.fromJson(Map<String, dynamic> json) {
archive = json['archive'] != null
@ -452,6 +454,7 @@ class DynamicMajorModel {
json['none'] != null ? DynamicNoneModel.fromJson(json['none']) : null;
type = json['type'];
courses = json['courses'] ?? {};
common = json['common'] ?? {};
}
}

View File

@ -23,6 +23,7 @@ class HotVideoItemModel {
this.dimension,
this.shortLinkV2,
this.firstFrame,
this.cover,
this.pubLocation,
this.seasontype,
this.isOgv,
@ -50,6 +51,7 @@ class HotVideoItemModel {
Dimension? dimension;
String? shortLinkV2;
String? firstFrame;
String? cover;
String? pubLocation;
int? seasontype;
bool? isOgv;
@ -77,6 +79,7 @@ class HotVideoItemModel {
dimension = Dimension.fromMap(json['dimension']);
shortLinkV2 = json["short_link_v2"];
firstFrame = json["first_frame"];
cover = json["first_frame"];
pubLocation = json["pub_location"];
seasontype = json["seasontype"];
isOgv = json["isOgv"];

View File

@ -39,6 +39,14 @@ extension VideoQualityCode on VideoQuality {
}
return null;
}
static int? toCode(VideoQuality quality) {
final index = VideoQuality.values.indexOf(quality);
if (index != -1 && index < _codeList.length) {
return _codeList[index];
}
return null;
}
}
extension VideoQualityDesc on VideoQuality {

View File

@ -67,6 +67,7 @@ class VideoDetailData {
String? likeIcon;
bool? needJumpBv;
String? epId;
List<Staff>? staff;
VideoDetailData({
this.bvid,
@ -103,6 +104,7 @@ class VideoDetailData {
this.likeIcon,
this.needJumpBv,
this.epId,
this.staff,
});
VideoDetailData.fromJson(Map<String, dynamic> json) {
@ -155,6 +157,9 @@ class VideoDetailData {
if (json['redirect_url'] != null) {
epId = resolveEpId(json['redirect_url']);
}
staff = json["staff"] != null
? List<Staff>.from(json["staff"]!.map((e) => Staff.fromJson(e)))
: null;
}
String resolveEpId(url) {
@ -377,6 +382,7 @@ class Part {
String? weblink;
Dimension? dimension;
String? firstFrame;
String? cover;
Part({
this.cid,
@ -388,6 +394,7 @@ class Part {
this.weblink,
this.dimension,
this.firstFrame,
this.cover,
});
fromRawJson(String str) => Part.fromJson(json.decode(str));
@ -405,7 +412,8 @@ class Part {
dimension = json["dimension"] == null
? null
: Dimension.fromJson(json["dimension"]);
firstFrame = json["first_frame"];
firstFrame = json["first_frame"] ?? '';
cover = json["first_frame"] ?? '';
}
Map<String, dynamic> toJson() {
@ -629,6 +637,7 @@ class EpisodeItem {
this.attribute,
this.page,
this.bvid,
this.cover,
});
int? seasonId;
int? sectionId;
@ -639,6 +648,7 @@ class EpisodeItem {
int? attribute;
Part? page;
String? bvid;
String? cover;
EpisodeItem.fromJson(Map<String, dynamic> json) {
seasonId = json['season_id'];
@ -650,5 +660,46 @@ class EpisodeItem {
attribute = json['attribute'];
page = Part.fromJson(json['page']);
bvid = json['bvid'];
cover = json['arc']['pic'];
}
}
class Staff {
Staff({
this.mid,
this.title,
this.name,
this.face,
this.vip,
});
int? mid;
String? title;
String? name;
String? face;
int? status;
Vip? vip;
Staff.fromJson(Map<String, dynamic> json) {
mid = json['mid'];
title = json['title'];
name = json['name'];
face = json['face'];
vip = Vip.fromJson(json['vip']);
}
}
class Vip {
Vip({
this.type,
this.status,
});
int? type;
int? status;
Vip.fromJson(Map<String, dynamic> json) {
type = json['type'];
status = json['status'];
}
}

View File

@ -131,51 +131,37 @@ class BangumiIntroController extends GetxController {
builder: (context) {
return AlertDialog(
title: const Text('选择投币个数'),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
RadioListTile(
value: 1,
title: const Text('1枚'),
groupValue: _tempThemeValue,
onChanged: (value) {
_tempThemeValue = value!;
Get.appUpdate();
},
),
RadioListTile(
value: 2,
title: const Text('2枚'),
groupValue: _tempThemeValue,
onChanged: (value) {
_tempThemeValue = value!;
Get.appUpdate();
},
),
],
children: [1, 2]
.map(
(e) => RadioListTile(
value: e,
title: Text('$e枚'),
groupValue: _tempThemeValue,
onChanged: (value) async {
_tempThemeValue = value!;
setState(() {});
var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue);
if (res['status']) {
SmartDialog.showToast('投币成功 👏');
hasCoin.value = true;
bangumiDetail.value.stat!['coins'] =
bangumiDetail.value.stat!['coins'] +
_tempThemeValue;
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
),
)
.toList(),
);
}),
actions: [
TextButton(onPressed: () => Get.back(), child: const Text('取消')),
TextButton(
onPressed: () async {
var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue);
if (res['status']) {
SmartDialog.showToast('投币成功 👏');
hasCoin.value = true;
bangumiDetail.value.stat!['coins'] =
bangumiDetail.value.stat!['coins'] + _tempThemeValue;
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
child: const Text('确定'),
)
],
);
});
}
@ -229,13 +215,15 @@ class BangumiIntroController extends GetxController {
}
// 修改分P或番剧分集
Future changeSeasonOrbangu(bvid, cid, aid) async {
Future changeSeasonOrbangu(bvid, cid, aid, cover) async {
// 重新获取视频资源
VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
videoDetailCtr.bvid = bvid;
videoDetailCtr.cid.value = cid;
videoDetailCtr.danmakuCid.value = cid;
videoDetailCtr.oid.value = aid;
videoDetailCtr.cover.value = cover;
videoDetailCtr.queryVideoUrl();
// 重新请求评论
try {
@ -294,7 +282,8 @@ class BangumiIntroController extends GetxController {
int cid = episodes[nextIndex].cid!;
String bvid = episodes[nextIndex].bvid!;
int aid = episodes[nextIndex].aid!;
changeSeasonOrbangu(bvid, cid, aid);
String cover = episodes[nextIndex].cover!;
changeSeasonOrbangu(bvid, cid, aid, cover);
}
// 播放器底栏 选集 回调
@ -315,7 +304,7 @@ class BangumiIntroController extends GetxController {
sheetHeight: Get.size.height,
isFullScreen: true,
changeFucCall: (item, index) {
changeSeasonOrbangu(item.bvid, item.cid, item.aid);
changeSeasonOrbangu(item.bvid, item.cid, item.aid, item.cover);
SmartDialog.dismiss();
},
).buildShowContent(Get.context!),

View File

@ -322,8 +322,8 @@ class _BangumiInfoState extends State<BangumiInfo> {
pages: widget.bangumiDetail!.episodes!,
cid: cid! ?? widget.bangumiDetail!.episodes!.first.cid!,
sheetHeight: sheetHeight,
changeFuc: (bvid, cid, aid) =>
bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid),
changeFuc: (bvid, cid, aid, cover) => bangumiIntroController
.changeSeasonOrbangu(bvid, cid, aid, cover),
bangumiDetail: bangumiIntroController.bangumiDetail.value,
bangumiIntroController: bangumiIntroController,
)

View File

@ -84,9 +84,12 @@ class _BangumiPanelState extends State<BangumiPanel> {
item.bvid,
item.cid,
item.aid,
item.cover,
);
_bottomSheetController?.close();
currentIndex = i;
if (_bottomSheetController != null) {
_bottomSheetController?.close();
}
currentIndex.value = i;
scrollToIndex();
}

View File

@ -25,6 +25,7 @@ class DynamicDetailController extends GetxController {
RxString sortTypeTitle = ReplySortType.time.titles.obs;
RxString sortTypeLabel = ReplySortType.time.labels.obs;
Box setting = GStrorage.setting;
RxInt replyReqCode = 200.obs;
@override
void onInit() {
@ -84,6 +85,7 @@ class DynamicDetailController extends GetxController {
replyList.addAll(replies);
}
}
replyReqCode.value = res['code'];
isLoadingMore = false;
return res;
}

View File

@ -369,35 +369,40 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
curve: Curves.easeInOut,
),
),
child: FloatingActionButton(
heroTag: null,
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _dynamicDetailController.oid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.values[replyType],
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'] != null)
{
_dynamicDetailController.replyList.add(value['data']),
_dynamicDetailController.acount.value++
}
},
);
},
tooltip: '评论动态',
child: const Icon(Icons.reply),
child: Obx(
() => _dynamicDetailController.replyReqCode.value == 12061
? const SizedBox()
: FloatingActionButton(
heroTag: null,
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _dynamicDetailController.oid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.values[replyType],
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'] != null)
{
_dynamicDetailController.replyList
.add(value['data']),
_dynamicDetailController.acount.value++
}
},
);
},
tooltip: '评论动态',
child: const Icon(Icons.reply),
),
),
),
);

View File

@ -2,6 +2,7 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/utils/utils.dart';
import 'additional_panel.dart';
@ -182,6 +183,61 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
)
],
);
// 活动
case 'DYNAMIC_TYPE_COMMON_SQUARE':
return Padding(
padding: const EdgeInsets.only(top: 8),
child: InkWell(
onTap: () {
Get.toNamed('/webview', parameters: {
'url': item.modules.moduleDynamic.major.common['jump_url'],
'type': 'url',
'pageTitle': item.modules.moduleDynamic.major.common['title']
});
},
child: Container(
width: double.infinity,
padding:
const EdgeInsets.only(left: 12, top: 10, right: 12, bottom: 10),
color: Theme.of(context).dividerColor.withOpacity(0.08),
child: Row(
children: [
NetworkImgLayer(
width: 45,
height: 45,
src: item.modules.moduleDynamic.major.common['cover'],
),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.modules.moduleDynamic.major.common['title'],
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
item.modules.moduleDynamic.major.common['desc'],
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
)
],
),
// TextButton(onPressed: () {}, child: Text('123'))
),
),
);
default:
return const SizedBox(
width: double.infinity,

View File

@ -214,6 +214,34 @@ class UserInfoWidget extends StatelessWidget {
final VoidCallback? callback;
final HomeController? ctr;
Widget buildLoggedInWidget(context) {
return Stack(
children: [
NetworkImgLayer(
type: 'avatar',
width: 34,
height: 34,
src: userFace,
),
Positioned.fill(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () => callback?.call(),
splashColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.3),
borderRadius: const BorderRadius.all(
Radius.circular(50),
),
),
),
)
],
);
}
@override
Widget build(BuildContext context) {
return Row(
@ -231,31 +259,7 @@ class UserInfoWidget extends StatelessWidget {
const SizedBox(width: 8),
Obx(
() => userLogin.value
? Stack(
children: [
NetworkImgLayer(
type: 'avatar',
width: 34,
height: 34,
src: userFace,
),
Positioned.fill(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () => callback?.call(),
splashColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.3),
borderRadius: const BorderRadius.all(
Radius.circular(50),
),
),
),
)
],
)
? buildLoggedInWidget(context)
: DefaultUser(callback: () => callback!()),
),
],
@ -402,30 +406,27 @@ class SearchBar extends StatelessWidget {
color: colorScheme.onSecondaryContainer.withOpacity(0.05),
child: InkWell(
splashColor: colorScheme.primaryContainer.withOpacity(0.3),
onTap: () => Get.toNamed(
'/search',
parameters: {'hintText': ctr!.defaultSearch.value},
),
child: Row(
children: [
const SizedBox(width: 14),
Icon(
Icons.search_outlined,
color: colorScheme.onSecondaryContainer,
),
const SizedBox(width: 10),
Obx(
() => Expanded(
child: Text(
onTap: () => Get.toNamed('/search',
parameters: {'hintText': ctr!.defaultSearch.value}),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Row(
children: [
Icon(
Icons.search_outlined,
color: colorScheme.onSecondaryContainer,
),
const SizedBox(width: 10),
Obx(
() => Text(
ctr!.defaultSearch.value,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: colorScheme.outline),
),
),
),
const SizedBox(width: 15),
],
],
),
),
),
),

View File

@ -79,6 +79,7 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
videoItem: list[index],
showOwner: false,
showPubdate: true,
showCharge: true,
);
},
childCount: list.length,

View File

@ -5,9 +5,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/skeleton/video_card_v.dart';
import 'package:pilipala/common/widgets/animated_dialog.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/overlay_pop.dart';
import 'package:pilipala/common/widgets/video_card_v.dart';
import 'package:pilipala/utils/main_stream.dart';
@ -118,16 +116,6 @@ class _RcmdPageState extends State<RcmdPage>
);
}
OverlayEntry _createPopupDialog(videoItem) {
return OverlayEntry(
builder: (context) => AnimatedDialog(
closeFn: _rcmdController.popupDialog?.remove,
child: OverlayPop(
videoItem: videoItem, closeFn: _rcmdController.popupDialog?.remove),
),
);
}
Widget contentGrid(ctr, videoList) {
// double maxWidth = Get.size.width;
// int baseWidth = 500;
@ -158,14 +146,6 @@ class _RcmdPageState extends State<RcmdPage>
? VideoCardV(
videoItem: videoList[index],
crossAxisCount: crossAxisCount,
longPress: () {
_rcmdController.popupDialog =
_createPopupDialog(videoList[index]);
Overlay.of(context).insert(_rcmdController.popupDialog!);
},
longPressEnd: () {
_rcmdController.popupDialog?.remove();
},
)
: const VideoCardVSkeleton();
},

View File

@ -131,7 +131,7 @@ class _PlaySettingState extends State<PlaySetting> {
title: '开启硬解',
subTitle: '以较低功耗播放视频',
setKey: SettingBoxKey.enableHA,
defaultVal: true,
defaultVal: false,
),
const SetSwitchItem(
title: '观看人数',

View File

@ -29,7 +29,7 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
return AlertDialog(
title: Text(widget.title),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return SingleChildScrollView(
child: Column(

View File

@ -51,7 +51,7 @@ class VideoDetailController extends GetxController
/// 播放器配置 画质 音质 解码格式
late VideoQuality currentVideoQa;
AudioQuality? currentAudioQa;
late VideoDecodeFormats currentDecodeFormats;
VideoDecodeFormats? currentDecodeFormats;
// 是否开始自动播放 存在多p的情况下第二p需要为true
RxBool autoPlay = true.obs;
// 视频资源是否有效
@ -59,7 +59,7 @@ class VideoDetailController extends GetxController
// 封面图的展示
RxBool isShowCover = true.obs;
// 硬解
RxBool enableHA = true.obs;
RxBool enableHA = false.obs;
/// 本地存储
Box userInfoCache = GStrorage.userInfo;
@ -73,6 +73,7 @@ class VideoDetailController extends GetxController
ReplyItemModel? firstFloor;
final scaffoldKey = GlobalKey<ScaffoldState>();
RxString bgCover = ''.obs;
RxString cover = ''.obs;
PlPlayerController plPlayerController = PlPlayerController.getInstance();
late VideoItem firstVideo;
@ -107,28 +108,26 @@ class VideoDetailController extends GetxController
BottomControlType.fullscreen,
].obs;
RxDouble sheetHeight = 0.0.obs;
RxString archiveSourceType = 'dash'.obs;
@override
void onInit() {
super.onInit();
final Map argMap = Get.arguments;
userInfo = userInfoCache.get('userInfoCache');
var keys = argMap.keys.toList();
if (keys.isNotEmpty) {
if (keys.contains('videoItem')) {
var args = argMap['videoItem'];
if (args.pic != null && args.pic != '') {
videoItem['pic'] = args.pic;
}
}
if (keys.contains('pic')) {
videoItem['pic'] = argMap['pic'];
}
if (argMap.containsKey('videoItem')) {
var args = argMap['videoItem'];
updateCover(args.pic);
}
if (argMap.containsKey('pic')) {
updateCover(argMap['pic']);
}
tabCtr = TabController(length: 2, vsync: this);
autoPlay.value =
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: false);
enableRelatedVideo =
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
if (userInfo == null ||
@ -161,11 +160,11 @@ class VideoDetailController extends GetxController
getSubtitle();
}
showReplyReplyPanel() {
showReplyReplyPanel(oid, fRpid, firstFloor) {
replyReplyBottomSheetCtr =
scaffoldKey.currentState?.showBottomSheet((BuildContext context) {
return VideoReplyReplyPanel(
oid: oid.value,
oid: oid,
rpid: fRpid,
closePanel: () => {
fRpid = 0,
@ -189,37 +188,43 @@ class VideoDetailController extends GetxController
plPlayerController.isBuffering.value = false;
plPlayerController.buffered.value = Duration.zero;
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
List<VideoItem> videoList =
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
try {
firstVideo = videoList
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
} catch (_) {
if (currentVideoQa == VideoQuality.dolbyVision) {
firstVideo = videoList.first;
currentDecodeFormats =
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
} else {
// 当前格式不可用
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormats.values.last.code))!;
firstVideo = videoList
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
if (archiveSourceType.value == 'dash') {
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
List<VideoItem> videoList =
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
try {
firstVideo = videoList.firstWhere(
(i) => i.codecs!.startsWith(currentDecodeFormats?.code));
} catch (_) {
if (currentVideoQa == VideoQuality.dolbyVision) {
firstVideo = videoList.first;
currentDecodeFormats =
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
} else {
// 当前格式不可用
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormats.values.last.code))!;
firstVideo = videoList.firstWhere(
(i) => i.codecs!.startsWith(currentDecodeFormats?.code));
}
}
videoUrl = firstVideo.baseUrl!;
/// 根据currentAudioQa 重新设置audioUrl
if (currentAudioQa != null) {
final AudioItem firstAudio = data.dash!.audio!.firstWhere(
(AudioItem i) => i.id == currentAudioQa!.code,
orElse: () => data.dash!.audio!.first,
);
audioUrl = firstAudio.baseUrl ?? '';
}
}
videoUrl = firstVideo.baseUrl!;
/// 根据currentAudioQa 重新设置audioUrl
if (currentAudioQa != null) {
final AudioItem firstAudio = data.dash!.audio!.firstWhere(
(AudioItem i) => i.id == currentAudioQa!.code,
orElse: () => data.dash!.audio!.first,
);
audioUrl = firstAudio.baseUrl ?? '';
if (archiveSourceType.value == 'durl') {
cacheVideoQa = VideoQualityCode.toCode(currentVideoQa);
queryVideoUrl();
}
playerInit();
}
@ -272,7 +277,8 @@ class VideoDetailController extends GetxController
// 视频链接
Future queryVideoUrl() async {
var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid);
var result =
await VideoHttp.videoUrl(cid: cid.value, bvid: bvid, qn: cacheVideoQa);
if (result['status']) {
data = result['data'];
if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) {
@ -290,8 +296,22 @@ class VideoDetailController extends GetxController
}
return result;
}
if (data.durl != null) {
archiveSourceType.value = 'durl';
videoUrl = data.durl!.first.url!;
audioUrl = '';
defaultST = Duration.zero;
firstVideo = VideoItem();
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
if (autoPlay.value) {
await playerInit();
isShowCover.value = false;
}
return result;
}
final List<VideoItem> allVideosList = data.dash!.video!;
try {
archiveSourceType.value = 'dash';
// 当前可播放的最高质量视频
int currentHighVideoQa = allVideosList.first.quality!.code;
// 预设的画质为null则当前可用的最高质量
@ -321,7 +341,7 @@ class VideoDetailController extends GetxController
// 当前视频没有对应格式返回第一个
bool flag = false;
for (var i in supportDecodeFormats) {
if (i.startsWith(currentDecodeFormats.code)) {
if (i.startsWith(currentDecodeFormats?.code)) {
flag = true;
}
}
@ -335,7 +355,7 @@ class VideoDetailController extends GetxController
/// 取出符合当前解码格式的videoItem
try {
firstVideo = videosList.firstWhere(
(e) => e.codecs!.startsWith(currentDecodeFormats.code));
(e) => e.codecs!.startsWith(currentDecodeFormats?.code));
} catch (_) {
firstVideo = videosList.first;
}
@ -525,4 +545,10 @@ class VideoDetailController extends GetxController
},
);
}
void updateCover(String? pic) {
if (pic != null && pic != '') {
cover.value = videoItem['pic'] = pic;
}
}
}

View File

@ -90,6 +90,7 @@ class VideoIntroController extends GetxController {
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
videoDetailCtr.tabs.value = ['简介', '评论 ${result['data']?.stat?.reply}'];
videoDetailCtr.cover.value = result['data'].pic ?? '';
// 获取到粉丝数再返回
await queryUserStat();
}
@ -219,50 +220,36 @@ class VideoIntroController extends GetxController {
builder: (context) {
return AlertDialog(
title: const Text('选择投币个数'),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
RadioListTile(
value: 1,
title: const Text('1枚'),
groupValue: _tempThemeValue,
onChanged: (value) {
_tempThemeValue = value!;
Get.appUpdate();
},
),
RadioListTile(
value: 2,
title: const Text('2枚'),
groupValue: _tempThemeValue,
onChanged: (value) {
_tempThemeValue = value!;
Get.appUpdate();
},
),
],
children: [1, 2]
.map(
(e) => RadioListTile(
value: e,
title: Text('$e枚'),
groupValue: _tempThemeValue,
onChanged: (value) async {
_tempThemeValue = value!;
setState(() {});
var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue);
if (res['status']) {
SmartDialog.showToast('投币成功 👏');
hasCoin.value = true;
videoDetail.value.stat!.coin =
videoDetail.value.stat!.coin! + _tempThemeValue;
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
),
)
.toList(),
);
}),
actions: [
TextButton(onPressed: () => Get.back(), child: const Text('取消')),
TextButton(
onPressed: () async {
var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue);
if (res['status']) {
SmartDialog.showToast('投币成功 👏');
hasCoin.value = true;
videoDetail.value.stat!.coin =
videoDetail.value.stat!.coin! + _tempThemeValue;
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
child: const Text('确定'))
],
);
});
}
@ -446,7 +433,7 @@ class VideoIntroController extends GetxController {
}
// 修改分P或番剧分集
Future changeSeasonOrbangu(bvid, cid, aid) async {
Future changeSeasonOrbangu(bvid, cid, aid, cover) async {
// 重新获取视频资源
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
@ -461,6 +448,7 @@ class VideoIntroController extends GetxController {
videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid);
videoDetailCtr.cid.value = cid;
videoDetailCtr.danmakuCid.value = cid;
videoDetailCtr.cover.value = cover;
videoDetailCtr.queryVideoUrl();
// 重新请求评论
try {
@ -508,6 +496,7 @@ class VideoIntroController extends GetxController {
void nextPlay() {
final List episodes = [];
bool isPages = false;
late String cover;
if (videoDetail.value.ugcSeason != null) {
final UgcSeason ugcSeason = videoDetail.value.ugcSeason!;
final List<SectionItem> sections = ugcSeason.sections!;
@ -524,6 +513,7 @@ class VideoIntroController extends GetxController {
final int currentIndex =
episodes.indexWhere((e) => e.cid == lastPlayCid.value);
int nextIndex = currentIndex + 1;
cover = episodes[nextIndex].cover;
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
@ -540,7 +530,7 @@ class VideoIntroController extends GetxController {
final int cid = episodes[nextIndex].cid!;
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
changeSeasonOrbangu(rBvid, cid, rAid);
changeSeasonOrbangu(rBvid, cid, rAid, cover);
}
// 设置关注分组
@ -605,10 +595,11 @@ class VideoIntroController extends GetxController {
isFullScreen: true,
changeFucCall: (item, index) {
if (dataType == VideoEpidoesType.videoEpisode) {
changeSeasonOrbangu(IdUtils.av2bv(item.aid), item.cid, item.aid);
changeSeasonOrbangu(
IdUtils.av2bv(item.aid), item.cid, item.aid, item.cover);
}
if (dataType == VideoEpidoesType.videoPart) {
changeSeasonOrbangu(bvid, item.cid, null);
changeSeasonOrbangu(bvid, item.cid, null, item.cover);
}
SmartDialog.dismiss();
},

View File

@ -22,6 +22,7 @@ import 'widgets/fav_panel.dart';
import 'widgets/intro_detail.dart';
import 'widgets/page_panel.dart';
import 'widgets/season_panel.dart';
import 'widgets/staff_up_item.dart';
class VideoIntroPanel extends StatefulWidget {
final String bvid;
@ -380,11 +381,12 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
? videoIntroController.lastPlayCid.value
: widget.videoDetail!.pages!.first.cid,
sheetHeight: videoDetailCtr.sheetHeight.value,
changeFuc: (bvid, cid, aid) =>
changeFuc: (bvid, cid, aid, cover) =>
videoIntroController.changeSeasonOrbangu(
bvid,
cid,
aid,
cover,
),
videoIntroCtr: videoIntroController,
),
@ -398,77 +400,128 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
pages: widget.videoDetail!.pages!,
cid: videoIntroController.lastPlayCid.value,
sheetHeight: videoDetailCtr.sheetHeight.value,
changeFuc: (cid) => videoIntroController.changeSeasonOrbangu(
changeFuc: (cid, cover) =>
videoIntroController.changeSeasonOrbangu(
videoIntroController.bvid,
cid,
null,
cover,
),
videoIntroCtr: videoIntroController,
),
)
],
GestureDetector(
onTap: onPushMember,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 4),
child: Row(
children: [
NetworkImgLayer(
type: 'avatar',
src: widget.videoDetail!.owner!.face,
width: 34,
height: 34,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
const SizedBox(width: 10),
Text(owner.name, style: const TextStyle(fontSize: 13)),
const SizedBox(width: 6),
Text(
follower,
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: outline,
if (widget.videoDetail!.staff == null)
GestureDetector(
onTap: onPushMember,
child: Container(
padding:
const EdgeInsets.symmetric(vertical: 12, horizontal: 4),
child: Row(
children: [
NetworkImgLayer(
type: 'avatar',
src: widget.videoDetail!.owner!.face,
width: 34,
height: 34,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
),
const Spacer(),
Obx(
() {
final bool isFollowed =
videoIntroController.followStatus['attribute'] != 0;
return videoIntroController.followStatus.isEmpty
? const SizedBox()
: SizedBox(
height: 32,
child: TextButton(
onPressed:
videoIntroController.actionRelationMod,
style: TextButton.styleFrom(
padding: const EdgeInsets.only(
left: 8,
right: 8,
const SizedBox(width: 10),
Text(owner.name, style: const TextStyle(fontSize: 13)),
const SizedBox(width: 6),
Text(
follower,
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: outline,
),
),
const Spacer(),
Obx(
() {
final bool isFollowed =
videoIntroController.followStatus['attribute'] != 0;
return videoIntroController.followStatus.isEmpty
? const SizedBox()
: SizedBox(
height: 32,
child: TextButton(
onPressed:
videoIntroController.actionRelationMod,
style: TextButton.styleFrom(
padding: const EdgeInsets.only(
left: 8,
right: 8,
),
foregroundColor: isFollowed
? outline
: t.colorScheme.onPrimary,
backgroundColor: isFollowed
? t.colorScheme.onInverseSurface
: t.colorScheme.primary, // 设置按钮背景色
),
foregroundColor: isFollowed
? outline
: t.colorScheme.onPrimary,
backgroundColor: isFollowed
? t.colorScheme.onInverseSurface
: t.colorScheme.primary, // 设置按钮背景色
),
child: Text(
isFollowed ? '已关注' : '关注',
style: TextStyle(
fontSize: t.textTheme.labelMedium!.fontSize,
child: Text(
isFollowed ? '已关注' : '关注',
style: TextStyle(
fontSize:
t.textTheme.labelMedium!.fontSize,
),
),
),
),
);
},
)
],
);
},
)
],
),
),
),
),
if (widget.videoDetail!.staff != null) ...[
const SizedBox(height: 15),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
TextSpan(
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
),
children: [
TextSpan(
text: '创作团队',
style: Theme.of(context)
.textTheme
.titleSmall!
.copyWith(fontWeight: FontWeight.bold),
),
const WidgetSpan(child: SizedBox(width: 6)),
TextSpan(
text: '${widget.videoDetail!.staff!.length}',
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
)
],
),
),
SizedBox(
height: 120,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
for (int i = 0;
i < widget.videoDetail!.staff!.length;
i++) ...[
StaffUpItem(item: widget.videoDetail!.staff![i])
],
],
),
),
],
),
]
],
)),
);
@ -535,4 +588,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
);
});
}
// Widget StaffPanel(BuildContext context, videoIntroController) {
// return
// }
}

View File

@ -23,16 +23,34 @@ class IntroDetail extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 4),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: videoDetail!.bvid!));
SmartDialog.showToast('已复制');
},
child: Text(
videoDetail!.bvid!,
style: TextStyle(
fontSize: 13, color: Theme.of(context).colorScheme.primary),
),
Row(
children: [
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: videoDetail!.bvid!));
SmartDialog.showToast('已复制');
},
child: Text(
videoDetail!.bvid!,
style: TextStyle(
fontSize: 13,
color: Theme.of(context).colorScheme.primary),
),
),
const SizedBox(width: 10),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: videoDetail!.bvid!));
SmartDialog.showToast('已复制');
},
child: Text(
videoDetail!.aid!.toString(),
style: TextStyle(
fontSize: 13,
color: Theme.of(context).colorScheme.primary),
),
)
],
),
const SizedBox(height: 4),
Text.rich(

View File

@ -58,7 +58,7 @@ class _PagesPanelState extends State<PagesPanel> {
}
void changeFucCall(item, i) async {
widget.changeFuc?.call(item.cid);
widget.changeFuc?.call(item.cid, item.cover);
currentIndex.value = i;
_bottomSheetController?.close();
scrollToIndex();
@ -129,7 +129,7 @@ class _PagesPanelState extends State<PagesPanel> {
),
),
Container(
height: 35,
height: 55,
margin: const EdgeInsets.only(bottom: 8),
child: ListView.builder(
scrollDirection: Axis.horizontal,
@ -163,7 +163,7 @@ class _PagesPanelState extends State<PagesPanel> {
Expanded(
child: Text(
widget.pages[i].pagePart!,
maxLines: 1,
maxLines: 2,
style: TextStyle(
fontSize: 13,
color: isCurrentIndex

View File

@ -67,6 +67,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
IdUtils.av2bv(item.aid),
item.cid,
item.aid,
item.cover,
);
currentIndex.value = i;
_bottomSheetController?.close();

View File

@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/video_detail_res.dart';
import 'package:pilipala/utils/utils.dart';
class StaffUpItem extends StatelessWidget {
final Staff item;
const StaffUpItem({
super.key,
required this.item,
});
@override
Widget build(BuildContext context) {
final String heroTag = Utils.makeHeroTag(item.mid);
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 15),
GestureDetector(
onTap: () => Get.toNamed(
'/member?mid=${item.mid}',
arguments: {'face': item.face, 'heroTag': heroTag},
),
child: Hero(
tag: heroTag,
child: NetworkImgLayer(
width: 45,
height: 45,
src: item.face,
type: 'avatar',
),
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: SizedBox(
width: 85,
child: Text(
item.name!,
overflow: TextOverflow.ellipsis,
softWrap: false,
textAlign: TextAlign.center,
style: TextStyle(
color: item.vip!.status == 1
? const Color.fromARGB(255, 251, 100, 163)
: null,
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 4),
child: SizedBox(
width: 85,
child: Text(
item.title!,
overflow: TextOverflow.ellipsis,
softWrap: false,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: 12,
),
),
),
),
],
);
}
}

View File

@ -37,6 +37,7 @@ class VideoReplyController extends GetxController {
RxString sortTypeLabel = ReplySortType.time.labels.obs;
Box setting = GStrorage.setting;
RxInt replyReqCode = 200.obs;
@override
void onInit() {
@ -106,6 +107,7 @@ class VideoReplyController extends GetxController {
replyList.addAll(replies);
}
}
replyReqCode.value = res['code'];
isLoadingMore = false;
return res;
}

View File

@ -117,7 +117,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
videoDetailCtr.oid.value = replyItem.oid;
videoDetailCtr.fRpid = replyItem.rpid!;
videoDetailCtr.firstFloor = replyItem;
videoDetailCtr.showReplyReplyPanel();
videoDetailCtr.showReplyReplyPanel(
replyItem.oid, replyItem.rpid!, replyItem);
}
}
@ -276,32 +277,39 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
parent: fabAnimationCtr,
curve: Curves.easeInOut,
)),
child: FloatingActionButton(
heroTag: null,
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _videoReplyController.aid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.video,
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'] != null)
{_videoReplyController.replyList.add(value['data'])}
},
);
},
tooltip: '发表评论',
child: const Icon(Icons.reply),
child: Obx(
() => _videoReplyController.replyReqCode.value == 12061
? const SizedBox()
: FloatingActionButton(
heroTag: null,
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _videoReplyController.aid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.video,
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'] != null)
{
_videoReplyController.replyList
.add(value['data'])
}
},
);
},
tooltip: '发表评论',
child: const Icon(Icons.reply),
),
),
),
),

View File

@ -12,7 +12,6 @@ import 'package:pilipala/pages/preview/index.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/reply_new/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/url_utils.dart';
import 'package:pilipala/utils/utils.dart';
@ -45,7 +44,7 @@ class ReplyItem extends StatelessWidget {
onTap: () {
feedBack();
if (replyReply != null) {
replyReply!(replyItem);
replyReply!(replyItem, null);
}
},
onLongPress: () {
@ -59,28 +58,23 @@ class ReplyItem extends StatelessWidget {
},
);
},
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(12, 14, 8, 5),
child: content(context),
),
Divider(
indent: 55,
endIndent: 15,
height: 0.3,
color: Theme.of(context)
.colorScheme
.onInverseSurface
.withOpacity(0.5),
)
],
child: Container(
padding: const EdgeInsets.fromLTRB(12, 14, 8, 5),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 1,
color:
Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.5),
))),
child: content(context),
),
),
);
}
Widget lfAvtar(BuildContext context, String heroTag) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
return Stack(
children: [
Hero(
@ -100,11 +94,11 @@ class ReplyItem extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: Theme.of(context).colorScheme.background,
color: colorScheme.background,
),
child: Icon(
Icons.offline_bolt,
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
size: 16,
),
),
@ -117,7 +111,7 @@ class ReplyItem extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: Theme.of(context).colorScheme.background,
color: colorScheme.background,
),
child: Image.asset(
'assets/images/big-vip.png',
@ -131,6 +125,8 @@ class ReplyItem extends StatelessWidget {
Widget content(BuildContext context) {
final String heroTag = Utils.makeHeroTag(replyItem!.mid);
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@ -160,16 +156,17 @@ class ReplyItem extends StatelessWidget {
style: TextStyle(
color: replyItem!.member!.vip!['vipStatus'] > 0
? const Color.fromARGB(255, 251, 100, 163)
: Theme.of(context).colorScheme.outline,
: colorScheme.outline,
fontSize: 13,
),
),
const SizedBox(width: 6),
Image.asset(
'assets/images/lv/lv${replyItem!.member!.level}.png',
height: 11,
Padding(
padding: const EdgeInsets.only(left: 6, right: 6),
child: Image.asset(
'assets/images/lv/lv${replyItem!.member!.level}.png',
height: 11,
),
),
const SizedBox(width: 6),
if (replyItem!.isUp!)
const PBadge(
text: 'UP',
@ -184,9 +181,8 @@ class ReplyItem extends StatelessWidget {
Text(
Utils.dateFormat(replyItem!.ctime),
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
color: Theme.of(context).colorScheme.outline,
fontSize: textTheme.labelSmall!.fontSize,
color: colorScheme.outline,
),
),
if (replyItem!.replyControl != null &&
@ -194,11 +190,8 @@ class ReplyItem extends StatelessWidget {
Text(
'${replyItem!.replyControl!.location!}',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context).colorScheme.outline),
fontSize: textTheme.labelSmall!.fontSize,
color: colorScheme.outline),
),
],
)
@ -256,6 +249,8 @@ class ReplyItem extends StatelessWidget {
// 感谢、回复、复制
Widget bottonAction(BuildContext context, replyControl) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
return Row(
children: <Widget>[
const SizedBox(width: 32),
@ -287,15 +282,13 @@ class ReplyItem extends StatelessWidget {
},
child: Row(children: [
Icon(Icons.reply,
size: 18,
color:
Theme.of(context).colorScheme.outline.withOpacity(0.8)),
size: 18, color: colorScheme.outline.withOpacity(0.8)),
const SizedBox(width: 3),
Text(
'回复',
style: TextStyle(
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
fontSize: textTheme.labelMedium!.fontSize,
color: colorScheme.outline,
),
),
]),
@ -306,8 +299,8 @@ class ReplyItem extends StatelessWidget {
Text(
'up主觉得很赞',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize),
color: colorScheme.primary,
fontSize: textTheme.labelMedium!.fontSize),
),
const SizedBox(width: 2),
],
@ -316,8 +309,8 @@ class ReplyItem extends StatelessWidget {
Text(
'热评',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize),
color: colorScheme.primary,
fontSize: textTheme.labelMedium!.fontSize),
),
const Spacer(),
ZanButton(replyItem: replyItem, replyType: replyType),
@ -347,10 +340,13 @@ class ReplyItemRow extends StatelessWidget {
Widget build(BuildContext context) {
final bool isShow = replyControl!.isShow!;
final int extraRow = replyControl != null && isShow ? 1 : 0;
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
return Container(
margin: const EdgeInsets.only(left: 42, right: 4, top: 0),
child: Material(
color: Theme.of(context).colorScheme.onInverseSurface,
color: colorScheme.onInverseSurface,
borderRadius: BorderRadius.circular(6),
clipBehavior: Clip.hardEdge,
animationDuration: Duration.zero,
@ -361,7 +357,9 @@ class ReplyItemRow extends StatelessWidget {
for (int i = 0; i < replies!.length; i++) ...[
InkWell(
// 一楼点击评论展开评论详情
onTap: () => replyReply!(replyItem),
// onTap: () {
// replyReply?.call(replyItem, replies![i]);
// },
onLongPress: () {
feedBack();
showModalBottomSheet(
@ -379,7 +377,7 @@ class ReplyItemRow extends StatelessWidget {
8,
i == 0 && (extraRow == 1 || replies!.length > 1) ? 8 : 5,
8,
i == 0 && (extraRow == 1 || replies!.length > 1) ? 5 : 6,
6,
),
child: Text.rich(
overflow: TextOverflow.ellipsis,
@ -393,7 +391,7 @@ class ReplyItemRow extends StatelessWidget {
.textTheme
.titleSmall!
.fontSize,
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () {
@ -436,8 +434,7 @@ class ReplyItemRow extends StatelessWidget {
child: Text.rich(
TextSpan(
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
fontSize: textTheme.labelMedium!.fontSize,
),
children: [
if (replyControl!.upReply!)
@ -445,7 +442,7 @@ class ReplyItemRow extends StatelessWidget {
TextSpan(
text: replyControl!.entryText!,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
)
],
@ -464,6 +461,7 @@ InlineSpan buildContent(
BuildContext context, replyItem, replyReply, fReplyItem) {
final String routePath = Get.currentRoute;
bool isVideoPage = routePath.startsWith('/video');
ColorScheme colorScheme = Theme.of(context).colorScheme;
// replyItem 当前回复内容
// replyReply 查看二楼回复(回复详情)回调
@ -564,7 +562,7 @@ InlineSpan buildContent(
TextSpan(
text: matchStr,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () {
@ -584,7 +582,7 @@ InlineSpan buildContent(
text: ' $matchStr ',
style: isVideoPage
? TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
)
: null,
recognizer: TapGestureRecognizer()
@ -624,14 +622,14 @@ InlineSpan buildContent(
child: Image.network(
content.jumpUrl[matchStr]['prefix_icon'],
height: 19,
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
)
],
TextSpan(
text: content.jumpUrl[matchStr]['title'],
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () async {
@ -721,7 +719,7 @@ InlineSpan buildContent(
TextSpan(
text: matchStr,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () {
@ -747,7 +745,7 @@ InlineSpan buildContent(
text: ' $matchStr ',
style: isVideoPage
? TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
)
: null,
recognizer: TapGestureRecognizer()
@ -786,14 +784,14 @@ InlineSpan buildContent(
child: Image.network(
content.jumpUrl[patternStr]['prefix_icon'],
height: 19,
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
)
],
TextSpan(
text: content.jumpUrl[patternStr]['title'],
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
color: colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () {
@ -997,7 +995,8 @@ class MorePanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
Color errorColor = Theme.of(context).colorScheme.error;
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Column(
@ -1013,7 +1012,7 @@ class MorePanel extends StatelessWidget {
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.outline,
color: colorScheme.outline,
borderRadius: const BorderRadius.all(Radius.circular(3))),
),
),
@ -1023,13 +1022,13 @@ class MorePanel extends StatelessWidget {
onTap: () async => await menuActionHandler('copyAll'),
minLeadingWidth: 0,
leading: const Icon(Icons.copy_all_outlined, size: 19),
title: Text('复制全部', style: Theme.of(context).textTheme.titleSmall),
title: Text('复制全部', style: textTheme.titleSmall),
),
ListTile(
onTap: () async => await menuActionHandler('copyFreedom'),
minLeadingWidth: 0,
leading: const Icon(Icons.copy_outlined, size: 19),
title: Text('自由复制', style: Theme.of(context).textTheme.titleSmall),
title: Text('自由复制', style: textTheme.titleSmall),
),
// ListTile(
// onTap: () async => await menuActionHandler('block'),

View File

@ -43,6 +43,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
String toolbarType = 'input';
RxBool isForward = false.obs;
RxBool showForward = false.obs;
RxString message = ''.obs;
@override
void initState() {
@ -80,15 +81,15 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
Future submitReplyAdd() async {
feedBack();
String message = _replyContentController.text;
// String message = _replyContentController.text;
var result = await VideoHttp.replyAdd(
type: widget.replyType ?? ReplyType.video,
oid: widget.oid!,
root: widget.root!,
parent: widget.parent!,
message: widget.replyItem != null && widget.replyItem!.root != 0
? ' 回复 @${widget.replyItem!.member!.uname!} : $message'
: message,
? ' 回复 @${widget.replyItem!.member!.uname!} : ${message.value}'
: message.value,
);
if (result['status']) {
SmartDialog.showToast(result['data']['success_toast']);
@ -100,7 +101,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
if (isForward.value) {
await DynamicsHttp.dynamicCreate(
mid: 0,
rawText: message,
rawText: message.value,
oid: widget.oid!,
scene: 5,
);
@ -188,7 +189,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
autovalidateMode: AutovalidateMode.onUserInteraction,
child: TextField(
controller: _replyContentController,
minLines: 1,
minLines: 3,
maxLines: null,
autofocus: false,
focusNode: replyContentFocusNode,
@ -199,6 +200,9 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
fontSize: 14,
)),
style: Theme.of(context).textTheme.bodyLarge,
onChanged: (text) {
message.value = text;
},
),
),
),
@ -267,9 +271,11 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
const Spacer(),
SizedBox(
height: 36,
child: FilledButton(
onPressed: () => submitReplyAdd(),
child: const Text('发送'),
child: Obx(
() => FilledButton(
onPressed: message.isNotEmpty ? submitReplyAdd : null,
child: const Text('发送'),
),
),
),
],

View File

@ -39,7 +39,7 @@ class VideoDetailPage extends StatefulWidget {
}
class _VideoDetailPageState extends State<VideoDetailPage>
with TickerProviderStateMixin, RouteAware {
with TickerProviderStateMixin, RouteAware, WidgetsBindingObserver {
late VideoDetailController vdCtr;
PlPlayerController? plPlayerController;
final ScrollController _extendNestCtr = ScrollController();
@ -62,6 +62,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
late bool autoPiP;
late Floating floating;
bool isShowing = true;
// 生命周期监听
late final AppLifecycleListener _lifecycleListener;
late double statusHeight;
@override
@ -99,6 +101,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
floating = vdCtr.floating!;
autoEnterPip();
}
WidgetsBinding.instance.addObserver(this);
lifecycleListener();
}
// 获取视频资源,初始化播放器
@ -226,6 +230,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
floating.dispose();
}
appbarStream.close();
WidgetsBinding.instance.removeObserver(this);
_lifecycleListener.dispose();
super.dispose();
}
@ -288,6 +294,29 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}
}
// 生命周期监听
void lifecycleListener() {
_lifecycleListener = AppLifecycleListener(
// onResume: () => _handleTransition('resume'),
// 后台
// onInactive: () => _handleTransition('inactive'),
// 在Android和iOS端不生效
// onHide: () => _handleTransition('hide'),
onShow: () => _handleTransition('show'),
onPause: () => _handleTransition('pause'),
onRestart: () => _handleTransition('restart'),
onDetach: () => _handleTransition('detach'),
);
}
void _handleTransition(String name) {
switch (name) {
case 'show' || 'restart':
plPlayerController?.danmakuController?.clear();
break;
}
}
/// 手动播放
Widget handlePlayPanel() {
return Stack(

View File

@ -180,15 +180,16 @@ class _HeaderControlState extends State<HeaderControl> {
'当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}',
style: subTitleStyle),
),
ListTile(
onTap: () => {Get.back(), showSetDecodeFormats()},
dense: true,
leading: const Icon(Icons.av_timer_outlined, size: 20),
title: const Text('解码格式', style: titleStyle),
subtitle: Text(
'当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats.description}',
style: subTitleStyle),
),
if (widget.videoDetailCtr!.currentDecodeFormats != null)
ListTile(
onTap: () => {Get.back(), showSetDecodeFormats()},
dense: true,
leading: const Icon(Icons.av_timer_outlined, size: 20),
title: const Text('解码格式', style: titleStyle),
subtitle: Text(
'当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats!.description}',
style: subTitleStyle),
),
ListTile(
onTap: () => {Get.back(), showSetRepeat()},
dense: true,
@ -445,7 +446,7 @@ class _HeaderControlState extends State<HeaderControl> {
children: [
RadioListTile(
value: -1,
title: const Text('关闭'),
title: const Text('关闭'),
groupValue: tempThemeValue,
onChanged: (value) {
tempThemeValue = value!;
@ -541,16 +542,24 @@ class _HeaderControlState extends State<HeaderControl> {
/// 可用的质量分类
int userfulQaSam = 0;
final List<VideoItem> video = videoInfo.dash!.video!;
final Set<int> idSet = {};
for (final VideoItem item in video) {
final int id = item.id!;
if (!idSet.contains(id)) {
idSet.add(id);
userfulQaSam++;
if (videoInfo.dash != null) {
// dash格式视频一次请求会返回所有可播放的清晰度video
final List<VideoItem> video = videoInfo.dash!.video!;
final Set<int> idSet = {};
for (final VideoItem item in video) {
final int id = item.id!;
if (!idSet.contains(id)) {
idSet.add(id);
userfulQaSam++;
}
}
}
if (videoInfo.durl != null) {
// durl格式视频一次请求返回对应清晰度video
userfulQaSam = videoFormat.length - 1;
}
showModalBottomSheet(
context: context,
elevation: 0,
@ -707,7 +716,7 @@ class _HeaderControlState extends State<HeaderControl> {
void showSetDecodeFormats() {
// 当前选中的解码格式
final VideoDecodeFormats currentDecodeFormats =
widget.videoDetailCtr!.currentDecodeFormats;
widget.videoDetailCtr!.currentDecodeFormats!;
final VideoItem firstVideo = widget.videoDetailCtr!.firstVideo;
// 当前视频可用的解码格式
final List<FormatItem> videoFormat = videoInfo.supportFormats!;

View File

@ -101,7 +101,7 @@ class PlPlayerController {
bool _isFirstTime = true;
Timer? _timer;
late Timer? _timerForSeek;
Timer? _timerForSeek;
Timer? _timerForVolume;
Timer? _timerForShowingVolume;
Timer? _timerForGettingVolume;
@ -335,8 +335,10 @@ class PlPlayerController {
}) {
// 如果实例尚未创建,则创建一个新实例
_instance ??= PlPlayerController._();
_instance!._playerCount.value += 1;
_videoType.value = videoType;
if (videoType != 'none') {
_instance!._playerCount.value += 1;
_videoType.value = videoType;
}
return _instance!;
}
@ -351,7 +353,7 @@ class PlPlayerController {
// 初始化播放速度
double speed = 1.0,
// 硬件加速
bool enableHA = true,
bool enableHA = false,
double? width,
double? height,
Duration? duration,
@ -1120,9 +1122,6 @@ class PlPlayerController {
}
Future<void> dispose({String type = 'single'}) async {
print('dispose');
print('dispose: ${playerCount.value}');
// 每次减1最后销毁
if (type == 'single' && playerCount.value > 1) {
_playerCount.value -= 1;
@ -1132,7 +1131,6 @@ class PlPlayerController {
}
_playerCount.value = 0;
try {
print('dispose dispose ---------');
_timer?.cancel();
_timerForVolume?.cancel();
_timerForGettingVolume?.cancel();

View File

@ -26,7 +26,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
static final List<MediaItem> _item = [];
Box setting = GStrorage.setting;
bool enableBackgroundPlay = false;
PlPlayerController player = PlPlayerController.getInstance();
PlPlayerController player = PlPlayerController.getInstance(videoType: 'none');
VideoPlayerServiceHandler() {
revalidateSetting();

View File

@ -18,7 +18,7 @@ class AudioSessionHandler {
session.configure(const AudioSessionConfiguration.music());
session.interruptionEventStream.listen((event) {
final player = PlPlayerController.getInstance();
final player = PlPlayerController.getInstance(videoType: 'none');
if (event.begin) {
if (!player.playerStatus.playing) return;
switch (event.type) {
@ -51,7 +51,7 @@ class AudioSessionHandler {
// 耳机拔出暂停
session.becomingNoisyEventStream.listen((_) {
final player = PlPlayerController.getInstance();
final player = PlPlayerController.getInstance(videoType: 'none');
if (player.playerStatus.playing) {
player.pause();
}

View File

@ -29,8 +29,8 @@ class ShutdownTimerService {
return;
}
SmartDialog.showToast("设置 $scheduledExitInMinutes 分钟后定时关闭");
_shutdownTimer = Timer(Duration(minutes: scheduledExitInMinutes),
() => _shutdownDecider());
_shutdownTimer = Timer(
Duration(minutes: scheduledExitInMinutes), () => _shutdownDecider());
}
void _showTimeUpButPauseDialog() {
@ -59,7 +59,7 @@ class ShutdownTimerService {
// Start the 10-second timer to auto close the dialog
_autoCloseDialogTimer?.cancel();
_autoCloseDialogTimer = Timer(const Duration(seconds: 10), () {
SmartDialog.dismiss();// Close the dialog
SmartDialog.dismiss(); // Close the dialog
_executeShutdown();
});
return AlertDialog(
@ -88,7 +88,8 @@ class ShutdownTimerService {
_showShutdownDialog();
return;
}
PlPlayerController plPlayerController = PlPlayerController.getInstance();
PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'none');
if (!exitApp && !waitForPlayingCompleted) {
if (!plPlayerController.playerStatus.playing) {
//仅提示用户
@ -108,19 +109,22 @@ class ShutdownTimerService {
//该方法依赖耦合实现,不够优雅
isWaiting = true;
}
void handleWaitingFinished(){
if(isWaiting){
void handleWaitingFinished() {
if (isWaiting) {
_showShutdownDialog();
isWaiting = false;
}
}
void _executeShutdown() {
if (exitApp) {
//退出app
exit(0);
} else {
//暂停播放
PlPlayerController plPlayerController = PlPlayerController.getInstance();
PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'none');
if (plPlayerController.playerStatus.playing) {
plPlayerController.pause();
waitForPlayingCompleted = true;

View File

@ -117,7 +117,7 @@ class PiliSchame {
// ignore: always_specify_types
(e) => Get.toNamed<dynamic>('/video?bvid=$bvid&cid=$cid',
arguments: <String, String?>{
'pic': null,
'pic': '',
'heroTag': heroTag,
}),
);

View File

@ -109,7 +109,6 @@ class Utils {
toInt: false,
formatType: formatType);
}
print('distance: $distance');
if (distance <= 60) {
return '刚刚';
} else if (distance <= 3600) {