99 lines
2.9 KiB
Dart
99 lines
2.9 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:hgdj/hj_page/pre_sale/pre_sale_provider.dart';
|
|
import 'package:hgdj/hj_utils/api_service/ai_service.dart';
|
|
import 'package:hgdj/tools_base/global_store/store.dart';
|
|
import 'package:hgdj/tools_base/widget/keep_alive_widget.dart';
|
|
|
|
import '../../config/config.dart';
|
|
import '../../hj_model/splash/domain_source_model.dart';
|
|
import './ai_change_face_page.dart';
|
|
import './ai_draw/ai_paint_page.dart';
|
|
import './ai_image_to_video/ai_main_itv_page.dart';
|
|
import './ai_novel/ai_novel_page.dart';
|
|
import './ai_sub_type/ai_function_logic.dart';
|
|
import './ai_sub_type/ai_strip_sub_page.dart';
|
|
import './models/ai_mod_list_model.dart';
|
|
import 'ai_square/ai_square_page.dart';
|
|
|
|
class AiHomeLogic extends GetxController
|
|
with GetSingleTickerProviderStateMixin {
|
|
bool isShowLoading = true;
|
|
final AiType? aiType;
|
|
// int tabIndex;
|
|
|
|
AiHomeLogic({this.aiType});
|
|
|
|
AiModList? aiModList;
|
|
|
|
late List<AISwitchConf> menus = [];
|
|
|
|
late TabController tabCtr;
|
|
|
|
// 跳转相关模块的亚模块
|
|
void jumpSubModule(int index) {
|
|
tabCtr.index = index;
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
List<AISwitchConf>? aiTypes = Config.aiTypes;
|
|
//1.删除未开启的
|
|
aiTypes?.removeWhere((model) => model.isOpen == false);
|
|
//2.排序
|
|
aiTypes?.sort(
|
|
(m1, m2) => (m1.sort ?? 0).compareTo(m2.sort ?? 0),
|
|
);
|
|
menus.addAll(aiTypes ?? []);
|
|
//3.获取到默认进来的排序
|
|
int? initialIndex = aiTypes?.indexWhere((model) => model.aiType == aiType);
|
|
initialIndex = max(0, initialIndex ?? 0);
|
|
tabCtr = TabController(
|
|
initialIndex: initialIndex, length: menus.length, vsync: this)
|
|
..addListener(() {
|
|
if (!tabCtr.indexIsChanging) {
|
|
update(['tab']);
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
presaleProvider.refreshStatus(); //刷新预售权益
|
|
globalStore.refreshWallet(); //刷新钱包
|
|
loadData();
|
|
}
|
|
|
|
void loadData() async {
|
|
aiModList = await AIService.getModelList();
|
|
aiModList ??= AiModList();
|
|
isShowLoading = false;
|
|
update();
|
|
}
|
|
|
|
Widget subPage(AISwitchConf model) {
|
|
switch (model.aiType) {
|
|
case AiType.imageToVideo:
|
|
return AiMainItvPage(aiModList: aiModList).keepAlive; //图生视频
|
|
case AiType.aiPaint:
|
|
return AiPaintPage(aiModList: aiModList).keepAlive; //ai绘画
|
|
case AiType.autoStrip:
|
|
return AIStripSubPage().keepAlive; //脱衣
|
|
case AiType.videoChangeFace:
|
|
return AIChangeFacePage(type: AiType.videoChangeFace).keepAlive; //视频换脸
|
|
case AiType.imageChangeFace:
|
|
return AIChangeFacePage(type: AiType.imageChangeFace).keepAlive; //图片换脸
|
|
case AiType.aiNovel:
|
|
return AINovelSubPage().keepAlive; //ai小说
|
|
case AiType.aiMate:
|
|
return AiSquarePage().keepAlive; //ai女友
|
|
default:
|
|
return Container();
|
|
}
|
|
}
|
|
}
|