Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

better orientation for tablet

Prediditc9930a819732
diff --git a/lib/pages/favorite/favorite_page.dart b/lib/pages/favorite/favorite_page.dart
index 7f7d095c..005c87de 100644
--- a/lib/pages/favorite/favorite_page.dart
+++ b/lib/pages/favorite/favorite_page.dart
@@ -40,34 +40,38 @@ class _FavoritePageState extends State<FavoritePage> {
@override
Widget build(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: const SysAppBar(title: Text('追番')),
- body: favoriteController.favorites.isEmpty
- ? const Center(
- child: Text('啊咧(⊙.⊙) 没有追番的说'),
- )
- : CustomScrollView(
- slivers: [
- SliverPadding(
- padding: const EdgeInsets.all(StyleString.cardSpace),
- sliver: contentGrid(favoriteController.favorites),
+ return OrientationBuilder(
+ builder: (context, orientation) {
+ return PopScope(
+ canPop: false,
+ onPopInvokedWithResult: (bool didPop, Object? result) {
+ if (didPop) {
+ return;
+ }
+ onBackPressed(context);
+ },
+ child: Scaffold(
+ appBar: const SysAppBar(title: Text('追番')),
+ body: favoriteController.favorites.isEmpty
+ ? const Center(
+ child: Text('啊咧(⊙.⊙) 没有追番的说'),
+ )
+ : CustomScrollView(
+ slivers: [
+ SliverPadding(
+ padding: const EdgeInsets.all(StyleString.cardSpace),
+ sliver: contentGrid(favoriteController.favorites, orientation),
+ ),
+ ],
),
- ],
- ),
- ),
+ ),
+ );
+ }
);
}
- Widget contentGrid(List bangumiList) {
- int crossCount = (!Utils.isCompact()) ? 6 : 3;
+ Widget contentGrid(List bangumiList, Orientation orientation) {
+ int crossCount = orientation != Orientation.portrait ? 6 : 3;
return SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
mainAxisSpacing: StyleString.cardSpace - 2,
diff --git a/lib/pages/history/history_page.dart b/lib/pages/history/history_page.dart
index c0802b0b..a3ab34e9 100644
--- a/lib/pages/history/history_page.dart
+++ b/lib/pages/history/history_page.dart
@@ -46,29 +46,33 @@ class _HistoryPageState extends State<HistoryPage>
WidgetsBinding.instance.addPostFrameCallback((_) {
navigationBarState.hideNavigate();
});
- return Observer(builder: (context) {
- return PopScope(
- canPop: true,
- onPopInvokedWithResult: (bool didPop, Object? result) async {
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: const SysAppBar(title: Text('历史记录')),
- body: renderBody,
- floatingActionButton: FloatingActionButton(
- child: const Icon(Icons.clear_all),
- onPressed: () {
- historyController.clearAll();
+ return OrientationBuilder(
+ builder: (context, orientation) {
+ return Observer(builder: (context) {
+ return PopScope(
+ canPop: true,
+ onPopInvokedWithResult: (bool didPop, Object? result) async {
+ onBackPressed(context);
},
- ),
- ),
- );
- });
+ child: Scaffold(
+ appBar: const SysAppBar(title: Text('历史记录')),
+ body: renderBody(orientation),
+ floatingActionButton: FloatingActionButton(
+ child: const Icon(Icons.clear_all),
+ onPressed: () {
+ historyController.clearAll();
+ },
+ ),
+ ),
+ );
+ });
+ }
+ );
}
- Widget get renderBody {
+ Widget renderBody(Orientation orientation) {
if (historyController.histories.isNotEmpty) {
- return contentGrid;
+ return contentGrid(orientation);
} else {
return const Center(
child: Text('没有找到历史记录 (´;ω;`)'),
@@ -76,9 +80,8 @@ class _HistoryPageState extends State<HistoryPage>
}
}
- Widget get contentGrid {
- // List<Widget> gridViewList = [];
- int crossCount = (!Utils.isCompact()) ? 3 : 1;
+ Widget contentGrid(Orientation orientation) {
+ int crossCount = orientation != Orientation.portrait ? 3 : 1;
return CustomScrollView(
slivers: [
SliverGrid(
diff --git a/lib/pages/popular/popular_page.dart b/lib/pages/popular/popular_page.dart
index f480cb3a..4a28b166 100644
--- a/lib/pages/popular/popular_page.dart
+++ b/lib/pages/popular/popular_page.dart
@@ -48,7 +48,8 @@ class _PopularPageState extends State<PopularPage>
popularController.isLoadingMore == false &&
popularController.searchKeyword == '') {
KazumiLogger().log(Level.info, 'Popular 正在加载更多');
- popularController.queryBangumiListFeed(type: 'onload', tag: popularController.currentTag);
+ popularController.queryBangumiListFeed(
+ type: 'onload', tag: popularController.currentTag);
}
});
if (popularController.bangumiList.isEmpty) {
@@ -88,201 +89,207 @@ class _PopularPageState extends State<PopularPage>
// 暂时移除,某些情况下可能 crash
// scrollController.jumpTo(popularController.scrollOffset);
});
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: RefreshIndicator(
- onRefresh: () async {
- await popularController.queryBangumiListFeed(
- tag: popularController.currentTag);
+ return OrientationBuilder(builder: (context, orientation) {
+ return PopScope(
+ canPop: false,
+ onPopInvokedWithResult: (bool didPop, Object? result) {
+ if (didPop) {
+ return;
+ }
+ onBackPressed(context);
},
- child: Scaffold(
- appBar: SysAppBar(
- leading: (Utils.isCompact())
- ? Row(
- children: [
- const SizedBox(
- width: 10,
- ),
- ClipOval(
- child: Image.asset(
- 'assets/images/logo/logo_android.png',
+ child: RefreshIndicator(
+ onRefresh: () async {
+ await popularController.queryBangumiListFeed(
+ tag: popularController.currentTag);
+ },
+ child: Scaffold(
+ appBar: SysAppBar(
+ leading: (Utils.isCompact())
+ ? Row(
+ children: [
+ const SizedBox(
+ width: 10,
),
- ),
- ],
- )
- : null,
- backgroundColor: Colors.transparent,
- title: Stack(
- children: [
- Positioned.fill(
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onPanStart: (_) => windowManager.startDragging(),
- child: Container(),
- ),
- ),
- Row(
- children: [
- Expanded(
- child: Visibility(
- visible: showSearchBar,
- child: TextFormField(
- focusNode: _focusNode,
- cursorColor: Theme.of(context).colorScheme.primary,
- decoration: const InputDecoration(
- alignLabelWithHint: true,
- contentPadding: EdgeInsets.symmetric(
- vertical: 8, horizontal: 8),
- border: OutlineInputBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(8)),
- ),
+ ClipOval(
+ child: Image.asset(
+ 'assets/images/logo/logo_android.png',
),
- style: TextStyle(
- color:
- isLight ? Colors.black87 : Colors.white70),
- onChanged: (_) {
- scrollController.jumpTo(0.0);
- },
- controller: keywordController,
- onFieldSubmitted: (t) async {
- setState(() {
- searchLoading = true;
- popularController.currentTag = '';
- });
- if (t != '') {
- popularController.searchKeyword = t;
- await popularController.queryBangumi(
- popularController.searchKeyword);
- } else {
- popularController.searchKeyword = '';
- await popularController.queryBangumiListFeed();
- }
- setState(() {
- searchLoading = false;
- });
- },
),
- ),
+ ],
+ )
+ : null,
+ backgroundColor: Colors.transparent,
+ title: Stack(
+ children: [
+ Positioned.fill(
+ child: GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onPanStart: (_) => windowManager.startDragging(),
+ child: Container(),
),
- IconButton(
- onPressed: () async {
- if (!showSearchBar) {
- setState(() {
- showSearchBar = true;
- });
- _focusNode.requestFocus();
- } else {
- if (keywordController.text == '') {
- _focusNode.unfocus();
+ ),
+ Row(
+ children: [
+ Expanded(
+ child: Visibility(
+ visible: showSearchBar,
+ child: TextFormField(
+ focusNode: _focusNode,
+ cursorColor:
+ Theme.of(context).colorScheme.primary,
+ decoration: const InputDecoration(
+ alignLabelWithHint: true,
+ contentPadding: EdgeInsets.symmetric(
+ vertical: 8, horizontal: 8),
+ border: OutlineInputBorder(
+ borderRadius:
+ BorderRadius.all(Radius.circular(8)),
+ ),
+ ),
+ style: TextStyle(
+ color: isLight
+ ? Colors.black87
+ : Colors.white70),
+ onChanged: (_) {
+ scrollController.jumpTo(0.0);
+ },
+ controller: keywordController,
+ onFieldSubmitted: (t) async {
setState(() {
- showSearchBar = false;
searchLoading = true;
popularController.currentTag = '';
});
- popularController.searchKeyword == '';
- await popularController.queryBangumiListFeed();
+ if (t != '') {
+ popularController.searchKeyword = t;
+ await popularController.queryBangumi(
+ popularController.searchKeyword);
+ } else {
+ popularController.searchKeyword = '';
+ await popularController
+ .queryBangumiListFeed();
+ }
setState(() {
searchLoading = false;
});
- } else {
- keywordController.text = '';
- popularController.searchKeyword = '';
+ },
+ ),
+ ),
+ ),
+ IconButton(
+ onPressed: () async {
+ if (!showSearchBar) {
+ setState(() {
+ showSearchBar = true;
+ });
_focusNode.requestFocus();
+ } else {
+ if (keywordController.text == '') {
+ _focusNode.unfocus();
+ setState(() {
+ showSearchBar = false;
+ searchLoading = true;
+ popularController.currentTag = '';
+ });
+ popularController.searchKeyword == '';
+ await popularController
+ .queryBangumiListFeed();
+ setState(() {
+ searchLoading = false;
+ });
+ } else {
+ keywordController.text = '';
+ popularController.searchKeyword = '';
+ _focusNode.requestFocus();
+ }
}
- }
- },
- icon: showSearchBar
- ? const Icon(Icons.close)
- : const Icon(Icons.search))
- ],
- ),
- ],
+ },
+ icon: showSearchBar
+ ? const Icon(Icons.close)
+ : const Icon(Icons.search))
+ ],
+ ),
+ ],
+ ),
),
- ),
- body: Column(
- children: [
- SizedBox(
- height: showTagFilter ? 50 : 0,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(0, 0, 14, 0),
- child: tagFilter(),
+ body: Column(
+ children: [
+ SizedBox(
+ height: showTagFilter ? 50 : 0,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(0, 0, 14, 0),
+ child: tagFilter(),
+ ),
),
- ),
- Expanded(
- child: CustomScrollView(
- controller: scrollController,
- slivers: [
- SliverToBoxAdapter(
- child: Padding(
- padding: const EdgeInsets.only(
- top: 0, bottom: 10, left: 0),
- child: searchLoading
- ? const LinearProgressIndicator()
- : Container(),
+ Expanded(
+ child: CustomScrollView(
+ controller: scrollController,
+ slivers: [
+ SliverToBoxAdapter(
+ child: Padding(
+ padding: const EdgeInsets.only(
+ top: 0, bottom: 10, left: 0),
+ child: searchLoading
+ ? const LinearProgressIndicator()
+ : Container(),
+ ),
),
- ),
- SliverPadding(
- padding: const EdgeInsets.fromLTRB(
- StyleString.safeSpace,
- 0,
- StyleString.safeSpace,
- 0),
- sliver: Observer(builder: (context) {
- if (popularController.bangumiList.isEmpty &&
- timeout == true) {
- return HttpError(
- errMsg: '什么都没有找到 (´;ω;`)',
- fn: () {
- popularController.queryBangumiListFeed();
- },
- );
- }
- if (popularController.bangumiList.isEmpty &&
- timeout == false) {
- return SliverToBoxAdapter(
- child: SizedBox(
- height:
- (MediaQuery.of(context).size.height /
- 2),
- child: const Column(
- crossAxisAlignment:
- CrossAxisAlignment.center,
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: [
- CircularProgressIndicator(),
- ],
- )),
- );
- }
- return contentGrid(popularController.bangumiList);
- })),
- ],
+ SliverPadding(
+ padding: const EdgeInsets.fromLTRB(
+ StyleString.safeSpace,
+ 0,
+ StyleString.safeSpace,
+ 0),
+ sliver: Observer(builder: (context) {
+ if (popularController.bangumiList.isEmpty &&
+ timeout == true) {
+ return HttpError(
+ errMsg: '什么都没有找到 (´;ω;`)',
+ fn: () {
+ popularController.queryBangumiListFeed();
+ },
+ );
+ }
+ if (popularController.bangumiList.isEmpty &&
+ timeout == false) {
+ return SliverToBoxAdapter(
+ child: SizedBox(
+ height:
+ (MediaQuery.of(context).size.height /
+ 2),
+ child: const Column(
+ crossAxisAlignment:
+ CrossAxisAlignment.center,
+ mainAxisAlignment:
+ MainAxisAlignment.center,
+ children: [
+ CircularProgressIndicator(),
+ ],
+ )),
+ );
+ }
+ return contentGrid(popularController.bangumiList, orientation);
+ })),
+ ],
+ ),
),
- ),
- ],
- ),
- floatingActionButton: FloatingActionButton(
- onPressed: () {
- scrollController.jumpTo(0.0);
- },
- child: const Icon(Icons.arrow_upward),
- )
- // backgroundColor: themedata.colorScheme.primaryContainer,
- ),
- ),
- );
+ ],
+ ),
+ floatingActionButton: FloatingActionButton(
+ onPressed: () {
+ scrollController.jumpTo(0.0);
+ },
+ child: const Icon(Icons.arrow_upward),
+ )
+ // backgroundColor: themedata.colorScheme.primaryContainer,
+ ),
+ ),
+ );
+ });
}
- Widget contentGrid(bangumiList) {
- int crossCount = !Utils.isCompact() ? 6 : 3;
+ Widget contentGrid(bangumiList, Orientation orientation) {
+ int crossCount = orientation != Orientation.portrait ? 6 : 3;
return SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// 行间距
diff --git a/lib/pages/timeline/timeline_page.dart b/lib/pages/timeline/timeline_page.dart
index 8d6f87f1..c83a4d44 100644
--- a/lib/pages/timeline/timeline_page.dart
+++ b/lib/pages/timeline/timeline_page.dart
@@ -76,42 +76,46 @@ class _TimelinePageState extends State<TimelinePage>
@override
Widget build(BuildContext context) {
- return Observer(builder: (context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: SysAppBar(
- toolbarHeight: 104,
- bottom: TabBar(
- controller: controller,
- tabs: tabs,
- indicatorColor: Theme.of(context).colorScheme.primary,
- ),
- title: InkWell(
- child: const Text('新番时间表'),
- onTap: () {},
- ),
- ),
- body: Padding(
- padding: const EdgeInsets.only(left: 5, right: 5, top: 10),
- child: renderBody
+ return OrientationBuilder(
+ builder: (context, orientation) {
+ return Observer(builder: (context) {
+ return PopScope(
+ canPop: false,
+ onPopInvokedWithResult: (bool didPop, Object? result) {
+ if (didPop) {
+ return;
+ }
+ onBackPressed(context);
+ },
+ child: Scaffold(
+ appBar: SysAppBar(
+ toolbarHeight: 104,
+ bottom: TabBar(
+ controller: controller,
+ tabs: tabs,
+ indicatorColor: Theme.of(context).colorScheme.primary,
+ ),
+ title: InkWell(
+ child: const Text('新番时间表'),
+ onTap: () {},
+ ),
+ ),
+ body: Padding(
+ padding: const EdgeInsets.only(left: 5, right: 5, top: 10),
+ child: renderBody(orientation)
+ ),
),
- ),
- );
- });
+ );
+ });
+ }
+ );
}
- Widget get renderBody {
+ Widget renderBody(Orientation orientation) {
if (timelineController.bangumiCalendar.length > 0) {
return TabBarView(
controller: controller,
- children: contentGrid(timelineController.bangumiCalendar),
+ children: contentGrid(timelineController.bangumiCalendar, orientation),
);
} else {
return const Center(
@@ -120,9 +124,9 @@ class _TimelinePageState extends State<TimelinePage>
}
}
- List<Widget> contentGrid(List<List<BangumiItem>> bangumiCalendar) {
+ List<Widget> contentGrid(List<List<BangumiItem>> bangumiCalendar, Orientation orientation) {
List<Widget> gridViewList = [];
- int crossCount = !Utils.isCompact() ? 6 : 3;
+ int crossCount = orientation != Orientation.portrait ? 6 : 3;
for (dynamic bangumiList in bangumiCalendar) {
gridViewList.add(
CustomScrollView(