showThemeModal function
void
showThemeModal(
- dynamic context, {
- double itemSize = 40,
- List<
ColorThemesEnum> themes = const [],
Implementation
void showThemeModal(
context, {
double itemSize = 40,
List<ColorThemesEnum> themes = const [],
}) {
Rx<ColorThemesEnum> selectedTheme = ColorThemesEnum.blueDelight.obs;
showDialog(
context: context,
builder: (BuildContext context) {
return Center(
child: SingleChildScrollView(
child: AlertDialog(
title: Text('app_service.select_theme'.tr),
contentPadding: const EdgeInsets.all(16.0),
content: Obx(
() => Wrap(
alignment: WrapAlignment.start,
spacing: 8.0,
runSpacing: 8.0,
children: [
if (themes.isEmpty)
for (var theme in ColorThemesEnum.values)
ThemeItem(
theme: theme,
size: itemSize,
isSelected: selectedTheme.value == theme,
onSelected: (selected) {
selectedTheme.value = selected;
},
),
if (themes.isNotEmpty)
...themes.map((theme) => ThemeItem(
theme: theme,
size: itemSize,
isSelected: selectedTheme.value == theme,
onSelected: (selected) {
selectedTheme.value = selected;
},
))
],
),
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('app_service.close'.tr),
),
],
),
),
);
},
);
}