chore: Adjust power level UX
This commit is contained in:
parent
1ea607f633
commit
47934a3378
4 changed files with 186 additions and 106 deletions
|
|
@ -9,7 +9,7 @@ Future<int?> showPermissionChooser(
|
|||
int currentLevel = 0,
|
||||
int maxLevel = 100,
|
||||
}) async {
|
||||
final controller = TextEditingController();
|
||||
final controller = TextEditingController(text: currentLevel.toString());
|
||||
final error = ValueNotifier<String?>(null);
|
||||
return await showAdaptiveDialog<int>(
|
||||
context: context,
|
||||
|
|
@ -22,7 +22,7 @@ Future<int?> showPermissionChooser(
|
|||
crossAxisAlignment: .stretch,
|
||||
spacing: 12.0,
|
||||
children: [
|
||||
Text(L10n.of(context).setPermissionsLevelDescription),
|
||||
Text(L10n.of(context).setPowerLevelDescription),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: error,
|
||||
builder: (context, errorText, _) => DialogTextField(
|
||||
|
|
@ -38,8 +38,6 @@ Future<int?> showPermissionChooser(
|
|||
),
|
||||
actions: [
|
||||
AdaptiveDialogAction(
|
||||
bigButtons: true,
|
||||
borderRadius: AdaptiveDialogAction.topRadius,
|
||||
onPressed: () {
|
||||
final level = int.tryParse(controller.text.trim());
|
||||
if (level == null) {
|
||||
|
|
@ -52,31 +50,12 @@ Future<int?> showPermissionChooser(
|
|||
}
|
||||
Navigator.of(context).pop<int>(level);
|
||||
},
|
||||
child: Text(L10n.of(context).setCustomPermissionLevel),
|
||||
child: Text(L10n.of(context).setPowerLevel),
|
||||
),
|
||||
AdaptiveDialogAction(
|
||||
onPressed: () => Navigator.of(context).pop<int>(null),
|
||||
child: Text(L10n.of(context).cancel),
|
||||
),
|
||||
if (maxLevel >= 100 && currentLevel != 100)
|
||||
AdaptiveDialogAction(
|
||||
borderRadius: AdaptiveDialogAction.centerRadius,
|
||||
bigButtons: true,
|
||||
onPressed: () => Navigator.of(context).pop<int>(100),
|
||||
child: Text(L10n.of(context).admin),
|
||||
),
|
||||
if (maxLevel >= 50 && currentLevel != 50)
|
||||
AdaptiveDialogAction(
|
||||
borderRadius: maxLevel != 0
|
||||
? AdaptiveDialogAction.centerRadius
|
||||
: AdaptiveDialogAction.bottomRadius,
|
||||
bigButtons: true,
|
||||
onPressed: () => Navigator.of(context).pop<int>(50),
|
||||
child: Text(L10n.of(context).moderator),
|
||||
),
|
||||
if (currentLevel != 0)
|
||||
AdaptiveDialogAction(
|
||||
borderRadius: AdaptiveDialogAction.bottomRadius,
|
||||
bigButtons: true,
|
||||
onPressed: () => Navigator.of(context).pop<int>(0),
|
||||
child: Text(L10n.of(context).normalUser),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue