refactor dialogs into separate files

This commit is contained in:
Fabian Freund
2026-01-01 07:40:32 +01:00
parent 260ce173b6
commit f7a05f57f4
25 changed files with 796 additions and 410 deletions
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024-2025 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
Future<bool?> showUserAgentRestartDialog(BuildContext context) {
return showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
icon: const Icon(Icons.warning),
title: const Text('User Agent Changed'),
content: const Text(
'The Browser needs to get restarted for the new user agent to take effect',
),
actions: [
TextButton(
onPressed: () {
context.pop(false);
},
child: const Text('Later'),
),
TextButton(
onPressed: () {
context.pop(true);
},
child: const Text('Restart Now'),
),
],
),
);
}
@@ -25,13 +25,13 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:weblibre/core/logger.dart';
import 'package:weblibre/core/providers/app_state.dart';
import 'package:weblibre/core/routing/routes.dart';
import 'package:weblibre/features/settings/presentation/controllers/save_settings.dart';
import 'package:weblibre/features/settings/presentation/dialogs/user_agent_restart_dialog.dart';
import 'package:weblibre/features/settings/presentation/widgets/custom_list_tile.dart';
import 'package:weblibre/features/user/data/models/engine_settings.dart';
import 'package:weblibre/features/user/domain/repositories/engine_settings.dart';
@@ -93,30 +93,7 @@ class DeveloperSettingsScreen extends HookConsumerWidget {
);
if (context.mounted) {
final restart = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
icon: const Icon(Icons.warning),
title: const Text('User Agent Changed'),
content: const Text(
'The Browser needs to get restarted for the new user agent to take effect',
),
actions: [
TextButton(
onPressed: () {
context.pop(false);
},
child: const Text('Later'),
),
TextButton(
onPressed: () {
context.pop(true);
},
child: const Text('Restart Now'),
),
],
),
);
final restart = await showUserAgentRestartDialog(context);
if (restart == true) {
await exitApp(ref.container);