| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import 'package:injectable/injectable.dart';
- import 'package:keyboard/base/base_controller.dart';
- import 'package:keyboard/data/bean/keyboard_info.dart';
- import 'package:keyboard/utils/atmob_log.dart';
- import 'package:get/get.dart';
- import '../../../data/bean/custom_config_info.dart';
- import '../../../data/repository/config_repository.dart';
- @injectable
- class ProfileEditController extends BaseController {
- final tag = "ProfileEditController";
- final ConfigRepository configRepository;
- final RxInt _gender = 1.obs;
- final RxString _avatarUrl = "".obs;
- String get avatarUrl => _avatarUrl.value;
- CustomConfigInfo? get currentCharacterCustomConfig =>
- configRepository.characterCustomConfig;
- final Rx<KeyboardInfo> _currentCustomKeyboardInfo = KeyboardInfo().obs;
- KeyboardInfo get currentCustomKeyboardInfo =>
- _currentCustomKeyboardInfo.value;
- // 当前自定义键盘亲密度
- final RxInt _currentCustomIntimacy = 0.obs;
- int get currentCustomIntimacy => _currentCustomIntimacy.value;
- // 当前定制亲密度是否有变化
- final RxBool _customIntimacyChanged = false.obs;
- bool get customIntimacyChanged => _customIntimacyChanged.value;
- final List<String> _boyAvatars = [];
- final List<String> _girlAvatars = [];
- ProfileEditController(this.configRepository);
- @override
- void onInit() {
- super.onInit();
- initData();
- }
- void initData() {
- AtmobLog.d(tag, "initData");
- _boyAvatars.addAll(currentCharacterCustomConfig?.boyAvatars ?? []);
- _girlAvatars.addAll(currentCharacterCustomConfig?.girlAvatars ?? []);
- if (_gender.value == 1) {
- _avatarUrl.value = _boyAvatars[0];
- } else {
- _avatarUrl.value = _girlAvatars[0];
- }
- }
- clickSaveButton() {
- AtmobLog.d(tag, 'clickSaveButton');
- }
- void nextAvatar() {
- AtmobLog.d(tag, "nextAvatar");
- if (_gender.value == 1) {
- int currentIndex = _boyAvatars.indexOf(_avatarUrl.value);
- _avatarUrl.value = _boyAvatars[(currentIndex + 1) % _boyAvatars.length];
- } else {
- int currentIndex = _girlAvatars.indexOf(_avatarUrl.value);
- _avatarUrl.value = _girlAvatars[(currentIndex + 1) % _girlAvatars.length];
- }
- }
- // 更新亲密度
- void updateIntimacy(int intimacy) {
- _currentCustomIntimacy.value = intimacy;
- }
- clickBack() {
- AtmobLog.d(tag, 'clickBackButton');
- Get.back();
- }
- }
|