Skip to content

Commit 5911cb4

Browse files
committed
refactor(local_ads_management): statically define ad type tab order
- Introduce a static list `_tabs` to define the order of ad types - Update `TabController` length and `TabBar` tabs to use `_tabs` instead of `AdType.values` - Modify `TabBarView` children to use `_tabs` for consistent tab order
1 parent 9df1464 commit 5911cb4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/local_ads_management/view/archived_local_ads_page.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ class _ArchivedLocalAdsViewState extends State<_ArchivedLocalAdsView>
5151
with SingleTickerProviderStateMixin {
5252
late TabController _tabController;
5353

54+
// Statically define the tab order to ensure consistency.
55+
final List<AdType> _tabs = [
56+
AdType.native,
57+
AdType.banner,
58+
AdType.interstitial,
59+
AdType.video,
60+
];
61+
5462
@override
5563
void initState() {
5664
super.initState();
5765
_tabController = TabController(
58-
length: AdType.values.length,
66+
length: _tabs.length,
5967
vsync: this,
6068
);
6169
}
@@ -76,9 +84,7 @@ class _ArchivedLocalAdsViewState extends State<_ArchivedLocalAdsView>
7684
controller: _tabController,
7785
tabAlignment: TabAlignment.start,
7886
isScrollable: true,
79-
tabs: AdType.values
80-
.map((type) => Tab(text: type.l10n(context)))
81-
.toList(),
87+
tabs: _tabs.map((type) => Tab(text: type.l10n(context))).toList(),
8288
),
8389
),
8490
body: BlocListener<ArchiveLocalAdsBloc, ArchiveLocalAdsState>(
@@ -149,9 +155,8 @@ class _ArchivedLocalAdsViewState extends State<_ArchivedLocalAdsView>
149155
},
150156
child: TabBarView(
151157
controller: _tabController,
152-
children: AdType.values.map((type) {
153-
return _ArchivedLocalAdsDataTable(adType: type);
154-
}).toList(),
158+
children:
159+
_tabs.map((type) => _ArchivedLocalAdsDataTable(adType: type)).toList(),
155160
),
156161
),
157162
);

0 commit comments

Comments
 (0)