From 83f451077a0b0dff05789c2a5bdf73ab52d2cecb Mon Sep 17 00:00:00 2001 From: Eldiiar Almazbek <76556278+Eldar2021@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:39:58 +0600 Subject: [PATCH] review by Urmat --- app/lib/app/services/app_service.dart | 2 ++ app/lib/components/card/select_lang_list.dart | 6 ++-- app/lib/constants/app/app_const.dart | 2 ++ app/lib/core/interface/either.dart | 3 ++ .../core/messages/move_files_from_util.show | 0 app/lib/l10n/l10.dart | 2 ++ .../block_logging.dart} | 8 ++++- .../home/{ => view}/widgets/home_card.dart | 0 .../custom/component/componet_theme.dart | 12 +++---- app/lib/theme/custom/custom_theme.dart | 33 ++++++++----------- 10 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 app/lib/core/messages/move_files_from_util.show rename app/lib/{app_observer.dart => logging/block_logging.dart} (81%) rename app/lib/modules/home/{ => view}/widgets/home_card.dart (100%) diff --git a/app/lib/app/services/app_service.dart b/app/lib/app/services/app_service.dart index 02314588..2c14fc79 100644 --- a/app/lib/app/services/app_service.dart +++ b/app/lib/app/services/app_service.dart @@ -14,6 +14,8 @@ final class AppService { Locale get init { final code = storage.readString(key: AppConst.localeKey); + // TODO check + // final code = storage.readString(StorageKeys.locale); if (code != null) return Locale(code); // ignore: deprecated_member_use final deviceLocal = window.locale.languageCode; diff --git a/app/lib/components/card/select_lang_list.dart b/app/lib/components/card/select_lang_list.dart index 6cc49740..a43d1e61 100644 --- a/app/lib/components/card/select_lang_list.dart +++ b/app/lib/components/card/select_lang_list.dart @@ -12,15 +12,15 @@ class SelectLangFromListViewBuilder extends StatelessWidget { Widget build(BuildContext context) { final appCubit = context.watch(); final colorScheme = Theme.of(context).colorScheme; + return ListView.builder( itemCount: AppConst.locales.length, itemBuilder: (BuildContext context, int index) { - final locale = AppConst.locales[index]; - final langName = AppConst.getName(locale.toLanguageTag()); + final locale = AppLocale.supportedLocales[index]; return Card( child: ListTile( key: Key(MqKeys.languageCode(locale.languageCode)), - title: Text(langName, locale: locale), + title: Text(locale.name, locale: locale), onTap: () => context.read().changeLang(locale.languageCode), trailing: appCubit.state.currentLocale == locale ? CircleAvatar( diff --git a/app/lib/constants/app/app_const.dart b/app/lib/constants/app/app_const.dart index 64b6b41a..70349413 100644 --- a/app/lib/constants/app/app_const.dart +++ b/app/lib/constants/app/app_const.dart @@ -4,6 +4,7 @@ import 'package:my_quran/config/app_config.dart'; class AppConst { const AppConst._(); + // TODO Move to AppStatics static const bismallah = 'بِسْمِ ٱللَّهِ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ'; static const sajdaSymbol = '۩'; static const sajdaAyats = [1160, 1722, 1951, 2138, 2308, 2613, 2672, 2915, 3185, 3518, 3994, 4256, 4846, 5905, 6125]; @@ -52,6 +53,7 @@ class AppConst { static const _readThemeKeyDev = 'readThemeKey-dev'; static const _colorKeyDev = 'color-dev'; + static const locales = [ Locale('en'), Locale('ky'), diff --git a/app/lib/core/interface/either.dart b/app/lib/core/interface/either.dart index c9f7c401..fbba39f6 100644 --- a/app/lib/core/interface/either.dart +++ b/app/lib/core/interface/either.dart @@ -1,5 +1,8 @@ import 'package:meta/meta.dart'; +// TODO change directory name to either + + /// The Either class is an abstract class representing right and left values. /// ```dart /// void main() { diff --git a/app/lib/core/messages/move_files_from_util.show b/app/lib/core/messages/move_files_from_util.show new file mode 100644 index 00000000..e69de29b diff --git a/app/lib/l10n/l10.dart b/app/lib/l10n/l10.dart index 17c891b5..6926a2c9 100644 --- a/app/lib/l10n/l10.dart +++ b/app/lib/l10n/l10.dart @@ -5,4 +5,6 @@ export 'package:flutter_gen/gen_l10n/app_localizations.dart'; extension AppLocalizationsX on BuildContext { AppLocalizations get l10n => AppLocalizations.of(this); + + // TODO write supported lolales and get locale name } diff --git a/app/lib/app_observer.dart b/app/lib/logging/block_logging.dart similarity index 81% rename from app/lib/app_observer.dart rename to app/lib/logging/block_logging.dart index 5fd8fbe7..05acb491 100644 --- a/app/lib/app_observer.dart +++ b/app/lib/logging/block_logging.dart @@ -2,11 +2,17 @@ import 'dart:developer'; import 'package:flutter_bloc/flutter_bloc.dart'; -class AppBlocObserver extends BlocObserver { +class BlocLogging extends BlocObserver { + + BlocLogging({this.onLog}); + + final void Function(String log)? onLog; + @override void onCreate(BlocBase bloc) { super.onCreate(bloc); log('onCreate(${bloc.state})'); + onLog?.call('onCreate(${bloc.state})'); } @override diff --git a/app/lib/modules/home/widgets/home_card.dart b/app/lib/modules/home/view/widgets/home_card.dart similarity index 100% rename from app/lib/modules/home/widgets/home_card.dart rename to app/lib/modules/home/view/widgets/home_card.dart diff --git a/app/lib/theme/custom/component/componet_theme.dart b/app/lib/theme/custom/component/componet_theme.dart index e48bf0d8..2cee00cd 100644 --- a/app/lib/theme/custom/component/componet_theme.dart +++ b/app/lib/theme/custom/component/componet_theme.dart @@ -3,13 +3,11 @@ import 'package:flutter/material.dart'; mixin CompomnentTheme { ShapeBorder get shapeMedium => const RoundedRectangleBorder(); - CardTheme cardTheme() { - return const CardTheme(); - } + ColorScheme get scheme; - ButtonThemeData buttonTheme(ColorScheme colors) { - return const ButtonThemeData(); - } + CardTheme cardTheme => const CardTheme(); + + ButtonThemeData buttonTheme => const ButtonThemeData(); ElevatedButtonThemeData elevatedButtonThemeData(ColorScheme colors) { return ElevatedButtonThemeData( @@ -28,7 +26,7 @@ mixin CompomnentTheme { } AppBarTheme appBarTheme(ColorScheme colors) { - return AppBarTheme(backgroundColor: colors.surfaceVariant); + return AppBarTheme(backgroundColor: scheme.surfaceVariant); } TabBarTheme tabBarTheme(ColorScheme colors) { diff --git a/app/lib/theme/custom/custom_theme.dart b/app/lib/theme/custom/custom_theme.dart index 01fd61e0..780ba56f 100644 --- a/app/lib/theme/custom/custom_theme.dart +++ b/app/lib/theme/custom/custom_theme.dart @@ -7,16 +7,14 @@ class CustomTheme with CompomnentTheme { final Brightness brightness; final Color targetColor; - ColorScheme colors() { - return ColorScheme.fromSeed( + @override + ColorScheme get scheme => ColorScheme.fromSeed( seedColor: targetColor, brightness: brightness, ); - } - ThemeData light() { - final scheme = colors(); - return ThemeData.light().copyWith( + ThemeData get _base { + return ThemeData( colorScheme: scheme, appBarTheme: appBarTheme(scheme), cardTheme: cardTheme(), @@ -33,22 +31,19 @@ class CustomTheme with CompomnentTheme { ); } - ThemeData dark() { - final scheme = colors(); - return ThemeData.dark().copyWith( - colorScheme: scheme, - appBarTheme: appBarTheme(scheme), - cardTheme: cardTheme(), - listTileTheme: listTileTheme(scheme), - bottomAppBarTheme: bottomAppBarTheme(scheme), - bottomNavigationBarTheme: bottomNavigationBarTheme(scheme), - navigationRailTheme: navigationRailTheme(scheme), - tabBarTheme: tabBarTheme(scheme), - drawerTheme: drawerTheme(scheme), + ThemeData get light { + return _base.copyWith( + brightness: Brightness.light + ); + } + + ThemeData get dark { + return _base.copyWith( + brightness: Brightness.dart ); } - ThemeData get themeData => brightness == Brightness.dark ? dark() : light(); + ThemeData get themeData => brightness == Brightness.dark ? dark : light; CustomTheme copyWith({Brightness? brightness, Color? targetColor}) { return CustomTheme(brightness ?? this.brightness, targetColor ?? this.targetColor);