feat: add action options for closing the application
This commit is contained in:
@@ -5,6 +5,8 @@ import 'package:hiddify/core/localization/locale_extensions.dart';
|
||||
import 'package:hiddify/core/localization/locale_preferences.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/model/region.dart';
|
||||
import 'package:hiddify/core/preferences/actions_at_closing.dart';
|
||||
import 'package:hiddify/core/preferences/general_preferences.dart';
|
||||
import 'package:hiddify/core/theme/app_theme_mode.dart';
|
||||
import 'package:hiddify/core/theme/theme_preferences.dart';
|
||||
import 'package:hiddify/features/config_option/data/config_option_repository.dart';
|
||||
@@ -177,3 +179,43 @@ class ThemeModePrefTile extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ClosingPrefTile extends ConsumerWidget {
|
||||
const ClosingPrefTile({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
|
||||
final action = ref.watch(Preferences.actionAtClose);
|
||||
|
||||
return ListTile(
|
||||
title: Text(t.settings.general.actionAtClosing),
|
||||
subtitle: Text(action.present(t)),
|
||||
leading: const Icon(FluentIcons.arrow_exit_20_regular),
|
||||
onTap: () async {
|
||||
final selectedAction = await showDialog<ActionsAtClosing>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SimpleDialog(
|
||||
title: Text(t.settings.general.actionAtClosing),
|
||||
children: ActionsAtClosing.values
|
||||
.map(
|
||||
(e) => RadioListTile(
|
||||
title: Text(e.present(t)),
|
||||
value: e,
|
||||
groupValue: action,
|
||||
onChanged: Navigator.of(context).maybePop,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (selectedAction != null) {
|
||||
await ref.read(Preferences.actionAtClose.notifier).update(selectedAction);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user