Skip to content

Commit

Permalink
Merge pull request #7 from yelmuratoff/feat/icons
Browse files Browse the repository at this point in the history
Feat/icons
  • Loading branch information
yelmuratoff authored Sep 14, 2024
2 parents 2e802a6 + 54cb687 commit 8152fff
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 128 deletions.
7 changes: 7 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
arb-dir: lib/src/core/l10n/translations
template-arb-file: intl_en.arb
output-localization-file: app_localizations.g.dart
output-dir: lib/src/core/l10n/generated
synthetic-package: false
nullable-getter: false
untranslated-messages-file: untranslated_messages.txt
3 changes: 2 additions & 1 deletion lib/src/app/presentation/page/root.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:iconsax_plus/iconsax_plus.dart';

part '../widget/bottom_navigation_bar.dart';

Expand Down
10 changes: 6 additions & 4 deletions lib/src/app/presentation/widget/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ class _BottomNavigationBar extends StatelessWidget {
},
destinations: [
NavigationDestination(
icon: const Icon(Icons.home_outlined),
selectedIcon: const Icon(Icons.home, color: Colors.white),
icon: const Icon(IconsaxPlusLinear.home),
selectedIcon:
const Icon(IconsaxPlusBold.home, color: Colors.white),
label: L10n.current.home,
),
NavigationDestination(
icon: const Icon(Icons.person_outline),
selectedIcon: const Icon(Icons.person, color: Colors.white),
icon: const Icon(IconsaxPlusLinear.user_square),
selectedIcon:
const Icon(IconsaxPlusBold.user_square, color: Colors.white),
label: L10n.current.profile,
),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/src/app/presentation/widget/material_context.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:base_starter/flavors.dart';
import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:base_starter/src/features/settings/presentation/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
Expand Down Expand Up @@ -43,7 +43,7 @@ class MaterialContext extends ConsumerWidget {
localizationsDelegates: ISpectLocalizations.localizationDelegates([
L10n.delegate,
]),
supportedLocales: L10n.delegate.supportedLocales,
supportedLocales: L10n.supportedLocales,
locale: locale,
routerConfig: routerConfig,
builder: (context, child) {
Expand Down
63 changes: 0 additions & 63 deletions lib/src/app/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,67 +96,4 @@ GoRouter createRouter = GoRouter(
);
},
routes: $appRoutes,
// routes: [
// $splashRoute,
// $authRoute,
// StatefulShellRoute.indexedStack(
// builder: (
// _,
// __,
// navigationShell,
// ) {
// /// Return the widget that implements the custom shell (in this case
// /// using a BottomNavigationBar). The StatefulNavigationShell is passed
// /// to be able access the state of the shell and to navigate to other
// /// branches in a stateful way.
// return RootPage(navigationShell: navigationShell);
// },
// branches: [
// StatefulShellBranch(
// navigatorKey: _homeSectionNavigatorKey,
// observers: [
// HeroController(),
// ISpectNavigatorObserver(
// isLogModals: false,
// ),
// ],
// routes: [
// GoRoute(
// name: HomePage.name,
// path: HomePage.routePath,
// builder: (_, __) => const HomePage(),
// ),
// ],
// ),
// StatefulShellBranch(
// navigatorKey: _profileSectionNavigatorKey,
// routes: [
// GoRoute(
// name: ProfilePage.name,
// path: ProfilePage.routePath,
// builder: (_, __) => const ProfilePage(),
// routes: [
// GoRoute(
// name: SettingsPage.name,
// path: SettingsPage.routePath,
// builder: (_, state) {
// final queryParameters = state.uri.queryParameters;
// return SettingsPage(
// title: queryParameters[ExtraKeys.title] ?? 'Settings',
// );
// },
// ),
// ],
// ),
// ],
// observers: [
// HeroController(),
// ISpectNavigatorObserver(
// isLogModals: false,
// ),
// ],
// ),
// ],
// ),
// ],
);
2 changes: 1 addition & 1 deletion lib/src/common/presentation/pages/error_router_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';

Expand Down
6 changes: 5 additions & 1 deletion lib/src/common/presentation/widgets/bottom_sheet/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:auto_size_text/auto_size_text.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';

import 'package:flutter/material.dart';
import 'package:iconsax_plus/iconsax_plus.dart';

class AppBottomSheet extends StatelessWidget {
const AppBottomSheet({
Expand Down Expand Up @@ -72,7 +73,10 @@ class AppBottomSheet extends StatelessWidget {
padding: const EdgeInsets.only(left: 16),
child: IconButton(
iconSize: 20,
icon: const Icon(Icons.cancel_outlined, size: 32),
icon: const Icon(
IconsaxPlusLinear.close_circle,
size: 32,
),
onPressed: () {
Navigator.of(context).pop();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:base_starter/src/common/presentation/widgets/app_loading_indicator.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import 'package:base_starter/src/common/constants/preferences.dart';
import 'package:base_starter/src/common/presentation/pages/restart_wrapper.dart';
import 'package:base_starter/src/common/presentation/widgets/dialogs/toaster.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:iconsax_plus/iconsax_plus.dart';
import 'package:ispect/ispect.dart';

final class ChangeEnvironmentDialog {
Expand Down Expand Up @@ -37,7 +38,7 @@ final class ChangeEnvironmentDialog {
children: [
if (F.appFlavor == env) ...[
Icon(
Icons.check_circle_outline_rounded,
IconsaxPlusLinear.tick_square,
color: context.theme.colorScheme.primary,
),
const Gap(8),
Expand Down
42 changes: 42 additions & 0 deletions lib/src/core/l10n/localization.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:base_starter/src/core/l10n/generated/app_localizations.g.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

/// Localization class which is used to localize app.
/// This class provides handy methods and tools.
/// Usage:
/// Before using L10n.localizations, ensure to call L10n.load(locale).
/// Example:
/// L10n.load(Locale('en'));
/// var myString = L10n.localizations.someTranslation;
final class L10n {
static late AppLocalizations _localizations;

/// Initialize the L10n class with the correct localization
static void load(Locale locale) {
_localizations = lookupAppLocalizations(locale);
}

/// Access localized strings directly
static AppLocalizations get current => _localizations;

static LocalizationsDelegate<Object> get delegate =>
AppLocalizations.delegate;

static List<Locale> get supportedLocales => AppLocalizations.supportedLocales;

static Locale get computeDefaultLocale {
final locale = WidgetsBinding.instance.platformDispatcher.locale;

if (AppLocalizations.delegate.isSupported(locale)) return locale;

return const Locale('en');
}

static List<LocalizationsDelegate<dynamic>> get delegates => [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
];
}
File renamed without changes.
File renamed without changes.
22 changes: 0 additions & 22 deletions lib/src/core/localization/localization.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import 'package:base_starter/src/common/constants/exception_keys.dart';
import 'package:base_starter/src/common/utils/utils.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:dio/dio.dart';

/// `DioInterceptor` - This class is used to intercept `dio` errors.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/features/auth/presentation/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:base_starter/src/common/presentation/widgets/buttons/app_button.
import 'package:base_starter/src/common/presentation/widgets/dialogs/app_dialogs.dart';
import 'package:base_starter/src/common/presentation/widgets/dialogs/toaster.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:base_starter/src/features/auth/bloc/auth/auth_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down
7 changes: 4 additions & 3 deletions lib/src/features/home/presentation/home.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/common/utils/extensions/string_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:base_starter/src/features/home/state/counter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gap/gap.dart';
import 'package:iconsax_plus/iconsax_plus.dart';

class HomePage extends ConsumerWidget {
const HomePage({super.key});
Expand All @@ -25,13 +26,13 @@ class HomePage extends ConsumerWidget {
FloatingActionButton(
heroTag: 'increment',
onPressed: () => ref.read(counterProvider.notifier).increment(),
child: const Icon(Icons.add),
child: const Icon(IconsaxPlusLinear.add),
),
const Gap(8),
FloatingActionButton(
heroTag: 'decrement',
onPressed: () => ref.read(counterProvider.notifier).decrement(),
child: const Icon(Icons.remove),
child: const Icon(IconsaxPlusLinear.minus),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import 'package:base_starter/flavors.dart';
import 'package:base_starter/src/common/constants/app_constants.dart';
import 'package:base_starter/src/common/constants/preferences.dart';
import 'package:base_starter/src/core/database/src/preferences/app_config_manager.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/localization/localization.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:base_starter/src/core/rest_client/dio_rest_client/src/rest_client_dio.dart';
import 'package:base_starter/src/features/auth/bloc/auth/auth_bloc.dart';
import 'package:base_starter/src/features/auth/bloc/user/user_cubit.dart';
Expand Down Expand Up @@ -79,9 +78,9 @@ mixin InitializationSteps {

final localeFuture = localeRepository.getLocale();
final theme = await themeRepository.getTheme();
final locale = await localeFuture ?? Localization.computeDefaultLocale;
final locale = await localeFuture ?? L10n.computeDefaultLocale;

await L10n.load(locale);
L10n.load(locale);

final initialState = IdleSettingsState(appTheme: theme, locale: locale);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'package:base_starter/src/core/assets/generated/assets.gen.dart';
import 'package:base_starter/src/core/di/containers/dependencies.dart';
import 'package:base_starter/src/core/di/containers/repositories.dart';
import 'package:base_starter/src/core/di/dependencies_scope.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/localization/localization.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:base_starter/src/features/settings/bloc/settings_bloc.dart';
import 'package:base_starter/src/features/settings/core/data/locale/locale_datasource.dart';
import 'package:base_starter/src/features/settings/core/data/locale/locale_repository.dart';
Expand All @@ -19,6 +18,7 @@ import 'package:base_starter/src/features/settings/presentation/settings.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:iconsax_plus/iconsax_plus.dart';
import 'package:ispect/ispect.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:talker/talker.dart';
Expand Down Expand Up @@ -121,8 +121,8 @@ class _InitializationFailedAppState extends State<InitializationFailedApp> {
darkTheme: _settingsState?.appTheme?.darkTheme,
themeMode: _settingsState?.appTheme?.mode,
locale: _settingsState?.locale,
localizationsDelegates: Localization.delegates,
supportedLocales: L10n.delegate.supportedLocales,
localizationsDelegates: L10n.delegates,
supportedLocales: L10n.supportedLocales,
home: _View(
error: widget.error,
retryInitialization: widget.retryInitialization != null
Expand Down Expand Up @@ -185,7 +185,7 @@ class _View extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(right: 8),
child: IconButton.filledTonal(
icon: const Icon(Icons.monitor_heart),
icon: const Icon(IconsaxPlusLinear.activity),
onPressed: () {
Navigator.push(
context,
Expand Down Expand Up @@ -237,7 +237,8 @@ class _View extends StatelessWidget {
),
const Gap(8),
const Icon(
Icons.refresh_rounded,
IconsaxPlusLinear.refresh_2,
size: 18,
color: Colors.white,
),
],
Expand Down
10 changes: 8 additions & 2 deletions lib/src/features/profile/presentation/profile.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:base_starter/src/app/router/router.dart';
import 'package:base_starter/src/common/utils/extensions/context_extension.dart';
import 'package:base_starter/src/core/localization/generated/l10n.dart';
import 'package:base_starter/src/core/l10n/localization.dart';
import 'package:flutter/material.dart';
import 'package:iconsax_plus/iconsax_plus.dart';

class ProfilePage extends StatefulWidget {
const ProfilePage({super.key});
Expand All @@ -11,6 +12,11 @@ class ProfilePage extends StatefulWidget {
}

class _ProfilePageState extends State<ProfilePage> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
Expand All @@ -24,7 +30,7 @@ class _ProfilePageState extends State<ProfilePage> {
padding: const EdgeInsets.only(right: 16),
child: IconButton.filledTonal(
icon: const Icon(
Icons.settings_rounded,
IconsaxPlusLinear.setting_2,
color: Colors.white,
),
onPressed: () => SettingsRoute(
Expand Down
Loading

0 comments on commit 8152fff

Please sign in to comment.