调换tab顺序
This commit is contained in:
@@ -44,12 +44,16 @@ class HomeMainLogic extends GetxController {
|
||||
|
||||
int get selectedTabIndex => tabCtr?.index ?? _initIndex;
|
||||
|
||||
/// 主页固定注入的「热门短剧」tab(从短剧频道挪过来),不走后端模块
|
||||
static const hotDramaTabId = '-120';
|
||||
|
||||
//服务端下发的原始顺序(抽屉「恢复默认」用)
|
||||
List<ModuleData> get defaultList {
|
||||
if (isDarkStyle) return Config.plateModule?.deepWeb ?? [];
|
||||
// 固定最新模块
|
||||
// 固定最新 + 热门短剧模块,热门短剧排第二个
|
||||
return [
|
||||
ModuleData(id: "-110", moduleName: "最新", type: 1, showType: 1),
|
||||
ModuleData(id: hotDramaTabId, moduleName: "热门短剧"),
|
||||
...?Config.plateModule?.homePage,
|
||||
];
|
||||
}
|
||||
@@ -74,6 +78,7 @@ class HomeMainLogic extends GetxController {
|
||||
/// 应用抽屉里的新排序:顺序没变只切 tab,变了就落盘并换 key 重建 TabView
|
||||
Future<void> resortTabs(List<ModuleData> dataArr, ModuleData? tagData) async {
|
||||
final curTagData = tagData ?? tabs[selectedTabIndex];
|
||||
dataArr = _pinHotDrama(dataArr);
|
||||
bool isSameArr = true;
|
||||
int selectIndex = 0;
|
||||
//抽屉只重排不增删,长度必然一致;逐项比名字,顺带定位选中项的新位置
|
||||
@@ -102,13 +107,15 @@ class HomeMainLogic extends GetxController {
|
||||
serverTabs: defaultList,
|
||||
key: _sortKey,
|
||||
);
|
||||
if (!isDarkStyle) tabs = _pinHotDrama(tabs);
|
||||
if (darkDefaultId?.isNotEmpty == true) {
|
||||
// 初始化指定模块(一般暗网模块用)
|
||||
final index = tabs.indexWhere((e) => e.id == darkDefaultId);
|
||||
if (index >= 0) _initIndex = index;
|
||||
} else if (!isDarkStyle) {
|
||||
//默认不显示最新模块,选中「热门」(index 1);但 tab 不足 2 个时回退到 0,避免越界
|
||||
_initIndex = (tabs.first.moduleName == "最新" && tabs.length > 1) ? 1 : 0;
|
||||
//默认选中「热门短剧」
|
||||
final index = tabs.indexWhere((e) => e.id == hotDramaTabId);
|
||||
_initIndex = index >= 0 ? index : 0;
|
||||
}
|
||||
} catch (e) {
|
||||
debugLog(e);
|
||||
@@ -117,6 +124,15 @@ class HomeMainLogic extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
/// 「热门短剧」固定排第二个:本地排序里新 tab 会被追加到末尾,抽屉里也可能被拖走,这里统一挪回来
|
||||
List<ModuleData> _pinHotDrama(List<ModuleData> list) {
|
||||
final index = list.indexWhere((e) => e.id == hotDramaTabId);
|
||||
if (index < 0 || index == 1 || list.length < 2) return list;
|
||||
final result = [...list];
|
||||
result.insert(1, result.removeAt(index));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 首页弹窗链:预售 → 支付分层 → VIP 引导。
|
||||
/// 逐个 await 串行弹,每次启动只跑一次。
|
||||
/// 广告类弹窗(九宫格/图片公告/文字公告)不在这里:它们跟着启动落地页弹,见 MainPageLogic.onReady
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:tgdj/tools_base/widget/keep_alive_widget.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../cartoon/cartoon_sub_detail_page.dart';
|
||||
import '../drama/drama_list_page.dart';
|
||||
import '../main_page/provider/bottom_bar_provider.dart';
|
||||
import 'activity_float/home_float_widget.dart';
|
||||
import 'home_drawer.dart';
|
||||
@@ -203,6 +204,9 @@ class _HomeTabViewState extends State<HomeTabView>
|
||||
/// 按 module type/showType/isACG 分发到对应子页,统一 keepAlive
|
||||
Widget _tabPage(int index) {
|
||||
final module = logic.tabs[index];
|
||||
if (module.id == HomeMainLogic.hotDramaTabId) {
|
||||
return const DramaListPage().keepAlive;
|
||||
}
|
||||
if (module.type == 1 || module.type == 3) {
|
||||
//showType==2 走分区聚合页,其余走排序列表页
|
||||
return module.showType == 2
|
||||
|
||||
Reference in New Issue
Block a user