Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
canewsin committed Feb 7, 2022
1 parent 27ffdaa commit 5727401
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/controllers/uicontroller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ final uiStore = Get.put(UiController());

class UiController extends GetxController {
PersistentBottomSheetController currentBottomSheetController;
final isWindowVisible = false.obs;

var appUpdate = AppUpdate.NOT_AVAILABLE.obs;

Expand Down
15 changes: 13 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class MyApp extends StatelessWidget {
Row(
children: [
MinimizeWindowButton(
onPressed: () {
appWindow.minimize();
uiStore.isWindowVisible.value = false;
},
colors: WindowButtonColors(
normal:
uiStore.currentTheme.value.cardBgColor,
Expand All @@ -59,6 +63,10 @@ class MyApp extends StatelessWidget {
),
),
MaximizeWindowButton(
onPressed: () {
appWindow.maximize();
uiStore.isWindowVisible.value = true;
},
colors: WindowButtonColors(
normal:
uiStore.currentTheme.value.cardBgColor,
Expand All @@ -67,12 +75,15 @@ class MyApp extends StatelessWidget {
),
),
CloseWindowButton(
onPressed: () => appWindow.hide(),
onPressed: () {
appWindow.hide();
uiStore.isWindowVisible.value = false;
},
colors: WindowButtonColors(
normal:
uiStore.currentTheme.value.cardBgColor,
mouseOver: Colors.redAccent,
mouseDown: Colors.red,
mouseDown: Color(0xFFF44336),
),
),
],
Expand Down
16 changes: 10 additions & 6 deletions lib/others/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ String zeroBrowserTheme = 'light';
String snackMessage = '';

SystemTray _systemTray;
AppWindow _appWindow;

ZeroNetService service;
// FlutterBackgroundService service;
Expand Down Expand Up @@ -163,7 +162,6 @@ init() async {

if (PlatformExt.isDesktop) {
_systemTray = SystemTray();
_appWindow = AppWindow();
}
}

Expand Down Expand Up @@ -202,7 +200,7 @@ Future<void> initSystemTray() async {
MenuSeparator(),
MenuItem(
label: 'Exit',
onClicked: _appWindow.close,
onClicked: appWindow.close,
),
];

Expand All @@ -217,7 +215,13 @@ Future<void> initSystemTray() async {
_systemTray.registerSystemTrayEventHandler((eventName) {
if (eventName == "leftMouseDown") {
} else if (eventName == "leftMouseUp") {
_appWindow.show();
if (uiStore.isWindowVisible.value) {
uiStore.isWindowVisible.value = false;
appWindow.hide();
} else {
uiStore.isWindowVisible.value = true;
appWindow.show();
}
} else if (eventName == "rightMouseDown") {
} else if (eventName == "rightMouseUp") {
_systemTray.popUpContextMenu();
Expand Down Expand Up @@ -272,14 +276,14 @@ Future<void> backUpUserJsonFile(
.then(
(_) {
printToConsole(strController.usersFileCopied.value);
Get.showSnackbar(GetBar(
Get.showSnackbar(GetSnackBar(
message: strController.usersFileCopied.value,
));
},
);
} else {
String result = await saveUserJsonFile(getZeroNetUsersFilePath());
Get.showSnackbar(GetBar(
Get.showSnackbar(GetSnackBar(
message: (result.contains('success'))
? result
: strController.chkBckUpStr.value,
Expand Down

0 comments on commit 5727401

Please sign in to comment.