From 6eaf163a1adb7b113706abd88fe171d6e0630ead Mon Sep 17 00:00:00 2001 From: nyne Date: Tue, 15 Oct 2024 20:54:00 +0800 Subject: [PATCH] fix explore page translation --- lib/pages/explore_page.dart | 101 +++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 49 deletions(-) diff --git a/lib/pages/explore_page.dart b/lib/pages/explore_page.dart index 6f58300..84c51f7 100644 --- a/lib/pages/explore_page.dart +++ b/lib/pages/explore_page.dart @@ -27,7 +27,10 @@ class _ExplorePageState extends State @override void initState() { pages = List.from(appdata.settings["explore_pages"]); - var all = ComicSource.all().map((e) => e.explorePages).expand((e) => e.map((e) => e.title)).toList(); + var all = ComicSource.all() + .map((e) => e.explorePages) + .expand((e) => e.map((e) => e.title)) + .toList(); pages = pages.where((e) => all.contains(e)).toList(); controller = TabController( length: pages.length, @@ -43,16 +46,18 @@ class _ExplorePageState extends State } Widget buildFAB() => Material( - color: Colors.transparent, - child: FloatingActionButton( - key: const Key("FAB"), - onPressed: refresh, - child: const Icon(Icons.refresh), - ), - ); + color: Colors.transparent, + child: FloatingActionButton( + key: const Key("FAB"), + onPressed: refresh, + child: const Icon(Icons.refresh), + ), + ); Tab buildTab(String i) { - return Tab(text: i.tl, key: Key(i)); + var comicSource = ComicSource.all() + .firstWhere((e) => e.explorePages.any((e) => e.title == i)); + return Tab(text: i.ts(comicSource.key), key: Key(i)); } Widget buildBody(String i) => _SingleExplorePage(i, key: Key(i)); @@ -70,49 +75,47 @@ class _ExplorePageState extends State children: [ Positioned.fill( child: Column( - children: [ - tabBar, - Expanded( - child: NotificationListener( - onNotification: (notifications) { - if (notifications.metrics.axis == Axis.horizontal) { - if (!showFB) { - setState(() { - showFB = true; - }); - } - return true; - } + children: [ + tabBar, + Expanded( + child: NotificationListener( + onNotification: (notifications) { + if (notifications.metrics.axis == Axis.horizontal) { + if (!showFB) { + setState(() { + showFB = true; + }); + } + return true; + } - var current = notifications.metrics.pixels; + var current = notifications.metrics.pixels; - if ((current > location && current != 0) && showFB) { - setState(() { - showFB = false; - }); - } else if ((current < location || current == 0) && !showFB) { - setState(() { - showFB = true; - }); - } + if ((current > location && current != 0) && showFB) { + setState(() { + showFB = false; + }); + } else if ((current < location || current == 0) && !showFB) { + setState(() { + showFB = true; + }); + } - location = current; - return false; - }, - child: MediaQuery.removePadding( - context: context, - removeTop: true, - child: TabBarView( - controller: controller, - children: pages - .map((e) => buildBody(e)) - .toList(), - ), - ), + location = current; + return false; + }, + child: MediaQuery.removePadding( + context: context, + removeTop: true, + child: TabBarView( + controller: controller, + children: pages.map((e) => buildBody(e)).toList(), ), - ) - ], - )), + ), + ), + ) + ], + )), Positioned( right: 16, bottom: 16, @@ -341,7 +344,7 @@ Iterable _buildExplorePagePart( Text( part.title, style: - const TextStyle(fontSize: 20, fontWeight: FontWeight.w500), + const TextStyle(fontSize: 20, fontWeight: FontWeight.w500), ), const Spacer(), if (part.viewMore != null)