Theme Mode #1
This commit is contained in:
33
lib/features/profile/preferences/theme_mode_dialog.dart
Normal file
33
lib/features/profile/preferences/theme_mode_dialog.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||
|
||||
Future<void> showThemeModeDialog(BuildContext context) async {
|
||||
final cubit = context.read<ThemeModeCubit>();
|
||||
final currentMode = context.read<ThemeModeCubit>().state.mode;
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Select Theme Mode"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: ThemeMode.values.map((mode) {
|
||||
return RadioListTile<ThemeMode>(
|
||||
title: Text(mode.toString().split('.').last.toUpperCase()),
|
||||
value: mode,
|
||||
groupValue: currentMode,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
cubit.changeThemeMode(value);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user