add switch user warning
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:weblibre/core/filesystem.dart';
|
import 'package:weblibre/core/filesystem.dart';
|
||||||
import 'package:weblibre/core/routing/routes.dart';
|
import 'package:weblibre/core/routing/routes.dart';
|
||||||
@@ -26,10 +27,37 @@ class SelectProfileDialog extends HookConsumerWidget {
|
|||||||
title: Text(profile.name),
|
title: Text(profile.name),
|
||||||
subtitle: isSelected ? const Text('Active') : null,
|
subtitle: isSelected ? const Text('Active') : null,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await ref
|
final result = await showDialog<bool>(
|
||||||
.read(profileRepositoryProvider.notifier)
|
context: context,
|
||||||
.switchProfile(profile.id);
|
builder: (context) => AlertDialog(
|
||||||
await exitApp(ref.container);
|
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(),
|
}).toList(),
|
||||||
|
|||||||
Reference in New Issue
Block a user