基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
fix query manager null safety && clean unused rating module
Prediditc39fbf515451
diff --git a/lib/modules/bangumi/rating_item.dart b/lib/modules/bangumi/rating_item.dartdeleted file mode 100644index 4b3a848c..00000000--- a/lib/modules/bangumi/rating_item.dart+++ /dev/null@@ -1,56 +0,0 @@-class Rating {- int total;- RatingCount count;- double score;-- Rating({required this.total, required this.count, required this.score});-- factory Rating.fromJson(Map<String, dynamic> json) {- return Rating(- total: json['total'],- count: RatingCount.fromJson(json['count']),- score: json['score'].toDouble(),- );- }-}--class RatingCount {- int? count1;- int? count2;- int? count3;- int? count4;- int? count5;- int? count6;- int? count7;- int? count8;- int? count9;- int? count10;-- RatingCount({- this.count1,- this.count2,- this.count3,- this.count4,- this.count5,- this.count6,- this.count7,- this.count8,- this.count9,- this.count10,- });-- factory RatingCount.fromJson(Map<String, dynamic> json) {- return RatingCount(- count1: json['1'],- count2: json['2'],- count3: json['3'],- count4: json['4'],- count5: json['5'],- count6: json['6'],- count7: json['7'],- count8: json['8'],- count9: json['9'],- count10: json['10'],- );- }-}\ No newline at end of filediff --git a/lib/pages/info/info_page.dart b/lib/pages/info/info_page.dartindex c3b92e74..6bd6da2c 100644--- a/lib/pages/info/info_page.dart+++ b/lib/pages/info/info_page.dart@@ -1,6 +1,5 @@import 'dart:io';import 'dart:ui';-import 'package:flutter_mobx/flutter_mobx.dart';import 'package:kazumi/utils/utils.dart';import 'package:flutter/material.dart';import 'package:flutter_modular/flutter_modular.dart';@@ -19,6 +18,7 @@ import 'package:kazumi/utils/logger.dart';import 'package:kazumi/pages/info/info_tabview.dart';import 'package:url_launcher/url_launcher.dart';import 'package:window_manager/window_manager.dart';+import 'package:flutter_mobx/flutter_mobx.dart';class InfoPage extends StatefulWidget {const InfoPage({super.key});@@ -73,82 +73,81 @@ class _InfoPageState extends State<InfoPage>final List<String> tabs = <String>['概览', '吐槽', '角色', '评论', '制作人员'];final bool showWindowButton = GStorage.setting.get(SettingBoxKey.showWindowButton, defaultValue: false);- return Observer(builder: (context) {- return PopScope(- canPop: true,- child: DefaultTabController(- length: tabs.length,- child: Scaffold(- body: NestedScrollView(- headerSliverBuilder:- (BuildContext context, bool innerBoxIsScrolled) {- return <Widget>[- SliverOverlapAbsorber(- handle: NestedScrollView.sliverOverlapAbsorberHandleFor(- context),- sliver: SliverAppBar.medium(- title: EmbeddedNativeControlArea(- child: Text(- infoController.bangumiItem.nameCn == ''- ? infoController.bangumiItem.name- : infoController.bangumiItem.nameCn,- ),+ return PopScope(+ canPop: true,+ child: DefaultTabController(+ length: tabs.length,+ child: Scaffold(+ body: NestedScrollView(+ headerSliverBuilder:+ (BuildContext context, bool innerBoxIsScrolled) {+ return <Widget>[+ SliverOverlapAbsorber(+ handle:+ NestedScrollView.sliverOverlapAbsorberHandleFor(context),+ sliver: SliverAppBar.medium(+ title: EmbeddedNativeControlArea(+ child: Text(+ infoController.bangumiItem.nameCn == ''+ ? infoController.bangumiItem.name+ : infoController.bangumiItem.nameCn,+ ),+ ),+ automaticallyImplyLeading: false,+ scrolledUnderElevation: 0.0,+ leading: EmbeddedNativeControlArea(+ child: IconButton(+ onPressed: () {+ Navigator.maybePop(context);+ },+ icon: Icon(Icons.arrow_back),),- automaticallyImplyLeading: false,- scrolledUnderElevation: 0.0,- leading: EmbeddedNativeControlArea(+ ),+ actions: [+ if (innerBoxIsScrolled)+ EmbeddedNativeControlArea(+ child: CollectButton(+ bangumiItem: infoController.bangumiItem,+ color:+ Theme.of(context).colorScheme.onSurfaceVariant,+ ),+ ),+ EmbeddedNativeControlArea(child: IconButton(onPressed: () {- Navigator.maybePop(context);+ launchUrl(+ Uri.parse(+ 'https://bangumi.tv/subject/${infoController.bangumiItem.id}'),+ mode: LaunchMode.externalApplication,+ );},- icon: Icon(Icons.arrow_back),+ icon: const Icon(Icons.open_in_browser_rounded),),),- actions: [- if (innerBoxIsScrolled)- EmbeddedNativeControlArea(- child: CollectButton(- bangumiItem: infoController.bangumiItem,- color: Theme.of(context)- .colorScheme- .onSurfaceVariant,- ),- ),- EmbeddedNativeControlArea(- child: IconButton(- onPressed: () {- launchUrl(- Uri.parse(- 'https://bangumi.tv/subject/${infoController.bangumiItem.id}'),- mode: LaunchMode.externalApplication,- );- },- icon: const Icon(Icons.open_in_browser_rounded),- ),- ),- if (!showWindowButton && Utils.isDesktop())- CloseButton(onPressed: () => windowManager.close()),- SizedBox(width: 8),- ],- toolbarHeight: (Platform.isMacOS && showWindowButton)- ? kToolbarHeight + 22- : kToolbarHeight,- stretch: true,- centerTitle: false,- expandedHeight: (Platform.isMacOS && showWindowButton)- ? 308 + kTextTabBarHeight + kToolbarHeight + 22- : 308 + kTextTabBarHeight + kToolbarHeight,- collapsedHeight: (Platform.isMacOS && showWindowButton)- ? kTextTabBarHeight +- kToolbarHeight +- MediaQuery.paddingOf(context).top +- 22- : kTextTabBarHeight +- kToolbarHeight +- MediaQuery.paddingOf(context).top,- flexibleSpace: FlexibleSpaceBar(- collapseMode: CollapseMode.pin,- background: Stack(+ if (!showWindowButton && Utils.isDesktop())+ CloseButton(onPressed: () => windowManager.close()),+ SizedBox(width: 8),+ ],+ toolbarHeight: (Platform.isMacOS && showWindowButton)+ ? kToolbarHeight + 22+ : kToolbarHeight,+ stretch: true,+ centerTitle: false,+ expandedHeight: (Platform.isMacOS && showWindowButton)+ ? 308 + kTextTabBarHeight + kToolbarHeight + 22+ : 308 + kTextTabBarHeight + kToolbarHeight,+ collapsedHeight: (Platform.isMacOS && showWindowButton)+ ? kTextTabBarHeight ++ kToolbarHeight ++ MediaQuery.paddingOf(context).top ++ 22+ : kTextTabBarHeight ++ kToolbarHeight ++ MediaQuery.paddingOf(context).top,+ flexibleSpace: FlexibleSpaceBar(+ collapseMode: CollapseMode.pin,+ background: Observer(builder: (context) {+ return Stack(children: [// No background image when loading to make loading looks betterif (!infoController.isLoading)@@ -211,50 +210,50 @@ class _InfoPageState extends State<InfoPage>),),],- ),- ),- forceElevated: innerBoxIsScrolled,- bottom: TabBar(- isScrollable: true,- tabAlignment: TabAlignment.center,- dividerHeight: 0,- tabs: tabs.map((name) => Tab(text: name)).toList(),- ),+ );+ }),+ ),+ forceElevated: innerBoxIsScrolled,+ bottom: TabBar(+ isScrollable: true,+ tabAlignment: TabAlignment.center,+ dividerHeight: 0,+ tabs: tabs.map((name) => Tab(text: name)).toList(),),),- ];- },- body: InfoTabView(),- ),- floatingActionButton: FloatingActionButton.extended(- icon: const Icon(Icons.play_arrow_rounded),- label: Text('开始观看'),- onPressed: () async {- showModalBottomSheet(- isScrollControlled: true,- constraints: BoxConstraints(- maxHeight: (MediaQuery.sizeOf(context).height >=- LayoutBreakpoint.compact['height']!)- ? MediaQuery.of(context).size.height * 3 / 4- : MediaQuery.of(context).size.height,- maxWidth: (MediaQuery.sizeOf(context).width >=- LayoutBreakpoint.medium['width']!)- ? MediaQuery.of(context).size.width * 9 / 16- : MediaQuery.of(context).size.width,- ),- clipBehavior: Clip.antiAlias,- backgroundColor: Theme.of(context).scaffoldBackgroundColor,- showDragHandle: true,- context: context,- builder: (context) {- return SourceSheet(tabController: tabController);- },- );- },- ),+ ),+ ];+ },+ body: InfoTabView(),+ ),+ floatingActionButton: FloatingActionButton.extended(+ icon: const Icon(Icons.play_arrow_rounded),+ label: Text('开始观看'),+ onPressed: () async {+ showModalBottomSheet(+ isScrollControlled: true,+ constraints: BoxConstraints(+ maxHeight: (MediaQuery.sizeOf(context).height >=+ LayoutBreakpoint.compact['height']!)+ ? MediaQuery.of(context).size.height * 3 / 4+ : MediaQuery.of(context).size.height,+ maxWidth: (MediaQuery.sizeOf(context).width >=+ LayoutBreakpoint.medium['width']!)+ ? MediaQuery.of(context).size.width * 9 / 16+ : MediaQuery.of(context).size.width,+ ),+ clipBehavior: Clip.antiAlias,+ backgroundColor: Theme.of(context).scaffoldBackgroundColor,+ showDragHandle: true,+ context: context,+ builder: (context) {+ return SourceSheet(tabController: tabController);+ },+ );+ },),),- );- });+ ),+ );}}diff --git a/lib/pages/info/source_sheet.dart b/lib/pages/info/source_sheet.dartindex 8ebd2c52..71279cb0 100644--- a/lib/pages/info/source_sheet.dart+++ b/lib/pages/info/source_sheet.dart@@ -34,23 +34,23 @@ class _SourceSheetState extends State<SourceSheet>late String keyword;/// Concurrent query manager- late QueryManager queryManager;+ QueryManager? queryManager;@overridevoid initState() {keyword = infoController.bangumiItem.nameCn == ''? infoController.bangumiItem.name: infoController.bangumiItem.nameCn;- queryManager = QueryManager();if (infoController.pluginSearchResponseList.isEmpty) {- queryManager.queryAllSource(keyword);+ queryManager = QueryManager();+ queryManager?.queryAllSource(keyword);}super.initState();}@overridevoid dispose() {- queryManager.cancel();+ queryManager?.cancel();super.dispose();}@@ -117,7 +117,7 @@ class _SourceSheetState extends State<SourceSheet>),onTap: () {KazumiDialog.dismiss();- queryManager.querySource(alias, pluginName);+ queryManager?.querySource(alias, pluginName);},);}).toList(),@@ -140,7 +140,7 @@ class _SourceSheetState extends State<SourceSheet>if (textController.text != '') {infoController.bangumiItem.alias.add(textController.text);KazumiDialog.dismiss();- queryManager.querySource(textController.text, pluginName);+ queryManager?.querySource(textController.text, pluginName);}},),@@ -161,7 +161,7 @@ class _SourceSheetState extends State<SourceSheet>collectController.updateLocalCollect(infoController.bangumiItem);KazumiDialog.dismiss();- queryManager.querySource(textController.text, pluginName);+ queryManager?.querySource(textController.text, pluginName);}},child: const Text(@@ -303,7 +303,7 @@ class _SourceSheetState extends State<SourceSheet>actions: [GeneralErrorButton(onPressed: () {- queryManager.querySource(+ queryManager?.querySource(keyword, plugin.name);},text: '重试',