Localization Changes #6
This commit is contained in:
@@ -1,21 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
String _getThemeModeText(ThemeMode mode, AppLocalizations l10n) {
|
||||
switch (mode) {
|
||||
case ThemeMode.system:
|
||||
return l10n.themeModeSystem;
|
||||
case ThemeMode.light:
|
||||
return l10n.themeModeLight;
|
||||
case ThemeMode.dark:
|
||||
return l10n.themeModeDark;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> showThemeModeDialog(BuildContext context) async {
|
||||
final cubit = context.read<ThemeModeCubit>();
|
||||
final currentMode = context.read<ThemeModeCubit>().state.mode;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Select Theme Mode"),
|
||||
title: Text(l10n.selectThemeMode),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: ThemeMode.values.map((mode) {
|
||||
return RadioListTile<ThemeMode>(
|
||||
title: Text(mode.toString().split('.').last.toUpperCase()),
|
||||
title: Text(_getThemeModeText(mode, l10n)),
|
||||
value: mode,
|
||||
groupValue: currentMode,
|
||||
onChanged: (value) {
|
||||
@@ -30,4 +43,4 @@ Future<void> showThemeModeDialog(BuildContext context) async {
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user