49 lines
1.4 KiB
Dart
49 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:uae_stat/config/theme/app_theme.dart';
|
|
|
|
class ThemeSelectorDialog extends StatefulWidget {
|
|
final AppTheme initialTheme;
|
|
|
|
const ThemeSelectorDialog({super.key, required this.initialTheme});
|
|
|
|
@override
|
|
State<ThemeSelectorDialog> createState() => _ThemeSelectorDialogState();
|
|
}
|
|
|
|
class _ThemeSelectorDialogState extends State<ThemeSelectorDialog> {
|
|
late AppTheme _selectedTheme;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_selectedTheme = widget.initialTheme;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
title: const Text("Choose Theme"),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: AppTheme.values.map((theme) {
|
|
return RadioListTile<AppTheme>(
|
|
title: Text(theme.name[0].toUpperCase() + theme.name.substring(1)),
|
|
value: theme,
|
|
groupValue: _selectedTheme,
|
|
onChanged: (value) => setState(() => _selectedTheme = value!),
|
|
);
|
|
}).toList(),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(null),
|
|
child: const Text("Cancel"),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () => Navigator.of(context).pop(_selectedTheme),
|
|
child: const Text("OK"),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |