add optional dropdown prefix label

This commit is contained in:
julian 2023-03-16 12:22:57 -06:00
parent 6f7f9c24eb
commit 9e0bd2aa35
2 changed files with 9 additions and 1 deletions

View file

@ -281,6 +281,7 @@ class _DesktopCoinControlUseDialogState
}); });
} }
}, },
displayPrefix: "Sort by",
) )
], ],
), ),

View file

@ -128,11 +128,13 @@ class JDropdownIconButton<T> extends StatefulWidget {
const JDropdownIconButton({ const JDropdownIconButton({
Key? key, Key? key,
required this.items, required this.items,
required this.displayPrefix,
this.onSelectionChanged, this.onSelectionChanged,
this.groupValue, this.groupValue,
this.redrawOnScreenSizeChanged = false, this.redrawOnScreenSizeChanged = false,
}) : super(key: key); }) : super(key: key);
final String displayPrefix;
final void Function(T?)? onSelectionChanged; final void Function(T?)? onSelectionChanged;
final T? groupValue; final T? groupValue;
final Set<T> items; final Set<T> items;
@ -180,6 +182,7 @@ class _JDropdownIconButtonState<T> extends State<JDropdownIconButton<T>> {
(e) => _JDropdownButtonItem<T>( (e) => _JDropdownButtonItem<T>(
value: e, value: e,
groupValue: widget.groupValue, groupValue: widget.groupValue,
displayPrefix: widget.displayPrefix,
onSelected: (T value) { onSelected: (T value) {
widget.onSelectionChanged?.call(value); widget.onSelectionChanged?.call(value);
close(); close();
@ -310,12 +313,14 @@ class _JDropdownButtonItem<T> extends StatelessWidget {
required this.groupValue, required this.groupValue,
required this.onSelected, required this.onSelected,
this.height = 53, this.height = 53,
this.displayPrefix,
}) : super(key: key); }) : super(key: key);
final T value; final T value;
final T? groupValue; final T? groupValue;
final double height; final double height;
final void Function(T) onSelected; final void Function(T) onSelected;
final String? displayPrefix;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -337,7 +342,9 @@ class _JDropdownButtonItem<T> extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text( Text(
value.toString(), displayPrefix == null
? value.toString()
: "$displayPrefix ${value.toString().toLowerCase()}",
style: STextStyles.desktopTextExtraSmall(context).copyWith( style: STextStyles.desktopTextExtraSmall(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.textDark, color: Theme.of(context).extension<StackColors>()!.textDark,
), ),