Skip to content

Commit

Permalink
review by Urmat
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldar2021 authored Feb 2, 2024
1 parent 108bfa0 commit 83f4510
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 30 deletions.
2 changes: 2 additions & 0 deletions app/lib/app/services/app_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions app/lib/components/card/select_lang_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class SelectLangFromListViewBuilder extends StatelessWidget {
Widget build(BuildContext context) {
final appCubit = context.watch<AppCubit>();
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<AppCubit>().changeLang(locale.languageCode),
trailing: appCubit.state.currentLocale == locale
? CircleAvatar(
Expand Down
2 changes: 2 additions & 0 deletions app/lib/constants/app/app_const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -52,6 +53,7 @@ class AppConst {
static const _readThemeKeyDev = 'readThemeKey-dev';
static const _colorKeyDev = 'color-dev';


static const locales = <Locale>[
Locale('en'),
Locale('ky'),
Expand Down
3 changes: 3 additions & 0 deletions app/lib/core/interface/either.dart
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions app/lib/l10n/l10.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<dynamic> bloc) {
super.onCreate(bloc);
log('onCreate(${bloc.state})');
onLog?.call('onCreate(${bloc.state})');
}

@override
Expand Down
File renamed without changes.
12 changes: 5 additions & 7 deletions app/lib/theme/custom/component/componet_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -28,7 +26,7 @@ mixin CompomnentTheme {
}

AppBarTheme appBarTheme(ColorScheme colors) {
return AppBarTheme(backgroundColor: colors.surfaceVariant);
return AppBarTheme(backgroundColor: scheme.surfaceVariant);
}

TabBarTheme tabBarTheme(ColorScheme colors) {
Expand Down
33 changes: 14 additions & 19 deletions app/lib/theme/custom/custom_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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);
Expand Down

0 comments on commit 83f4510

Please sign in to comment.