mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-01-13 11:40:27 +00:00
fix: 高级汉化,性能优化 页面故障
This commit is contained in:
parent
80f87a8337
commit
64d5e27a72
@ -28,9 +28,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
}, const []);
|
||||
|
||||
return ContentDialog(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width * .8,
|
||||
),
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .8),
|
||||
title: makeTitle(context, state, model, destTextCtrl),
|
||||
content: state.keyMaps == null
|
||||
? makeLoading(context)
|
||||
@ -47,19 +45,17 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Text(
|
||||
S.current.input_method_online_version_prompt,
|
||||
style: TextStyle(
|
||||
color: Color(0xff4ca0e0),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Text(
|
||||
S.current.input_method_online_version_prompt,
|
||||
style: TextStyle(color: Color(0xff4ca0e0), fontSize: 12),
|
||||
),
|
||||
onTap: () {
|
||||
launchUrlString("https://ime.citizenwiki.cn/");
|
||||
}),
|
||||
),
|
||||
onTap: () {
|
||||
launchUrlString("https://ime.citizenwiki.cn/");
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
@ -67,14 +63,12 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
placeholder: S.current.input_method_input_placeholder,
|
||||
controller: srcTextCtrl,
|
||||
maxLines: 5,
|
||||
placeholderStyle:
|
||||
TextStyle(color: Colors.white.withValues(alpha: .6)),
|
||||
placeholderStyle: TextStyle(color: Colors.white.withValues(alpha: .6)),
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
onChanged: (str) async {
|
||||
final text = model.onTextChange("src", str);
|
||||
destTextCtrl.text = text ?? "";
|
||||
if (text != null) {
|
||||
}
|
||||
if (text != null) {}
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
@ -85,10 +79,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
if (state.isAutoTranslateWorking)
|
||||
SizedBox(width: 24, height: 24, child: ProgressRing())
|
||||
else
|
||||
SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: Icon(FluentIcons.down))
|
||||
SizedBox(width: 24, height: 24, child: Icon(FluentIcons.down)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -97,8 +88,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
placeholder: S.current.input_method_encoded_text_placeholder,
|
||||
controller: destTextCtrl,
|
||||
maxLines: 5,
|
||||
placeholderStyle:
|
||||
TextStyle(color: Colors.white.withValues(alpha: .6)),
|
||||
placeholderStyle: TextStyle(color: Colors.white.withValues(alpha: .6)),
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
enabled: true,
|
||||
onChanged: (str) {
|
||||
@ -119,24 +109,15 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
if (serverState.isServerStartup)
|
||||
Button(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
ServerQrDialogUI(),
|
||||
);
|
||||
showDialog(context: context, builder: (BuildContext context) => ServerQrDialogUI());
|
||||
},
|
||||
child: Text(
|
||||
serverState.serverAddressText ?? "...",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
child: Text(serverState.serverAddressText ?? "...", style: TextStyle(fontSize: 14)),
|
||||
),
|
||||
SizedBox(width: 14),
|
||||
ToggleSwitch(
|
||||
checked: serverState.isServerStartup,
|
||||
onChanged: (b) =>
|
||||
_onSwitchServer(context, b, serverModel)),
|
||||
checked: serverState.isServerStartup,
|
||||
onChanged: (b) => _onSwitchServer(context, b, serverModel),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -148,12 +129,9 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
child: Text(
|
||||
textAlign: TextAlign.end,
|
||||
S.current.input_method_disclaimer,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withValues(alpha: .6),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Colors.white.withValues(alpha: .6)),
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -161,80 +139,59 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget makeTitle(BuildContext context, InputMethodDialogUIState state,
|
||||
InputMethodDialogUIModel model, TextEditingController destTextCtrl) {
|
||||
Widget makeTitle(
|
||||
BuildContext context,
|
||||
InputMethodDialogUIState state,
|
||||
InputMethodDialogUIModel model,
|
||||
TextEditingController destTextCtrl,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
FluentIcons.back,
|
||||
size: 22,
|
||||
),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
}),
|
||||
icon: const Icon(FluentIcons.back, size: 22),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(S.current.input_method_experimental_input_method),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
S.current.input_method_auto_copy,
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
Text(S.current.input_method_auto_copy, style: TextStyle(fontSize: 14)),
|
||||
SizedBox(width: 12),
|
||||
ToggleSwitch(
|
||||
checked: state.enableAutoCopy,
|
||||
onChanged: model.onSwitchAutoCopy),
|
||||
ToggleSwitch(checked: state.enableAutoCopy, onChanged: model.onSwitchAutoCopy),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 24),
|
||||
FilledButton(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
child: Icon(FluentIcons.copy),
|
||||
),
|
||||
child: Padding(padding: const EdgeInsets.all(6), child: Icon(FluentIcons.copy)),
|
||||
onPressed: () {
|
||||
if (destTextCtrl.text.isNotEmpty) {
|
||||
Clipboard.setData(ClipboardData(text: destTextCtrl.text));
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onSwitchServer(
|
||||
BuildContext context, bool value, InputMethodServer serverModel) async {
|
||||
Future<void> _onSwitchServer(BuildContext context, bool value, InputMethodServer serverModel) async {
|
||||
if (value) {
|
||||
final userOK = await showConfirmDialogs(
|
||||
context,
|
||||
S.current.input_method_confirm_enable_remote_input,
|
||||
Text(S.current.input_method_enable_remote_input_instructions));
|
||||
context,
|
||||
S.current.input_method_confirm_enable_remote_input,
|
||||
Text(S.current.input_method_enable_remote_input_instructions),
|
||||
);
|
||||
if (userOK) {
|
||||
// ignore: use_build_context_synchronously
|
||||
await serverModel.startServer().unwrap(context: context);
|
||||
if (!context.mounted) return;
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ServerQrDialogUI(),
|
||||
);
|
||||
await showDialog(context: context, builder: (BuildContext context) => ServerQrDialogUI());
|
||||
}
|
||||
} else {
|
||||
await serverModel.stopServer().unwrap(context: context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSwitchAutoTranslate(
|
||||
BuildContext context, InputMethodDialogUIModel model, bool b) async {
|
||||
if (b) {
|
||||
final ok = await showConfirmDialogs(
|
||||
context,
|
||||
S.current.input_method_auto_translate_dialog_title,
|
||||
Text(S.current.input_method_auto_translate_dialog_title_content));
|
||||
if (ok != true) return;
|
||||
}
|
||||
model.toggleAutoTranslate(b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,14 +43,14 @@ abstract class AdvancedLocalizationUIState with _$AdvancedLocalizationUIState {
|
||||
|
||||
extension AdvancedLocalizationUIStateEx on AdvancedLocalizationUIState {
|
||||
Map<AppAdvancedLocalizationClassKeysDataMode, String> get typeNames => {
|
||||
AppAdvancedLocalizationClassKeysDataMode.localization:
|
||||
S.current.home_localization_advanced_action_mod_change_localization,
|
||||
AppAdvancedLocalizationClassKeysDataMode.unLocalization:
|
||||
S.current.home_localization_advanced_action_mod_change_un_localization,
|
||||
AppAdvancedLocalizationClassKeysDataMode.mixed: S.current.home_localization_advanced_action_mod_change_mixed,
|
||||
AppAdvancedLocalizationClassKeysDataMode.mixedNewline:
|
||||
S.current.home_localization_advanced_action_mod_change_mixed_newline,
|
||||
};
|
||||
AppAdvancedLocalizationClassKeysDataMode.localization:
|
||||
S.current.home_localization_advanced_action_mod_change_localization,
|
||||
AppAdvancedLocalizationClassKeysDataMode.unLocalization:
|
||||
S.current.home_localization_advanced_action_mod_change_un_localization,
|
||||
AppAdvancedLocalizationClassKeysDataMode.mixed: S.current.home_localization_advanced_action_mod_change_mixed,
|
||||
AppAdvancedLocalizationClassKeysDataMode.mixedNewline:
|
||||
S.current.home_localization_advanced_action_mod_change_mixed_newline,
|
||||
};
|
||||
}
|
||||
|
||||
@riverpod
|
||||
@ -64,6 +64,11 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
return state;
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(previous, next) {
|
||||
return !identical(previous, next);
|
||||
}
|
||||
|
||||
Future<void> _init(LocalizationUIState localizationUIState, LocalizationUIModel localizationUIModel) async {
|
||||
final (p4kGlobalIni, serverGlobalIni) = await _readIni(localizationUIState, localizationUIModel);
|
||||
final ald = await _readClassJson();
|
||||
@ -74,17 +79,18 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
p4kGlobalIni,
|
||||
serverGlobalIni,
|
||||
S.current.home_localization_advanced_json_text_un_localization,
|
||||
S.current.home_localization_advanced_json_text_others
|
||||
S.current.home_localization_advanced_json_text_others,
|
||||
));
|
||||
final p4kGlobalIniLines = p4kGlobalIni.split("\n").length;
|
||||
final serverGlobalIniLines = serverGlobalIni.split("\n").length;
|
||||
state = state.copyWith(
|
||||
workingText: "",
|
||||
p4kGlobalIni: p4kGlobalIni,
|
||||
serverGlobalIni: serverGlobalIni,
|
||||
p4kGlobalIniLines: p4kGlobalIniLines,
|
||||
serverGlobalIniLines: serverGlobalIniLines,
|
||||
classMap: m);
|
||||
workingText: "",
|
||||
p4kGlobalIni: p4kGlobalIni,
|
||||
serverGlobalIni: serverGlobalIni,
|
||||
p4kGlobalIniLines: p4kGlobalIniLines,
|
||||
serverGlobalIniLines: serverGlobalIniLines,
|
||||
classMap: m,
|
||||
);
|
||||
}
|
||||
|
||||
void setCustomizeGlobalIni(String? data) async {
|
||||
@ -101,7 +107,8 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
String serverGlobalIni,
|
||||
String unLocalizationClassName,
|
||||
String othersClassName,
|
||||
) v,
|
||||
)
|
||||
v,
|
||||
) {
|
||||
final (
|
||||
AppAdvancedLocalizationData ald,
|
||||
@ -110,18 +117,11 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
String unLocalizationClassName,
|
||||
String othersClassName,
|
||||
) = v;
|
||||
final unLocalization = AppAdvancedLocalizationClassKeysData(
|
||||
id: "un_localization",
|
||||
className: unLocalizationClassName,
|
||||
keys: [],
|
||||
)
|
||||
..mode = AppAdvancedLocalizationClassKeysDataMode.unLocalization
|
||||
..lockMod = true;
|
||||
final unClass = AppAdvancedLocalizationClassKeysData(
|
||||
id: "un_class",
|
||||
className: othersClassName,
|
||||
keys: [],
|
||||
);
|
||||
final unLocalization =
|
||||
AppAdvancedLocalizationClassKeysData(id: "un_localization", className: unLocalizationClassName, keys: [])
|
||||
..mode = AppAdvancedLocalizationClassKeysDataMode.unLocalization
|
||||
..lockMod = true;
|
||||
final unClass = AppAdvancedLocalizationClassKeysData(id: "un_class", className: othersClassName, keys: []);
|
||||
final classMap = <String, AppAdvancedLocalizationClassKeysData>{
|
||||
for (final keys in ald.classKeys!) keys.id ?? "": keys,
|
||||
};
|
||||
@ -129,8 +129,9 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
final p4kIniMap = readIniAsMap(p4kGlobalIni);
|
||||
final serverIniMap = readIniAsMap(serverGlobalIni);
|
||||
|
||||
var regexList =
|
||||
classMap.values.expand((c) => c.keys!.map((k) => MapEntry(c, RegExp(k, caseSensitive: false)))).toList();
|
||||
var regexList = classMap.values
|
||||
.expand((c) => c.keys!.map((k) => MapEntry(c, RegExp(k, caseSensitive: false))))
|
||||
.toList();
|
||||
|
||||
iniKeysLoop:
|
||||
for (var p4kIniKey in p4kIniMap.keys) {
|
||||
@ -180,7 +181,9 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
}
|
||||
|
||||
Future<(String, String)> _readIni(
|
||||
LocalizationUIState localizationUIState, LocalizationUIModel localizationUIModel) async {
|
||||
LocalizationUIState localizationUIState,
|
||||
LocalizationUIModel localizationUIModel,
|
||||
) async {
|
||||
final homeUIState = ref.read(homeUIModelProvider);
|
||||
final gameDir = homeUIState.scInstalledPath;
|
||||
if (gameDir == null) return ("", "");
|
||||
@ -190,15 +193,18 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
state = state.copyWith(workingText: S.current.home_localization_advanced_msg_reading_server_localization_text);
|
||||
|
||||
if (state.customizeGlobalIni != null) {
|
||||
final apiLocalizationData =
|
||||
ScLocalizationData(versionName: S.current.localization_info_custom_files, info: "Customize");
|
||||
final apiLocalizationData = ScLocalizationData(
|
||||
versionName: S.current.localization_info_custom_files,
|
||||
info: "Customize",
|
||||
);
|
||||
state = state.copyWith(apiLocalizationData: apiLocalizationData);
|
||||
return (p4kGlobalIni, state.customizeGlobalIni!);
|
||||
} else {
|
||||
final apiLocalizationData = localizationUIState.apiLocalizationData?.values.firstOrNull;
|
||||
if (apiLocalizationData == null) return ("", "");
|
||||
final file =
|
||||
File("${localizationUIModel.getDownloadDir().absolute.path}\\${apiLocalizationData.versionName}.sclang");
|
||||
final file = File(
|
||||
"${localizationUIModel.getDownloadDir().absolute.path}\\${apiLocalizationData.versionName}.sclang",
|
||||
);
|
||||
if (!await file.exists()) {
|
||||
await localizationUIModel.downloadLocalizationFile(file, apiLocalizationData);
|
||||
}
|
||||
@ -211,8 +217,11 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
|
||||
Future<String> readEnglishInI(String gameDir) async {
|
||||
try {
|
||||
var data = await Unp4kCModel.unp4kTools(appGlobalState.applicationBinaryModuleDir!,
|
||||
["extract_memory", "$gameDir\\Data.p4k", "Data\\Localization\\english\\global.ini"]);
|
||||
var data = await Unp4kCModel.unp4kTools(appGlobalState.applicationBinaryModuleDir!, [
|
||||
"extract_memory",
|
||||
"$gameDir\\Data.p4k",
|
||||
"Data\\Localization\\english\\global.ini",
|
||||
]);
|
||||
// remove bom
|
||||
if (data.length > 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) {
|
||||
data = data.sublist(3);
|
||||
@ -224,15 +233,16 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
if (Unp4kCModel.checkRunTimeError(errorMessage)) {
|
||||
AnalyticsApi.touch("advanced_localization_no_runtime");
|
||||
}
|
||||
state = state.copyWith(
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
state = state.copyWith(errorMessage: errorMessage);
|
||||
// rethrow;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Future<void> onChangeMod(AppAdvancedLocalizationClassKeysData item, AppAdvancedLocalizationClassKeysDataMode mode) async {
|
||||
Future<void> onChangeMod(
|
||||
AppAdvancedLocalizationClassKeysData item,
|
||||
AppAdvancedLocalizationClassKeysDataMode mode,
|
||||
) async {
|
||||
if (item.lockMod) return;
|
||||
item.mode = mode;
|
||||
item.isWorking = true;
|
||||
@ -282,8 +292,13 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
state = state.copyWith(workingText: S.current.home_localization_advanced_msg_gen_localization_install);
|
||||
final localizationUIModel = ref.read(localizationUIModelProvider.notifier);
|
||||
if (!context.mounted) return false;
|
||||
await localizationUIModel.installFormString(globalIni, state.apiLocalizationData?.versionName ?? "-",
|
||||
advanced: true, isEnableCommunityInputMethod: isEnableCommunityInputMethod, context: context);
|
||||
await localizationUIModel.installFormString(
|
||||
globalIni,
|
||||
state.apiLocalizationData?.versionName ?? "-",
|
||||
advanced: true,
|
||||
isEnableCommunityInputMethod: isEnableCommunityInputMethod,
|
||||
context: context,
|
||||
);
|
||||
state = state.copyWith(workingText: "");
|
||||
return true;
|
||||
}
|
||||
@ -291,73 +306,72 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
// ignore: avoid_build_context_in_providers
|
||||
Future<void> onInstall(BuildContext context) async {
|
||||
var isEnableCommunityInputMethod = true;
|
||||
final userOK =
|
||||
await showConfirmDialogs(context, S.current.input_method_confirm_install_advanced_localization, HookConsumer(
|
||||
builder: (BuildContext context, WidgetRef ref, Widget? child) {
|
||||
final globalIni = useState<StringBuffer?>(null);
|
||||
final enableCommunityInputMethod = useState(true);
|
||||
final localizationState = ref.read(localizationUIModelProvider);
|
||||
useEffect(() {
|
||||
() async {
|
||||
final classMap = state.classMap!;
|
||||
final g = StringBuffer();
|
||||
for (var item in classMap.values) {
|
||||
for (var kv in item.valuesMap.entries) {
|
||||
g.write("${kv.key}=${kv.value}\n");
|
||||
await Future.delayed(Duration.zero);
|
||||
final userOK = await showConfirmDialogs(
|
||||
context,
|
||||
S.current.input_method_confirm_install_advanced_localization,
|
||||
HookConsumer(
|
||||
builder: (BuildContext context, WidgetRef ref, Widget? child) {
|
||||
final globalIni = useState<StringBuffer?>(null);
|
||||
final enableCommunityInputMethod = useState(true);
|
||||
final localizationState = ref.read(localizationUIModelProvider);
|
||||
useEffect(() {
|
||||
() async {
|
||||
final classMap = state.classMap!;
|
||||
final g = StringBuffer();
|
||||
for (var item in classMap.values) {
|
||||
for (var kv in item.valuesMap.entries) {
|
||||
g.write("${kv.key}=${kv.value}\n");
|
||||
await Future.delayed(Duration.zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
globalIni.value = g;
|
||||
}();
|
||||
return null;
|
||||
}, const []);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: globalIni.value == null
|
||||
? makeLoading(context)
|
||||
: CodeEditor(
|
||||
readOnly: true,
|
||||
controller: CodeLineEditingController.fromText(globalIni.value!.toString()),
|
||||
style: CodeEditorStyle(
|
||||
codeTheme: CodeHighlightTheme(
|
||||
languages: {'ini': CodeHighlightThemeMode(mode: langIni)},
|
||||
theme: vs2015Theme,
|
||||
globalIni.value = g;
|
||||
}();
|
||||
return null;
|
||||
}, const []);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: globalIni.value == null
|
||||
? makeLoading(context)
|
||||
: CodeEditor(
|
||||
readOnly: true,
|
||||
controller: CodeLineEditingController.fromText(globalIni.value!.toString()),
|
||||
style: CodeEditorStyle(
|
||||
codeTheme: CodeHighlightTheme(
|
||||
languages: {'ini': CodeHighlightThemeMode(mode: langIni)},
|
||||
theme: vs2015Theme,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
S.current.input_method_install_community_input_method_support,
|
||||
),
|
||||
Spacer(),
|
||||
ToggleSwitch(
|
||||
checked: enableCommunityInputMethod.value,
|
||||
onChanged: localizationState.communityInputMethodLanguageData == null
|
||||
? null
|
||||
: (v) {
|
||||
isEnableCommunityInputMethod = v;
|
||||
enableCommunityInputMethod.value = v;
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width * .8,
|
||||
));
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Text(S.current.input_method_install_community_input_method_support),
|
||||
Spacer(),
|
||||
ToggleSwitch(
|
||||
checked: enableCommunityInputMethod.value,
|
||||
onChanged: localizationState.communityInputMethodLanguageData == null
|
||||
? null
|
||||
: (v) {
|
||||
isEnableCommunityInputMethod = v;
|
||||
enableCommunityInputMethod.value = v;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .8),
|
||||
);
|
||||
if (userOK) {
|
||||
if (!context.mounted) return;
|
||||
await doInstall(context, isEnableCommunityInputMethod: isEnableCommunityInputMethod);
|
||||
|
||||
@ -47,6 +47,11 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
return state;
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(previous, next) {
|
||||
return !identical(previous, next);
|
||||
}
|
||||
|
||||
Future<void> _init() async {
|
||||
customizeCtrl.clear();
|
||||
_inAppKeys.clear();
|
||||
@ -69,8 +74,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
|
||||
final box = await Hive.openBox("app_conf");
|
||||
final v = box.get("close_graphics_performance_tip", defaultValue: -1);
|
||||
state = state.copyWith(
|
||||
showGraphicsPerformanceTip: v != _graphicsPerformanceTipVersion);
|
||||
state = state.copyWith(showGraphicsPerformanceTip: v != _graphicsPerformanceTipVersion);
|
||||
}
|
||||
|
||||
Future<void> _readConf() async {
|
||||
@ -89,16 +93,14 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
}
|
||||
}
|
||||
if (kv.length == 2 && !_inAppKeys.contains(kv[0].trim())) {
|
||||
customizeCtrl.text =
|
||||
"${customizeCtrl.text}${kv[0].trim()}=${kv[1].trim()}\n";
|
||||
customizeCtrl.text = "${customizeCtrl.text}${kv[0].trim()}=${kv[1].trim()}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> closeTip() async {
|
||||
final box = await Hive.openBox("app_conf");
|
||||
await box.put(
|
||||
"close_graphics_performance_tip", _graphicsPerformanceTipVersion);
|
||||
await box.put("close_graphics_performance_tip", _graphicsPerformanceTipVersion);
|
||||
_init();
|
||||
}
|
||||
|
||||
@ -149,13 +151,11 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
}
|
||||
|
||||
Future<void> clean(BuildContext context) async {
|
||||
state = state.copyWith(
|
||||
workingString: S.current.performance_info_delete_config_file);
|
||||
state = state.copyWith(workingString: S.current.performance_info_delete_config_file);
|
||||
if (await confFile.exists()) {
|
||||
await confFile.delete(recursive: true);
|
||||
}
|
||||
state = state.copyWith(
|
||||
workingString: S.current.performance_action_clear_shaders);
|
||||
state = state.copyWith(workingString: S.current.performance_action_clear_shaders);
|
||||
if (!context.mounted) return;
|
||||
await cleanShaderCache(context);
|
||||
state = state.copyWith(workingString: S.current.performance_info_done);
|
||||
@ -166,8 +166,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
|
||||
Future<void> cleanShaderCache(BuildContext? context) async {
|
||||
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
|
||||
final l =
|
||||
await Directory(gameShaderCachePath!).list(recursive: false).toList();
|
||||
final l = await Directory(gameShaderCachePath!).list(recursive: false).toList();
|
||||
for (var value in l) {
|
||||
if (value is Directory) {
|
||||
if (!value.absolute.path.contains("Crashes")) {
|
||||
@ -184,8 +183,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
Future<void> applyProfile(bool cleanShader) async {
|
||||
if (state.performanceMap == null) return;
|
||||
AnalyticsApi.touch("performance_apply");
|
||||
state = state.copyWith(
|
||||
workingString: S.current.performance_info_generate_config_file);
|
||||
state = state.copyWith(workingString: S.current.performance_info_generate_config_file);
|
||||
String conf = "";
|
||||
for (var v in state.performanceMap!.entries) {
|
||||
for (var c in v.value) {
|
||||
@ -204,16 +202,14 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
state = state.copyWith(
|
||||
workingString: S.current.performance_info_write_out_config_file);
|
||||
state = state.copyWith(workingString: S.current.performance_info_write_out_config_file);
|
||||
if (await confFile.exists()) {
|
||||
await confFile.delete();
|
||||
}
|
||||
await confFile.create();
|
||||
await confFile.writeAsString(conf);
|
||||
if (cleanShader) {
|
||||
state = state.copyWith(
|
||||
workingString: S.current.performance_action_clear_shaders);
|
||||
state = state.copyWith(workingString: S.current.performance_action_clear_shaders);
|
||||
await cleanShaderCache(null);
|
||||
}
|
||||
state = state.copyWith(workingString: S.current.performance_info_done);
|
||||
|
||||
@ -1602,7 +1602,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
xml:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: xml
|
||||
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user