new: add exit dialog when press close button
This commit is contained in:
@@ -416,5 +416,10 @@
|
|||||||
"warpNoiseSize": "Noise Size",
|
"warpNoiseSize": "Noise Size",
|
||||||
"warpNoiseMode": "Noise Mode",
|
"warpNoiseMode": "Noise Mode",
|
||||||
"warpNoiseDelay": "Noise Delay"
|
"warpNoiseDelay": "Noise Delay"
|
||||||
|
},
|
||||||
|
"window":{
|
||||||
|
"hide": "Hide",
|
||||||
|
"close": "Exit",
|
||||||
|
"alertMessage":"Hide or Exit the application?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
core.version=2.1.2
|
core.version=2.1.4
|
||||||
@@ -54,7 +54,7 @@ class SystemTrayNotifier extends _$SystemTrayNotifier with AppLogger {
|
|||||||
// SystemTrayNotifier.setIcon(timeout ? Disconnecting() : Connecting());
|
// SystemTrayNotifier.setIcon(timeout ? Disconnecting() : Connecting());
|
||||||
} else {
|
} else {
|
||||||
setIcon(const Disconnecting());
|
setIcon(const Disconnecting());
|
||||||
tooltip = "${tooltip} - ${connection.present(t)}";
|
tooltip = "$tooltip - ${connection.present(t)}";
|
||||||
}
|
}
|
||||||
if (Platform.isMacOS) {
|
if (Platform.isMacOS) {
|
||||||
windowManager.setBadgeLabel("${delay}ms");
|
windowManager.setBadgeLabel("${delay}ms");
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:ui';
|
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/features/connection/notifier/connection_notifier.dart';
|
||||||
import 'package:hiddify/utils/utils.dart';
|
import 'package:hiddify/utils/utils.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
@@ -45,11 +47,7 @@ class WindowNotifier extends _$WindowNotifier with AppLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> quit() async {
|
Future<void> quit() async {
|
||||||
await ref
|
await ref.read(connectionNotifierProvider.notifier).abortConnection().timeout(const Duration(seconds: 2)).catchError(
|
||||||
.read(connectionNotifierProvider.notifier)
|
|
||||||
.abortConnection()
|
|
||||||
.timeout(const Duration(seconds: 2))
|
|
||||||
.catchError(
|
|
||||||
(e) {
|
(e) {
|
||||||
loggy.warning("error aborting connection on quit", e);
|
loggy.warning("error aborting connection on quit", e);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
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/features/window/notifier/window_notifier.dart';
|
||||||
import 'package:hiddify/utils/custom_loggers.dart';
|
import 'package:hiddify/utils/custom_loggers.dart';
|
||||||
import 'package:hiddify/utils/platform_utils.dart';
|
import 'package:hiddify/utils/platform_utils.dart';
|
||||||
@@ -16,8 +19,9 @@ class WindowWrapper extends StatefulHookConsumerWidget {
|
|||||||
ConsumerState<ConsumerStatefulWidget> createState() => _WindowWrapperState();
|
ConsumerState<ConsumerStatefulWidget> createState() => _WindowWrapperState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _WindowWrapperState extends ConsumerState<WindowWrapper>
|
class _WindowWrapperState extends ConsumerState<WindowWrapper> with WindowListener, AppLogger {
|
||||||
with WindowListener, AppLogger {
|
late AlertDialog closeDialog;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
ref.watch(windowNotifierProvider);
|
ref.watch(windowNotifierProvider);
|
||||||
@@ -44,7 +48,31 @@ class _WindowWrapperState extends ConsumerState<WindowWrapper>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onWindowClose() async {
|
Future<void> onWindowClose() async {
|
||||||
|
if (RootScaffold.stateKey.currentContext == null) {
|
||||||
await ref.read(windowNotifierProvider.notifier).close();
|
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
|
@override
|
||||||
|
|||||||
2
libcore
2
libcore
Submodule libcore updated: 0e3d3a0032...e4510270f3
Reference in New Issue
Block a user