remove unused preference dialogs and provider from the project
This commit is contained in:
parent
805aa5e015
commit
a2d1ac5226
@ -13,7 +13,6 @@ import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
|||||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
||||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import 'package:kmobile/src/preferences/preference.dart';
|
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
@ -175,10 +174,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
// Navigator.push(
|
||||||
context,
|
// context,
|
||||||
MaterialPageRoute(
|
// MaterialPageRoute(
|
||||||
builder: (context) => const Preference()));
|
// builder: (context) => const Preference()));
|
||||||
},
|
},
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
backgroundColor: Colors.grey[200],
|
backgroundColor: Colors.grey[200],
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
|
||||||
import 'package:kmobile/utils/theme/color/color_scheme.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
class ColorDialog extends StatelessWidget {
|
|
||||||
const ColorDialog({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: const Text('Select Theme'),
|
|
||||||
children: <Widget>[
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, KMobileColorScheme.everforest);
|
|
||||||
},
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Symbols.circle,
|
|
||||||
color: Colors.greenAccent,
|
|
||||||
fill: 1.0,
|
|
||||||
),
|
|
||||||
title: Text(AppLocalizations.of(context)!.everforest),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, KMobileColorScheme.rosy);
|
|
||||||
},
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Symbols.circle,
|
|
||||||
color: Colors.pinkAccent,
|
|
||||||
fill: 1.0,
|
|
||||||
),
|
|
||||||
title: Text(AppLocalizations.of(context)!.rosy),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, KMobileColorScheme.skypeia);
|
|
||||||
},
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Symbols.circle,
|
|
||||||
color: Colors.lightBlueAccent,
|
|
||||||
fill: 1.0,
|
|
||||||
),
|
|
||||||
title: Text(AppLocalizations.of(context)!.skypeia),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SimpleDialogOption(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, KMobileColorScheme.marigold);
|
|
||||||
},
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Symbols.circle,
|
|
||||||
color: Colors.amberAccent,
|
|
||||||
fill: 1.0,
|
|
||||||
),
|
|
||||||
title: Text(AppLocalizations.of(context)!.marigold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// const Divider(height: 0),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
class LanguageDialog extends StatelessWidget {
|
|
||||||
const LanguageDialog({super.key});
|
|
||||||
|
|
||||||
String getLocaleName(BuildContext context, String code) {
|
|
||||||
Map<String, String> localeCodeMap = {
|
|
||||||
'en': AppLocalizations.of(context)!.english,
|
|
||||||
'bn': AppLocalizations.of(context)!.bengali,
|
|
||||||
'ml': AppLocalizations.of(context)!.malayalam,
|
|
||||||
'hi': AppLocalizations.of(context)!.hindi,
|
|
||||||
};
|
|
||||||
return localeCodeMap[code] ?? 'Unknown';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: Text(AppLocalizations.of(context)!.select_language),
|
|
||||||
children: AppLocalizations.supportedLocales.map(
|
|
||||||
(locale) {
|
|
||||||
return SimpleDialogOption(
|
|
||||||
onPressed: () => Navigator.pop(context, locale),
|
|
||||||
child: ListTile(title: Text(getLocaleName(context, locale.languageCode))),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).toList(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:kmobile/src/preferences/color_dialog.dart';
|
|
||||||
import 'package:kmobile/src/preferences/language_dialog.dart';
|
|
||||||
import 'package:kmobile/src/preferences/preferences_provider.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
class Preference extends StatelessWidget {
|
|
||||||
const Preference({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
PreferencesProvider preferencesProvider =
|
|
||||||
Provider.of<PreferencesProvider>(context);
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(AppLocalizations.of(context)!.preferences),
|
|
||||||
),
|
|
||||||
body: ListView(
|
|
||||||
children: [
|
|
||||||
ListTile(
|
|
||||||
title: Text(AppLocalizations.of(context)!.dark_theme),
|
|
||||||
trailing: Switch(
|
|
||||||
value: preferencesProvider.themeMode == ThemeMode.dark,
|
|
||||||
onChanged: (value) {
|
|
||||||
preferencesProvider.themeMode =
|
|
||||||
value ? ThemeMode.dark : ThemeMode.light;
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
const Divider(height: 0),
|
|
||||||
ListTile(
|
|
||||||
title: Text(AppLocalizations.of(context)!.color_theme),
|
|
||||||
onTap: () => _changeCurrentTheme(context),
|
|
||||||
),
|
|
||||||
const Divider(height: 0),
|
|
||||||
ListTile(
|
|
||||||
title: Text(AppLocalizations.of(context)!.language),
|
|
||||||
onTap: () => _changeCurrentLocale(context),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _changeCurrentTheme(BuildContext context) async {
|
|
||||||
Map<ThemeMode, ColorScheme> selectedColorScheme = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return const ColorDialog();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (context.mounted) {
|
|
||||||
PreferencesProvider provider =
|
|
||||||
Provider.of<PreferencesProvider>(context, listen: false);
|
|
||||||
provider.colorScheme = selectedColorScheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _changeCurrentLocale(BuildContext context) async {
|
|
||||||
Locale selectedLocale = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return const LanguageDialog();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (context.mounted) {
|
|
||||||
PreferencesProvider provider =
|
|
||||||
Provider.of<PreferencesProvider>(context, listen: false);
|
|
||||||
provider.locale = selectedLocale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:kmobile/utils/theme/color/color_scheme.dart';
|
|
||||||
|
|
||||||
class PreferencesProvider with ChangeNotifier {
|
|
||||||
ThemeMode _themeMode = ThemeMode.light;
|
|
||||||
ThemeMode get themeMode => _themeMode;
|
|
||||||
set themeMode(ThemeMode currentMode) {
|
|
||||||
_themeMode = currentMode;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<ThemeMode, ColorScheme> _colorScheme = KMobileColorScheme.everforest;
|
|
||||||
Map<ThemeMode, ColorScheme> get colorScheme => _colorScheme;
|
|
||||||
set colorScheme(Map<ThemeMode, ColorScheme> currentColorScheme) {
|
|
||||||
_colorScheme = currentColorScheme;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
Locale _locale = const Locale.fromSubtags(languageCode: 'en');
|
|
||||||
Locale get locale => _locale;
|
|
||||||
set locale(Locale currentLocale) {
|
|
||||||
_locale = currentLocale;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user