34 lines
1.0 KiB
Dart
34 lines
1.0 KiB
Dart
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(),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|