feat: comment can be closed
This commit is contained in:
18
lib/models/common/comment_range_type.dart
Normal file
18
lib/models/common/comment_range_type.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
enum CommentRangeType {
|
||||||
|
video,
|
||||||
|
bangumi,
|
||||||
|
// dynamic,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ActionTypeExtension on CommentRangeType {
|
||||||
|
String get value => [
|
||||||
|
'video',
|
||||||
|
'bangumi',
|
||||||
|
// 'dynamic',
|
||||||
|
][index];
|
||||||
|
String get label => [
|
||||||
|
'视频',
|
||||||
|
'番剧',
|
||||||
|
// '动态',
|
||||||
|
][index];
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ 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:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/models/common/comment_range_type.dart';
|
||||||
import 'package:pilipala/models/common/dynamics_type.dart';
|
import 'package:pilipala/models/common/dynamics_type.dart';
|
||||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||||
@ -27,6 +28,8 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
late String defaultSystemProxyHost;
|
late String defaultSystemProxyHost;
|
||||||
late String defaultSystemProxyPort;
|
late String defaultSystemProxyPort;
|
||||||
bool userLogin = false;
|
bool userLogin = false;
|
||||||
|
// 记录每个选项是否被选中的状态
|
||||||
|
late List<String> enableComment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -47,6 +50,8 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
localCache.get(LocalCacheKey.systemProxyHost, defaultValue: '');
|
localCache.get(LocalCacheKey.systemProxyHost, defaultValue: '');
|
||||||
defaultSystemProxyPort =
|
defaultSystemProxyPort =
|
||||||
localCache.get(LocalCacheKey.systemProxyPort, defaultValue: '');
|
localCache.get(LocalCacheKey.systemProxyPort, defaultValue: '');
|
||||||
|
enableComment = setting
|
||||||
|
.get(SettingBoxKey.enableComment, defaultValue: ['video', 'bangumi']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置代理
|
// 设置代理
|
||||||
@ -202,6 +207,82 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
title: Text('评论展示', style: titleStyle),
|
title: Text('评论展示', style: titleStyle),
|
||||||
|
onTap: () async {
|
||||||
|
List<String> tempEnableComment = List.from(enableComment);
|
||||||
|
int? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
// 带多选框的list
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('评论展示'),
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(0, 24, 0, 24),
|
||||||
|
content: SizedBox(
|
||||||
|
width: double.maxFinite,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: CommentRangeType.values.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return CheckboxListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24, vertical: 0),
|
||||||
|
title: Text(
|
||||||
|
'${CommentRangeType.values[index].label}评论'),
|
||||||
|
value: tempEnableComment.contains(
|
||||||
|
CommentRangeType.values[index].value),
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
setState(() {
|
||||||
|
if (value == true) {
|
||||||
|
tempEnableComment.add(
|
||||||
|
CommentRangeType.values[index].value);
|
||||||
|
} else {
|
||||||
|
tempEnableComment.remove(
|
||||||
|
CommentRangeType.values[index].value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: Navigator.of(context).pop,
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
enableComment = tempEnableComment;
|
||||||
|
setting.put(
|
||||||
|
SettingBoxKey.enableComment, enableComment);
|
||||||
|
GlobalDataCache.enableComment = enableComment;
|
||||||
|
SmartDialog.showToast('操作成功');
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text('确认'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
defaultReplySort = result;
|
||||||
|
setting.put(SettingBoxKey.replySortType, result);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('评论排序', style: titleStyle),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'当前优先展示「${ReplySortType.values[defaultReplySort].titles}」',
|
'当前优先展示「${ReplySortType.values[defaultReplySort].titles}」',
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
@ -211,7 +292,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SelectDialog<int>(
|
return SelectDialog<int>(
|
||||||
title: '评论展示',
|
title: '评论排序',
|
||||||
value: defaultReplySort,
|
value: defaultReplySort,
|
||||||
values: ReplySortType.values.map((e) {
|
values: ReplySortType.values.map((e) {
|
||||||
return {'title': e.titles, 'value': e.index};
|
return {'title': e.titles, 'value': e.index};
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import 'package:pilipala/models/video/play/url.dart';
|
|||||||
import 'package:pilipala/models/video/reply/item.dart';
|
import 'package:pilipala/models/video/reply/item.dart';
|
||||||
import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
|
import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'package:pilipala/utils/video_utils.dart';
|
import 'package:pilipala/utils/video_utils.dart';
|
||||||
@ -140,8 +141,16 @@ class VideoDetailController extends GetxController
|
|||||||
} else if (argMap.containsKey('pic')) {
|
} else if (argMap.containsKey('pic')) {
|
||||||
updateCover(argMap['pic']);
|
updateCover(argMap['pic']);
|
||||||
}
|
}
|
||||||
|
tabs.value = <String>[
|
||||||
tabCtr = TabController(length: 2, vsync: this);
|
'简介',
|
||||||
|
if (videoType == SearchType.video &&
|
||||||
|
GlobalDataCache.enableComment.contains('video'))
|
||||||
|
'评论',
|
||||||
|
if (videoType == SearchType.media_bangumi &&
|
||||||
|
GlobalDataCache.enableComment.contains('bangumi'))
|
||||||
|
'评论'
|
||||||
|
];
|
||||||
|
tabCtr = TabController(length: tabs.length, vsync: this);
|
||||||
autoPlay.value =
|
autoPlay.value =
|
||||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||||
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: false);
|
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: false);
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import 'package:pilipala/pages/video/detail/controller.dart';
|
|||||||
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
@ -99,7 +100,11 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
final VideoDetailController videoDetailCtr =
|
final VideoDetailController videoDetailCtr =
|
||||||
Get.find<VideoDetailController>(tag: heroTag);
|
Get.find<VideoDetailController>(tag: heroTag);
|
||||||
videoDetailCtr.tabs.value = ['简介', '评论 ${result['data']?.stat?.reply}'];
|
videoDetailCtr.tabs.value = [
|
||||||
|
'简介',
|
||||||
|
if (GlobalDataCache.enableComment.contains('video'))
|
||||||
|
'评论 ${result['data']?.stat?.reply}'
|
||||||
|
];
|
||||||
videoDetailCtr.cover.value = cover ?? result['data'].pic ?? '';
|
videoDetailCtr.cover.value = cover ?? result['data'].pic ?? '';
|
||||||
// 获取到粉丝数再返回
|
// 获取到粉丝数再返回
|
||||||
await queryUserStat();
|
await queryUserStat();
|
||||||
@ -469,10 +474,12 @@ class VideoIntroController extends GetxController {
|
|||||||
// 重新请求评论
|
// 重新请求评论
|
||||||
try {
|
try {
|
||||||
/// 未渲染回复组件时可能异常
|
/// 未渲染回复组件时可能异常
|
||||||
final VideoReplyController videoReplyCtr =
|
if (GlobalDataCache.enableComment.contains('video')) {
|
||||||
Get.find<VideoReplyController>(tag: heroTag);
|
final VideoReplyController videoReplyCtr =
|
||||||
videoReplyCtr.aid = aid;
|
Get.find<VideoReplyController>(tag: heroTag);
|
||||||
videoReplyCtr.queryReplyList(type: 'init');
|
videoReplyCtr.aid = aid;
|
||||||
|
videoReplyCtr.queryReplyList(type: 'init');
|
||||||
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
this.bvid = bvid;
|
this.bvid = bvid;
|
||||||
await queryVideoIntro(cover: cover);
|
await queryVideoIntro(cover: cover);
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import 'package:pilipala/pages/video/detail/related/index.dart';
|
|||||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:pilipala/services/service_locator.dart';
|
import 'package:pilipala/services/service_locator.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:status_bar_control/status_bar_control.dart';
|
import 'package:status_bar_control/status_bar_control.dart';
|
||||||
|
|
||||||
@ -779,13 +780,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Obx(
|
if ((vdCtr.videoType == SearchType.media_bangumi &&
|
||||||
() => VideoReplyPanel(
|
GlobalDataCache.enableComment
|
||||||
bvid: vdCtr.bvid,
|
.contains('bangumi')) ||
|
||||||
oid: vdCtr.oid.value,
|
(vdCtr.videoType == SearchType.video &&
|
||||||
onControllerCreated: vdCtr.onControllerCreated,
|
GlobalDataCache.enableComment
|
||||||
),
|
.contains('video'))) ...[
|
||||||
)
|
Obx(
|
||||||
|
() => VideoReplyPanel(
|
||||||
|
bvid: vdCtr.bvid,
|
||||||
|
oid: vdCtr.oid.value,
|
||||||
|
onControllerCreated: vdCtr.onControllerCreated,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import 'package:pilipala/plugin/pl_player/models/play_speed.dart';
|
|||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import '../models/common/index.dart';
|
import '../models/common/index.dart';
|
||||||
|
|
||||||
Box setting = GStorage.setting;
|
Box settingBox = GStorage.setting;
|
||||||
Box localCache = GStorage.localCache;
|
Box localCache = GStorage.localCache;
|
||||||
Box videoStorage = GStorage.video;
|
Box videoStorage = GStorage.video;
|
||||||
Box userInfoCache = GStorage.userInfo;
|
Box userInfoCache = GStorage.userInfo;
|
||||||
@ -55,6 +55,8 @@ class GlobalDataCache {
|
|||||||
static late bool enableDynamicSwitch;
|
static late bool enableDynamicSwitch;
|
||||||
// 投屏开关
|
// 投屏开关
|
||||||
static bool enableDlna = false;
|
static bool enableDlna = false;
|
||||||
|
// 视频评论开关
|
||||||
|
static List<String> enableComment = ['video', 'bangumi'];
|
||||||
|
|
||||||
// 私有构造函数
|
// 私有构造函数
|
||||||
GlobalDataCache._();
|
GlobalDataCache._();
|
||||||
@ -67,18 +69,18 @@ class GlobalDataCache {
|
|||||||
|
|
||||||
// 异步初始化方法
|
// 异步初始化方法
|
||||||
static Future<void> initialize() async {
|
static Future<void> initialize() async {
|
||||||
imgQuality = await setting.get(SettingBoxKey.defaultPicQa,
|
imgQuality = await settingBox.get(SettingBoxKey.defaultPicQa,
|
||||||
defaultValue: 10); // 设置全局变量
|
defaultValue: 10); // 设置全局变量
|
||||||
fullScreenGestureMode = FullScreenGestureMode.values[setting.get(
|
fullScreenGestureMode = FullScreenGestureMode.values[settingBox.get(
|
||||||
SettingBoxKey.fullScreenGestureMode,
|
SettingBoxKey.fullScreenGestureMode,
|
||||||
defaultValue: FullScreenGestureMode.fromBottomtoTop.index)];
|
defaultValue: FullScreenGestureMode.fromBottomtoTop.index)];
|
||||||
enablePlayerControlAnimation = setting
|
enablePlayerControlAnimation = settingBox
|
||||||
.get(SettingBoxKey.enablePlayerControlAnimation, defaultValue: true);
|
.get(SettingBoxKey.enablePlayerControlAnimation, defaultValue: true);
|
||||||
actionTypeSort = await setting.get(SettingBoxKey.actionTypeSort,
|
actionTypeSort = await settingBox.get(SettingBoxKey.actionTypeSort,
|
||||||
defaultValue: ['like', 'coin', 'collect', 'watchLater', 'share']);
|
defaultValue: ['like', 'coin', 'collect', 'watchLater', 'share']);
|
||||||
|
|
||||||
isOpenDanmu =
|
isOpenDanmu = await settingBox.get(SettingBoxKey.enableShowDanmaku,
|
||||||
await setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
|
defaultValue: false);
|
||||||
blockTypes =
|
blockTypes =
|
||||||
await localCache.get(LocalCacheKey.danmakuBlockType, defaultValue: []);
|
await localCache.get(LocalCacheKey.danmakuBlockType, defaultValue: []);
|
||||||
showArea =
|
showArea =
|
||||||
@ -99,7 +101,7 @@ class GlobalDataCache {
|
|||||||
.firstWhere((e) => e.value == defaultPlayRepeat);
|
.firstWhere((e) => e.value == defaultPlayRepeat);
|
||||||
playbackSpeed =
|
playbackSpeed =
|
||||||
await videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
|
await videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
|
||||||
enableAutoLongPressSpeed = await setting
|
enableAutoLongPressSpeed = await settingBox
|
||||||
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
||||||
if (!enableAutoLongPressSpeed) {
|
if (!enableAutoLongPressSpeed) {
|
||||||
longPressSpeed = await videoStorage.get(VideoBoxKey.longPressSpeedDefault,
|
longPressSpeed = await videoStorage.get(VideoBoxKey.longPressSpeedDefault,
|
||||||
@ -117,11 +119,13 @@ class GlobalDataCache {
|
|||||||
sheetHeight = localCache.get('sheetHeight', defaultValue: 0.0);
|
sheetHeight = localCache.get('sheetHeight', defaultValue: 0.0);
|
||||||
historyCacheList = localCache.get('cacheList', defaultValue: []);
|
historyCacheList = localCache.get('cacheList', defaultValue: []);
|
||||||
enableSearchSuggest =
|
enableSearchSuggest =
|
||||||
setting.get(SettingBoxKey.enableSearchSuggest, defaultValue: true);
|
settingBox.get(SettingBoxKey.enableSearchSuggest, defaultValue: true);
|
||||||
enableAutoExpand =
|
enableAutoExpand =
|
||||||
setting.get(SettingBoxKey.enableAutoExpand, defaultValue: false);
|
settingBox.get(SettingBoxKey.enableAutoExpand, defaultValue: false);
|
||||||
enableDynamicSwitch =
|
enableDynamicSwitch =
|
||||||
setting.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true);
|
settingBox.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true);
|
||||||
enableDlna = setting.get(SettingBoxKey.enableDlna, defaultValue: false);
|
enableDlna = settingBox.get(SettingBoxKey.enableDlna, defaultValue: false);
|
||||||
|
enableComment = settingBox
|
||||||
|
.get(SettingBoxKey.enableComment, defaultValue: ['video', 'bangumi']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,8 @@ class SettingBoxKey {
|
|||||||
enableAutoExpand = 'enableAutoExpand',
|
enableAutoExpand = 'enableAutoExpand',
|
||||||
defaultHomePage = 'defaultHomePage',
|
defaultHomePage = 'defaultHomePage',
|
||||||
enableRelatedVideo = 'enableRelatedVideo',
|
enableRelatedVideo = 'enableRelatedVideo',
|
||||||
enableDlna = 'enableDlna';
|
enableDlna = 'enableDlna',
|
||||||
|
enableComment = 'enableComment';
|
||||||
|
|
||||||
/// 外观
|
/// 外观
|
||||||
static const String themeMode = 'themeMode',
|
static const String themeMode = 'themeMode',
|
||||||
|
|||||||
Reference in New Issue
Block a user