45 lines
1.0 KiB
Dart
45 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:hgdj/hj_page/live/live_service.dart';
|
|
|
|
import 'live_model.dart';
|
|
|
|
//直播主逻辑
|
|
class LiveMainLogic extends GetxController with GetTickerProviderStateMixin {
|
|
TabController? tabController;
|
|
LiveMainModel? liveMainModel;
|
|
List<LiveModule> liveTabs = [];
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
loadData();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
tabController?.dispose();
|
|
super.onClose();
|
|
}
|
|
|
|
//获取媒体详情
|
|
loadData() async {
|
|
liveMainModel = await LiveService.getLiveModuleList();
|
|
if (liveMainModel != null) {
|
|
if (liveMainModel?.module != null &&
|
|
liveMainModel?.module?.isNotEmpty == true) {
|
|
liveTabs.clear();
|
|
liveTabs.add(LiveModule(id: '-1', title: '推荐')); //添加推荐数据
|
|
liveTabs.addAll(liveMainModel?.module ?? []);
|
|
tabController = TabController(
|
|
initialIndex: 0,
|
|
length: liveTabs.length,
|
|
vsync: this,
|
|
);
|
|
}
|
|
}
|
|
|
|
update();
|
|
}
|
|
}
|