fix explore page translation

This commit is contained in:
nyne
2024-10-15 20:54:00 +08:00
parent fc86b8bbc6
commit 6eaf163a1a

View File

@@ -27,7 +27,10 @@ class _ExplorePageState extends State<ExplorePage>
@override @override
void initState() { void initState() {
pages = List<String>.from(appdata.settings["explore_pages"]); pages = List<String>.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(); pages = pages.where((e) => all.contains(e)).toList();
controller = TabController( controller = TabController(
length: pages.length, length: pages.length,
@@ -43,16 +46,18 @@ class _ExplorePageState extends State<ExplorePage>
} }
Widget buildFAB() => Material( Widget buildFAB() => Material(
color: Colors.transparent, color: Colors.transparent,
child: FloatingActionButton( child: FloatingActionButton(
key: const Key("FAB"), key: const Key("FAB"),
onPressed: refresh, onPressed: refresh,
child: const Icon(Icons.refresh), child: const Icon(Icons.refresh),
), ),
); );
Tab buildTab(String i) { 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)); Widget buildBody(String i) => _SingleExplorePage(i, key: Key(i));
@@ -70,49 +75,47 @@ class _ExplorePageState extends State<ExplorePage>
children: [ children: [
Positioned.fill( Positioned.fill(
child: Column( child: Column(
children: [ children: [
tabBar, tabBar,
Expanded( Expanded(
child: NotificationListener<ScrollNotification>( child: NotificationListener<ScrollNotification>(
onNotification: (notifications) { onNotification: (notifications) {
if (notifications.metrics.axis == Axis.horizontal) { if (notifications.metrics.axis == Axis.horizontal) {
if (!showFB) { if (!showFB) {
setState(() { setState(() {
showFB = true; showFB = true;
}); });
} }
return true; return true;
} }
var current = notifications.metrics.pixels; var current = notifications.metrics.pixels;
if ((current > location && current != 0) && showFB) { if ((current > location && current != 0) && showFB) {
setState(() { setState(() {
showFB = false; showFB = false;
}); });
} else if ((current < location || current == 0) && !showFB) { } else if ((current < location || current == 0) && !showFB) {
setState(() { setState(() {
showFB = true; showFB = true;
}); });
} }
location = current; location = current;
return false; return false;
}, },
child: MediaQuery.removePadding( child: MediaQuery.removePadding(
context: context, context: context,
removeTop: true, removeTop: true,
child: TabBarView( child: TabBarView(
controller: controller, controller: controller,
children: pages children: pages.map((e) => buildBody(e)).toList(),
.map((e) => buildBody(e))
.toList(),
),
),
), ),
) ),
], ),
)), )
],
)),
Positioned( Positioned(
right: 16, right: 16,
bottom: 16, bottom: 16,
@@ -341,7 +344,7 @@ Iterable<Widget> _buildExplorePagePart(
Text( Text(
part.title, part.title,
style: style:
const TextStyle(fontSize: 20, fontWeight: FontWeight.w500), const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
), ),
const Spacer(), const Spacer(),
if (part.viewMore != null) if (part.viewMore != null)