Add android shortcuts
Fix init params issues Fix dynamic color issues Optimize navigator animate Optimize window init Optimize fab Optimize save
This commit is contained in:
@@ -29,6 +29,7 @@ class AppController {
|
||||
late Function updateGroupDebounce;
|
||||
late Function addCheckIpNumDebounce;
|
||||
late Function applyProfileDebounce;
|
||||
late Function savePreferencesDebounce;
|
||||
|
||||
AppController(this.context) {
|
||||
appState = context.read<AppState>();
|
||||
@@ -38,6 +39,9 @@ class AppController {
|
||||
updateClashConfigDebounce = debounce<Function()>(() async {
|
||||
await updateClashConfig();
|
||||
});
|
||||
savePreferencesDebounce = debounce<Function()>(() async {
|
||||
await savePreferences();
|
||||
});
|
||||
applyProfileDebounce = debounce<Function()>(() async {
|
||||
await applyProfile(isPrue: true);
|
||||
});
|
||||
@@ -51,10 +55,7 @@ class AppController {
|
||||
|
||||
updateStatus(bool isStart) async {
|
||||
if (isStart) {
|
||||
await globalState.handleStart(
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
await globalState.handleStart();
|
||||
updateRunTime();
|
||||
updateTraffic();
|
||||
globalState.updateFunctionLists = [
|
||||
@@ -202,17 +203,8 @@ class AppController {
|
||||
}
|
||||
|
||||
savePreferences() async {
|
||||
await saveConfigPreferences();
|
||||
await saveClashConfigPreferences();
|
||||
}
|
||||
|
||||
saveConfigPreferences() async {
|
||||
debugPrint("saveConfigPreferences");
|
||||
debugPrint("[APP] savePreferences");
|
||||
await preferences.saveConfig(config);
|
||||
}
|
||||
|
||||
saveClashConfigPreferences() async {
|
||||
debugPrint("saveClashConfigPreferences");
|
||||
await preferences.saveClashConfig(clashConfig);
|
||||
}
|
||||
|
||||
@@ -231,7 +223,7 @@ class AppController {
|
||||
handleBackOrExit() async {
|
||||
if (config.appSetting.minimizeOnExit) {
|
||||
if (system.isDesktop) {
|
||||
await savePreferences();
|
||||
await savePreferencesDebounce();
|
||||
}
|
||||
await system.back();
|
||||
} else {
|
||||
@@ -608,7 +600,6 @@ class AppController {
|
||||
}
|
||||
|
||||
Future _updateSystemTray({
|
||||
required bool isStart,
|
||||
required Brightness? brightness,
|
||||
bool force = false,
|
||||
}) async {
|
||||
@@ -617,7 +608,6 @@ class AppController {
|
||||
}
|
||||
await trayManager.setIcon(
|
||||
other.getTrayIconPath(
|
||||
isStart: isStart,
|
||||
brightness: brightness ??
|
||||
WidgetsBinding.instance.platformDispatcher.platformBrightness,
|
||||
),
|
||||
@@ -633,7 +623,6 @@ class AppController {
|
||||
updateTray([bool focus = false]) async {
|
||||
if (!Platform.isLinux) {
|
||||
await _updateSystemTray(
|
||||
isStart: appFlowingState.isStart,
|
||||
brightness: appState.brightness,
|
||||
force: focus,
|
||||
);
|
||||
@@ -697,15 +686,18 @@ class AppController {
|
||||
},
|
||||
checked: config.appSetting.autoLaunch,
|
||||
);
|
||||
final adminAutoStartMenuItem = MenuItem.checkbox(
|
||||
label: appLocalizations.adminAutoLaunch,
|
||||
onClick: (_) async {
|
||||
globalState.appController.updateAdminAutoLaunch();
|
||||
},
|
||||
checked: config.appSetting.adminAutoLaunch,
|
||||
);
|
||||
menuItems.add(autoStartMenuItem);
|
||||
menuItems.add(adminAutoStartMenuItem);
|
||||
|
||||
if(Platform.isWindows){
|
||||
final adminAutoStartMenuItem = MenuItem.checkbox(
|
||||
label: appLocalizations.adminAutoLaunch,
|
||||
onClick: (_) async {
|
||||
globalState.appController.updateAdminAutoLaunch();
|
||||
},
|
||||
checked: config.appSetting.adminAutoLaunch,
|
||||
);
|
||||
menuItems.add(adminAutoStartMenuItem);
|
||||
}
|
||||
menuItems.add(MenuItem.separator());
|
||||
final exitMenuItem = MenuItem(
|
||||
label: appLocalizations.exit,
|
||||
@@ -718,7 +710,6 @@ class AppController {
|
||||
await trayManager.setContextMenu(menu);
|
||||
if (Platform.isLinux) {
|
||||
await _updateSystemTray(
|
||||
isStart: appFlowingState.isStart,
|
||||
brightness: appState.brightness,
|
||||
force: focus,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user