Skip to content

Commit

Permalink
fix: destroy tray on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Jan 12, 2024
1 parent 9aa720d commit 8881334
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/view/specialized/title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/material.dart';
import 'package:system_tray/system_tray.dart';

import '../../common/platform.dart';

Expand Down Expand Up @@ -60,21 +61,28 @@ class TitleBar extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Exit Program?'),
content: const Text(
'Press Hide to hide window in tray, or press yes to exit.'),
title: const Text('关闭'),
content: const Text('确定要关闭吗?'),
actions: <Widget>[
TextButton(
child: const Text('Hide'),
child: const Text('退出应用'),
onPressed: () {
final SystemTray systemTray = SystemTray();
systemTray.destroy();
appWindow.close();
},
),
TextButton(
child: const Text('最小化到托盘'),
onPressed: () {
Navigator.of(context).pop();
appWindow.hide();
},
),
TextButton(
child: const Text('Yes'),
child: const Text('取消'),
onPressed: () {
appWindow.close();
Navigator.of(context).pop();
},
),
],
Expand Down

0 comments on commit 8881334

Please sign in to comment.