From 3338dc536c37b6680667fc9d22e3d5ca04a368e8 Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Thu, 27 Nov 2025 07:53:55 +0100 Subject: [PATCH] add switch user warning --- .../presentation/dialogs/select_profile.dart | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/app/lib/features/user/domain/presentation/dialogs/select_profile.dart b/app/lib/features/user/domain/presentation/dialogs/select_profile.dart index 92ac4c44..ed3209fa 100644 --- a/app/lib/features/user/domain/presentation/dialogs/select_profile.dart +++ b/app/lib/features/user/domain/presentation/dialogs/select_profile.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:weblibre/core/filesystem.dart'; import 'package:weblibre/core/routing/routes.dart'; @@ -26,10 +27,37 @@ class SelectProfileDialog extends HookConsumerWidget { title: Text(profile.name), subtitle: isSelected ? const Text('Active') : null, onTap: () async { - await ref - .read(profileRepositoryProvider.notifier) - .switchProfile(profile.id); - await exitApp(ref.container); + final result = await showDialog( + context: context, + builder: (context) => AlertDialog( + icon: const Icon(Icons.warning), + title: const Text('Switch User'), + content: Text( + "Switching to User '${profile.name}' will require a restart of the Browser", + ), + actions: [ + TextButton( + onPressed: () { + context.pop(false); + }, + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + context.pop(true); + }, + child: const Text('Switch Profile'), + ), + ], + ), + ); + + if (result == true) { + await ref + .read(profileRepositoryProvider.notifier) + .switchProfile(profile.id); + await exitApp(ref.container); + } }, ); }).toList(),