diff --git a/lib/common/widgets/dialog/report_member.dart b/lib/common/widgets/dialog/report_member.dart index 53028e201..a5c9b24b9 100644 --- a/lib/common/widgets/dialog/report_member.dart +++ b/lib/common/widgets/dialog/report_member.dart @@ -8,7 +8,6 @@ Future showMemberReportDialog( required Object? name, required Object mid, }) { - final List reasonList = List.generate(3, (_) => false); final Set reason = {}; int? reasonV2; @@ -44,12 +43,11 @@ Future showMemberReportDialog( (index) => Builder( builder: (context) => CheckboxListTile( dense: true, - value: reasonList[index], + value: reason.contains(index + 1), controlAffinity: ListTileControlAffinity.leading, contentPadding: EdgeInsets.zero, onChanged: (value) { - reasonList[index] = value!; - if (value) { + if (value!) { reason.add(index + 1); } else { reason.remove(index + 1); diff --git a/lib/models_new/video/video_play_info/subtitle.dart b/lib/models_new/video/video_play_info/subtitle.dart index f43b0f9d1..789d0f607 100644 --- a/lib/models_new/video/video_play_info/subtitle.dart +++ b/lib/models_new/video/video_play_info/subtitle.dart @@ -1,19 +1,14 @@ class Subtitle { - String? lan; + late String lan; String? lanDoc; String? subtitleUrl; String? subtitleUrlV2; - - Subtitle({ - this.lan, - this.lanDoc, - this.subtitleUrl, - this.subtitleUrlV2, - }); + bool isAi = false; Subtitle.fromJson(Map json) { lan = json["lan"]; - lanDoc = '${json["lan_doc"]}${lan!.startsWith('ai') ? '(AI)' : ''}'; + isAi = json["type"] == 1; + lanDoc = '${json["lan_doc"]}${isAi ? '(AI)' : ''}'; subtitleUrl = json["subtitle_url"]; subtitleUrlV2 = json["subtitle_url_v2"]; } diff --git a/lib/models_new/video/video_play_info/subtitle_info.dart b/lib/models_new/video/video_play_info/subtitle_info.dart index 128f33d54..d559c1697 100644 --- a/lib/models_new/video/video_play_info/subtitle_info.dart +++ b/lib/models_new/video/video_play_info/subtitle_info.dart @@ -7,22 +7,19 @@ class SubtitleInfo { SubtitleInfo({this.lan, this.lanDoc, this.subtitles}); - SubtitleInfo.fromJson(Map json) { - lan = json['lan'] as String?; - lanDoc = json['lan_doc'] as String?; - final List? list = json['subtitles']; - if (list != null && list.isNotEmpty) { - subtitles = []; - int index = 0; - for (var e in list) { - final item = Subtitle.fromJson(e); - if (item.lan!.contains('zh')) { - subtitles!.insert(index, item); - index++; - } else { - subtitles!.add(item); - } - } - } - } + factory SubtitleInfo.fromJson(Map json) => SubtitleInfo( + lan: json['lan'] as String?, + lanDoc: json['lan_doc'] as String?, + subtitles: + (json['subtitles'] as List?) + ?.map((e) => Subtitle.fromJson(e as Map)) + .toList() + ?..sort((a, b) { + final aHasZh = a.lan.contains('zh'); + final bHasZh = b.lan.contains('zh'); + if (aHasZh != bHasZh) return aHasZh ? -1 : 1; + if (a.isAi != b.isAi) return a.isAi ? 1 : -1; + return 0; + }), + ); } diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 7e010a5b0..07965b120 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -1504,22 +1504,22 @@ class VideoDetailController extends GetxController } if (playInfo.subtitle?.subtitles?.isNotEmpty == true) { - int idx = 0; subtitles.value = playInfo.subtitle!.subtitles!; - SubtitlePrefType preference = - SubtitlePrefType.values[Pref.subtitlePreferenceV2]; - if (preference != SubtitlePrefType.off) { - idx = subtitles.indexWhere((i) => !i.lan!.startsWith('ai')) + 1; - if (idx == 0) { - if (preference == SubtitlePrefType.on || - (Utils.isMobile && - preference == SubtitlePrefType.auto && - (await FlutterVolumeController.getVolume() ?? 0) <= 0)) { - idx = 1; - } - } - } + final idx = switch (SubtitlePrefType.values[Pref + .subtitlePreferenceV2]) { + SubtitlePrefType.off => 0, + SubtitlePrefType.on => 1, + SubtitlePrefType.withoutAi => + subtitles.first.lan.startsWith('ai') ? 0 : 1, + SubtitlePrefType.auto => + !subtitles.first.lan.startsWith('ai') || + (Utils.isMobile && + (await FlutterVolumeController.getVolume() ?? 0.0) <= + 0.0) + ? 1 + : 0, + }; setSubtitle(idx); } } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index e2cff1e9b..6a3fee600 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -1487,29 +1487,36 @@ class _PLVideoPlayerState extends State alignment: Alignment.bottomCenter, children: [ IgnorePointer( - child: Obx(() { - final int value = - plPlayerController.sliderPositionSeconds.value; - final int max = - plPlayerController.durationSeconds.value.inSeconds; - final int buffer = - plPlayerController.bufferedSeconds.value; - if (value > max || max <= 0) { - return const SizedBox.shrink(); - } - return ProgressBar( - progress: Duration(seconds: value), - buffered: Duration(seconds: buffer), - total: Duration(seconds: max), - progressBarColor: primary, - baseBarColor: Colors.white.withValues(alpha: 0.2), - bufferedBarColor: primary.withValues(alpha: 0.4), - timeLabelLocation: TimeLabelLocation.none, - thumbColor: primary, - barHeight: 3.5, - thumbRadius: draggingFixedProgressBar.value ? 7 : 2.5, - ); - }), + child: RepaintBoundary.wrap( + Obx(() { + final int value = + plPlayerController.sliderPositionSeconds.value; + final int max = plPlayerController + .durationSeconds + .value + .inSeconds; + final int buffer = + plPlayerController.bufferedSeconds.value; + if (value > max || max <= 0) { + return const SizedBox.shrink(); + } + return ProgressBar( + progress: Duration(seconds: value), + buffered: Duration(seconds: buffer), + total: Duration(seconds: max), + progressBarColor: primary, + baseBarColor: const Color(0x33FFFFFF), + bufferedBarColor: primary.withValues(alpha: 0.4), + timeLabelLocation: TimeLabelLocation.none, + thumbColor: primary, + barHeight: 3.5, + thumbRadius: draggingFixedProgressBar.value + ? 7 + : 2.5, + ); + }), + 0, + ), ), if (plPlayerController.enableSponsorBlock && videoDetailController.segmentProgressList.isNotEmpty) @@ -1518,15 +1525,15 @@ class _PLVideoPlayerState extends State right: 0, bottom: 0.75, child: IgnorePointer( - child: RepaintBoundary( - child: CustomPaint( - key: const Key('segmentList'), + child: RepaintBoundary.wrap( + CustomPaint( size: const Size(double.infinity, 3.5), painter: SegmentProgressBar( segmentColors: videoDetailController.segmentProgressList, ), ), + 1, ), ), ), @@ -1538,15 +1545,15 @@ class _PLVideoPlayerState extends State right: 0, bottom: 0.75, child: IgnorePointer( - child: RepaintBoundary( - child: CustomPaint( - key: const Key('viewPointList'), + child: RepaintBoundary.wrap( + CustomPaint( size: const Size(double.infinity, 3.5), painter: SegmentProgressBar( segmentColors: videoDetailController.viewPointList, ), ), + 2, ), ), ),