Kaynağa Gözat

[feat]1.修改了人设市场切换切换人设组得滑到一半才刷新数据的问题(不再共享同一个controller)

云天逵 7 ay önce
ebeveyn
işleme
93d0ccc47b

+ 5 - 0
lib/data/repository/account_repository.dart

@@ -7,6 +7,7 @@ import 'package:keyboard/data/api/request/user_info_setting_request.dart';
 import 'package:keyboard/data/api/request/wechat_login_request.dart';
 import 'package:keyboard/data/api/response/wechat_login_response.dart';
 import 'package:keyboard/data/bean/member_info.dart';
+import 'package:keyboard/data/repository/characters_repository.dart';
 import 'package:keyboard/data/repository/keyboard_repository.dart';
 
 import '../../base/app_base_request.dart';
@@ -62,6 +63,9 @@ class AccountRepository {
   final KeyboardRepository keyboardRepository =
       KeyboardRepository.getInstance();
 
+  final CharactersRepository charactersRepository =
+      CharactersRepository.getInstance();
+
   AccountRepository(this.atmobApi) {
     AtmobLog.d(tag, '$tag....init $hashCode');
 
@@ -248,6 +252,7 @@ class AccountRepository {
     loginPhoneNum.value = null;
     isLogin.value = false;
     keyboardRepository.refreshData();
+    charactersRepository.refreshCharacterGroup();
     GravityHelper.onLogout();
     KVUtil.putString(Constants.keyboardSelect, null);
     DailyLimiterUtil.clearDailyLimitData("SurpriseDialog");

+ 15 - 0
lib/data/repository/characters_repository.dart

@@ -10,6 +10,7 @@ import 'package:keyboard/data/api/response/new_user_get_character_response.dart'
 import 'package:keyboard/data/repository/keyboard_repository.dart';
 import '../../base/app_base_request.dart';
 import '../../di/get_it.dart';
+import '../../module/character/content/character_group_content_controller.dart';
 import '../../utils/atmob_log.dart';
 import '../../utils/http_handler.dart';
 import '../api/atmob_api.dart';
@@ -41,6 +42,20 @@ class CharactersRepository {
     getCharactersGroup();
   }
 
+  void refreshCharacterGroup(){
+    KeyboardRepository.getInstance().keyboardInfoList.forEach((keyboardInfo) {
+      CharactersRepository.getInstance().characterGroupList.forEach((characterGroupInfo) {
+        final tag = "CharacterGroupContentController${keyboardInfo.id}${characterGroupInfo.id}";
+
+        if (Get.isRegistered<CharacterGroupContentController>(tag: tag)) {
+          var controller = Get.find<CharacterGroupContentController>(tag: tag);
+          controller.refreshData();
+        }
+      });
+    });
+
+  }
+
   // 获取主题
   Future<CharacterGroupResponse> getCharactersGroup() async {
     return atmobApi

+ 8 - 0
lib/data/repository/keyboard_repository.dart

@@ -43,6 +43,10 @@ class KeyboardRepository {
 
   RxList<KeyboardInfo> get customKeyboardInfoList => _customKeyboardInfoList;
 
+  final RxList<KeyboardInfo> _generalKeyboardInfoList = RxList();
+
+  RxList<KeyboardInfo> get generalKeyboardInfoList => _generalKeyboardInfoList;
+
   final Rxn<KeyboardLoveIndexResponse> _homeLoveIndex =
       Rxn<KeyboardLoveIndexResponse>();
 
@@ -131,6 +135,10 @@ class KeyboardRepository {
           response.keyboardInfos
               .where((keyboard) => keyboard.type != KeyboardType.system.name)
               .toList();
+      _generalKeyboardInfoList.value =
+          response.keyboardInfos
+              .where((keyboard) => keyboard.type == KeyboardType.system.name)
+              .toList();
 
     });
   }

+ 13 - 6
lib/di/get_it.config.dart

@@ -287,6 +287,19 @@ extension GetItInjectableX on _i174.GetIt {
         gh<_i83.AccountRepository>(),
       ),
     );
+    gh.factoryParam<
+      _i970.CharacterGroupContentController,
+      _i96.CharacterGroupInfo,
+      _i497.KeyboardInfo
+    >(
+      (currentCharacterGroupInfo, currentKeyboardInfo) =>
+          _i970.CharacterGroupContentController(
+            gh<_i421.CharactersRepository>(),
+            gh<_i83.AccountRepository>(),
+            currentCharacterGroupInfo: currentCharacterGroupInfo,
+            currentKeyboardInfo: currentKeyboardInfo,
+          ),
+    );
     gh.lazySingleton<_i987.StoreRepository>(
       () => _i987.StoreRepository(
         gh<_i243.AtmobApi>(),
@@ -327,12 +340,6 @@ extension GetItInjectableX on _i174.GetIt {
         gh<_i274.KeyboardRepository>(),
       ),
     );
-    gh.factory<_i970.CharacterGroupContentController>(
-      () => _i970.CharacterGroupContentController(
-        gh<_i421.CharactersRepository>(),
-        gh<_i83.AccountRepository>(),
-      ),
-    );
     gh.factory<_i876.FeedbackController>(
       () => _i876.FeedbackController(gh<_i83.AccountRepository>()),
     );

+ 6 - 0
lib/dialog/content/character_tab_group_content_controller.dart

@@ -16,6 +16,7 @@ import '../../../data/bean/keyboard_info.dart';
 import '../../../utils/error_handler.dart';
 import '../../data/consts/event_report.dart';
 import '../../handler/event_handler.dart';
+import '../../module/character/content/character_group_content_controller.dart';
 
 @injectable
 class CharacterTabGroupContentController extends BaseController {
@@ -121,6 +122,11 @@ class CharacterTabGroupContentController extends BaseController {
           );
           if (index != -1) {
             characterList[index] = characterAddResponse.characterInfo;
+          var keyboardTag = "CharacterGroupContentController${currentKeyboardInfo.id}${currentCharacterGroupInfo.id}";
+            if (Get.isRegistered<CharacterGroupContentController>(tag: keyboardTag)) {
+              var controller = Get.find<CharacterGroupContentController>(tag: keyboardTag);
+              controller.characterList[index] = characterAddResponse.characterInfo;
+            }
           }
           ToastUtil.show('添加成功~');
         })

+ 9 - 24
lib/module/character/character_controller.dart

@@ -71,45 +71,29 @@ class CharacterController extends BaseController
   void _dataLoad() async {
     AtmobLog.d(tag, "_dataLoad");
 
-    tabController.value = TabController(
-      length: characterGroupList.length,
-      vsync: this,
-      initialIndex: 0,
-    );
 
-    debugPrint("qqq tabController: ${tabController.hashCode}");
-
-    // ever(charactersRepository.characterGroupList, (value) {
-    //   AtmobLog.d(tag, "characterGroupList changed");
-    //   if (value.isNotEmpty) {
-    //     tabController.value?.dispose();
-    //     tabController.value = TabController(
-    //       length: characterGroupList.length,
-    //       vsync: this,
-    //       initialIndex: 0,
-    //     );
-    //     currentCharacterGroupInfo.value = characterGroupList.first;
-    //     AtmobLog.d(
-    //       tag,
-    //       "currentCharacterGroupInfo.value: ${characterGroupList.first.id}",
-    //     );
-    //   }
-    // });
 
     ever(keyboardInfoList, (value) {
       AtmobLog.d(tag, "keyboardInfoList1 changed ${keyboardInfoList.length}");
       if (value.isNotEmpty) {
         currentKeyboardInfo.value = keyboardInfoList.first;
         print("currentKeyboardInfo.value: ${currentKeyboardInfo.value}");
+        tabController.value = TabController(
+          length: characterGroupList.length,
+          vsync: this,
+          initialIndex: currentTabBarIndex.value,
+        );
+
       }
+
     });
+
   }
 
   void onTabChanged(int index) {
     if (index >= characterGroupList.length) {
       return;
     }
-
     pageController.animateToPage(
       index,
       duration: const Duration(milliseconds: 300),
@@ -118,6 +102,7 @@ class CharacterController extends BaseController
   }
 
   void onPageChanged(int index) {
+
     if (index >= characterGroupList.length) {
       return;
     }

+ 4 - 2
lib/module/character/character_view.dart

@@ -260,9 +260,10 @@ class CharacterView extends BaseView<CharacterController> {
   /// **TabBar**
   Widget _tabBar() {
     return Obx(() {
-      if (controller.characterGroupList.isEmpty) {
+      if (controller.characterGroupList.isEmpty||controller.tabController.value==null) {
         return const SizedBox.shrink();
       }
+
       return TabBar(
         controller: controller.tabController.value,
         dividerHeight: 0,
@@ -331,6 +332,7 @@ class CharacterView extends BaseView<CharacterController> {
 
   Widget _pages() {
     return Obx(() {
+
       if (controller.characterGroupList.isEmpty) {
         return const Center(child: CircularProgressIndicator());
       }
@@ -341,7 +343,7 @@ class CharacterView extends BaseView<CharacterController> {
         },
         children:
             controller.characterGroupList.map((group) {
-              return CharacterGroupContentView();
+              return CharacterGroupContentView(currentKeyboardInfo: controller.currentKeyboardInfo.value,currentCharacterGroupInfo: group);
             }).toList(),
       );
     });

+ 15 - 16
lib/module/character/content/character_group_content_controller.dart

@@ -36,11 +36,10 @@ import '../../store/suprise/surprise_dialog.dart';
 class CharacterGroupContentController extends BaseController {
   final tag = "CharacterGroupContentController";
 
-  Rx<KeyboardInfo> get currentKeyboardInfo =>
-      Get.find<CharacterController>().currentKeyboardInfo;
+  KeyboardInfo currentKeyboardInfo;
+
+  CharacterGroupInfo currentCharacterGroupInfo;
 
-  Rx<CharacterGroupInfo> get currentCharacterGroupInfo =>
-      Get.find<CharacterController>().currentCharacterGroupInfo;
   final CharactersRepository charactersRepository;
 
   final AccountRepository accountRepository;
@@ -55,10 +54,12 @@ class CharacterGroupContentController extends BaseController {
   MemberInfo? get memberStatusInfo => accountRepository.memberStatusInfo.value;
 
   UserInfoResponse? get userInfo => accountRepository.userInfo.value;
-
+  @factoryMethod
   CharacterGroupContentController(
     this.charactersRepository,
     this.accountRepository,
+  {     @factoryParam required this.currentCharacterGroupInfo,
+   @factoryParam required this.currentKeyboardInfo,}
   );
 
   RxList<CharacterInfo> characterList = <CharacterInfo>[].obs;
@@ -79,9 +80,7 @@ class CharacterGroupContentController extends BaseController {
     WidgetsBinding.instance.addPostFrameCallback((_) {
       refreshData();
     });
-    everAll([currentCharacterGroupInfo, currentKeyboardInfo], (_) async {
-      await refreshData();
-    });
+
   }
 
   @override
@@ -92,10 +91,8 @@ class CharacterGroupContentController extends BaseController {
 
   // 下拉刷新
   Future<void> refreshData() async {
-    AtmobLog.d(
-      tag,
-      'refreshData ${currentCharacterGroupInfo.value.id}, ${currentKeyboardInfo.value.id}',
-    );
+
+    AtmobLog.d(tag, "qqq refreshData");
     currentPage.value = 1;
     await getCurrentCharacterListInfo(isRefresh: true);
     refreshController.finishRefresh();
@@ -116,9 +113,9 @@ class CharacterGroupContentController extends BaseController {
   // 获取角色列表
   Future<void> getCurrentCharacterListInfo({bool isRefresh = false}) async {
     var response = await charactersRepository.getCharactersPage(
-      groupId: currentCharacterGroupInfo.value.id.toString(),
+      groupId: currentCharacterGroupInfo.id.toString(),
       page: currentPage.value,
-      keyboardId: currentKeyboardInfo.value.id.toString(),
+      keyboardId: currentKeyboardInfo.id.toString(),
     );
     if (isRefresh) {
       characterList.value = response.characterInfos;
@@ -191,7 +188,7 @@ class CharacterGroupContentController extends BaseController {
     try {
       final characterAddResponse = await charactersRepository.characterAdd(
         characterId: characterInfo.id.toString(),
-        keyboardId: currentKeyboardInfo.value.id.toString(),
+        keyboardId: currentKeyboardInfo.id.toString(),
       );
 
       int index = characterList.indexWhere(
@@ -199,6 +196,7 @@ class CharacterGroupContentController extends BaseController {
       );
       if (index != -1) {
         characterList[index] = characterAddResponse.characterInfo;
+
       }
 
       ToastUtil.show('添加成功~');
@@ -220,7 +218,7 @@ class CharacterGroupContentController extends BaseController {
     charactersRepository
         .characterUnlock(
           characterId: characterInfo.id.toString(),
-          keyboardId: currentKeyboardInfo.value.id.toString(),
+          keyboardId: currentKeyboardInfo.id.toString(),
         )
         .then((characterUnlockResponse) {
           int index = characterList.indexWhere(
@@ -228,6 +226,7 @@ class CharacterGroupContentController extends BaseController {
           );
           if (index != -1) {
             characterList[index] = characterUnlockResponse.characterInfo;
+
           }
           ToastUtil.show('解锁成功~');
         })

+ 24 - 2
lib/module/character/content/character_group_content_view.dart

@@ -4,21 +4,42 @@ import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:keyboard/base/base_view.dart';
 import 'package:get/get.dart';
+import 'package:keyboard/data/repository/account_repository.dart';
 import 'package:keyboard/module/character/content/character_group_content_controller.dart';
 import 'package:keyboard/resource/string.gen.dart';
 
+import '../../../data/bean/character_group_info.dart';
 import '../../../data/bean/character_info.dart';
+import '../../../data/bean/keyboard_info.dart';
+import '../../../data/repository/characters_repository.dart';
 import '../../../resource/assets.gen.dart';
-
+import 'package:get_it/get_it.dart';
 class CharacterGroupContentView
     extends BaseView<CharacterGroupContentController> {
-  const CharacterGroupContentView({super.key});
+  final KeyboardInfo currentKeyboardInfo;
+  final CharacterGroupInfo currentCharacterGroupInfo;
+
+  @override
+  String? get tag => "CharacterGroupContentController${currentKeyboardInfo.id}${currentCharacterGroupInfo.id}";
+
+  const CharacterGroupContentView({super.key, required this.currentKeyboardInfo,required this.currentCharacterGroupInfo});
 
   @override
   backgroundColor() => const Color(0xFFF4F2FB);
 
   @override
   Widget buildBody(BuildContext context) {
+
+    Get.put(
+          CharacterGroupContentController(
+        GetIt.instance.get<CharactersRepository>(),
+        GetIt.instance.get<AccountRepository>(),
+        currentCharacterGroupInfo: currentCharacterGroupInfo,
+        currentKeyboardInfo: currentKeyboardInfo,
+      ),
+      tag: tag,
+    );
+
     return
 
       Column(
@@ -207,4 +228,5 @@ class CharacterGroupContentView
       ),
     );
   }
+
 }

+ 101 - 80
lib/module/keyboard_manage/keyboard_manage_controller.dart

@@ -18,6 +18,7 @@ import 'package:keyboard/utils/toast_util.dart';
 
 import '../../data/bean/keyboard_info.dart';
 import '../../data/consts/error_code.dart';
+import '../../data/repository/characters_repository.dart';
 import '../../plugins/keyboard_android_platform.dart';
 import '../../utils/error_handler.dart';
 import '../../utils/http_handler.dart';
@@ -34,12 +35,12 @@ class KeyboardManageController extends BaseController
 
   final AccountRepository accountRepository;
 
-  bool get isLogin => accountRepository.isLogin.value;
+  final KeyboardRepository keyboardRepository;
 
-  // 自定义键盘列表
-  final RxList<KeyboardInfo> _customKeyboardInfoList = RxList();
+  RxBool get isLogin => accountRepository.isLogin;
 
-  List<KeyboardInfo> get customKeyboardInfoList => _customKeyboardInfoList;
+  RxList<KeyboardInfo> get customKeyboardInfoList =>
+      keyboardRepository.customKeyboardInfoList;
 
   // 当前自定义键盘
   final Rx<KeyboardInfo> _currentCustomKeyboardInfo = KeyboardInfo().obs;
@@ -71,10 +72,8 @@ class KeyboardManageController extends BaseController
   // 存储排序前的定制人设列表,用于比较是否有变化
   List<CharacterInfo> _oldCustomCharacterList = [];
 
-  // 通用键盘列表
-  final RxList<KeyboardInfo> _generalKeyboardInfoList = RxList();
-
-  List<KeyboardInfo> get generalKeyboardInfoList => _generalKeyboardInfoList;
+  RxList<KeyboardInfo> get generalKeyboardInfoList =>
+      keyboardRepository.generalKeyboardInfoList;
 
   // 当前通用键盘
   final Rx<KeyboardInfo> _currentGeneralKeyboardInfo = KeyboardInfo().obs;
@@ -106,7 +105,7 @@ class KeyboardManageController extends BaseController
   // 存储排序前的通用人设列表,用于比较是否有变化
   late List<CharacterInfo> _oldGeneralCharacterList;
 
-  final KeyboardRepository keyboardRepository;
+  late Worker _customKeyboardInfoListWorker;
 
   // 最小人设数量
   final _minCount = 9;
@@ -137,14 +136,16 @@ class KeyboardManageController extends BaseController
       _currentCustomKeyboardInfo.value = args["customKeyboardInfo"];
     }
 
-   await _dataLoad();
+    await _dataLoad();
   }
 
   _dataLoad() async {
+    getCustomKeyboard();
+    getGeneralKeyboard();
     tabController = TabController(
       length: keyboardManageType.length,
       vsync: this,
-      initialIndex: 0,
+      initialIndex: customKeyboardInfoList.isEmpty ? 1 : 0,
     );
     tabController.addListener(() {
       if (tabController.indexIsChanging) {
@@ -157,21 +158,36 @@ class KeyboardManageController extends BaseController
       }
     });
 
-    pageController = PageController();
+    pageController = PageController(
+      initialPage: customKeyboardInfoList.isEmpty ? 1 : 0,
+    );
 
-    await getCustomKeyboard();
-    if (isFirstLoad.value) {
-      if (_customKeyboardInfoList.isEmpty) {
-        //   去另一个tab
-        pageController.jumpToPage(1);
-      }
+    _customKeyboardInfoListWorker = everAll(
+      [customKeyboardInfoList, generalKeyboardInfoList],
+      (_) {
 
-      isFirstLoad.value = false;
-    }
-    if (tabController.index == 0) {
-      EventHandler.report(EventId.event_13001);
-    }
-    getGeneralKeyboard();
+
+          if (customKeyboardInfoList.isNotEmpty) {
+            _currentCustomKeyboardInfo.value = customKeyboardInfoList.firstWhere(
+                  (element) => element.isChoose == true,
+              orElse: () => customKeyboardInfoList.first,
+            );
+          getCustomKeyboard();
+          }else
+            {
+              _oldCustomCharacterList = [];
+              _currentCustomKeyboardInfo.value = KeyboardInfo();
+              _currentCustomKeyboardCharacterList.clear();
+            }
+
+
+        if (generalKeyboardInfoList.isNotEmpty) {
+          _currentGeneralKeyboardInfo.value = generalKeyboardInfoList.first;
+          getGeneralKeyboard();
+        }
+
+      },
+    );
   }
 
   clickBack() {
@@ -187,64 +203,47 @@ class KeyboardManageController extends BaseController
   //   获取定制键盘
   Future<void> getCustomKeyboard() async {
     AtmobLog.i(tag, 'getCustomKeyboard');
-   await keyboardRepository.getKeyboardList(type: KeyboardType.custom.name).then((
-      keyboardListResponse,
-    ) {
+    if (customKeyboardInfoList.isNotEmpty) {
       AtmobLog.i(
         tag,
-        'keyboardListResponse: ${keyboardListResponse.keyboardInfos}',
+        'customKeyboardInfoList: ${customKeyboardInfoList.length}',
       );
-      _customKeyboardInfoList.value = keyboardListResponse.keyboardInfos;
-
-      //检查是否是选择的键盘,如果没有选择的键盘,默认选择第一个
-      if (_customKeyboardInfoList.isNotEmpty) {
-        if (_currentCustomKeyboardInfo.value.id == null) {
-          _currentCustomKeyboardInfo.value = _customKeyboardInfoList.firstWhere(
-            (element) => element.isChoose == true,
-            orElse: () => _customKeyboardInfoList.first,
-          );
-        }
-        _currentCustomIntimacy.value =
-            _currentCustomKeyboardInfo.value.intimacy ?? 0;
-        _currentCustomIntimacy.listen((intimacy) {
-          _customIntimacyChanged.value =
-              _currentCustomKeyboardInfo.value.intimacy != intimacy;
-          AtmobLog.d(tag, 'intimacyChanged: $_customIntimacyChanged');
-        });
+      if (_currentCustomKeyboardInfo.value.id == null) {
+        _currentCustomKeyboardInfo.value = customKeyboardInfoList.firstWhere(
+          (element) => element.isChoose == true,
+          orElse: () => customKeyboardInfoList.first,
+        );
+      }
+      _currentCustomIntimacy.value =
+          _currentCustomKeyboardInfo.value.intimacy ?? 0;
+      _currentCustomIntimacy.listen((intimacy) {
+        _customIntimacyChanged.value =
+            _currentCustomKeyboardInfo.value.intimacy != intimacy;
+        AtmobLog.d(tag, 'intimacyChanged: $_customIntimacyChanged');
+      });
 
-        String? id = _currentCustomKeyboardInfo.value.id;
-        if (id != null) {
-          getKeyboardCharacterList(keyboardId: id, isCustom: true);
-        }
+      String? id = _currentCustomKeyboardInfo.value.id;
+      if (id != null) {
+        getKeyboardCharacterList(keyboardId: id, isCustom: true);
       }
-    });
+    }
   }
 
   //   获取通用键盘
   void getGeneralKeyboard() {
-    AtmobLog.i(tag, 'getGeneralKeyboard');
-    keyboardRepository.getKeyboardList(type: KeyboardType.system.name).then((
-      keyboardListResponse,
-    ) {
-      AtmobLog.i(
-        tag,
-        'keyboardListResponse: ${keyboardListResponse.keyboardInfos}',
-      );
-      _generalKeyboardInfoList.value = keyboardListResponse.keyboardInfos;
-      _currentGeneralKeyboardInfo.value = _generalKeyboardInfoList.first;
-      _currentGeneralIntimacy.value =
-          _currentGeneralKeyboardInfo.value.intimacy ?? 0;
-      _currentGeneralIntimacy.listen((intimacy) {
-        _generalIntimacyChanged.value =
-            _currentGeneralKeyboardInfo.value.intimacy != intimacy;
-        AtmobLog.d(tag, 'intimacyChanged: $_generalIntimacyChanged');
-      });
-
-      String? id = _currentGeneralKeyboardInfo.value.id;
-      if (id != null) {
-        getKeyboardCharacterList(keyboardId: id, isCustom: false);
-      }
+    _currentGeneralKeyboardInfo.value = generalKeyboardInfoList.first;
+    _currentGeneralIntimacy.value =
+        _currentGeneralKeyboardInfo.value.intimacy ?? 0;
+    _currentGeneralIntimacy.listen((intimacy) {
+      _generalIntimacyChanged.value =
+          _currentGeneralKeyboardInfo.value.intimacy != intimacy;
+      AtmobLog.d(tag, 'intimacyChanged: $_generalIntimacyChanged');
     });
+    String? id = _currentGeneralKeyboardInfo.value.id;
+    if (id != null) {
+      AtmobLog.i(tag, 'getGeneralKeyboard id: $id');
+      getKeyboardCharacterList(keyboardId: id, isCustom: false);
+    }
   }
 
   // 获取当前键盘人设列表
@@ -310,9 +309,9 @@ class KeyboardManageController extends BaseController
 
   //   切换当前定制键盘
   void switchCustomKeyboard(String? keyboardName) {
-    _currentCustomKeyboardInfo.value = _customKeyboardInfoList.firstWhere(
+    _currentCustomKeyboardInfo.value = customKeyboardInfoList.firstWhere(
       (element) => element.name == keyboardName,
-      orElse: () => _customKeyboardInfoList.first,
+      orElse: () => customKeyboardInfoList.first,
     );
     String? keyboardId = _currentCustomKeyboardInfo.value.id;
     _currentCustomIntimacy.value =
@@ -324,7 +323,6 @@ class KeyboardManageController extends BaseController
 
   // tab切换
   void switchTabKeyboardType(int index) {
-    // AtmobLog.i(tag, 'onTabChanged: $index');
     pageController.animateToPage(
       index,
       duration: const Duration(milliseconds: 300),
@@ -404,7 +402,17 @@ class KeyboardManageController extends BaseController
         _oldCustomCharacterList = List<CharacterInfo>.from(
           _currentCustomKeyboardCharacterList,
         );
-        Get.find<CharacterGroupContentController>().refreshData();
+
+        // 更具键盘组刷新对应的数据
+        CharactersRepository.getInstance().characterGroupList.forEach((e) {
+          final tag = "CharacterGroupContentController${_currentCustomKeyboardInfo.value.id}${e.id}";
+
+          if (Get.isRegistered<CharacterGroupContentController>(tag: tag)) {
+
+            var controller = Get.find<CharacterGroupContentController>(tag: tag);
+            controller.refreshData();
+          }
+        });
         // 通知键盘,刷新人设列表
         KeyboardAndroidPlatform.refreshCharacterList();
         saveSuccessGetBack();
@@ -424,6 +432,17 @@ class KeyboardManageController extends BaseController
         _oldGeneralCharacterList = List<CharacterInfo>.from(
           _currentGeneralKeyboardCharacterList,
         );
+
+        // 每次保存对应键盘都刷一次数据,一瞬间刷新8次
+        CharactersRepository.getInstance().characterGroupList.forEach((e) {
+          final tag = "CharacterGroupContentController${_currentGeneralKeyboardInfo.value.id}${e.id}";
+
+          if (Get.isRegistered<CharacterGroupContentController>(tag: tag)) {
+
+            var controller = Get.find<CharacterGroupContentController>(tag: tag);
+            controller.refreshData();
+          }
+        });
         // 通知键盘,刷新人设列表
         KeyboardAndroidPlatform.refreshCharacterList();
       },
@@ -510,19 +529,20 @@ class KeyboardManageController extends BaseController
   }
 
   clickAddCharacter({required bool isCustom}) {
-    if (!isLogin) {
+    if (!isLogin.value) {
       ToastUtil.show("请先登录");
       LoginDialog.show();
       return;
     }
     if (isCustom) {
       CharacterAddDialog.show(
-        currentKeyboardInfo: currentCustomKeyboardInfo,
+        currentKeyboardInfo: _currentCustomKeyboardInfo.value,
         clickCallback: () {
           getKeyboardCharacterList(
             keyboardId: _currentCustomKeyboardInfo.value.id ?? "",
             isCustom: true,
           );
+
         },
       );
     } else {
@@ -536,14 +556,14 @@ class KeyboardManageController extends BaseController
   }
 
   clickCustomCharacter() {
-    if (!isLogin) {
+    if (!isLogin.value) {
       ToastUtil.show("请先登录");
       LoginDialog.show();
       return;
     }
     AtmobLog.i(tag, 'clickCustomCharacter');
     CustomCharacterAddDialog.show(
-      currentKeyboardInfo: currentCustomKeyboardInfo,
+      currentKeyboardInfo: _currentCustomKeyboardInfo.value,
       clickCallback: () {
         getKeyboardCharacterList(
           keyboardId: _currentCustomKeyboardInfo.value.id ?? "",
@@ -557,6 +577,7 @@ class KeyboardManageController extends BaseController
   void onClose() {
     tabController.dispose();
     pageController.dispose();
+    _customKeyboardInfoListWorker.dispose();
     super.onClose();
   }
 

+ 2 - 15
lib/module/main/main_controller.dart

@@ -56,13 +56,7 @@ class MainController extends BaseController {
       Assets.images.iconTabKeyboardUnselect.path,
       Assets.anim.animTabKeyboardSelectedData,
       () {
-        return AnimatedSwitcher(
-          duration: Duration(milliseconds: 300),
-          transitionBuilder: (Widget child, Animation<double> animation) {
-            return FadeTransition(opacity: animation, child: child);
-          },
-          child: KeyBoardView(),
-        );
+        return KeyBoardView();
       },
     ),
     TabBean(
@@ -80,14 +74,7 @@ class MainController extends BaseController {
       Assets.anim.animTabMineSelectedData,
 
       () {
-        return AnimatedSwitcher(
-          duration: Duration(milliseconds: 300),
-          transitionBuilder: (Widget child, Animation<double> animation) {
-            return FadeTransition(opacity: animation, child: child);
-          },
-
-          child: MineView(),
-        );
+        return MineView();
       },
     ),
   ];

+ 4 - 2
lib/module/main/main_page.dart

@@ -40,7 +40,10 @@ class MainPage extends BasePage<MainController> {
             // 处理跳转参数
             controller.handleJumpParameters();
           },
-          child: Obx(() => controller.tabBeans[controller.currentIndex].page()),
+          child: Obx(() => IndexedStack(
+            index: controller.currentIndex,
+            children: controller.tabBeans.map((e) => e.page()).toList(),
+          ))
         ),
       ),
     );
@@ -72,7 +75,6 @@ class MainPage extends BasePage<MainController> {
             Obx(() {
               TabBean tabBean = controller.tabBeans[index];
               bool isSelected = controller.currentIndex == index;
-
               return Column(
                 children: [
                   isSelected

+ 1 - 1
lib/router/app_pages.dart

@@ -162,7 +162,7 @@ class AppBinding extends Bindings {
     lazyPut(() => getIt.get<FeedbackController>());
     lazyPut(() => getIt.get<AboutController>());
     lazyPut(() => getIt.get<BrowserController>());
-    lazyPut(() => getIt.get<CharacterGroupContentController>());
+    // lazyPut(() => getIt.get<CharacterGroupContentController>());
     lazyPut(() => getIt.get<KeyboardManageController>());
     lazyPut(() => getIt.get<CharacterCustomController>());
     lazyPut(() => getIt.get<CharacterCustomDetailController>());