mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 09:16:19 +01:00
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
class FancyOptionPickerItem {
|
|
FancyOptionPickerItem({
|
|
required this.label,
|
|
this.isSelected = false,
|
|
this.onSelect,
|
|
});
|
|
|
|
String label;
|
|
bool isSelected;
|
|
VoidCallback? onSelect;
|
|
}
|
|
|
|
/// A fancy looking dialog to pick an option
|
|
class FancyOptionPicker extends StatelessWidget {
|
|
FancyOptionPicker({
|
|
Key? key,
|
|
this.title,
|
|
required this.items,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
build(BuildContext context) {
|
|
return SimpleDialog(
|
|
title: title != null ? Text(title!) : null,
|
|
children: items
|
|
.map((e) => SimpleDialogOption(
|
|
child: ListTile(
|
|
leading: Icon(
|
|
e.isSelected ? Icons.check : null,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
title: Text(
|
|
e.label,
|
|
style: e.isSelected
|
|
? TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
)
|
|
: null,
|
|
),
|
|
onTap: e.isSelected ? null : e.onSelect,
|
|
),
|
|
))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
final String? title;
|
|
final List<FancyOptionPickerItem> items;
|
|
}
|