diff --git a/assets/translations/strings_en.i18n.json b/assets/translations/strings_en.i18n.json index 26caa7e2..5fbc9148 100644 --- a/assets/translations/strings_en.i18n.json +++ b/assets/translations/strings_en.i18n.json @@ -416,5 +416,10 @@ "warpNoiseSize": "Noise Size", "warpNoiseMode": "Noise Mode", "warpNoiseDelay": "Noise Delay" + }, + "window":{ + "hide": "Hide", + "close": "Exit", + "alertMessage":"Hide or Exit the application?" } } diff --git a/dependencies.properties b/dependencies.properties index 2a714af6..4c08ccc2 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1 +1 @@ -core.version=2.1.2 \ No newline at end of file +core.version=2.1.4 \ No newline at end of file diff --git a/lib/features/system_tray/notifier/system_tray_notifier.dart b/lib/features/system_tray/notifier/system_tray_notifier.dart index ba9ca425..06031d24 100644 --- a/lib/features/system_tray/notifier/system_tray_notifier.dart +++ b/lib/features/system_tray/notifier/system_tray_notifier.dart @@ -54,7 +54,7 @@ class SystemTrayNotifier extends _$SystemTrayNotifier with AppLogger { // SystemTrayNotifier.setIcon(timeout ? Disconnecting() : Connecting()); } else { setIcon(const Disconnecting()); - tooltip = "${tooltip} - ${connection.present(t)}"; + tooltip = "$tooltip - ${connection.present(t)}"; } if (Platform.isMacOS) { windowManager.setBadgeLabel("${delay}ms"); diff --git a/lib/features/window/notifier/window_notifier.dart b/lib/features/window/notifier/window_notifier.dart index f9708520..8b379155 100644 --- a/lib/features/window/notifier/window_notifier.dart +++ b/lib/features/window/notifier/window_notifier.dart @@ -1,6 +1,8 @@ import 'dart:io'; import 'dart:ui'; +import 'package:flutter/material.dart'; +import 'package:hiddify/core/localization/translations.dart'; import 'package:hiddify/features/connection/notifier/connection_notifier.dart'; import 'package:hiddify/utils/utils.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; @@ -45,11 +47,7 @@ class WindowNotifier extends _$WindowNotifier with AppLogger { } Future quit() async { - await ref - .read(connectionNotifierProvider.notifier) - .abortConnection() - .timeout(const Duration(seconds: 2)) - .catchError( + await ref.read(connectionNotifierProvider.notifier).abortConnection().timeout(const Duration(seconds: 2)).catchError( (e) { loggy.warning("error aborting connection on quit", e); }, diff --git a/lib/features/window/widget/window_wrapper.dart b/lib/features/window/widget/window_wrapper.dart index 9f31d5d7..05a7151d 100644 --- a/lib/features/window/widget/window_wrapper.dart +++ b/lib/features/window/widget/window_wrapper.dart @@ -1,6 +1,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:hiddify/core/localization/translations.dart'; +import 'package:hiddify/features/common/adaptive_root_scaffold.dart'; +import 'package:hiddify/features/connection/notifier/connection_notifier.dart'; import 'package:hiddify/features/window/notifier/window_notifier.dart'; import 'package:hiddify/utils/custom_loggers.dart'; import 'package:hiddify/utils/platform_utils.dart'; @@ -16,8 +19,9 @@ class WindowWrapper extends StatefulHookConsumerWidget { ConsumerState createState() => _WindowWrapperState(); } -class _WindowWrapperState extends ConsumerState - with WindowListener, AppLogger { +class _WindowWrapperState extends ConsumerState with WindowListener, AppLogger { + late AlertDialog closeDialog; + @override Widget build(BuildContext context) { ref.watch(windowNotifierProvider); @@ -44,7 +48,31 @@ class _WindowWrapperState extends ConsumerState @override Future onWindowClose() async { - await ref.read(windowNotifierProvider.notifier).close(); + if (RootScaffold.stateKey.currentContext == null) { + await ref.read(windowNotifierProvider.notifier).close(); + return; + } + final t = ref.watch(translationsProvider); + + await showDialog( + context: RootScaffold.stateKey.currentContext!, + builder: (BuildContext context) => AlertDialog( + title: Text(t.window.alertMessage), + actions: [ + TextButton( + onPressed: () async => await ref.read(windowNotifierProvider.notifier).quit(), + child: Text(t.window.close.toUpperCase()), + ), + TextButton( + onPressed: () async { + Navigator.of(context).maybePop(false); + await ref.read(windowNotifierProvider.notifier).close(); + }, + child: Text(t.window.hide.toUpperCase()), + ), + ], + ), + ); } @override diff --git a/libcore b/libcore index 0e3d3a00..e4510270 160000 --- a/libcore +++ b/libcore @@ -1 +1 @@ -Subproject commit 0e3d3a00328869d000b7416da84f346d0a0188be +Subproject commit e4510270f353f3c1642ab2ccd048831621233439