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
void initState() {
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();
controller = TabController(
length: pages.length,
@@ -52,7 +55,9 @@ class _ExplorePageState extends State<ExplorePage>
);
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));
@@ -104,9 +109,7 @@ class _ExplorePageState extends State<ExplorePage>
removeTop: true,
child: TabBarView(
controller: controller,
children: pages
.map((e) => buildBody(e))
.toList(),
children: pages.map((e) => buildBody(e)).toList(),
),
),
),