mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 16:01:58 +00:00
Make TabBar and TabBarView cleaner
Use the _visibleTabTypes list instead of the repeated if-statements.
This commit is contained in:
parent
66b508d65d
commit
30e6d50210
1 changed files with 28 additions and 49 deletions
|
|
@ -89,6 +89,17 @@ class _UpdatesScreenState extends ConsumerState<UpdatesScreen>
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = l10nLocalizations(context)!;
|
final l10n = l10nLocalizations(context)!;
|
||||||
|
String localizedItemType(ItemType type) {
|
||||||
|
switch (type) {
|
||||||
|
case ItemType.manga:
|
||||||
|
return l10n.manga;
|
||||||
|
case ItemType.anime:
|
||||||
|
return l10n.anime;
|
||||||
|
case ItemType.novel:
|
||||||
|
return l10n.novel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
|
@ -182,61 +193,29 @@ class _UpdatesScreenState extends ConsumerState<UpdatesScreen>
|
||||||
bottom: TabBar(
|
bottom: TabBar(
|
||||||
indicatorSize: TabBarIndicatorSize.tab,
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
controller: _tabBarController,
|
controller: _tabBarController,
|
||||||
tabs: [
|
tabs: _visibleTabTypes.map((type) {
|
||||||
if (!hideItems.contains("/MangaLibrary"))
|
return Row(
|
||||||
Row(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Tab(text: localizedItemType(type)),
|
||||||
Tab(text: l10n.manga),
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 8),
|
_updateNumbers(ref, type),
|
||||||
_updateNumbers(ref, ItemType.manga),
|
],
|
||||||
],
|
);
|
||||||
),
|
}).toList(),
|
||||||
if (!hideItems.contains("/AnimeLibrary"))
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Tab(text: l10n.anime),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
_updateNumbers(ref, ItemType.anime),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (!hideItems.contains("/NovelLibrary"))
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Tab(text: l10n.novel),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
_updateNumbers(ref, ItemType.novel),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: _tabBarController,
|
controller: _tabBarController,
|
||||||
children: [
|
children: _visibleTabTypes.map((type) {
|
||||||
if (!hideItems.contains("/MangaLibrary"))
|
return UpdateTab(
|
||||||
UpdateTab(
|
itemType: type,
|
||||||
itemType: ItemType.manga,
|
query: _textEditingController.text,
|
||||||
query: _textEditingController.text,
|
isLoading: _isLoading,
|
||||||
isLoading: _isLoading,
|
);
|
||||||
),
|
}).toList(),
|
||||||
if (!hideItems.contains("/AnimeLibrary"))
|
|
||||||
UpdateTab(
|
|
||||||
itemType: ItemType.anime,
|
|
||||||
query: _textEditingController.text,
|
|
||||||
isLoading: _isLoading,
|
|
||||||
),
|
|
||||||
if (!hideItems.contains("/NovelLibrary"))
|
|
||||||
UpdateTab(
|
|
||||||
itemType: ItemType.novel,
|
|
||||||
query: _textEditingController.text,
|
|
||||||
isLoading: _isLoading,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue