fix: 首页tabbar排序无效

This commit is contained in:
guozhigq
2024-01-28 23:44:41 +08:00
parent 1014c26d29
commit 8169f5739c
2 changed files with 18 additions and 4 deletions

View File

@ -63,13 +63,16 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
}
void setTabConfig() async {
defaultTabs = tabsConfig;
defaultTabs = [...tabsConfig];
tabbarSort = settingStorage.get(SettingBoxKey.tabbarSort,
defaultValue: ['live', 'rcmd', 'hot', 'bangumi']);
defaultTabs.retainWhere(
(item) => tabbarSort.contains((item['type'] as TabType).id));
defaultTabs.sort((a, b) => tabbarSort
.indexOf((a['type'] as TabType).id)
.compareTo(tabbarSort.indexOf((b['type'] as TabType).id)));
tabs.value = defaultTabs
.where((i) => tabbarSort.contains((i['type'] as TabType).id))
.toList();
tabs.value = defaultTabs;
if (tabbarSort.contains(TabType.rcmd.id)) {
initialIndex.value = tabbarSort.indexOf(TabType.rcmd.id);