|
|
@@ -9,6 +9,8 @@ import 'package:keyboard/data/bean/upload_info.dart';
|
|
|
import 'package:keyboard/utils/upload/upload_scene_type.dart';
|
|
|
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
|
|
|
import '../../../data/api/response/intimacy_analyze_config_response.dart';
|
|
|
+import '../../../data/api/response/intimacy_analyze_response.dart';
|
|
|
+import '../../../data/bean/ai_model.dart';
|
|
|
import '../../../data/bean/keyboard_info.dart';
|
|
|
import '../../../data/bean/option_select_config.dart';
|
|
|
import '../../../data/bean/option_select_item.dart';
|
|
|
@@ -45,10 +47,10 @@ class IntimacyAnalyseUploadController extends BaseController {
|
|
|
RxList<UploadInfo> uploadInfoList = <UploadInfo>[].obs;
|
|
|
|
|
|
/// Ai模型列表
|
|
|
- RxList<String> aiModelList = <String>[].obs;
|
|
|
+ RxList<AiModel> aiModelList = <AiModel>[].obs;
|
|
|
|
|
|
/// 当前应用的Ai模型
|
|
|
- Rx<String> currentAiModel = ''.obs;
|
|
|
+ Rxn<AiModel> currentAiModel = Rxn();
|
|
|
|
|
|
/// 预测方向的选项列表
|
|
|
RxList<OptionSelectConfig> directionOptionSelectConfigList =
|
|
|
@@ -90,6 +92,9 @@ class IntimacyAnalyseUploadController extends BaseController {
|
|
|
/// 当前键盘信息
|
|
|
Rxn<KeyboardInfo> currentKeyboardInfo = Rxn();
|
|
|
|
|
|
+ /// 当前选择的预测方向
|
|
|
+ Rx<String> currentDirectionOption = "".obs;
|
|
|
+
|
|
|
IntimacyAnalyseUploadController(
|
|
|
this.intimacyAnalyzeRepository,
|
|
|
this.intimacyAnalyzeConfigHelper,
|
|
|
@@ -137,11 +142,7 @@ class IntimacyAnalyseUploadController extends BaseController {
|
|
|
|
|
|
/// 初始化Ai模型列表
|
|
|
void _initAiModelList(IntimacyAnalyzeConfigResponse? config) {
|
|
|
- List<String> newModelList =
|
|
|
- config?.modes?.map((item) {
|
|
|
- return item.name ?? "";
|
|
|
- }).toList() ??
|
|
|
- [];
|
|
|
+ List<AiModel> newModelList = config?.modes?.toList() ?? [];
|
|
|
aiModelList.clear();
|
|
|
aiModelList.addAll(newModelList);
|
|
|
|
|
|
@@ -240,24 +241,32 @@ class IntimacyAnalyseUploadController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/// 切换Ai模型
|
|
|
- void switchAiModel(String newAiModel) {
|
|
|
+ void switchAiModel(AiModel newAiModel) {
|
|
|
currentAiModel.value = newAiModel;
|
|
|
+ currentAiModel.refresh();
|
|
|
}
|
|
|
|
|
|
/// 添加预测方向
|
|
|
- void addDirection() {}
|
|
|
+ void addDirection() {
|
|
|
+ // 弹出预测方向的编辑弹窗
|
|
|
+ }
|
|
|
|
|
|
/// 预测方向,选中选项
|
|
|
void selectDirectionOption(
|
|
|
OptionSelectConfig rowConfig,
|
|
|
OptionSelectItem optionItem,
|
|
|
) {
|
|
|
- // 先全部反选
|
|
|
- rowConfig.options =
|
|
|
- rowConfig.options.map((ele) {
|
|
|
- ele.selected = false;
|
|
|
- return ele;
|
|
|
- }).toList();
|
|
|
+ // 更新当前选中项
|
|
|
+ currentDirectionOption.value = optionItem.name;
|
|
|
+
|
|
|
+ // 将所有预测方向都反选
|
|
|
+ for (var config in directionOptionSelectConfigList) {
|
|
|
+ config.options =
|
|
|
+ config.options.map((ele) {
|
|
|
+ ele.selected = false;
|
|
|
+ return ele;
|
|
|
+ }).toList();
|
|
|
+ }
|
|
|
// 再勾选当前的选中项
|
|
|
optionItem.selected = true;
|
|
|
// 由于Rx响应式变量,无法监听对象中嵌套对象的某个属性的变化,导致页面不会刷新,需要手动刷新页面
|
|
|
@@ -265,7 +274,7 @@ class IntimacyAnalyseUploadController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/// 点击了下一步按钮
|
|
|
- void clickNextBtn() {
|
|
|
+ void clickNextBtn() async {
|
|
|
// TODO hezihao,需要判断是否解锁,未解锁弹出购买弹窗,目前先直接让通过
|
|
|
|
|
|
// 上传的图片后端地址
|
|
|
@@ -276,14 +285,16 @@ class IntimacyAnalyseUploadController extends BaseController {
|
|
|
// 键盘Id
|
|
|
String keyboardId = currentKeyboardInfo.value?.id ?? "";
|
|
|
// 预测方向
|
|
|
- // TODO hezihao,多个预测方向,用逗号分割,还是?
|
|
|
- String direction = "缘分指数";
|
|
|
+ String direction = currentDirectionOption.value;
|
|
|
// 当前选择的Ai模型
|
|
|
- String aiModel = currentAiModel.value;
|
|
|
-
|
|
|
- intimacyAnalyzeRepository.getIntimacyAnalyze(
|
|
|
- IntimacyAnalyzeRequest(imageList, keyboardId, direction, aiModel),
|
|
|
- );
|
|
|
+ String aiModel = currentAiModel.value?.value ?? "";
|
|
|
+
|
|
|
+ // 分析亲密度
|
|
|
+ IntimacyAnalyzeResponse response = await intimacyAnalyzeRepository
|
|
|
+ .getIntimacyAnalyze(
|
|
|
+ IntimacyAnalyzeRequest(imageList, keyboardId, direction, aiModel),
|
|
|
+ );
|
|
|
+ AtmobLog.d(tag, "分析亲密度 => ${response.toJson()}");
|
|
|
isUploadPage.value = false;
|
|
|
}
|
|
|
|