|
|
@@ -8,12 +8,14 @@ import 'package:injectable/injectable.dart';
|
|
|
import 'package:keyboard/data/repository/chat_repository.dart';
|
|
|
import 'package:keyboard/data/repository/keyboard_repository.dart';
|
|
|
import 'package:keyboard/module/keyboard_manage/keyboard_manage_controller.dart';
|
|
|
+import 'package:keyboard/module/main/main_controller.dart';
|
|
|
import 'package:keyboard/utils/atmob_log.dart';
|
|
|
|
|
|
import '../data/api/response/chat_prologue_response.dart';
|
|
|
import '../data/api/response/chat_super_speak_response.dart';
|
|
|
import '../data/api/response/keyboard_list_response.dart';
|
|
|
import '../data/consts/constants.dart';
|
|
|
+import '../router/app_pages.dart';
|
|
|
import '../utils/http_handler.dart';
|
|
|
import '../utils/mmkv_util.dart';
|
|
|
import '../utils/toast_util.dart';
|
|
|
@@ -22,7 +24,6 @@ import '../utils/toast_util.dart';
|
|
|
class KeyboardMethodHandler {
|
|
|
final tag = "KeyboardMethodHandler";
|
|
|
|
|
|
-
|
|
|
bool get isLogin => KVUtil.getBool(Constants.keyIsLogin, false);
|
|
|
|
|
|
bool get isMember => KVUtil.getBool(Constants.keyIsMember, false);
|
|
|
@@ -66,7 +67,10 @@ class KeyboardMethodHandler {
|
|
|
final keyboardList = await KeyboardRepository.getInstance().getKeyboardList(
|
|
|
type: type,
|
|
|
);
|
|
|
- final selectedKeyboardJson = KVUtil.getString(Constants.keyboardSelect, null);
|
|
|
+ final selectedKeyboardJson = KVUtil.getString(
|
|
|
+ Constants.keyboardSelect,
|
|
|
+ null,
|
|
|
+ );
|
|
|
if (selectedKeyboardJson != null) {
|
|
|
try {
|
|
|
final Map<String, dynamic> keyboardMap = jsonDecode(
|
|
|
@@ -99,24 +103,30 @@ class KeyboardMethodHandler {
|
|
|
final selectedKeyboard = keyboardListResponse.keyboardInfos
|
|
|
.firstWhereOrNull((element) => element.id == keyboardId);
|
|
|
if (selectedKeyboard != null) {
|
|
|
- if(selectedKeyboard.type == KeyboardType.custom.name) {
|
|
|
+ if (selectedKeyboard.type == KeyboardType.custom.name) {
|
|
|
try {
|
|
|
- await KeyboardRepository.getInstance().keyboardChoose(keyboardId:keyboardId);
|
|
|
+ await KeyboardRepository.getInstance().keyboardChoose(
|
|
|
+ keyboardId: keyboardId,
|
|
|
+ );
|
|
|
KeyboardRepository.getInstance().refreshData();
|
|
|
-
|
|
|
} catch (error) {
|
|
|
- return handleError(error);
|
|
|
+ return handleError(error);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- KVUtil.putString(Constants.keyboardSelect, jsonEncode(selectedKeyboard.toJson()));
|
|
|
+ KVUtil.putString(
|
|
|
+ Constants.keyboardSelect,
|
|
|
+ jsonEncode(selectedKeyboard.toJson()),
|
|
|
+ );
|
|
|
}
|
|
|
return "{}";
|
|
|
}
|
|
|
|
|
|
Future<String> _handleGetCurrentKeyboardInfo(MethodCall call) async {
|
|
|
AtmobLog.d(tag, "_handleGetCurrentKeyboardInfo");
|
|
|
- final String? keyboardJsonStr = KVUtil.getString(Constants.keyboardSelect, null);
|
|
|
+ final String? keyboardJsonStr = KVUtil.getString(
|
|
|
+ Constants.keyboardSelect,
|
|
|
+ null,
|
|
|
+ );
|
|
|
if (keyboardJsonStr != null) {
|
|
|
try {
|
|
|
final jsonMap = jsonDecode(keyboardJsonStr);
|
|
|
@@ -189,10 +199,9 @@ class KeyboardMethodHandler {
|
|
|
name: name,
|
|
|
);
|
|
|
return jsonEncode(chatPrologueResponse.toJson());
|
|
|
- }catch (error) {
|
|
|
+ } catch (error) {
|
|
|
return handleError(error);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
Future<String> _handleJumpAppPage(MethodCall call) async {
|
|
|
@@ -214,10 +223,26 @@ class KeyboardMethodHandler {
|
|
|
|
|
|
// 是否跳转到新页面后,并清除上层的所有页面
|
|
|
if (offAll) {
|
|
|
- Get.offAllNamed(
|
|
|
- path,
|
|
|
- parameters: parsedArgs.map((k, v) => MapEntry(k, v.toString())),
|
|
|
- );
|
|
|
+ action() {
|
|
|
+ Get.offAllNamed(
|
|
|
+ path,
|
|
|
+ parameters: parsedArgs.map((k, v) => MapEntry(k, v.toString())),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ // 如果目标页面已存在,则删除其他页面,并拉起目标页面,手动传参
|
|
|
+ if (path == RoutePath.mainTab) {
|
|
|
+ if (Get.isRegistered<MainController>()) {
|
|
|
+ var controller = Get.find<MainController>();
|
|
|
+ controller.handleJumpParameters(
|
|
|
+ parameters: parsedArgs.map((k, v) => MapEntry(k, v.toString())),
|
|
|
+ );
|
|
|
+ Get.until((route) => route.settings.name == path);
|
|
|
+ } else {
|
|
|
+ action();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ action();
|
|
|
+ }
|
|
|
} else {
|
|
|
// 普通路由跳转
|
|
|
Get.toNamed(
|