forked from Nexus/nexus
add room access settings
This commit is contained in:
parent
8e51852ae3
commit
b390dbbbe1
1 changed files with 974 additions and 128 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import "dart:async";
|
||||
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
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/helpers/hooks/saving.dart";
|
||||
import "package:nexus/widgets/settings/radio_sheet.dart";
|
||||
|
||||
final class const DialogListTile<T>({
|
||||
|
|
@ -8,32 +11,44 @@ final class const DialogListTile<T>({
|
|||
required final Icon icon,
|
||||
required final String title,
|
||||
required final List<T> options,
|
||||
required final void Function(T value)? onChanged,
|
||||
|
||||
/// While a returned future runs, the tile is disabled.
|
||||
required final FutureOr<void> Function(T value)? onChanged,
|
||||
required final String Function(T option) getName,
|
||||
final Widget? subtitle,
|
||||
super.key,
|
||||
}) extends ConsumerWidget {
|
||||
}) extends HookWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) => ListTile(
|
||||
enabled: onChanged != null,
|
||||
onTap: () => context.showAdaptiveSheet(
|
||||
(context) => RadioSheet<T>(
|
||||
title: title,
|
||||
getName: getName,
|
||||
onChanged: onChanged,
|
||||
value: value,
|
||||
options: options,
|
||||
Widget build(BuildContext context) {
|
||||
final saving = Saving.use();
|
||||
Future<void> change(T value) => saving.run(() => onChanged!(value));
|
||||
|
||||
return ListTile(
|
||||
enabled: onChanged != null && !saving.active,
|
||||
onTap: () => context.showAdaptiveSheet(
|
||||
(context) => RadioSheet<T>(
|
||||
title: title,
|
||||
getName: getName,
|
||||
onChanged: onChanged == null ? null : change,
|
||||
value: value,
|
||||
options: options,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(title),
|
||||
subtitle: subtitle,
|
||||
leading: icon,
|
||||
trailing: Chip(
|
||||
label: Text(
|
||||
value == null ? "None" : getName(value as T),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: onChanged == null ? .new(color: Colors.grey) : null,
|
||||
title: Text(title),
|
||||
subtitle: subtitle,
|
||||
leading: icon,
|
||||
trailing: ConstrainedBox(
|
||||
constraints: const .new(maxWidth: 160),
|
||||
child: Chip(
|
||||
label: Text(
|
||||
value is T ? getName(value as T) : "None",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: onChanged == null || saving.active
|
||||
? .new(color: Colors.grey)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue