mass migrate to adaptive sheets
This commit is contained in:
parent
ba258c2fcd
commit
9117663c48
13 changed files with 292 additions and 289 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/helpers/extensions/show_adaptive_sheet.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/widgets/settings/radio_dialog.dart";
|
||||
import "package:nexus/widgets/settings/radio_sheet.dart";
|
||||
|
||||
final class const DialogListTile<T>({
|
||||
required final T? initialValue,
|
||||
|
|
@ -26,9 +27,8 @@ final class const DialogListTile<T>({
|
|||
),
|
||||
child: ListTile(
|
||||
enabled: onChanged != null,
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => RadioDialog<T>(
|
||||
onTap: () => context.showAdaptiveSheet(
|
||||
(context) => RadioSheet<T>(
|
||||
title: title,
|
||||
getName: getName,
|
||||
onChanged: onChanged == null
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/widgets/sheet_layout.dart";
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
|
||||
final class const RadioDialog<T>({
|
||||
final class const RadioSheet<T>({
|
||||
required final T? value,
|
||||
required final String title,
|
||||
required final List<T> options,
|
||||
|
|
@ -12,26 +13,8 @@ final class const RadioDialog<T>({
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mutValue = useState<T?>(null);
|
||||
return AlertDialog(
|
||||
return SheetLayout(
|
||||
title: Text(title),
|
||||
content: RadioGroup<T>(
|
||||
groupValue: mutValue.value ?? value,
|
||||
onChanged: (value) => mutValue.value = value ?? mutValue.value,
|
||||
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: options
|
||||
.map(
|
||||
(option) => RadioListTile<T>(
|
||||
enabled: onChanged != null,
|
||||
value: option,
|
||||
title: Text(getName(option)),
|
||||
dense: true,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: Navigator.of(context).pop, child: Text("Cancel")),
|
||||
if (onChanged != null)
|
||||
|
|
@ -43,6 +26,26 @@ final class const RadioDialog<T>({
|
|||
child: Text("OK"),
|
||||
),
|
||||
],
|
||||
children: [
|
||||
RadioGroup<T>(
|
||||
groupValue: mutValue.value ?? value,
|
||||
onChanged: (value) => mutValue.value = value ?? mutValue.value,
|
||||
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: options
|
||||
.map(
|
||||
(option) => RadioListTile<T>(
|
||||
enabled: onChanged != null,
|
||||
value: option,
|
||||
title: Text(getName(option)),
|
||||
dense: true,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue