|
@@ -5,6 +5,7 @@ import 'package:keyboard/base/base_controller.dart';
|
|
|
import 'package:keyboard/data/bean/custom_config_info.dart';
|
|
import 'package:keyboard/data/bean/custom_config_info.dart';
|
|
|
import 'package:keyboard/data/repository/config_repository.dart';
|
|
import 'package:keyboard/data/repository/config_repository.dart';
|
|
|
import 'package:keyboard/module/character_custom/detail/character_custom_detail_page.dart';
|
|
import 'package:keyboard/module/character_custom/detail/character_custom_detail_page.dart';
|
|
|
|
|
+import 'package:keyboard/module/character_custom/list/character_custom_list_page.dart';
|
|
|
import 'package:keyboard/resource/string.gen.dart';
|
|
import 'package:keyboard/resource/string.gen.dart';
|
|
|
import 'package:keyboard/utils/atmob_log.dart';
|
|
import 'package:keyboard/utils/atmob_log.dart';
|
|
|
|
|
|
|
@@ -25,16 +26,19 @@ enum StepType {
|
|
|
@injectable
|
|
@injectable
|
|
|
class CharacterCustomController extends BaseController {
|
|
class CharacterCustomController extends BaseController {
|
|
|
final String tag = 'CharacterCustomController';
|
|
final String tag = 'CharacterCustomController';
|
|
|
|
|
+
|
|
|
final ConfigRepository configRepository;
|
|
final ConfigRepository configRepository;
|
|
|
|
|
|
|
|
- final Rxn<CustomConfigInfo> currentCharacterCustomConfig =
|
|
|
|
|
- Rxn<CustomConfigInfo>();
|
|
|
|
|
|
|
+ CustomConfigInfo? get currentCharacterCustomConfig =>
|
|
|
|
|
+ configRepository.characterCustomConfig;
|
|
|
|
|
|
|
|
final RxList<Hobbies> hobbiesLabelsList = <Hobbies>[].obs;
|
|
final RxList<Hobbies> hobbiesLabelsList = <Hobbies>[].obs;
|
|
|
- final RxList<String> hobbiesSelectLabels = <String>[].obs;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ final RxList<Hobbies> hobbiesSelectLabels = <Hobbies>[].obs;
|
|
|
|
|
|
|
|
final RxList<CharactersList> characterLabelsList = <CharactersList>[].obs;
|
|
final RxList<CharactersList> characterLabelsList = <CharactersList>[].obs;
|
|
|
- final RxList<String> characterSelectLabels = <String>[].obs;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ final RxList<CharactersList> characterSelectLabels = <CharactersList>[].obs;
|
|
|
|
|
|
|
|
final Rx<StepType> currentStep = StepType.home.obs;
|
|
final Rx<StepType> currentStep = StepType.home.obs;
|
|
|
|
|
|
|
@@ -42,23 +46,25 @@ class CharacterCustomController extends BaseController {
|
|
|
|
|
|
|
|
CharacterCustomController(this.configRepository);
|
|
CharacterCustomController(this.configRepository);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@override
|
|
@override
|
|
|
void onInit() {
|
|
void onInit() {
|
|
|
super.onInit();
|
|
super.onInit();
|
|
|
-
|
|
|
|
|
|
|
+ initData();
|
|
|
AtmobLog.d(tag, "首次加载数据,触发 refreshCharacterCustomConfig()");
|
|
AtmobLog.d(tag, "首次加载数据,触发 refreshCharacterCustomConfig()");
|
|
|
- refreshCharacterCustomConfig();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化数据
|
|
// 初始化数据
|
|
|
|
|
+ void initData() {
|
|
|
|
|
+ AtmobLog.d(tag, "initData");
|
|
|
|
|
+ hobbiesLabelsList.value = currentCharacterCustomConfig?.hobbies ?? [];
|
|
|
|
|
+ characterLabelsList.value = currentCharacterCustomConfig?.characters ?? [];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 自定义兴趣爱好
|
|
// 自定义兴趣爱好
|
|
|
void clickHobbiesCustom() {
|
|
void clickHobbiesCustom() {
|
|
|
AtmobLog.d(tag, "clickHobbiesCustom");
|
|
AtmobLog.d(tag, "clickHobbiesCustom");
|
|
|
CustomLabelDialog.show(
|
|
CustomLabelDialog.show(
|
|
|
- maxLength: currentCharacterCustomConfig.value?.maxHobbyWords ?? 10,
|
|
|
|
|
|
|
+ maxLength: currentCharacterCustomConfig?.maxHobbyWords ?? 10,
|
|
|
hintText: StringName.customLabelHobbiesHint,
|
|
hintText: StringName.customLabelHobbiesHint,
|
|
|
clickCallback: (value) {
|
|
clickCallback: (value) {
|
|
|
hobbiesLabelsList.add(Hobbies(name: value));
|
|
hobbiesLabelsList.add(Hobbies(name: value));
|
|
@@ -70,7 +76,7 @@ class CharacterCustomController extends BaseController {
|
|
|
void clickCharacterCustom() {
|
|
void clickCharacterCustom() {
|
|
|
AtmobLog.d(tag, "clickCharacterCustom");
|
|
AtmobLog.d(tag, "clickCharacterCustom");
|
|
|
CustomLabelDialog.show(
|
|
CustomLabelDialog.show(
|
|
|
- maxLength: currentCharacterCustomConfig.value?.maxCharacterWords ?? 10,
|
|
|
|
|
|
|
+ maxLength: currentCharacterCustomConfig?.maxCharacterWords ?? 10,
|
|
|
hintText: StringName.customLabelCharacterHint,
|
|
hintText: StringName.customLabelCharacterHint,
|
|
|
clickCallback: (value) {
|
|
clickCallback: (value) {
|
|
|
characterLabelsList.add(CharactersList(name: value));
|
|
characterLabelsList.add(CharactersList(name: value));
|
|
@@ -92,21 +98,10 @@ class CharacterCustomController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Future<void> refreshCharacterCustomConfig() async {
|
|
|
|
|
- try {
|
|
|
|
|
- final value = await configRepository.getCharacterCustomConfig();
|
|
|
|
|
- currentCharacterCustomConfig.value = value.characterInfo;
|
|
|
|
|
- hobbiesLabelsList.value = value.characterInfo?.hobbies ?? [];
|
|
|
|
|
- characterLabelsList.value = value.characterInfo?.characters ?? [];
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- AtmobLog.e(tag, "获取定制人设配置失败: $e");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 爱好页的下一步
|
|
// 爱好页的下一步
|
|
|
void clickHobbiesNext() {
|
|
void clickHobbiesNext() {
|
|
|
- int min = currentCharacterCustomConfig.value?.minHobbyNum ?? 1;
|
|
|
|
|
- int max = currentCharacterCustomConfig.value?.maxHobbyNum ?? 3;
|
|
|
|
|
|
|
+ int min = currentCharacterCustomConfig?.minHobbyNum ?? 1;
|
|
|
|
|
+ int max = currentCharacterCustomConfig?.maxHobbyNum ?? 3;
|
|
|
|
|
|
|
|
if (hobbiesSelectLabels.isEmpty) {
|
|
if (hobbiesSelectLabels.isEmpty) {
|
|
|
ToastUtil.show("请选择爱好");
|
|
ToastUtil.show("请选择爱好");
|
|
@@ -125,8 +120,8 @@ class CharacterCustomController extends BaseController {
|
|
|
|
|
|
|
|
// 性格页的下一步
|
|
// 性格页的下一步
|
|
|
void clickCharacterNext() {
|
|
void clickCharacterNext() {
|
|
|
- int min = currentCharacterCustomConfig.value?.minCharacterNum ?? 1;
|
|
|
|
|
- int max = currentCharacterCustomConfig.value?.maxCharacterNum ?? 3;
|
|
|
|
|
|
|
+ int min = currentCharacterCustomConfig?.minCharacterNum ?? 1;
|
|
|
|
|
+ int max = currentCharacterCustomConfig?.maxCharacterNum ?? 3;
|
|
|
|
|
|
|
|
if (characterSelectLabels.isEmpty) {
|
|
if (characterSelectLabels.isEmpty) {
|
|
|
ToastUtil.show("请选择特质");
|
|
ToastUtil.show("请选择特质");
|
|
@@ -154,12 +149,16 @@ class CharacterCustomController extends BaseController {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- CharacterCustomDetailPage.start();
|
|
|
|
|
|
|
+ CharacterCustomDetailPage.start(
|
|
|
|
|
+ hobbiesSelectLabels: hobbiesSelectLabels,
|
|
|
|
|
+ characterSelectLabels: characterSelectLabels,
|
|
|
|
|
+ characterCustomName: currentNameValue.value,
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 处理下一步
|
|
// 处理下一步
|
|
|
void clickNextButton(StepType stepType) {
|
|
void clickNextButton(StepType stepType) {
|
|
|
- if (currentCharacterCustomConfig.value == null) {
|
|
|
|
|
|
|
+ if (currentCharacterCustomConfig == null) {
|
|
|
AtmobLog.e(tag, "clickStartCustom - 当前配置为空");
|
|
AtmobLog.e(tag, "clickStartCustom - 当前配置为空");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -175,31 +174,35 @@ class CharacterCustomController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// 选择爱好标签
|
|
/// 选择爱好标签
|
|
|
- void selectHobby(String name) {
|
|
|
|
|
|
|
+ void selectHobby(Hobbies hobby) {
|
|
|
handleSelection(
|
|
handleSelection(
|
|
|
- name: name,
|
|
|
|
|
|
|
+ name: hobby,
|
|
|
selectedList: hobbiesSelectLabels,
|
|
selectedList: hobbiesSelectLabels,
|
|
|
- max: currentCharacterCustomConfig.value?.maxHobbyNum ?? 3,
|
|
|
|
|
- errorMessage:
|
|
|
|
|
- "最多选择${currentCharacterCustomConfig.value?.maxHobbyNum ?? 3}个爱好",
|
|
|
|
|
|
|
+ max: currentCharacterCustomConfig?.maxHobbyNum ?? 3,
|
|
|
|
|
+ errorMessage: "最多选择${currentCharacterCustomConfig?.maxHobbyNum ?? 3}个爱好",
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// 选择性格标签
|
|
/// 选择性格标签
|
|
|
- void selectCharacter(String name) {
|
|
|
|
|
|
|
+ void selectCharacter(CharactersList name) {
|
|
|
handleSelection(
|
|
handleSelection(
|
|
|
name: name,
|
|
name: name,
|
|
|
selectedList: characterSelectLabels,
|
|
selectedList: characterSelectLabels,
|
|
|
- max: currentCharacterCustomConfig.value?.maxCharacterNum ?? 3,
|
|
|
|
|
|
|
+ max: currentCharacterCustomConfig?.maxCharacterNum ?? 3,
|
|
|
errorMessage:
|
|
errorMessage:
|
|
|
- "最多选择${currentCharacterCustomConfig.value?.maxCharacterNum ?? 3}个特质",
|
|
|
|
|
|
|
+ "最多选择${currentCharacterCustomConfig?.maxCharacterNum ?? 3}个特质",
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void clickHistory() {
|
|
|
|
|
+ AtmobLog.d(tag, "clickHistory");
|
|
|
|
|
+ CharacterCustomListPage.start();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
///标签选择处理
|
|
///标签选择处理
|
|
|
void handleSelection({
|
|
void handleSelection({
|
|
|
- required String name,
|
|
|
|
|
- required RxList<String> selectedList,
|
|
|
|
|
|
|
+ required dynamic name,
|
|
|
|
|
+ required RxList<dynamic> selectedList,
|
|
|
required int max,
|
|
required int max,
|
|
|
required String errorMessage,
|
|
required String errorMessage,
|
|
|
}) {
|
|
}) {
|