Merge branch 'main' into feature-collections

This commit is contained in:
guozhigq
2024-04-27 16:17:24 +08:00
50 changed files with 1674 additions and 961 deletions

View File

@ -206,4 +206,4 @@ jobs:
method: sendFile method: sendFile
path: Pilipala-Beta/* path: Pilipala-Beta/*
parse_mode: Markdown parse_mode: Markdown
context: "*Beta版本: v${{ needs.update_version.outputs.new_version }}*\n更新内容: [${{ needs.update_version.outputs.last_commit }}](${{ github.event.head_commit.url }})" context: "*Beta版本: v${{ needs.update_version.outputs.new_version }}*\n更新内容: [${{ needs.update_version.outputs.last_commit }}]"

View File

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

View File

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

View File

@ -1,7 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
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:pilipala/utils/feed_back.dart';
import '../../models/model_rec_video_item.dart'; import '../../models/model_rec_video_item.dart';
import 'overlay_pop.dart';
import 'stat/danmu.dart'; import 'stat/danmu.dart';
import 'stat/view.dart'; import 'stat/view.dart';
import '../../http/dynamics.dart'; import '../../http/dynamics.dart';
@ -19,15 +21,11 @@ import 'network_img_layer.dart';
class VideoCardV extends StatelessWidget { class VideoCardV extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
final int crossAxisCount; final int crossAxisCount;
final Function()? longPress;
final Function()? longPressEnd;
const VideoCardV({ const VideoCardV({
Key? key, Key? key,
required this.videoItem, required this.videoItem,
required this.crossAxisCount, required this.crossAxisCount,
this.longPress,
this.longPressEnd,
}) : super(key: key); }) : super(key: key);
bool isStringNumeric(String str) { bool isStringNumeric(String str) {
@ -127,64 +125,56 @@ class VideoCardV extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(videoItem.id); String heroTag = Utils.makeHeroTag(videoItem.id);
return Card( return InkWell(
elevation: 0, onTap: () async => onPushDetail(heroTag),
clipBehavior: Clip.hardEdge, onLongPress: () {
margin: EdgeInsets.zero, SmartDialog.show(
child: GestureDetector( builder: (context) => OverlayPop(
onLongPress: () { videoItem: videoItem,
if (longPress != null) { closeFn: () => SmartDialog.dismiss(),
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)
],
), ),
), );
},
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( const VideoContent(
{Key? key, required this.videoItem, required this.crossAxisCount}) {Key? key, required this.videoItem, required this.crossAxisCount})
: super(key: key); : 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Expanded( return Padding(
flex: crossAxisCount == 1 ? 0 : 1, padding: crossAxisCount == 1
child: Padding( ? const EdgeInsets.fromLTRB(9, 9, 9, 4)
padding: crossAxisCount == 1 : const EdgeInsets.fromLTRB(5, 8, 5, 4),
? const EdgeInsets.fromLTRB(9, 9, 9, 4) child: Column(
: const EdgeInsets.fromLTRB(5, 8, 5, 4), crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, Text(
// mainAxisAlignment: MainAxisAlignment.spaceBetween, videoItem.title,
children: [ maxLines: 2,
Row( overflow: TextOverflow.ellipsis,
children: [ ),
Expanded( if (crossAxisCount > 1) ...[
child: Text( const SizedBox(height: 2),
videoItem.title, VideoStat(videoItem: videoItem, crossAxisCount: crossAxisCount),
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)
]
],
),
], ],
), 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) { Widget build(BuildContext context) {
return Row( return Row(
children: [ children: [
StatView( StatView(theme: 'gray', view: videoItem.stat.view),
theme: 'gray',
view: videoItem.stat.view,
),
const SizedBox(width: 8), const SizedBox(width: 8),
StatDanMu( StatDanMu(theme: 'gray', danmu: videoItem.stat.danmu),
theme: 'gray',
danmu: videoItem.stat.danmu,
),
if (videoItem is RecVideoItemModel) ...<Widget>[ if (videoItem is RecVideoItemModel) ...<Widget>[
crossAxisCount > 1 ? const Spacer() : const SizedBox(width: 8), crossAxisCount > 1 ? const Spacer() : const SizedBox(width: 8),
RichText( RichText(
@ -358,99 +310,98 @@ class VideoStat extends StatelessWidget {
} }
} }
class VideoPopupMenu extends StatelessWidget { class MorePanel extends StatelessWidget {
final double? size;
final double? iconSize;
final dynamic videoItem; final dynamic videoItem;
const MorePanel({super.key, required this.videoItem});
const VideoPopupMenu({ Future<dynamic> menuActionHandler(String type) async {
Key? key, switch (type) {
required this.size, case 'block':
required this.iconSize, blockUser();
required this.videoItem, break;
}) : super(key: key); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return Container(
width: size, padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
height: size, child: Column(
child: PopupMenuButton<String>( mainAxisSize: MainAxisSize.min,
padding: EdgeInsets.zero, children: [
icon: Icon( InkWell(
Icons.more_vert_outlined, onTap: () => Get.back(),
color: Theme.of(context).colorScheme.outline, child: Container(
size: iconSize, height: 35,
), padding: const EdgeInsets.only(bottom: 2),
position: PopupMenuPosition.under, child: Center(
// constraints: const BoxConstraints(maxHeight: 35), child: Container(
onSelected: (String type) {}, width: 32,
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ height: 3,
PopupMenuItem<String>( decoration: BoxDecoration(
onTap: () async { color: Theme.of(context).colorScheme.outline,
var res = borderRadius: const BorderRadius.all(Radius.circular(3))),
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))
],
), ),
), ),
const PopupMenuDivider(), ListTile(
PopupMenuItem<String>( onTap: () async => await menuActionHandler('block'),
onTap: () async { minLeadingWidth: 0,
SmartDialog.show( leading: const Icon(Icons.block, size: 19),
useSystem: true, title: Text(
animationType: SmartAnimationType.centerFade_otherSlide, '拉黑up主 「${videoItem.owner.name}',
builder: (BuildContext context) { style: Theme.of(context).textTheme.titleSmall,
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('watchLater'),
minLeadingWidth: 0,
leading: const Icon(Icons.watch_later_outlined, size: 19),
title:
Text('添加至稍后再看', style: Theme.of(context).textTheme.titleSmall),
),
], ],
), ),
); );

View File

@ -511,4 +511,13 @@ class Api {
/// 取消订阅 /// 取消订阅
static const String cancelSub = '/x/v3/fav/season/unfav'; static const String cancelSub = '/x/v3/fav/season/unfav';
/// 动态转发
static const String dynamicForwardUrl = '/x/dynamic/feed/create/submit_check';
/// 创建动态
static const String dynamicCreate = '/x/dynamic/feed/create/dyn';
/// 删除收藏夹
static const String delFavFolder = '/x/v3/fav/folder/del';
} }

View File

@ -1,3 +1,4 @@
import 'dart:math';
import '../models/dynamics/result.dart'; import '../models/dynamics/result.dart';
import '../models/dynamics/up.dart'; import '../models/dynamics/up.dart';
import 'index.dart'; import 'index.dart';
@ -117,4 +118,94 @@ class DynamicsHttp {
}; };
} }
} }
static Future dynamicForward() async {
var res = await Request().post(
Api.dynamicForwardUrl,
queryParameters: {
'csrf': await Request.getCsrf(),
'x-bili-device-req-json': {'platform': 'web', 'device': 'pc'},
'x-bili-web-req-json': {'spm_id': '333.999'},
},
data: {
'attach_card': null,
'scene': 4,
'content': {
'conetents': [
{'raw_text': "2", 'type': 1, 'biz_id': ""}
]
}
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data'],
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
static Future dynamicCreate({
required int mid,
required int scene,
int? oid,
String? dynIdStr,
String? rawText,
}) async {
DateTime now = DateTime.now();
int timestamp = now.millisecondsSinceEpoch ~/ 1000;
Random random = Random();
int randomNumber = random.nextInt(9000) + 1000;
String uploadId = '${mid}_${timestamp}_$randomNumber';
Map<String, dynamic> webRepostSrc = {
'dyn_id_str': dynIdStr ?? '',
};
/// 投稿转发
if (scene == 5) {
webRepostSrc = {
'revs_id': {'dyn_type': 8, 'rid': oid}
};
}
var res = await Request().post(Api.dynamicCreate, queryParameters: {
'platform': 'web',
'csrf': await Request.getCsrf(),
'x-bili-device-req-json': {'platform': 'web', 'device': 'pc'},
'x-bili-web-req-json': {'spm_id': '333.999'},
}, data: {
'dyn_req': {
'content': {
'contents': [
{'raw_text': rawText ?? '', 'type': 1, 'biz_id': ''}
]
},
'scene': scene,
'attach_card': null,
'upload_id': uploadId,
'meta': {
'app_meta': {'from': 'create.dynamic.web', 'mobi_app': 'web'}
}
},
'web_repost_src': webRepostSrc
});
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data'],
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
} }

View File

@ -395,4 +395,21 @@ class UserHttp {
return {'status': false, 'msg': res.data['message']}; return {'status': false, 'msg': res.data['message']};
} }
} }
// 删除文件夹
static Future delFavFolder({required int mediaIds}) async {
var res = await Request().post(
Api.delFavFolder,
queryParameters: {
'media_ids': mediaIds,
'platform': 'web',
'csrf': await Request.getCsrf(),
},
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
} }

View File

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

View File

@ -130,27 +130,10 @@ class MyApp extends StatelessWidget {
); );
} }
final SnackBarThemeData snackBarThemeData = SnackBarThemeData(
actionTextColor: darkColorScheme.primary,
backgroundColor: darkColorScheme.secondaryContainer,
closeIconColor: darkColorScheme.secondary,
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
elevation: 20,
);
ThemeData themeData = ThemeData( ThemeData themeData = ThemeData(
// fontFamily: 'HarmonyOS',
colorScheme: currentThemeValue == ThemeType.dark colorScheme: currentThemeValue == ThemeType.dark
? darkColorScheme ? darkColorScheme
: lightColorScheme, : lightColorScheme,
snackBarTheme: snackBarThemeData,
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(
allowEnterRouteSnapshotting: false,
),
},
),
); );
// 小白条、导航栏沉浸 // 小白条、导航栏沉浸
@ -171,9 +154,38 @@ class MyApp extends StatelessWidget {
// 图片缓存 // 图片缓存
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20; // PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
return GetMaterialApp( return GetMaterialApp(
title: 'PiLiPaLa', title: 'PiliPala',
theme: themeData, theme: ThemeData(
darkTheme: themeData, colorScheme: currentThemeValue == ThemeType.dark
? darkColorScheme
: lightColorScheme,
snackBarTheme: SnackBarThemeData(
actionTextColor: lightColorScheme.primary,
backgroundColor: lightColorScheme.secondaryContainer,
closeIconColor: lightColorScheme.secondary,
contentTextStyle: TextStyle(color: lightColorScheme.secondary),
elevation: 20,
),
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(
allowEnterRouteSnapshotting: false,
),
},
),
),
darkTheme: ThemeData(
colorScheme: currentThemeValue == ThemeType.light
? lightColorScheme
: darkColorScheme,
snackBarTheme: SnackBarThemeData(
actionTextColor: darkColorScheme.primary,
backgroundColor: darkColorScheme.secondaryContainer,
closeIconColor: darkColorScheme.secondary,
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
elevation: 20,
),
),
localizationsDelegates: const [ localizationsDelegates: const [
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/pages/rank/zone/index.dart'; import 'package:pilipala/pages/rank/zone/index.dart';
enum RandType { enum RandType {
@ -74,7 +73,6 @@ List tabsConfig = [
), ),
'label': '全站', 'label': '全站',
'type': RandType.all, 'type': RandType.all,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 0), 'page': const ZonePage(rid: 0),
}, },
{ {
@ -84,7 +82,6 @@ List tabsConfig = [
), ),
'label': '国创相关', 'label': '国创相关',
'type': RandType.creation, 'type': RandType.creation,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 168), 'page': const ZonePage(rid: 168),
}, },
{ {
@ -94,7 +91,6 @@ List tabsConfig = [
), ),
'label': '动画', 'label': '动画',
'type': RandType.animation, 'type': RandType.animation,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 1), 'page': const ZonePage(rid: 1),
}, },
{ {
@ -104,7 +100,6 @@ List tabsConfig = [
), ),
'label': '音乐', 'label': '音乐',
'type': RandType.music, 'type': RandType.music,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 3), 'page': const ZonePage(rid: 3),
}, },
{ {
@ -114,7 +109,6 @@ List tabsConfig = [
), ),
'label': '舞蹈', 'label': '舞蹈',
'type': RandType.dance, 'type': RandType.dance,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 129), 'page': const ZonePage(rid: 129),
}, },
{ {
@ -124,7 +118,6 @@ List tabsConfig = [
), ),
'label': '游戏', 'label': '游戏',
'type': RandType.game, 'type': RandType.game,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 4), 'page': const ZonePage(rid: 4),
}, },
{ {
@ -134,7 +127,6 @@ List tabsConfig = [
), ),
'label': '知识', 'label': '知识',
'type': RandType.knowledge, 'type': RandType.knowledge,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 36), 'page': const ZonePage(rid: 36),
}, },
{ {
@ -144,7 +136,6 @@ List tabsConfig = [
), ),
'label': '科技', 'label': '科技',
'type': RandType.technology, 'type': RandType.technology,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 188), 'page': const ZonePage(rid: 188),
}, },
{ {
@ -154,7 +145,6 @@ List tabsConfig = [
), ),
'label': '运动', 'label': '运动',
'type': RandType.sport, 'type': RandType.sport,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 234), 'page': const ZonePage(rid: 234),
}, },
{ {
@ -164,7 +154,6 @@ List tabsConfig = [
), ),
'label': '汽车', 'label': '汽车',
'type': RandType.car, 'type': RandType.car,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 223), 'page': const ZonePage(rid: 223),
}, },
{ {
@ -174,7 +163,6 @@ List tabsConfig = [
), ),
'label': '生活', 'label': '生活',
'type': RandType.life, 'type': RandType.life,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 160), 'page': const ZonePage(rid: 160),
}, },
{ {
@ -184,7 +172,6 @@ List tabsConfig = [
), ),
'label': '美食', 'label': '美食',
'type': RandType.food, 'type': RandType.food,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 211), 'page': const ZonePage(rid: 211),
}, },
{ {
@ -194,7 +181,6 @@ List tabsConfig = [
), ),
'label': '动物圈', 'label': '动物圈',
'type': RandType.animal, 'type': RandType.animal,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 217), 'page': const ZonePage(rid: 217),
}, },
{ {
@ -204,7 +190,6 @@ List tabsConfig = [
), ),
'label': '鬼畜', 'label': '鬼畜',
'type': RandType.madness, 'type': RandType.madness,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 119), 'page': const ZonePage(rid: 119),
}, },
{ {
@ -214,7 +199,6 @@ List tabsConfig = [
), ),
'label': '时尚', 'label': '时尚',
'type': RandType.fashion, 'type': RandType.fashion,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 155), 'page': const ZonePage(rid: 155),
}, },
{ {
@ -224,7 +208,6 @@ List tabsConfig = [
), ),
'label': '娱乐', 'label': '娱乐',
'type': RandType.entertainment, 'type': RandType.entertainment,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 5), 'page': const ZonePage(rid: 5),
}, },
{ {
@ -234,7 +217,6 @@ List tabsConfig = [
), ),
'label': '影视', 'label': '影视',
'type': RandType.film, 'type': RandType.film,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 181), 'page': const ZonePage(rid: 181),
} }
]; ];

View File

@ -5,6 +5,10 @@ enum SubtitleType {
aizh, aizh,
// 英语(自动生成) // 英语(自动生成)
aien, aien,
// 中文(简体)
zhHans,
// 英文(美国)
enUS,
} }
extension SubtitleTypeExtension on SubtitleType { extension SubtitleTypeExtension on SubtitleType {
@ -16,6 +20,10 @@ extension SubtitleTypeExtension on SubtitleType {
return '中文(自动翻译)'; return '中文(自动翻译)';
case SubtitleType.aien: case SubtitleType.aien:
return '英语(自动生成)'; return '英语(自动生成)';
case SubtitleType.zhHans:
return '中文(简体)';
case SubtitleType.enUS:
return '英文(美国)';
} }
} }
} }
@ -29,6 +37,10 @@ extension SubtitleIdExtension on SubtitleType {
return 'ai-zh'; return 'ai-zh';
case SubtitleType.aien: case SubtitleType.aien:
return 'ai-en'; return 'ai-en';
case SubtitleType.zhHans:
return 'zh-Hans';
case SubtitleType.enUS:
return 'en-US';
} }
} }
} }
@ -42,6 +54,10 @@ extension SubtitleCodeExtension on SubtitleType {
return 2; return 2;
case SubtitleType.aien: case SubtitleType.aien:
return 3; return 3;
case SubtitleType.zhHans:
return 4;
case SubtitleType.enUS:
return 5;
} }
} }
} }

View File

@ -39,6 +39,14 @@ extension VideoQualityCode on VideoQuality {
} }
return null; 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 { extension VideoQualityDesc on VideoQuality {

View File

@ -67,6 +67,7 @@ class VideoDetailData {
String? likeIcon; String? likeIcon;
bool? needJumpBv; bool? needJumpBv;
String? epId; String? epId;
List<Staff>? staff;
VideoDetailData({ VideoDetailData({
this.bvid, this.bvid,
@ -103,6 +104,7 @@ class VideoDetailData {
this.likeIcon, this.likeIcon,
this.needJumpBv, this.needJumpBv,
this.epId, this.epId,
this.staff,
}); });
VideoDetailData.fromJson(Map<String, dynamic> json) { VideoDetailData.fromJson(Map<String, dynamic> json) {
@ -155,6 +157,9 @@ class VideoDetailData {
if (json['redirect_url'] != null) { if (json['redirect_url'] != null) {
epId = resolveEpId(json['redirect_url']); epId = resolveEpId(json['redirect_url']);
} }
staff = json["staff"] != null
? List<Staff>.from(json["staff"]!.map((e) => Staff.fromJson(e)))
: null;
} }
String resolveEpId(url) { String resolveEpId(url) {
@ -652,3 +657,43 @@ class EpisodeItem {
bvid = json['bvid']; bvid = json['bvid'];
} }
} }
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) { builder: (context) {
return AlertDialog( return AlertDialog(
title: const Text('选择投币个数'), 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) { content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [1, 2]
RadioListTile( .map(
value: 1, (e) => RadioListTile(
title: const Text('1枚'), value: e,
groupValue: _tempThemeValue, title: Text('$e枚'),
onChanged: (value) { groupValue: _tempThemeValue,
_tempThemeValue = value!; onChanged: (value) async {
Get.appUpdate(); _tempThemeValue = value!;
}, setState(() {});
), var res = await VideoHttp.coinVideo(
RadioListTile( bvid: bvid, multiply: _tempThemeValue);
value: 2, if (res['status']) {
title: const Text('2枚'), SmartDialog.showToast('投币成功 👏');
groupValue: _tempThemeValue, hasCoin.value = true;
onChanged: (value) { bangumiDetail.value.stat!['coins'] =
_tempThemeValue = value!; bangumiDetail.value.stat!['coins'] +
Get.appUpdate(); _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('确定'),
)
],
); );
}); });
} }
@ -236,6 +222,7 @@ class BangumiIntroController extends GetxController {
videoDetailCtr.bvid = bvid; videoDetailCtr.bvid = bvid;
videoDetailCtr.cid.value = cid; videoDetailCtr.cid.value = cid;
videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.danmakuCid.value = cid;
videoDetailCtr.oid.value = aid;
videoDetailCtr.queryVideoUrl(); videoDetailCtr.queryVideoUrl();
// 重新请求评论 // 重新请求评论
try { try {

View File

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

View File

@ -16,6 +16,7 @@ import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/id_utils.dart';
import '../../../models/video/reply/item.dart';
import '../widgets/dynamic_panel.dart'; import '../widgets/dynamic_panel.dart';
class DynamicDetailPage extends StatefulWidget { class DynamicDetailPage extends StatefulWidget {
@ -182,6 +183,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
scrollController.removeListener(() {}); scrollController.removeListener(() {});
fabAnimationCtr.dispose(); fabAnimationCtr.dispose();
scrollController.dispose(); scrollController.dispose();
titleStreamC.close();
super.dispose(); super.dispose();
} }
@ -210,208 +212,194 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
onRefresh: () async { onRefresh: () async {
await _dynamicDetailController.queryReplyList(); await _dynamicDetailController.queryReplyList();
}, },
child: Stack( child: CustomScrollView(
children: [ controller: scrollController,
CustomScrollView( slivers: [
controller: scrollController, if (action != 'comment')
slivers: [ SliverToBoxAdapter(
if (action != 'comment') child: DynamicPanel(
SliverToBoxAdapter( item: _dynamicDetailController.item,
child: DynamicPanel( source: 'detail',
item: _dynamicDetailController.item, ),
source: 'detail', ),
SliverPersistentHeader(
delegate: _MySliverPersistentHeaderDelegate(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
border: Border(
top: BorderSide(
width: 0.6,
color: Theme.of(context).dividerColor.withOpacity(0.05),
),
), ),
), ),
SliverPersistentHeader( height: 45,
delegate: _MySliverPersistentHeaderDelegate( padding: const EdgeInsets.only(left: 12, right: 6),
child: Container( child: Row(
decoration: BoxDecoration( children: [
color: Theme.of(context).colorScheme.surface, Obx(
border: Border( () => AnimatedSwitcher(
top: BorderSide( duration: const Duration(milliseconds: 400),
width: 0.6, transitionBuilder:
color: Theme.of(context) (Widget child, Animation<double> animation) {
.dividerColor return ScaleTransition(
.withOpacity(0.05), scale: animation, child: child);
},
child: Text(
'${_dynamicDetailController.acount.value}',
key: ValueKey<int>(
_dynamicDetailController.acount.value),
), ),
), ),
), ),
height: 45, const Text('条回复'),
padding: const EdgeInsets.only(left: 12, right: 6), const Spacer(),
child: Row( SizedBox(
children: [ height: 35,
Obx( child: TextButton.icon(
() => AnimatedSwitcher( onPressed: () =>
duration: const Duration(milliseconds: 400), _dynamicDetailController.queryBySort(),
transitionBuilder: icon: const Icon(Icons.sort, size: 16),
(Widget child, Animation<double> animation) { label: Obx(() => Text(
return ScaleTransition( _dynamicDetailController.sortTypeLabel.value,
scale: animation, child: child); style: const TextStyle(fontSize: 13),
}, )),
child: Text( ),
'${_dynamicDetailController.acount.value}', )
key: ValueKey<int>( ],
_dynamicDetailController.acount.value),
),
),
),
const Text('条回复'),
const Spacer(),
SizedBox(
height: 35,
child: TextButton.icon(
onPressed: () =>
_dynamicDetailController.queryBySort(),
icon: const Icon(Icons.sort, size: 16),
label: Obx(() => Text(
_dynamicDetailController
.sortTypeLabel.value,
style: const TextStyle(fontSize: 13),
)),
),
)
],
),
),
), ),
pinned: true,
),
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map;
if (snapshot.data['status']) {
// 请求成功
return Obx(
() => _dynamicDetailController.replyList.isEmpty &&
_dynamicDetailController.isLoadingMore
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
)
: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index ==
_dynamicDetailController
.replyList.length) {
return Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context)
.padding
.bottom),
height: MediaQuery.of(context)
.padding
.bottom +
100,
child: Center(
child: Obx(
() => Text(
_dynamicDetailController
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
.colorScheme
.outline,
),
),
),
),
);
} else {
return ReplyItem(
replyItem: _dynamicDetailController
.replyList[index],
showReplyRow: true,
replyLevel: '1',
replyReply: (replyItem) =>
replyReply(replyItem),
replyType:
ReplyType.values[replyType],
addReply: (replyItem) {
_dynamicDetailController
.replyList[index].replies!
.add(replyItem);
},
);
}
},
childCount: _dynamicDetailController
.replyList.length +
1,
),
),
);
} else {
// 请求错误
return HttpError(
errMsg: data['msg'],
fn: () => setState(() {}),
);
}
} else {
// 骨架屏
return SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
);
}
},
)
],
),
Positioned(
bottom: MediaQuery.of(context).padding.bottom + 14,
right: 14,
child: SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 2),
end: const Offset(0, 0),
).animate(CurvedAnimation(
parent: fabAnimationCtr,
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),
), ),
), ),
pinned: true,
), ),
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map;
if (snapshot.data['status']) {
RxList<ReplyItemModel> replyList =
_dynamicDetailController.replyList;
// 请求成功
return Obx(
() => replyList.isEmpty &&
_dynamicDetailController.isLoadingMore
? SliverList(
delegate:
SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
)
: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == replyList.length) {
return Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context)
.padding
.bottom),
height: MediaQuery.of(context)
.padding
.bottom +
100,
child: Center(
child: Obx(
() => Text(
_dynamicDetailController
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
.colorScheme
.outline,
),
),
),
),
);
} else {
return ReplyItem(
replyItem: replyList[index],
showReplyRow: true,
replyLevel: '1',
replyReply: (replyItem) =>
replyReply(replyItem),
replyType: ReplyType.values[replyType],
addReply: (replyItem) {
replyList[index]
.replies!
.add(replyItem);
},
);
}
},
childCount: replyList.length + 1,
),
),
);
} else {
// 请求错误
return HttpError(
errMsg: data['msg'],
fn: () => setState(() {}),
);
}
} else {
// 骨架屏
return SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton();
}, childCount: 8),
);
}
},
)
], ],
), ),
), ),
floatingActionButton: SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 2),
end: const Offset(0, 0),
).animate(
CurvedAnimation(
parent: fabAnimationCtr,
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),
),
),
); );
} }
} }

View File

@ -3,38 +3,58 @@ import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/http/dynamics.dart'; import 'package:pilipala/http/dynamics.dart';
import 'package:pilipala/models/dynamics/result.dart'; import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/pages/dynamics/index.dart'; import 'package:pilipala/pages/dynamics/index.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:status_bar_control/status_bar_control.dart';
import 'rich_node_panel.dart';
class ActionPanel extends StatefulWidget { class ActionPanel extends StatefulWidget {
const ActionPanel({ const ActionPanel({
super.key, super.key,
this.item, required this.item,
}); });
// ignore: prefer_typing_uninitialized_variables // ignore: prefer_typing_uninitialized_variables
final item; final DynamicItemModel item;
@override @override
State<ActionPanel> createState() => _ActionPanelState(); State<ActionPanel> createState() => _ActionPanelState();
} }
class _ActionPanelState extends State<ActionPanel> { class _ActionPanelState extends State<ActionPanel>
with TickerProviderStateMixin {
final DynamicsController _dynamicsController = Get.put(DynamicsController()); final DynamicsController _dynamicsController = Get.put(DynamicsController());
late ModuleStatModel stat; late ModuleStatModel stat;
bool isProcessing = false; bool isProcessing = false;
double defaultHeight = 260;
RxDouble height = 0.0.obs;
RxBool isExpand = false.obs;
late double statusHeight;
TextEditingController _inputController = TextEditingController();
FocusNode myFocusNode = FocusNode();
String _inputText = '';
void Function()? handleState(Future Function() action) { void Function()? handleState(Future Function() action) {
return isProcessing ? null : () async { return isProcessing
setState(() => isProcessing = true); ? null
await action(); : () async {
setState(() => isProcessing = false); isProcessing = true;
}; await action();
isProcessing = false;
};
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
stat = widget.item!.modules.moduleStat; stat = widget.item.modules!.moduleStat!;
onInit();
}
onInit() async {
statusHeight = await StatusBarControl.getHeight;
} }
// 动态点赞 // 动态点赞
@ -43,7 +63,7 @@ class _ActionPanelState extends State<ActionPanel> {
var item = widget.item!; var item = widget.item!;
String dynamicId = item.idStr!; String dynamicId = item.idStr!;
// 1 已点赞 2 不喜欢 0 未操作 // 1 已点赞 2 不喜欢 0 未操作
Like like = item.modules.moduleStat.like; Like like = item.modules!.moduleStat!.like!;
int count = like.count == '点赞' ? 0 : int.parse(like.count ?? '0'); int count = like.count == '点赞' ? 0 : int.parse(like.count ?? '0');
bool status = like.status!; bool status = like.status!;
int up = status ? 2 : 1; int up = status ? 2 : 1;
@ -51,15 +71,15 @@ class _ActionPanelState extends State<ActionPanel> {
if (res['status']) { if (res['status']) {
SmartDialog.showToast(!status ? '点赞成功' : '取消赞'); SmartDialog.showToast(!status ? '点赞成功' : '取消赞');
if (up == 1) { if (up == 1) {
item.modules.moduleStat.like.count = (count + 1).toString(); item.modules!.moduleStat!.like!.count = (count + 1).toString();
item.modules.moduleStat.like.status = true; item.modules!.moduleStat!.like!.status = true;
} else { } else {
if (count == 1) { if (count == 1) {
item.modules.moduleStat.like.count = '点赞'; item.modules!.moduleStat!.like!.count = '点赞';
} else { } else {
item.modules.moduleStat.like.count = (count - 1).toString(); item.modules!.moduleStat!.like!.count = (count - 1).toString();
} }
item.modules.moduleStat.like.status = false; item.modules!.moduleStat!.like!.status = false;
} }
setState(() {}); setState(() {});
} else { } else {
@ -67,17 +87,307 @@ class _ActionPanelState extends State<ActionPanel> {
} }
} }
// 转发动态预览
Widget dynamicPreview() {
ItemModulesModel? modules = widget.item.modules;
final String type = widget.item.type!;
String? cover = modules?.moduleAuthor?.face;
switch (type) {
/// 图文动态
case 'DYNAMIC_TYPE_DRAW':
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
/// 投稿
case 'DYNAMIC_TYPE_AV':
cover = modules?.moduleDynamic?.major?.archive?.cover;
/// 转发的动态
case 'DYNAMIC_TYPE_FORWARD':
String forwardType = widget.item.orig!.type!;
switch (forwardType) {
/// 图文动态
case 'DYNAMIC_TYPE_DRAW':
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
/// 投稿
case 'DYNAMIC_TYPE_AV':
cover = modules?.moduleDynamic?.major?.archive?.cover;
/// 专栏文章
case 'DYNAMIC_TYPE_ARTICLE':
cover = '';
/// 番剧
case 'DYNAMIC_TYPE_PGC':
cover = '';
/// 纯文字动态
case 'DYNAMIC_TYPE_WORD':
cover = '';
/// 直播
case 'DYNAMIC_TYPE_LIVE_RCMD':
cover = '';
/// 合集查看
case 'DYNAMIC_TYPE_UGC_SEASON':
cover = '';
/// 番剧
case 'DYNAMIC_TYPE_PGC_UNION':
cover = modules?.moduleDynamic?.major?.pgc?.cover;
default:
cover = '';
}
/// 专栏文章
case 'DYNAMIC_TYPE_ARTICLE':
cover = '';
/// 番剧
case 'DYNAMIC_TYPE_PGC':
cover = '';
/// 纯文字动态
case 'DYNAMIC_TYPE_WORD':
cover = '';
/// 直播
case 'DYNAMIC_TYPE_LIVE_RCMD':
cover = '';
/// 合集查看
case 'DYNAMIC_TYPE_UGC_SEASON':
cover = '';
/// 番剧查看
case 'DYNAMIC_TYPE_PGC_UNION':
cover = '';
default:
cover = '';
}
return Container(
width: double.infinity,
height: 95,
margin: const EdgeInsets.fromLTRB(12, 0, 12, 14),
decoration: BoxDecoration(
color:
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4),
borderRadius: BorderRadius.circular(6),
border: Border(
left: BorderSide(
width: 4,
color: Theme.of(context).colorScheme.primary.withOpacity(0.8)),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'@${widget.item.modules!.moduleAuthor!.name}',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(height: 8),
Row(
children: [
NetworkImgLayer(
src: cover ?? '',
width: 34,
height: 34,
type: 'emote',
),
const SizedBox(width: 10),
Expanded(
child: Text.rich(
style: const TextStyle(height: 0),
richNode(widget.item, context),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
// Text(data)
],
)
],
),
),
);
}
// 动态转发
void forwardHandler() async {
showModalBottomSheet(
context: context,
enableDrag: false,
useRootNavigator: true,
isScrollControlled: true,
builder: (context) {
return Obx(
() => AnimatedContainer(
duration: Durations.medium1,
onEnd: () async {
if (isExpand.value) {
await Future.delayed(const Duration(milliseconds: 80));
myFocusNode.requestFocus();
}
},
height: height.value + MediaQuery.of(context).padding.bottom,
child: Column(
children: [
AnimatedContainer(
duration: Durations.medium1,
height: isExpand.value ? statusHeight : 0,
),
Padding(
padding: EdgeInsets.fromLTRB(
isExpand.value ? 10 : 16,
10,
isExpand.value ? 14 : 12,
0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (isExpand.value) ...[
IconButton(
onPressed: () => togglePanelState(false),
icon: const Icon(Icons.close),
),
Text(
'转发动态',
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontWeight: FontWeight.bold),
)
] else ...[
const Text(
'转发动态',
style: TextStyle(fontWeight: FontWeight.bold),
)
],
isExpand.value
? FilledButton(
onPressed: () => dynamicForward('forward'),
child: const Text('转发'),
)
: TextButton(
onPressed: () {},
child: const Text('立即转发'),
)
],
),
),
if (!isExpand.value) ...[
GestureDetector(
onTap: () => togglePanelState(true),
behavior: HitTestBehavior.translucent,
child: Container(
width: double.infinity,
alignment: Alignment.centerLeft,
padding: const EdgeInsets.fromLTRB(16, 0, 10, 14),
child: Text(
'说点什么吧',
textAlign: TextAlign.start,
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
),
),
),
] else ...[
Padding(
padding: const EdgeInsets.fromLTRB(16, 10, 16, 0),
child: TextField(
maxLines: 5,
focusNode: myFocusNode,
controller: _inputController,
onChanged: (value) {
setState(() {
_inputText = value;
});
},
decoration: const InputDecoration(
border: InputBorder.none,
hintText: '说点什么吧',
),
),
),
],
dynamicPreview(),
if (!isExpand.value) ...[
const Divider(thickness: 0.1, height: 1),
ListTile(
onTap: () => Get.back(),
minLeadingWidth: 0,
dense: true,
title: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
textAlign: TextAlign.center,
),
),
]
],
),
),
);
},
);
}
togglePanelState(status) {
if (!status) {
Get.back();
height.value = defaultHeight;
_inputText = '';
_inputController.clear();
} else {
height.value = Get.size.height;
}
isExpand.value = !(isExpand.value);
}
dynamicForward(String type) async {
String dynamicId = widget.item.idStr!;
var res = await DynamicsHttp.dynamicCreate(
dynIdStr: dynamicId,
mid: _dynamicsController.userInfo.mid,
rawText: _inputText,
scene: 4,
);
if (res['status']) {
SmartDialog.showToast(type == 'forward' ? '转发成功' : '发布成功');
togglePanelState(false);
}
}
@override
void dispose() {
myFocusNode.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var color = Theme.of(context).colorScheme.outline; var color = Theme.of(context).colorScheme.outline;
var primary = Theme.of(context).colorScheme.primary; var primary = Theme.of(context).colorScheme.primary;
height.value = defaultHeight;
print('height.value: ${height.value}');
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
Expanded( Expanded(
flex: 1, flex: 1,
child: TextButton.icon( child: TextButton.icon(
onPressed: () {}, onPressed: forwardHandler,
icon: const Icon( icon: const Icon(
FontAwesomeIcons.shareFromSquare, FontAwesomeIcons.shareFromSquare,
size: 16, size: 16,

View File

@ -1,15 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/pages/dynamics/index.dart'; import 'package:pilipala/pages/dynamics/index.dart';
import '../../../models/dynamics/result.dart';
import 'action_panel.dart'; import 'action_panel.dart';
import 'author_panel.dart'; import 'author_panel.dart';
import 'content_panel.dart'; import 'content_panel.dart';
import 'forward_panel.dart'; import 'forward_panel.dart';
class DynamicPanel extends StatelessWidget { class DynamicPanel extends StatelessWidget {
final dynamic item; final DynamicItemModel item;
final String? source; final String? source;
DynamicPanel({this.item, this.source, Key? key}) : super(key: key); DynamicPanel({required this.item, this.source, Key? key}) : super(key: key);
final DynamicsController _dynamicsController = Get.put(DynamicsController()); final DynamicsController _dynamicsController = Get.put(DynamicsController());
@override @override
@ -41,8 +42,8 @@ class DynamicPanel extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),
child: AuthorPanel(item: item), child: AuthorPanel(item: item),
), ),
if (item!.modules!.moduleDynamic!.desc != null || if (item.modules!.moduleDynamic!.desc != null ||
item!.modules!.moduleDynamic!.major != null) item.modules!.moduleDynamic!.major != null)
Content(item: item, source: source), Content(item: item, source: source),
forWard(item, context, _dynamicsController, source), forWard(item, context, _dynamicsController, source),
const SizedBox(height: 2), const SizedBox(height: 2),

View File

@ -10,10 +10,11 @@ import 'package:pilipala/utils/storage.dart';
class FavController extends GetxController { class FavController extends GetxController {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
Rx<FavFolderData> favFolderData = FavFolderData().obs; Rx<FavFolderData> favFolderData = FavFolderData().obs;
RxList<FavFolderItemData> favFolderList = <FavFolderItemData>[].obs;
Box userInfoCache = GStrorage.userInfo; Box userInfoCache = GStrorage.userInfo;
UserInfoData? userInfo; UserInfoData? userInfo;
int currentPage = 1; int currentPage = 1;
int pageSize = 10; int pageSize = 60;
RxBool hasMore = true.obs; RxBool hasMore = true.obs;
Future<dynamic> queryFavFolder({type = 'init'}) async { Future<dynamic> queryFavFolder({type = 'init'}) async {
@ -32,9 +33,10 @@ class FavController extends GetxController {
if (res['status']) { if (res['status']) {
if (type == 'init') { if (type == 'init') {
favFolderData.value = res['data']; favFolderData.value = res['data'];
favFolderList.value = res['data'].list;
} else { } else {
if (res['data'].list.isNotEmpty) { if (res['data'].list.isNotEmpty) {
favFolderData.value.list!.addAll(res['data'].list); favFolderList.addAll(res['data'].list);
favFolderData.update((val) {}); favFolderData.update((val) {});
} }
} }
@ -49,4 +51,13 @@ class FavController extends GetxController {
Future onLoad() async { Future onLoad() async {
queryFavFolder(type: 'onload'); queryFavFolder(type: 'onload');
} }
removeFavFolder({required int mediaIds}) async {
for (var i in favFolderList) {
if (i.id == mediaIds) {
favFolderList.remove(i);
break;
}
}
}
} }

View File

@ -62,11 +62,10 @@ class _FavPageState extends State<FavPage> {
return Obx( return Obx(
() => ListView.builder( () => ListView.builder(
controller: scrollController, controller: scrollController,
itemCount: _favController.favFolderData.value.list!.length, itemCount: _favController.favFolderList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return FavItem( return FavItem(
favFolderItem: favFolderItem: _favController.favFolderList[index]);
_favController.favFolderData.value.list![index]);
}, },
), ),
); );

View File

@ -13,14 +13,16 @@ class FavItem extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(favFolderItem.fid); String heroTag = Utils.makeHeroTag(favFolderItem.fid);
return InkWell( return InkWell(
onTap: () => Get.toNamed( onTap: () async {
'/favDetail', Get.toNamed(
arguments: favFolderItem, '/favDetail',
parameters: { arguments: favFolderItem,
'heroTag': heroTag, parameters: {
'mediaId': favFolderItem.id.toString(), 'heroTag': heroTag,
}, 'mediaId': favFolderItem.id.toString(),
), },
);
},
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(12, 7, 12, 7), padding: const EdgeInsets.fromLTRB(12, 7, 12, 7),
child: LayoutBuilder( child: LayoutBuilder(

View File

@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
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:pilipala/http/user.dart'; import 'package:pilipala/http/user.dart';
import 'package:pilipala/http/video.dart'; import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/user/fav_detail.dart'; import 'package:pilipala/models/user/fav_detail.dart';
import 'package:pilipala/models/user/fav_folder.dart'; import 'package:pilipala/models/user/fav_folder.dart';
import 'package:pilipala/pages/fav/index.dart';
class FavDetailController extends GetxController { class FavDetailController extends GetxController {
FavFolderItemData? item; FavFolderItemData? item;
@ -74,4 +76,41 @@ class FavDetailController extends GetxController {
onLoad() { onLoad() {
queryUserFavFolderDetail(type: 'onLoad'); queryUserFavFolderDetail(type: 'onLoad');
} }
onDelFavFolder() async {
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: const Text('确定删除这个收藏夹吗?'),
actions: [
TextButton(
onPressed: () async {
SmartDialog.dismiss();
},
child: Text(
'点错了',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await UserHttp.delFavFolder(mediaIds: mediaId!);
SmartDialog.dismiss();
SmartDialog.showToast(res['status'] ? '操作成功' : res['msg']);
if (res['status']) {
FavController favController = Get.find<FavController>();
await favController.removeFavFolder(mediaIds: mediaId!);
Get.back();
}
},
child: const Text('确认'),
)
],
);
},
);
}
} }

View File

@ -53,6 +53,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller.dispose();
titleStreamC.close();
super.dispose(); super.dispose();
} }
@ -100,11 +101,19 @@ class _FavDetailPageState extends State<FavDetailPage> {
Get.toNamed('/favSearch?searchType=0&mediaId=$mediaId'), Get.toNamed('/favSearch?searchType=0&mediaId=$mediaId'),
icon: const Icon(Icons.search_outlined), icon: const Icon(Icons.search_outlined),
), ),
// IconButton( PopupMenuButton<String>(
// onPressed: () {}, icon: const Icon(Icons.more_vert_outlined),
// icon: const Icon(Icons.more_vert), position: PopupMenuPosition.under,
// ), onSelected: (String type) {},
const SizedBox(width: 6), itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
PopupMenuItem<String>(
onTap: () => _favDetailController.onDelFavFolder(),
value: 'pause',
child: const Text('删除收藏夹'),
),
],
),
const SizedBox(width: 14),
], ],
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
background: Container( background: Container(

View File

@ -114,4 +114,10 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
defaultSearch.value = res.data['data']['name']; defaultSearch.value = res.data['data']['name'];
} }
} }
@override
void onClose() {
searchBarStream.close();
super.onClose();
}
} }

View File

@ -214,6 +214,34 @@ class UserInfoWidget extends StatelessWidget {
final VoidCallback? callback; final VoidCallback? callback;
final HomeController? ctr; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
@ -231,31 +259,7 @@ class UserInfoWidget extends StatelessWidget {
const SizedBox(width: 8), const SizedBox(width: 8),
Obx( Obx(
() => userLogin.value () => userLogin.value
? Stack( ? buildLoggedInWidget(context)
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),
),
),
),
)
],
)
: DefaultUser(callback: () => callback!()), : DefaultUser(callback: () => callback!()),
), ),
], ],
@ -402,30 +406,27 @@ class SearchBar extends StatelessWidget {
color: colorScheme.onSecondaryContainer.withOpacity(0.05), color: colorScheme.onSecondaryContainer.withOpacity(0.05),
child: InkWell( child: InkWell(
splashColor: colorScheme.primaryContainer.withOpacity(0.3), splashColor: colorScheme.primaryContainer.withOpacity(0.3),
onTap: () => Get.toNamed( onTap: () => Get.toNamed('/search',
'/search', parameters: {'hintText': ctr!.defaultSearch.value}),
parameters: {'hintText': ctr!.defaultSearch.value}, child: Padding(
), padding: const EdgeInsets.symmetric(horizontal: 14),
child: Row( child: Row(
children: [ children: [
const SizedBox(width: 14), Icon(
Icon( Icons.search_outlined,
Icons.search_outlined, color: colorScheme.onSecondaryContainer,
color: colorScheme.onSecondaryContainer, ),
), const SizedBox(width: 10),
const SizedBox(width: 10), Obx(
Obx( () => Text(
() => Expanded(
child: Text(
ctr!.defaultSearch.value, ctr!.defaultSearch.value,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(color: colorScheme.outline), style: TextStyle(color: colorScheme.outline),
), ),
), ),
), ],
const SizedBox(width: 15), ),
],
), ),
), ),
), ),

View File

@ -101,4 +101,10 @@ class MainController extends GetxController {
selectedIndex = defaultIndex != -1 ? defaultIndex : 0; selectedIndex = defaultIndex != -1 ? defaultIndex : 0;
pages = navigationBars.map<Widget>((e) => e['page']).toList(); pages = navigationBars.map<Widget>((e) => e['page']).toList();
} }
@override
void onClose() {
bottomBarStream.close();
super.onClose();
}
} }

View File

@ -54,6 +54,7 @@ class _MemberPageState extends State<MemberPage>
@override @override
void dispose() { void dispose() {
_extendNestCtr.removeListener(() {}); _extendNestCtr.removeListener(() {});
appbarStream.close();
super.dispose(); super.dispose();
} }

View File

@ -5,6 +5,7 @@ import 'package:pilipala/pages/member_dynamics/index.dart';
import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/utils.dart';
import '../../common/widgets/http_error.dart'; import '../../common/widgets/http_error.dart';
import '../../models/dynamics/result.dart';
import '../dynamics/widgets/dynamic_panel.dart'; import '../dynamics/widgets/dynamic_panel.dart';
class MemberDynamicsPage extends StatefulWidget { class MemberDynamicsPage extends StatefulWidget {
@ -66,7 +67,8 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data != null) { if (snapshot.data != null) {
Map data = snapshot.data as Map; Map data = snapshot.data as Map;
List list = _memberDynamicController.dynamicsList; RxList<DynamicItemModel> list =
_memberDynamicController.dynamicsList;
if (data['status']) { if (data['status']) {
return Obx( return Obx(
() => list.isNotEmpty () => list.isNotEmpty

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/models/common/rank_type.dart'; import 'package:pilipala/models/common/rank_type.dart';
import 'package:pilipala/pages/rank/zone/index.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
class RankController extends GetxController with GetTickerProviderStateMixin { class RankController extends GetxController with GetTickerProviderStateMixin {
@ -29,20 +30,22 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
void onRefresh() { void onRefresh() {
int index = tabController.index; int index = tabController.index;
var ctr = tabsCtrList[index]; final ZoneController ctr = tabsCtrList[index];
ctr().onRefresh(); ctr.onRefresh();
} }
void animateToTop() { void animateToTop() {
int index = tabController.index; int index = tabController.index;
var ctr = tabsCtrList[index]; final ZoneController ctr = tabsCtrList[index];
ctr().animateToTop(); ctr.animateToTop();
} }
void setTabConfig() async { void setTabConfig() async {
tabs.value = tabsConfig; tabs.value = tabsConfig;
initialIndex.value = 0; initialIndex.value = 0;
tabsCtrList = tabs.map((e) => e['ctr']).toList(); tabsCtrList = tabs
.map((e) => Get.put(ZoneController(), tag: e['rid'].toString()))
.toList();
tabsPageList = tabs.map<Widget>((e) => e['page']).toList(); tabsPageList = tabs.map<Widget>((e) => e['page']).toList();
tabController = TabController( tabController = TabController(
@ -51,4 +54,10 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
vsync: this, vsync: this,
); );
} }
@override
void onClose() {
searchBarStream.close();
super.onClose();
}
} }

View File

@ -102,7 +102,7 @@ class _RankPageState extends State<RankPage>
onTap: (value) { onTap: (value) {
feedBack(); feedBack();
if (_rankController.initialIndex.value == value) { if (_rankController.initialIndex.value == value) {
_rankController.tabsCtrList[value]().animateToTop(); _rankController.tabsCtrList[value].animateToTop();
} }
_rankController.initialIndex.value = value; _rankController.initialIndex.value = value;
}, },

View File

@ -42,12 +42,15 @@ class ZoneController extends GetxController {
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() async {
if (scrollController.offset >= if (scrollController.hasClients) {
MediaQuery.of(Get.context!).size.height * 5) { if (scrollController.offset >=
scrollController.jumpTo(0); MediaQuery.of(Get.context!).size.height * 5) {
} else { scrollController.jumpTo(0);
await scrollController.animateTo(0, } else {
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut);
}
} }
} }
} }

View File

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

View File

@ -29,7 +29,7 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
return AlertDialog( return AlertDialog(
title: Text(widget.title), 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) { content: StatefulBuilder(builder: (context, StateSetter setState) {
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(

View File

@ -53,6 +53,7 @@ class _SubDetailPageState extends State<SubDetailPage> {
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller.dispose();
titleStreamC.close();
super.dispose(); super.dispose();
} }

View File

@ -51,7 +51,7 @@ class VideoDetailController extends GetxController
/// 播放器配置 画质 音质 解码格式 /// 播放器配置 画质 音质 解码格式
late VideoQuality currentVideoQa; late VideoQuality currentVideoQa;
AudioQuality? currentAudioQa; AudioQuality? currentAudioQa;
late VideoDecodeFormats currentDecodeFormats; VideoDecodeFormats? currentDecodeFormats;
// 是否开始自动播放 存在多p的情况下第二p需要为true // 是否开始自动播放 存在多p的情况下第二p需要为true
RxBool autoPlay = true.obs; RxBool autoPlay = true.obs;
// 视频资源是否有效 // 视频资源是否有效
@ -107,6 +107,7 @@ class VideoDetailController extends GetxController
BottomControlType.fullscreen, BottomControlType.fullscreen,
].obs; ].obs;
RxDouble sheetHeight = 0.0.obs; RxDouble sheetHeight = 0.0.obs;
RxString archiveSourceType = 'dash'.obs;
@override @override
void onInit() { void onInit() {
@ -189,37 +190,43 @@ class VideoDetailController extends GetxController
plPlayerController.isBuffering.value = false; plPlayerController.isBuffering.value = false;
plPlayerController.buffered.value = Duration.zero; plPlayerController.buffered.value = Duration.zero;
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl if (archiveSourceType.value == 'dash') {
List<VideoItem> videoList = /// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList(); List<VideoItem> videoList =
try { data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
firstVideo = videoList try {
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code)); firstVideo = videoList.firstWhere(
} catch (_) { (i) => i.codecs!.startsWith(currentDecodeFormats?.code));
if (currentVideoQa == VideoQuality.dolbyVision) { } catch (_) {
firstVideo = videoList.first; if (currentVideoQa == VideoQuality.dolbyVision) {
currentDecodeFormats = firstVideo = videoList.first;
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!; currentDecodeFormats =
} else { VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
// 当前格式不可用 } else {
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get( // 当前格式不可用
SettingBoxKey.defaultDecode, currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
defaultValue: VideoDecodeFormats.values.last.code))!; SettingBoxKey.defaultDecode,
firstVideo = videoList defaultValue: VideoDecodeFormats.values.last.code))!;
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.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 (archiveSourceType.value == 'durl') {
if (currentAudioQa != null) { cacheVideoQa = VideoQualityCode.toCode(currentVideoQa);
final AudioItem firstAudio = data.dash!.audio!.firstWhere( queryVideoUrl();
(AudioItem i) => i.id == currentAudioQa!.code,
orElse: () => data.dash!.audio!.first,
);
audioUrl = firstAudio.baseUrl ?? '';
} }
playerInit(); playerInit();
} }
@ -272,7 +279,8 @@ class VideoDetailController extends GetxController
// 视频链接 // 视频链接
Future queryVideoUrl() async { 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']) { if (result['status']) {
data = result['data']; data = result['data'];
if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) { if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) {
@ -290,8 +298,22 @@ class VideoDetailController extends GetxController
} }
return result; 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!; final List<VideoItem> allVideosList = data.dash!.video!;
try { try {
archiveSourceType.value = 'dash';
// 当前可播放的最高质量视频 // 当前可播放的最高质量视频
int currentHighVideoQa = allVideosList.first.quality!.code; int currentHighVideoQa = allVideosList.first.quality!.code;
// 预设的画质为null则当前可用的最高质量 // 预设的画质为null则当前可用的最高质量
@ -321,7 +343,7 @@ class VideoDetailController extends GetxController
// 当前视频没有对应格式返回第一个 // 当前视频没有对应格式返回第一个
bool flag = false; bool flag = false;
for (var i in supportDecodeFormats) { for (var i in supportDecodeFormats) {
if (i.startsWith(currentDecodeFormats.code)) { if (i.startsWith(currentDecodeFormats?.code)) {
flag = true; flag = true;
} }
} }
@ -335,7 +357,7 @@ class VideoDetailController extends GetxController
/// 取出符合当前解码格式的videoItem /// 取出符合当前解码格式的videoItem
try { try {
firstVideo = videosList.firstWhere( firstVideo = videosList.firstWhere(
(e) => e.codecs!.startsWith(currentDecodeFormats.code)); (e) => e.codecs!.startsWith(currentDecodeFormats?.code));
} catch (_) { } catch (_) {
firstVideo = videosList.first; firstVideo = videosList.first;
} }

View File

@ -58,6 +58,7 @@ class VideoIntroController extends GetxController {
String heroTag = ''; String heroTag = '';
late ModelResult modelResult; late ModelResult modelResult;
PersistentBottomSheetController? bottomSheetController; PersistentBottomSheetController? bottomSheetController;
late bool enableRelatedVideo;
@override @override
void onInit() { void onInit() {
@ -74,6 +75,8 @@ class VideoIntroController extends GetxController {
queryOnlineTotal(); queryOnlineTotal();
startTimer(); // 在页面加载时启动定时器 startTimer(); // 在页面加载时启动定时器
} }
enableRelatedVideo =
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
} }
// 获取视频简介&分p // 获取视频简介&分p
@ -216,50 +219,36 @@ class VideoIntroController extends GetxController {
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
title: const Text('选择投币个数'), 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) { content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [1, 2]
RadioListTile( .map(
value: 1, (e) => RadioListTile(
title: const Text('1枚'), value: e,
groupValue: _tempThemeValue, title: Text('$e枚'),
onChanged: (value) { groupValue: _tempThemeValue,
_tempThemeValue = value!; onChanged: (value) async {
Get.appUpdate(); _tempThemeValue = value!;
}, setState(() {});
), var res = await VideoHttp.coinVideo(
RadioListTile( bvid: bvid, multiply: _tempThemeValue);
value: 2, if (res['status']) {
title: const Text('2枚'), SmartDialog.showToast('投币成功 👏');
groupValue: _tempThemeValue, hasCoin.value = true;
onChanged: (value) { videoDetail.value.stat!.coin =
_tempThemeValue = value!; videoDetail.value.stat!.coin! + _tempThemeValue;
Get.appUpdate(); } 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('确定'))
],
); );
}); });
} }
@ -447,15 +436,18 @@ class VideoIntroController extends GetxController {
// 重新获取视频资源 // 重新获取视频资源
final VideoDetailController videoDetailCtr = final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag); Get.find<VideoDetailController>(tag: heroTag);
final ReleatedController releatedCtr = if (enableRelatedVideo) {
Get.find<ReleatedController>(tag: heroTag); final ReleatedController releatedCtr =
Get.find<ReleatedController>(tag: heroTag);
releatedCtr.bvid = bvid;
releatedCtr.queryRelatedVideo();
}
videoDetailCtr.bvid = bvid; videoDetailCtr.bvid = bvid;
videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid); videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid);
videoDetailCtr.cid.value = cid; videoDetailCtr.cid.value = cid;
videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.danmakuCid.value = cid;
videoDetailCtr.queryVideoUrl(); videoDetailCtr.queryVideoUrl();
releatedCtr.bvid = bvid;
releatedCtr.queryRelatedVideo();
// 重新请求评论 // 重新请求评论
try { try {
/// 未渲染回复组件时可能异常 /// 未渲染回复组件时可能异常

View File

@ -22,6 +22,7 @@ import 'widgets/fav_panel.dart';
import 'widgets/intro_detail.dart'; import 'widgets/intro_detail.dart';
import 'widgets/page_panel.dart'; import 'widgets/page_panel.dart';
import 'widgets/season_panel.dart'; import 'widgets/season_panel.dart';
import 'widgets/staff_up_item.dart';
class VideoIntroPanel extends StatefulWidget { class VideoIntroPanel extends StatefulWidget {
final String bvid; final String bvid;
@ -409,32 +410,35 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
), ),
) )
], ],
GestureDetector( if (widget.videoDetail!.staff == null)
onTap: onPushMember, GestureDetector(
child: Container( onTap: onPushMember,
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 4), child: Container(
child: Row( padding:
children: [ const EdgeInsets.symmetric(vertical: 12, horizontal: 4),
NetworkImgLayer( child: Row(
type: 'avatar', children: [
src: widget.videoDetail!.owner!.face, NetworkImgLayer(
width: 34, type: 'avatar',
height: 34, src: widget.videoDetail!.owner!.face,
fadeInDuration: Duration.zero, width: 34,
fadeOutDuration: Duration.zero, height: 34,
), fadeInDuration: Duration.zero,
const SizedBox(width: 10), fadeOutDuration: Duration.zero,
Text(owner.name, style: const TextStyle(fontSize: 13)),
const SizedBox(width: 6),
Text(
follower,
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: outline,
), ),
), const SizedBox(width: 10),
const Spacer(), Text(owner.name, style: const TextStyle(fontSize: 13)),
Obx(() => AnimatedOpacity( const SizedBox(width: 6),
Text(
follower,
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: outline,
),
),
const Spacer(),
Obx(
() => AnimatedOpacity(
opacity: opacity:
videoIntroController.followStatus.isEmpty ? 0 : 1, videoIntroController.followStatus.isEmpty ? 0 : 1,
duration: const Duration(milliseconds: 50), duration: const Duration(milliseconds: 50),
@ -474,11 +478,58 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
), ),
), ),
), ),
)), ),
], ),
],
),
), ),
), ),
), 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])
],
],
),
),
],
),
]
], ],
)), )),
); );
@ -545,4 +596,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, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
const SizedBox(height: 4), const SizedBox(height: 4),
GestureDetector( Row(
onTap: () { children: [
Clipboard.setData(ClipboardData(text: videoDetail!.bvid!)); GestureDetector(
SmartDialog.showToast('已复制'); onTap: () {
}, Clipboard.setData(ClipboardData(text: videoDetail!.bvid!));
child: Text( SmartDialog.showToast('已复制');
videoDetail!.bvid!, },
style: TextStyle( child: Text(
fontSize: 13, color: Theme.of(context).colorScheme.primary), 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), const SizedBox(height: 4),
Text.rich( Text.rich(

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

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
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:pilipala/http/dynamics.dart';
import 'package:pilipala/http/video.dart'; import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/emote.dart'; import 'package:pilipala/models/video/reply/emote.dart';
@ -40,6 +41,8 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
double keyboardHeight = 0.0; // 键盘高度 double keyboardHeight = 0.0; // 键盘高度
final _debouncer = Debouncer(milliseconds: 200); // 设置延迟时间 final _debouncer = Debouncer(milliseconds: 200); // 设置延迟时间
String toolbarType = 'input'; String toolbarType = 'input';
RxBool isForward = false.obs;
RxBool showForward = false.obs;
@override @override
void initState() { void initState() {
@ -52,6 +55,10 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
_autoFocus(); _autoFocus();
// 监听聚焦状态 // 监听聚焦状态
_focuslistener(); _focuslistener();
final String routePath = Get.currentRoute;
if (routePath.startsWith('/video')) {
showForward.value = true;
}
} }
_autoFocus() async { _autoFocus() async {
@ -88,6 +95,16 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
Get.back(result: { Get.back(result: {
'data': ReplyItemModel.fromJson(result['data']['reply'], ''), 'data': ReplyItemModel.fromJson(result['data']['reply'], ''),
}); });
/// 投稿、番剧页面
if (isForward.value) {
await DynamicsHttp.dynamicCreate(
mid: 0,
rawText: message,
oid: widget.oid!,
scene: 5,
);
}
} else { } else {
SmartDialog.showToast(result['msg']); SmartDialog.showToast(result['msg']);
} }
@ -145,7 +162,6 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
double _keyboardHeight = EdgeInsets.fromViewPadding( double _keyboardHeight = EdgeInsets.fromViewPadding(
View.of(context).viewInsets, View.of(context).devicePixelRatio) View.of(context).viewInsets, View.of(context).devicePixelRatio)
.bottom; .bottom;
print('_keyboardHeight: $_keyboardHeight');
return Container( return Container(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -225,9 +241,37 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
toolbarType: toolbarType, toolbarType: toolbarType,
selected: toolbarType == 'emote', selected: toolbarType == 'emote',
), ),
const SizedBox(width: 6),
Obx(
() => showForward.value
? TextButton.icon(
onPressed: () {
isForward.value = !isForward.value;
},
icon: Icon(
isForward.value
? Icons.check_box
: Icons.check_box_outline_blank,
size: 22),
label: const Text('转发到动态'),
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(
isForward.value
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline,
),
),
)
: const SizedBox(),
),
const Spacer(), const Spacer(),
TextButton( SizedBox(
onPressed: () => submitReplyAdd(), child: const Text('发送')) height: 36,
child: FilledButton(
onPressed: () => submitReplyAdd(),
child: const Text('发送'),
),
),
], ],
), ),
), ),

View File

@ -404,27 +404,41 @@ class _VideoDetailPageState extends State<VideoDetailPage>
width: 38, width: 38,
height: 38, height: 38,
child: Obx( child: Obx(
() => IconButton( () => !vdCtr.isShowCover.value
onPressed: () { ? IconButton(
plPlayerController?.isOpenDanmu.value = onPressed: () {
!(plPlayerController?.isOpenDanmu.value ?? plPlayerController?.isOpenDanmu.value =
false); !(plPlayerController
}, ?.isOpenDanmu.value ??
icon: !(plPlayerController?.isOpenDanmu.value ?? false);
false) },
? SvgPicture.asset( icon:
!(plPlayerController?.isOpenDanmu.value ??
false)
? SvgPicture.asset(
'assets/images/video/danmu_close.svg',
// ignore: deprecated_member_use
color: Theme.of(context)
.colorScheme
.outline,
)
: SvgPicture.asset(
'assets/images/video/danmu_open.svg',
// ignore: deprecated_member_use
color: Theme.of(context)
.colorScheme
.primary,
),
)
: IconButton(
icon: SvgPicture.asset(
'assets/images/video/danmu_close.svg', 'assets/images/video/danmu_close.svg',
// ignore: deprecated_member_use // ignore: deprecated_member_use
color: color:
Theme.of(context).colorScheme.outline, Theme.of(context).colorScheme.outline,
)
: SvgPicture.asset(
'assets/images/video/danmu_open.svg',
// ignore: deprecated_member_use
color:
Theme.of(context).colorScheme.primary,
), ),
), onPressed: () {},
),
), ),
), ),
const SizedBox(width: 18), const SizedBox(width: 18),

View File

@ -49,7 +49,7 @@ class AiDetail extends StatelessWidget {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
Text( SelectableText(
modelResult!.summary!, modelResult!.summary!,
style: const TextStyle( style: const TextStyle(
fontSize: 15, fontSize: 15,
@ -60,13 +60,15 @@ class AiDetail extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
itemCount: modelResult!.outline!.length,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: modelResult!.outline!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final outline = modelResult!.outline![index];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( SelectableText(
modelResult!.outline![index].title!, outline.title!,
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -77,76 +79,59 @@ class AiDetail extends StatelessWidget {
ListView.builder( ListView.builder(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: modelResult! itemCount: outline.partOutline!.length,
.outline![index].partOutline!.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
final part = outline.partOutline![i];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Wrap( GestureDetector(
children: [ onTap: () {
RichText( try {
text: TextSpan( final controller =
style: TextStyle( Get.find<VideoDetailController>(
fontSize: 13, tag: Get.arguments['heroTag'],
color: Theme.of(context) );
.colorScheme controller.plPlayerController.seekTo(
.onBackground, Duration(
height: 1.5, seconds: Utils.duration(
Utils.tampToSeektime(
part.timestamp!),
).toInt(),
), ),
children: [ );
TextSpan( } catch (_) {}
text: Utils.tampToSeektime( },
modelResult! child: SelectableText.rich(
.outline![index] TextSpan(
.partOutline![i] style: TextStyle(
.timestamp!), fontSize: 13,
style: TextStyle( color: Theme.of(context)
color: Theme.of(context) .colorScheme
.colorScheme .onBackground,
.primary, height: 1.5,
),
recognizer: TapGestureRecognizer()
..onTap = () {
// 跳转到指定位置
try {
Get.find<VideoDetailController>(
tag: Get.arguments[
'heroTag'])
.plPlayerController
.seekTo(
Duration(
seconds:
Utils.duration(
Utils.tampToSeektime(modelResult!
.outline![
index]
.partOutline![
i]
.timestamp!)
.toString(),
),
),
);
} catch (_) {}
},
),
const TextSpan(text: ' '),
TextSpan(
text: modelResult!
.outline![index]
.partOutline![i]
.content!),
],
), ),
children: [
TextSpan(
text: Utils.tampToSeektime(
part.timestamp!),
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary,
),
),
const TextSpan(text: ' '),
TextSpan(text: part.content!),
],
), ),
], ),
), ),
const SizedBox(height: 20),
], ],
); );
}, },
), ),
const SizedBox(height: 20),
], ],
); );
}, },

View File

@ -180,15 +180,16 @@ class _HeaderControlState extends State<HeaderControl> {
'当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}', '当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}',
style: subTitleStyle), style: subTitleStyle),
), ),
ListTile( if (widget.videoDetailCtr!.currentDecodeFormats != null)
onTap: () => {Get.back(), showSetDecodeFormats()}, ListTile(
dense: true, onTap: () => {Get.back(), showSetDecodeFormats()},
leading: const Icon(Icons.av_timer_outlined, size: 20), dense: true,
title: const Text('解码格式', style: titleStyle), leading: const Icon(Icons.av_timer_outlined, size: 20),
subtitle: Text( title: const Text('解码格式', style: titleStyle),
'当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats.description}', subtitle: Text(
style: subTitleStyle), '当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats!.description}',
), style: subTitleStyle),
),
ListTile( ListTile(
onTap: () => {Get.back(), showSetRepeat()}, onTap: () => {Get.back(), showSetRepeat()},
dense: true, dense: true,
@ -541,16 +542,24 @@ class _HeaderControlState extends State<HeaderControl> {
/// 可用的质量分类 /// 可用的质量分类
int userfulQaSam = 0; int userfulQaSam = 0;
final List<VideoItem> video = videoInfo.dash!.video!; if (videoInfo.dash != null) {
final Set<int> idSet = {}; // dash格式视频一次请求会返回所有可播放的清晰度video
for (final VideoItem item in video) { final List<VideoItem> video = videoInfo.dash!.video!;
final int id = item.id!; final Set<int> idSet = {};
if (!idSet.contains(id)) { for (final VideoItem item in video) {
idSet.add(id); final int id = item.id!;
userfulQaSam++; if (!idSet.contains(id)) {
idSet.add(id);
userfulQaSam++;
}
} }
} }
if (videoInfo.durl != null) {
// durl格式视频一次请求返回对应清晰度video
userfulQaSam = videoFormat.length - 1;
}
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
elevation: 0, elevation: 0,
@ -707,7 +716,7 @@ class _HeaderControlState extends State<HeaderControl> {
void showSetDecodeFormats() { void showSetDecodeFormats() {
// 当前选中的解码格式 // 当前选中的解码格式
final VideoDecodeFormats currentDecodeFormats = final VideoDecodeFormats currentDecodeFormats =
widget.videoDetailCtr!.currentDecodeFormats; widget.videoDetailCtr!.currentDecodeFormats!;
final VideoItem firstVideo = widget.videoDetailCtr!.firstVideo; final VideoItem firstVideo = widget.videoDetailCtr!.firstVideo;
// 当前视频可用的解码格式 // 当前视频可用的解码格式
final List<FormatItem> videoFormat = videoInfo.supportFormats!; final List<FormatItem> videoFormat = videoInfo.supportFormats!;
@ -1306,20 +1315,6 @@ class _HeaderControlState extends State<HeaderControl> {
], ],
/// 字幕 /// 字幕
// SizedBox(
// width: 34,
// height: 34,
// child: IconButton(
// style: ButtonStyle(
// padding: MaterialStateProperty.all(EdgeInsets.zero),
// ),
// onPressed: () => showSubtitleDialog(),
// icon: const Icon(
// Icons.closed_caption_off,
// size: 22,
// ),
// ),
// ),
ComBtn( ComBtn(
icon: const Icon( icon: const Icon(
Icons.closed_caption_off, Icons.closed_caption_off,

View File

@ -101,7 +101,7 @@ class PlPlayerController {
bool _isFirstTime = true; bool _isFirstTime = true;
Timer? _timer; Timer? _timer;
late Timer? _timerForSeek; Timer? _timerForSeek;
Timer? _timerForVolume; Timer? _timerForVolume;
Timer? _timerForShowingVolume; Timer? _timerForShowingVolume;
Timer? _timerForGettingVolume; Timer? _timerForGettingVolume;
@ -335,8 +335,10 @@ class PlPlayerController {
}) { }) {
// 如果实例尚未创建,则创建一个新实例 // 如果实例尚未创建,则创建一个新实例
_instance ??= PlPlayerController._(); _instance ??= PlPlayerController._();
_instance!._playerCount.value += 1; if (videoType != 'none') {
_videoType.value = videoType; _instance!._playerCount.value += 1;
_videoType.value = videoType;
}
return _instance!; return _instance!;
} }
@ -473,17 +475,17 @@ class PlPlayerController {
} }
// 字幕 // 字幕
if (dataSource.subFiles != '' && dataSource.subFiles != null) { // if (dataSource.subFiles != '' && dataSource.subFiles != null) {
await pp.setProperty( // await pp.setProperty(
'sub-files', // 'sub-files',
UniversalPlatform.isWindows // UniversalPlatform.isWindows
? dataSource.subFiles!.replaceAll(';', '\\;') // ? dataSource.subFiles!.replaceAll(';', '\\;')
: dataSource.subFiles!.replaceAll(':', '\\:'), // : dataSource.subFiles!.replaceAll(':', '\\:'),
); // );
await pp.setProperty("subs-with-matching-audio", "no"); // await pp.setProperty("subs-with-matching-audio", "no");
await pp.setProperty("sub-forced-only", "yes"); // await pp.setProperty("sub-forced-only", "yes");
await pp.setProperty("blend-subtitles", "video"); // await pp.setProperty("blend-subtitles", "video");
} // }
_videoController = _videoController ?? _videoController = _videoController ??
VideoController( VideoController(
@ -522,7 +524,22 @@ class PlPlayerController {
Duration seekTo = Duration.zero, Duration seekTo = Duration.zero,
Duration? duration, Duration? duration,
}) async { }) async {
// 设置倍速 getVideoFit();
// if (_looping) {
// await setLooping(_looping);
// }
/// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
/// 自动播放
if (_autoPlay) {
await play(duration: duration);
}
/// 设置倍速
if (videoType.value == 'live') { if (videoType.value == 'live') {
await setPlaybackSpeed(1.0); await setPlaybackSpeed(1.0);
} else { } else {
@ -532,20 +549,6 @@ class PlPlayerController {
await setPlaybackSpeed(1.0); await setPlaybackSpeed(1.0);
} }
} }
getVideoFit();
// if (_looping) {
// await setLooping(_looping);
// }
// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
// 自动播放
if (_autoPlay) {
await play(duration: duration);
}
} }
List<StreamSubscription> subscriptions = []; List<StreamSubscription> subscriptions = [];
@ -603,7 +606,9 @@ class PlPlayerController {
makeHeartBeat(event.inSeconds); makeHeartBeat(event.inSeconds);
}), }),
videoPlayerController!.stream.duration.listen((event) { videoPlayerController!.stream.duration.listen((event) {
duration.value = event; if (event > Duration.zero) {
duration.value = event;
}
}), }),
videoPlayerController!.stream.buffer.listen((event) { videoPlayerController!.stream.buffer.listen((event) {
_buffered.value = event; _buffered.value = event;
@ -646,32 +651,38 @@ class PlPlayerController {
/// 跳转至指定位置 /// 跳转至指定位置
Future<void> seekTo(Duration position, {type = 'seek'}) async { Future<void> seekTo(Duration position, {type = 'seek'}) async {
if (position < Duration.zero) { try {
position = Duration.zero; if (position < Duration.zero) {
} position = Duration.zero;
_position.value = position;
updatePositionSecond();
_heartDuration = position.inSeconds;
if (duration.value.inSeconds != 0) {
if (type != 'slider') {
/// 拖动进度条调节时,不等待第一帧,防止抖动
await _videoPlayerController?.stream.buffer.first;
} }
await _videoPlayerController?.seek(position); _position.value = position;
} else { updatePositionSecond();
_timerForSeek?.cancel(); _heartDuration = position.inSeconds;
_timerForSeek ??= if (duration.value.inSeconds != 0) {
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async { if (type != 'slider') {
if (duration.value.inSeconds != 0) { await _videoPlayerController?.stream.buffer.first;
await _videoPlayerController!.stream.buffer.first;
await _videoPlayerController?.seek(position);
t.cancel();
_timerForSeek = null;
} }
}); await _videoPlayerController?.seek(position);
} else {
_timerForSeek?.cancel();
_timerForSeek ??= _startSeekTimer(position);
}
} catch (err) {
print('Error while seeking: $err');
} }
} }
Timer? _startSeekTimer(Duration position) {
return Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
if (duration.value.inSeconds != 0) {
await _videoPlayerController!.stream.buffer.first;
await _videoPlayerController?.seek(position);
t.cancel();
_timerForSeek = null;
}
});
}
/// 设置倍速 /// 设置倍速
Future<void> setPlaybackSpeed(double speed) async { Future<void> setPlaybackSpeed(double speed) async {
/// TODO _duration.value丢失 /// TODO _duration.value丢失
@ -708,11 +719,10 @@ class PlPlayerController {
await seekTo(Duration.zero); await seekTo(Duration.zero);
} }
await _videoPlayerController?.play(); await _videoPlayerController?.play();
playerStatus.status.value = PlayerStatus.playing;
await getCurrentVolume(); await getCurrentVolume();
await getCurrentBrightness(); await getCurrentBrightness();
playerStatus.status.value = PlayerStatus.playing;
// screenManager.setOverlays(false); // screenManager.setOverlays(false);
/// 临时fix _duration.value丢失 /// 临时fix _duration.value丢失
@ -1112,9 +1122,6 @@ class PlPlayerController {
} }
Future<void> dispose({String type = 'single'}) async { Future<void> dispose({String type = 'single'}) async {
print('dispose');
print('dispose: ${playerCount.value}');
// 每次减1最后销毁 // 每次减1最后销毁
if (type == 'single' && playerCount.value > 1) { if (type == 'single' && playerCount.value > 1) {
_playerCount.value -= 1; _playerCount.value -= 1;
@ -1124,7 +1131,6 @@ class PlPlayerController {
} }
_playerCount.value = 0; _playerCount.value = 0;
try { try {
print('dispose dispose ---------');
_timer?.cancel(); _timer?.cancel();
_timerForVolume?.cancel(); _timerForVolume?.cancel();
_timerForGettingVolume?.cancel(); _timerForGettingVolume?.cancel();

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ class PiliSchame {
/// 完整链接进入 b23.无效 /// 完整链接进入 b23.无效
appScheme.getLatestScheme().then((SchemeEntity? value) { appScheme.getLatestScheme().then((SchemeEntity? value) {
if (value != null) { if (value != null) {
_fullPathPush(value); _routePush(value);
} }
}); });
@ -37,7 +37,6 @@ class PiliSchame {
final String scheme = value.scheme; final String scheme = value.scheme;
final String host = value.host; final String host = value.host;
final String path = value.path; final String path = value.path;
if (scheme == 'bilibili') { if (scheme == 'bilibili') {
if (host == 'root') { if (host == 'root') {
Navigator.popUntil( Navigator.popUntil(
@ -85,6 +84,14 @@ class PiliSchame {
} }
} else if (host == 'search') { } else if (host == 'search') {
Get.toNamed('/searchResult', parameters: {'keyword': ''}); Get.toNamed('/searchResult', parameters: {'keyword': ''});
} else if (host == 'article') {
final String id = path.split('/').last.split('?').first;
Get.toNamed('/htmlRender', parameters: {
'url': 'https://www.bilibili.com/read/cv$id',
'title': 'cv$id',
'id': 'cv$id',
'dynamicType': 'read'
});
} }
} }
if (scheme == 'https') { if (scheme == 'https') {
@ -155,9 +162,14 @@ class PiliSchame {
final String host = value.host!; final String host = value.host!;
final String? path = value.path; final String? path = value.path;
Map<String, String>? query = value.query; Map<String, String>? query = value.query;
RegExp regExp = RegExp(r'^(www\.)?m?\.(bilibili\.com)$'); RegExp regExp = RegExp(r'^((www\.)|(m\.))?bilibili\.com$');
if (regExp.hasMatch(host)) { if (regExp.hasMatch(host)) {
print('bilibili.com'); print('bilibili.com host: $host');
print('bilibili.com path: $path');
final String lastPathSegment = path!.split('/').last;
if (lastPathSegment.contains('BV')) {
_videoPush(null, lastPathSegment);
}
} else if (host.contains('live')) { } else if (host.contains('live')) {
int roomId = int.parse(path!.split('/').last); int roomId = int.parse(path!.split('/').last);
Get.toNamed( Get.toNamed(
@ -226,6 +238,13 @@ class PiliSchame {
break; break;
case 'read': case 'read':
print('专栏'); print('专栏');
String id = 'cv${matchNum(query!['id']!).first}';
Get.toNamed('/htmlRender', parameters: {
'url': value.dataString!,
'title': '',
'id': id,
'dynamicType': 'read'
});
break; break;
case 'space': case 'space':
print('个人空间'); print('个人空间');

View File

@ -5,8 +5,8 @@ class SubTitleUtils {
for (int i = 0; i < jsonData.length; i++) { for (int i = 0; i < jsonData.length; i++) {
final item = jsonData[i]; final item = jsonData[i];
double from = item['from'] as double; double from = double.parse(item['from'].toString());
double to = item['to'] as double; double to = double.parse(item['to'].toString());
int sid = (item['sid'] ?? 0) as int; int sid = (item['sid'] ?? 0) as int;
String content = item['content'] as String; String content = item['content'] as String;

View File

@ -210,15 +210,18 @@ class Utils {
int minDiff = 127; int minDiff = 127;
int closestNumber = 0; // 初始化为0表示没有找到比目标值小的整数 int closestNumber = 0; // 初始化为0表示没有找到比目标值小的整数
if (numbers.contains(target)) {
return target;
}
// 向下查找 // 向下查找
try { try {
for (int number in numbers) { for (int number in numbers) {
if (number < target) { if (number < target) {
int diff = target - number; // 计算目标值与当前整数的差值 int diff = target - number; // 计算目标值与当前整数的差值
if (diff < minDiff) { if (diff < minDiff) {
minDiff = diff; minDiff = diff;
closestNumber = number; closestNumber = number;
return closestNumber;
} }
} }
} }