diff --git a/app/env/.dev b/app/env/.dev new file mode 100644 index 0000000..e93ecf0 --- /dev/null +++ b/app/env/.dev @@ -0,0 +1,3 @@ +API_URL=https://dummyjson.com +SECRET_KEY=your_secret_key_here +ENV=dev \ No newline at end of file diff --git a/app/lib/main/env/main.dart b/app/lib/main.dart similarity index 100% rename from app/lib/main/env/main.dart rename to app/lib/main.dart diff --git a/app/lib/main/app.dart b/app/lib/main/app.dart index 4d162e1..7ed667d 100644 --- a/app/lib/main/app.dart +++ b/app/lib/main/app.dart @@ -41,7 +41,7 @@ class App extends StatelessWidget { builder: (context, child) { return BlocListener( listener: (_, state) { - if (state is Success) { + if (state is RSuccess) { switch (state.data) { case AuthStateAuthenticated _: _goRouter.go('/home'); diff --git a/app/lib/main/env/env_config.dart b/app/lib/main/env/env_config.dart index bf43faf..a14d0f7 100644 --- a/app/lib/main/env/env_config.dart +++ b/app/lib/main/env/env_config.dart @@ -1,3 +1,4 @@ +import 'package:domain/env/env_config.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; enum Flavor { @@ -27,7 +28,6 @@ class Environment { } class FlavorValues { - FlavorValues(); } @@ -47,7 +47,7 @@ class FlavorConfig { flavor.toString(), values, ); - switch(flavor) { + switch (flavor) { case Flavor.dev: EnvConfig.env = EnvConfig.kDevEnv; break; diff --git a/app/lib/main/init.dart b/app/lib/main/init.dart index be6441d..08c6769 100644 --- a/app/lib/main/init.dart +++ b/app/lib/main/init.dart @@ -1,17 +1,13 @@ import 'package:app/main/app.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:app/main/env/env_config.dart'; import 'package:common/init.dart'; import 'package:data/init.dart'; import 'package:domain/init.dart'; -import 'package:example_domain/init.dart'; -import 'package:example_data/init.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get_it/get_it.dart'; import 'package:url_strategy/url_strategy.dart'; -import 'env/env_config.dart'; - void init() async { WidgetsFlutterBinding.ensureInitialized(); await initialize(); @@ -27,8 +23,4 @@ Future initialize() async { await CommonInit.initialize(getIt); await DataInit.initialize(getIt); await DomainInit.initialize(getIt); - - // Example Module init - await ExampleDataInit.initialize(getIt); - await ExampleDomainInit.initialize(getIt); } diff --git a/app/lib/presentation/themes/resources/dark_theme_colors.dart b/app/lib/presentation/themes/resources/dark_theme_colors.dart index ad8c579..d4a5746 100644 --- a/app/lib/presentation/themes/resources/dark_theme_colors.dart +++ b/app/lib/presentation/themes/resources/dark_theme_colors.dart @@ -5,24 +5,24 @@ import 'package:app/presentation/themes/resources/app_theme_data.dart'; class DarkThemeColors implements ThemeColors { /// 10: onPrimaryContainer /// 40: primary + /// 80: inversePrimary /// 90: primaryContainer /// 100: onPrimary @override - // TODO: implement primary - MaterialColor get primary => const MaterialColor(0xFFFFFFDE, { - 0: Color(0xFFFFFFDE), - 10: Color(0xFFFFFFDE), - 20: Color(0xFFFFFFDE), - 30: Color(0xFFFFFFDE), - 40: Color(0xFFFFFFDE), - 50: Color(0xFFFFFFDE), - 60: Color(0xFFFFFFDE), - 70: Color(0xFFFFFFDE), - 80: Color(0xFFFFFFDE), - 90: Color(0xFF6750A4), - 95: Color(0xFFFFFFDE), - 99: Color(0xFF6750A4), - 100: Color(0xFF6750A4), + MaterialColor get primary => const MaterialColor(0xFFD0BCFF, { + 0: Color(0xFF000000), + 10: Color(0xFF21005D), // onPrimaryContainer + 20: Color(0xFF381E72), + 30: Color(0xFF4F378B), + 40: Color(0xFF6750A4), // inversePrimary (light mode primary) + 50: Color(0xFF7F67BE), + 60: Color(0xFF9A82DB), + 70: Color(0xFFB69DF8), + 80: Color(0xFFD0BCFF), // primary - Main brand color in dark + 90: Color(0xFFEADDFF), // primaryContainer + 95: Color(0xFFF6EDFF), + 99: Color(0xFFFFFBFE), + 100: Color(0xFFFFFFFF), // onPrimary }); /// 10: onSecondaryContainer @@ -30,21 +30,20 @@ class DarkThemeColors implements ThemeColors { /// 90: secondaryContainer /// 100: onSecondary @override - // TODO: implement secondary - MaterialColor get secondary => const MaterialColor(0xFFFFFFFD, { - 0: Color(0xFFFFFFDE), - 10: Color(0xFF1D192B), - 20: Color(0xFFFFFFDE), - 30: Color(0xFFFFFFDE), - 40: Color(0xFFFFFFFD), - 50: Color(0xFFFFFFDE), - 60: Color(0xFFFFFFDE), - 70: Color(0xFFFFFFDE), - 80: Color(0xFFFFFFDE), - 90: Color(0xFF1D192B), - 95: Color(0xFFFFFFDE), - 99: Color(0xFF1D192B), - 100: Color(0xFF1D192B), + MaterialColor get secondary => const MaterialColor(0xFFCCC2DC, { + 0: Color(0xFF000000), + 10: Color(0xFF1D192B), // onSecondaryContainer + 20: Color(0xFF332D41), + 30: Color(0xFF4A4458), + 40: Color(0xFF625B71), + 50: Color(0xFF7A7289), + 60: Color(0xFF958DA5), + 70: Color(0xFFB0A7C0), + 80: Color(0xFFCCC2DC), // secondary + 90: Color(0xFFE8DEF8), // secondaryContainer + 95: Color(0xFFF6EDFF), + 99: Color(0xFFFFFBFE), + 100: Color(0xFFFFFFFF), // onSecondary }); /// 10: onTertiaryContainer @@ -52,21 +51,20 @@ class DarkThemeColors implements ThemeColors { /// 90: tertiaryContainer /// 100: onTertiary @override - // TODO: implement tertiary - MaterialColor get tertiary => const MaterialColor(0xFFFFFFDE, { - 0: Color(0xFFFFFFDE), - 10: Color(0xFFFFFFDE), - 20: Color(0xFFFFFFDE), - 30: Color(0xFFFFFFDE), - 40: Color(0xFFFFFFDE), - 50: Color(0xFFFFFFDE), - 60: Color(0xFFFFFFDE), - 70: Color(0xFFFFFFDE), - 80: Color(0xFFFFFFDE), - 90: Color(0xFFF0524D), - 95: Color(0xFFFFFFDE), - 99: Color(0xFFFFFFDE), - 100: Color(0xFFF0524D), + MaterialColor get tertiary => const MaterialColor(0xFFEFB8C8, { + 0: Color(0xFF000000), + 10: Color(0xFF31111D), // onTertiaryContainer + 20: Color(0xFF492532), + 30: Color(0xFF633B48), + 40: Color(0xFF7D5260), + 50: Color(0xFF986977), + 60: Color(0xFFB58392), + 70: Color(0xFFD29DAC), + 80: Color(0xFFEFB8C8), // tertiary + 90: Color(0xFFFFD8E4), // tertiaryContainer + 95: Color(0xFFFFECF1), + 99: Color(0xFFFFFBFA), + 100: Color(0xFFFFFFFF), // onTertiary }); /// 10: onErrorContainer @@ -74,63 +72,61 @@ class DarkThemeColors implements ThemeColors { /// 90: errorContainer /// 100: onError @override - // TODO: implement error - MaterialColor get error => const MaterialColor(0xFFB3261E, { - 0: Color(0xFFFFFFDE), - 10: Color(0xFF410E0B), - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), + MaterialColor get error => const MaterialColor(0xFFF2B8B5, { + 0: Color(0xFF000000), + 10: Color(0xFF410E0B), // onErrorContainer + 20: Color(0xFF601410), + 30: Color(0xFF8C1D18), 40: Color(0xFFB3261E), - 50: Color(0xFFF0524D), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFF9DEDC), - 95: Color(0xFFF0524D), - 99: Color(0xFFFFD8E4), - 100: Color(0xFFFFFFFF), + 50: Color(0xFFDC362E), + 60: Color(0xFFE46962), + 70: Color(0xFFEC928E), + 80: Color(0xFFF2B8B5), // error + 90: Color(0xFFF9DEDC), // errorContainer + 95: Color(0xFFFCEEEE), + 99: Color(0xFFFFFBF9), + 100: Color(0xFFFFFFFF), // onError }); - /// 0: shadow - /// 10: onBackground / onSurface - /// 99: background / surface + /// 0: shadow / scrim + /// 10: onSurface + /// 20: inverseSurface + /// 99: surface @override - // TODO: implement neutral - MaterialColor get neutral => const MaterialColor(0xFF410E0B, { - 0: Color(0xFF410E0B), - 10: Color(0xFF410E0B), - 20: Color(0xFF410E0B), - 30: Color(0xFF410E0B), - 40: Color(0xFF410E0B), - 50: Color(0xFF410E0B), - 60: Color(0xFF410E0B), - 70: Color(0xFF410E0B), - 80: Color(0xFF410E0B), - 90: Color(0xFF410E0B), - 95: Color(0xFF410E0B), - 99: Color(0xFF410E0B), - 100: Color(0xFF410E0B), + MaterialColor get neutral => const MaterialColor(0xFF1C1B1F, { + 0: Color(0xFF000000), // shadow / scrim + 10: Color(0xFFE6E1E5), // onSurface - Main text color in dark (light color) + 20: Color(0xFFF4EFF4), // inverseSurface (light color) + 30: Color(0xFFAEAAAE), + 40: Color(0xFF939094), + 50: Color(0xFF787579), + 60: Color(0xFF605D62), + 70: Color(0xFF484649), + 80: Color(0xFF313033), + 90: Color(0xFF1C1B1F), + 95: Color(0xFF141316), + 99: Color(0xFF141316), // surface - Main background in dark (dark color) + 100: Color(0xFF000000), }); /// 30: onSurfaceVariant /// 50: outline /// 80: outlineVariant - /// 90: surfaceVariant + /// 90: surfaceContainerHighest @override - // TODO: implement neutralVariant - MaterialColor get neutralVariant => const MaterialColor(0xFFFDDDDE, { + MaterialColor get neutralVariant => const MaterialColor(0xFF49454F, { 0: Color(0xFF000000), - 10: Color(0xFF49454F), - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), - 40: Color(0xFFFDDDDE), - 50: Color(0xFFF0524D), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFF0524D), - 95: Color(0xFFFDDDDE), - 99: Color(0xFFF0524D), - 100: Color(0xFFF0524D), + 10: Color(0xFFF5EEFA), + 20: Color(0xFFE7E0EC), + 30: Color(0xFFC9C5D0), // onSurfaceVariant - Secondary text (lighter in dark) + 40: Color(0xFFAEA9B4), + 50: Color(0xFF938F99), // outline - Borders, dividers + 60: Color(0xFF79747E), + 70: Color(0xFF605D66), + 80: Color(0xFF49454F), // outlineVariant - Subtle borders + 90: Color(0xFF322F37), // surfaceContainerHighest + 95: Color(0xFF1D1A22), + 99: Color(0xFF000000), + 100: Color(0xFF000000), }); } diff --git a/app/lib/presentation/themes/resources/light_theme_colors.dart b/app/lib/presentation/themes/resources/light_theme_colors.dart index d558dbd..8713f3f 100644 --- a/app/lib/presentation/themes/resources/light_theme_colors.dart +++ b/app/lib/presentation/themes/resources/light_theme_colors.dart @@ -4,24 +4,24 @@ import 'package:flutter/material.dart'; class LightThemeColors implements ThemeColors { /// 10: onPrimaryContainer /// 40: primary + /// 80: inversePrimary /// 90: primaryContainer /// 100: onPrimary @override - // TODO: implement primary MaterialColor get primary => const MaterialColor(0xFF6750A4, { 0: Color(0xFF000000), - 10: Color(0xFF21005D), // Default Bottom navigation bar labels - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), - 40: Color(0xFF6750A4), // Default Primary Buttons background - 50: Color(0xFFF0524D), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFEADDFF), // Default Bottom navigation bar background or variant button - 95: Color(0xFFF0524D), - 99: Color(0xFFEADDFF), - 100: Color(0xFFFFFFFF), + 10: Color(0xFF21005D), // onPrimaryContainer + 20: Color(0xFF381E72), + 30: Color(0xFF4F378B), + 40: Color(0xFF6750A4), // primary - Main brand color + 50: Color(0xFF7F67BE), + 60: Color(0xFF9A82DB), + 70: Color(0xFFB69DF8), + 80: Color(0xFFD0BCFF), // inversePrimary + 90: Color(0xFFEADDFF), // primaryContainer + 95: Color(0xFFF6EDFF), + 99: Color(0xFFFFFBFE), + 100: Color(0xFFFFFFFF), // onPrimary }); /// 10: onSecondaryContainer @@ -29,21 +29,20 @@ class LightThemeColors implements ThemeColors { /// 90: secondaryContainer /// 100: onSecondary @override - // TODO: implement secondary MaterialColor get secondary => const MaterialColor(0xFF625B71, { 0: Color(0xFF000000), - 10: Color(0xFF1D192B), - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), - 40: Color(0xFF625B71), - 50: Color(0xFFF0524D), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFE8DEF8), // Default Bottom navigation labels color - 95: Color(0xFFF0524D), - 99: Color(0xFFE8DEF8), - 100: Color(0xFFFFFFFF), + 10: Color(0xFF1D192B), // onSecondaryContainer + 20: Color(0xFF332D41), + 30: Color(0xFF4A4458), + 40: Color(0xFF625B71), // secondary + 50: Color(0xFF7A7289), + 60: Color(0xFF958DA5), + 70: Color(0xFFB0A7C0), + 80: Color(0xFFCCC2DC), + 90: Color(0xFFE8DEF8), // secondaryContainer + 95: Color(0xFFF6EDFF), + 99: Color(0xFFFFFBFE), + 100: Color(0xFFFFFFFF), // onSecondary }); /// 10: onTertiaryContainer @@ -51,21 +50,20 @@ class LightThemeColors implements ThemeColors { /// 90: tertiaryContainer /// 100: onTertiary @override - // TODO: implement tertiary MaterialColor get tertiary => const MaterialColor(0xFF7D5260, { 0: Color(0xFF000000), - 10: Color(0xFF31111D), - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), - 40: Color(0xFF7D5260), - 50: Color(0xFFF0524D), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFFFD8E4), - 95: Color(0xFFF0524D), - 99: Color(0xFFF0524D), - 100: Color(0xFFFFFFFF), + 10: Color(0xFF31111D), // onTertiaryContainer + 20: Color(0xFF492532), + 30: Color(0xFF633B48), + 40: Color(0xFF7D5260), // tertiary + 50: Color(0xFF986977), + 60: Color(0xFFB58392), + 70: Color(0xFFD29DAC), + 80: Color(0xFFEFB8C8), + 90: Color(0xFFFFD8E4), // tertiaryContainer + 95: Color(0xFFFFECF1), + 99: Color(0xFFFFFBFA), + 100: Color(0xFFFFFFFF), // onTertiary }); /// 10: onErrorContainer @@ -73,63 +71,61 @@ class LightThemeColors implements ThemeColors { /// 90: errorContainer /// 100: onError @override - // TODO: implement error MaterialColor get error => const MaterialColor(0xFFB3261E, { 0: Color(0xFF000000), - 10: Color(0xFF410E0B), - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), - 40: Color(0xFFB3261E), // Default Error text color & border color - 50: Color(0xFFF0524D), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFF9DEDC), - 95: Color(0xFFF0524D), - 99: Color(0xFFFFD8E4), - 100: Color(0xFFFFFFFF), + 10: Color(0xFF410E0B), // onErrorContainer + 20: Color(0xFF601410), + 30: Color(0xFF8C1D18), + 40: Color(0xFFB3261E), // error + 50: Color(0xFFDC362E), + 60: Color(0xFFE46962), + 70: Color(0xFFEC928E), + 80: Color(0xFFF2B8B5), + 90: Color(0xFFF9DEDC), // errorContainer + 95: Color(0xFFFCEEEE), + 99: Color(0xFFFFFBF9), + 100: Color(0xFFFFFFFF), // onError }); - /// 0: shadow - /// 10: onBackground / onSurface - /// 99: background / surface + /// 0: shadow / scrim + /// 10: onSurface + /// 20: inverseSurface + /// 99: surface @override - // TODO: implement neutral - MaterialColor get neutral => const MaterialColor(0xFFFFFFFF, { - 0: Color(0xFFFFFFFF), // Default Shadow - 10: Color(0xFFFFFFFF), // Default Text color - 20: Color(0xFFFFFFFF), - 30: Color(0xFFFFFFFF), - 40: Color(0xFFFFFFFF), - 50: Color(0xFFFFFFFF), - 60: Color(0xFFFFFFFF), - 70: Color(0xFFFFFFFF), - 80: Color(0xFFFFFFFF), - 90: Color(0xFFFFFFFF), - 95: Color(0xFFFFFFFF), - 99: Color(0xFFFFFFFF), // Default scaffold background + MaterialColor get neutral => const MaterialColor(0xFF1C1B1F, { + 0: Color(0xFF000000), // shadow / scrim + 10: Color(0xFF1C1B1F), // onSurface - Main text color + 20: Color(0xFF313033), // inverseSurface + 30: Color(0xFF484649), + 40: Color(0xFF605D62), + 50: Color(0xFF787579), + 60: Color(0xFF939094), + 70: Color(0xFFAEAAAE), + 80: Color(0xFFC9C5CA), + 90: Color(0xFFE6E1E5), + 95: Color(0xFFF4EFF4), + 99: Color(0xFFFFFBFE), // surface - Main background 100: Color(0xFFFFFFFF), }); /// 30: onSurfaceVariant /// 50: outline /// 80: outlineVariant - /// 90: surfaceVariant + /// 90: surfaceContainerHighest @override - // TODO: implement neutralVariant - MaterialColor get neutralVariant => const MaterialColor(0xFFF0524D, { + MaterialColor get neutralVariant => const MaterialColor(0xFF49454F, { 0: Color(0xFF000000), - 10: Color(0xFF49454F), - 20: Color(0xFFF0524D), - 30: Color(0xFFF0524D), // Labels in TextFormFields - 40: Color(0xFFF0524D), - 50: Color(0xFFFFFFFF), - 60: Color(0xFFF0524D), - 70: Color(0xFFF0524D), - 80: Color(0xFFF0524D), - 90: Color(0xFFF0524D), - 95: Color(0xFFF0524D), - 99: Color(0xFFE7E0EC), - 100: Color(0xFFF0524D), + 10: Color(0xFF1D1A22), + 20: Color(0xFF322F37), + 30: Color(0xFF49454F), // onSurfaceVariant - Secondary text, icons + 40: Color(0xFF605D66), + 50: Color(0xFF79747E), // outline - Borders, dividers + 60: Color(0xFF938F99), + 70: Color(0xFFAEA9B4), + 80: Color(0xFFC9C5D0), // outlineVariant - Subtle borders + 90: Color(0xFFE7E0EC), // surfaceContainerHighest + 95: Color(0xFFF5EEFA), + 99: Color(0xFFFFFBFE), + 100: Color(0xFFFFFFFF), }); } diff --git a/app/lib/presentation/ui/pages/home/home_page.dart b/app/lib/presentation/ui/pages/home/home_page.dart index b147341..acd94a0 100644 --- a/app/lib/presentation/ui/pages/home/home_page.dart +++ b/app/lib/presentation/ui/pages/home/home_page.dart @@ -1,19 +1,12 @@ -import 'package:app/main/init.dart'; import 'package:flutter/widgets.dart'; import 'package:app/presentation/ui/pages/home/home_view.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:example_domain/services/product_service.dart'; class HomePage extends StatelessWidget { - ProductService get _productsService => getIt(); - const HomePage({super.key}); @override Widget build(BuildContext context) { - return BlocProvider( - create: (_) => _productsService.productsCubit, - child: const HomeView(), - ); + /// TODO: add BlocProviders example here. + return HomeView(); } } diff --git a/app/lib/presentation/ui/pages/home/home_view.dart b/app/lib/presentation/ui/pages/home/home_view.dart index 5b84852..d3ed9d9 100644 --- a/app/lib/presentation/ui/pages/home/home_view.dart +++ b/app/lib/presentation/ui/pages/home/home_view.dart @@ -1,16 +1,7 @@ import 'package:app/main/init.dart'; -import 'package:common/core/failure/failure.dart'; -import 'package:common/core/resource.dart'; -import 'package:example_domain/models/product.dart'; import 'package:domain/services/auth_service.dart'; -import 'package:example_presentation/ui/product/products_list_widget.dart'; -import 'package:example_presentation/ui/product/products_loading.dart'; import 'package:flutter/material.dart'; -import 'package:example_domain/bloc/get_products/get_products_cubit.dart'; import 'package:app/presentation/ui/custom/app_theme_switch.dart'; -import 'package:app/presentation/ui/custom/failure_widget.dart'; - -import 'package:flutter_bloc/flutter_bloc.dart'; class HomeView extends StatelessWidget { AuthService get _authService => getIt(); @@ -29,19 +20,7 @@ class HomeView extends StatelessWidget { const AppThemeSwitch(), ], ), - body: BlocBuilder( - builder: (context, state) { - return switch (state) { - Loading _ => const ProductsLoading(), - Success> e => ProductsListWidget(products: e.data), - Error e => FailureWidget( - failure: e.exception, - onRetry: () => context.read(), - ), - _ => Container() - }; - }, - ), + body: const Text('Home Page'), ); } } diff --git a/app/lib/presentation/ui/pages/login/login_page.dart b/app/lib/presentation/ui/pages/login/login_page.dart index 13de3a3..17777c6 100644 --- a/app/lib/presentation/ui/pages/login/login_page.dart +++ b/app/lib/presentation/ui/pages/login/login_page.dart @@ -65,7 +65,7 @@ class _Loading extends StatelessWidget { return BlocBuilder( builder: (context, state) { return LoadingScreen( - isLoading: state is Loading, + isLoading: state is RLoading, ); }, ); diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 75e1768..c967b0a 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -39,7 +39,6 @@ dependencies: equatable: ^2.0.5 firebase_core: ^3.13.0 url_strategy: ^0.2.0 - flutter_dotenv: ^5.2.1 flutter_localizations: sdk: flutter domain: @@ -49,18 +48,9 @@ dependencies: data: path: ../modules/data - # Remove example dependencies - example_data: - path: ../example/example_data - example_domain: - path: ../example/example_domain - example_presentation: - path: ../example/example_presentation - http: ^1.5.0 melos: ^3.4.0 dev: ^1.0.0 - flutter_dotenv: ^5.2.1 dev_dependencies: bloc_test: ^9.0.2 @@ -84,8 +74,7 @@ flutter: # Remove example assets. assets: - assets/images/ - # remove example suffix - - env/.env.example + - env/ fonts: - family: Roboto Black fonts: diff --git a/example/example_data/.gitignore b/example/example_data/.gitignore deleted file mode 100644 index ac5aa98..0000000 --- a/example/example_data/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -build/ diff --git a/example/example_data/.metadata b/example/example_data/.metadata deleted file mode 100644 index bc3f0ae..0000000 --- a/example/example_data/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "300451adae589accbece3490f4396f10bdf15e6e" - channel: "stable" - -project_type: package diff --git a/example/example_data/CHANGELOG.md b/example/example_data/CHANGELOG.md deleted file mode 100644 index 41cc7d8..0000000 --- a/example/example_data/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/example/example_data/LICENSE b/example/example_data/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/example/example_data/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/example/example_data/README.md b/example/example_data/README.md deleted file mode 100644 index 02fe8ec..0000000 --- a/example/example_data/README.md +++ /dev/null @@ -1,39 +0,0 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. - -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. diff --git a/example/example_data/analysis_options.yaml b/example/example_data/analysis_options.yaml deleted file mode 100644 index a5744c1..0000000 --- a/example/example_data/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/example/example_data/lib/data_sources/local/README.md b/example/example_data/lib/data_sources/local/README.md deleted file mode 100644 index 5b1488e..0000000 --- a/example/example_data/lib/data_sources/local/README.md +++ /dev/null @@ -1,6 +0,0 @@ -### Local data source - -- Preferences. -- Local DB if needed. -- Cache. -- Get preloaded data in assets , e.g: Terms and conditions(you can add a .txt file with the T&C) \ No newline at end of file diff --git a/example/example_data/lib/data_sources/remote/README.md b/example/example_data/lib/data_sources/remote/README.md deleted file mode 100644 index de49d37..0000000 --- a/example/example_data/lib/data_sources/remote/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Remote data source - -- Api Connection \ No newline at end of file diff --git a/example/example_data/lib/data_sources/remote/abstract/product_data_source.dart b/example/example_data/lib/data_sources/remote/abstract/product_data_source.dart deleted file mode 100644 index 5a7337a..0000000 --- a/example/example_data/lib/data_sources/remote/abstract/product_data_source.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:common/core/failure/failure.dart'; -import 'package:common/core/result_type.dart'; - -import '../../../models/product_entity.dart'; - -abstract class ProductDataSource { - Future, Failure>> getProducts(); -} diff --git a/example/example_data/lib/data_sources/remote/concrete/product_data_source_impl.dart b/example/example_data/lib/data_sources/remote/concrete/product_data_source_impl.dart deleted file mode 100644 index 8724477..0000000 --- a/example/example_data/lib/data_sources/remote/concrete/product_data_source_impl.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:common/core/failure/failure.dart'; -import 'package:common/core/failure/failure_mapper.dart'; -import 'package:common/core/result_type.dart'; -import 'package:dio/dio.dart'; - -import '../../../models/product_entity.dart'; -import '../abstract/product_data_source.dart'; - -class ProductDataSourceImpl extends ProductDataSource { - final Dio _dio; - - ProductDataSourceImpl(this._dio); - - @override - Future, Failure>> getProducts() async { - try { - final response = await _dio.get(NetworkConstants.productsPath); - final products = (response.data['products'] as List) - .map((e) => ProductEntity.fromMap(e)) - .toList(); - return TSuccess(products); - } on DioException catch (e) { - return TError(e.toFailure()); - } catch (e) { - return TError(UnexpectedFailure(e.toString())); - } - } -} - -class NetworkConstants { - static const productsPath = "/products"; - static const baseUrl = "http://www.example.com"; -} diff --git a/example/example_data/lib/init.dart b/example/example_data/lib/init.dart deleted file mode 100644 index 9c1e15b..0000000 --- a/example/example_data/lib/init.dart +++ /dev/null @@ -1,22 +0,0 @@ - -import 'package:example_data/repositories/product_repository_impl.dart'; -import 'package:example_domain/repositories/product_repository.dart'; - -import 'package:get_it/get_it.dart'; - -import 'data_sources/remote/abstract/product_data_source.dart'; -import 'data_sources/remote/concrete/product_data_source_impl.dart'; - -class ExampleDataInit { - static Future initialize(GetIt getIt) async { - - getIt.registerLazySingleton( - () => ProductDataSourceImpl(getIt()), - ); - - //Repositories - getIt.registerLazySingleton( - () => ProductRepositoryImpl(getIt()), - ); - } -} diff --git a/example/example_data/lib/models/product_entity.dart b/example/example_data/lib/models/product_entity.dart deleted file mode 100644 index c467072..0000000 --- a/example/example_data/lib/models/product_entity.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:example_domain/models/product.dart'; - -class ProductEntity { - final int id; - final String title; - final String description; - final String thumbnail; - - ProductEntity(this.id, this.title, this.description, this.thumbnail); - - Map toMap() { - return { - 'id': id, - 'title': title, - 'description': description, - 'thumbnail': thumbnail, - }; - } - - factory ProductEntity.fromMap(Map map) { - return ProductEntity( - map['id'] as int, - map['title'] as String, - map['description'] as String, - map['thumbnail'] as String, - ); - } -} - -extension ProductEntityExtension on ProductEntity { - Product toProduct() { - return Product( - id, - title, - description, - thumbnail, - ); - } -} diff --git a/example/example_data/lib/repositories/product_repository_impl.dart b/example/example_data/lib/repositories/product_repository_impl.dart deleted file mode 100644 index 1d6318c..0000000 --- a/example/example_data/lib/repositories/product_repository_impl.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:common/core/failure/failure.dart'; -import 'package:common/core/result_type.dart'; -import 'package:example_domain/repositories/product_repository.dart'; - -import '../data_sources/remote/abstract/product_data_source.dart'; -import 'package:example_domain/models/product.dart'; -import 'package:example_data/models/product_entity.dart'; - -class ProductRepositoryImpl implements ProductRepository { - final ProductDataSource _productDataSource; - - ProductRepositoryImpl(this._productDataSource); - - @override - Future, Failure>> getProducts() async { - final productResult = await _productDataSource.getProducts(); - return productResult.mapSuccess( - (products) => products.map((e) => e.toProduct()).toList(), - ); - } -} diff --git a/example/example_data/pubspec.yaml b/example/example_data/pubspec.yaml deleted file mode 100644 index b059124..0000000 --- a/example/example_data/pubspec.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: example_data -description: "A new Flutter package project." -version: 0.0.1 -publish_to: none - -environment: - sdk: '>=3.3.3 <4.0.0' - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - example_domain: - path: ../example_domain - common: - path: ../../modules/common - data: - path: ../../modules/data - dio: ^5.1.2 - get_it: ^7.6.0 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^3.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/example/example_domain/.gitignore b/example/example_domain/.gitignore deleted file mode 100644 index ac5aa98..0000000 --- a/example/example_domain/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -build/ diff --git a/example/example_domain/.metadata b/example/example_domain/.metadata deleted file mode 100644 index bc3f0ae..0000000 --- a/example/example_domain/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "300451adae589accbece3490f4396f10bdf15e6e" - channel: "stable" - -project_type: package diff --git a/example/example_domain/CHANGELOG.md b/example/example_domain/CHANGELOG.md deleted file mode 100644 index 41cc7d8..0000000 --- a/example/example_domain/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/example/example_domain/LICENSE b/example/example_domain/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/example/example_domain/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/example/example_domain/README.md b/example/example_domain/README.md deleted file mode 100644 index 02fe8ec..0000000 --- a/example/example_domain/README.md +++ /dev/null @@ -1,39 +0,0 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. - -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. diff --git a/example/example_domain/analysis_options.yaml b/example/example_domain/analysis_options.yaml deleted file mode 100644 index a5744c1..0000000 --- a/example/example_domain/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/example/example_domain/lib/bloc/base_bloc_state.dart b/example/example_domain/lib/bloc/base_bloc_state.dart deleted file mode 100644 index 138433f..0000000 --- a/example/example_domain/lib/bloc/base_bloc_state.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:common/core/resource.dart'; -import 'package:common/core/result_type.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -class BaseBlocState extends Cubit { - BaseBlocState(super.initialState); - - void isLoading() { - emit(Loading()); - } - - void isSuccess(T data) { - emit(Success(data)); - } - - void isError(E? error) { - emit(Error(exception: error)); - } - - void onResult(ResultType result) { - switch (result) { - case TSuccess e: - isSuccess(e.data); - case TError e: - isError(e.error); - } - } -} diff --git a/example/example_domain/lib/bloc/get_products/get_products_cubit.dart b/example/example_domain/lib/bloc/get_products/get_products_cubit.dart deleted file mode 100644 index 5bf341d..0000000 --- a/example/example_domain/lib/bloc/get_products/get_products_cubit.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:common/core/failure/failure.dart'; -import 'package:common/core/mixins/cancelable_cubit_mixin.dart'; -import 'package:common/core/resource.dart'; -import 'package:example_domain/bloc/base_bloc_state.dart'; -import 'package:example_domain/models/product.dart'; - -class GetProductsCubit extends BaseBlocState, Failure> - with CancelableCubitMixin { - GetProductsCubit() : super(Loading()); -} diff --git a/example/example_domain/lib/init.dart b/example/example_domain/lib/init.dart deleted file mode 100644 index 7f00e89..0000000 --- a/example/example_domain/lib/init.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:example_domain/services/product_service.dart'; -import 'package:get_it/get_it.dart'; -import 'bloc/get_products/get_products_cubit.dart'; - -class ExampleDomainInit { - static Future initialize(GetIt getIt) async { - getIt.registerSingleton(GetProductsCubit()); - - //Services - getIt.registerLazySingleton(() => ProductService(getIt(), getIt())); - } -} diff --git a/example/example_domain/lib/models/product.dart b/example/example_domain/lib/models/product.dart deleted file mode 100644 index bccdd0b..0000000 --- a/example/example_domain/lib/models/product.dart +++ /dev/null @@ -1,8 +0,0 @@ -class Product { - final int id; - final String title; - final String description; - final String thumbnail; - - Product(this.id, this.title, this.description, this.thumbnail); -} diff --git a/example/example_domain/lib/repositories/product_repository.dart b/example/example_domain/lib/repositories/product_repository.dart deleted file mode 100644 index ab54691..0000000 --- a/example/example_domain/lib/repositories/product_repository.dart +++ /dev/null @@ -1,9 +0,0 @@ - -import 'package:common/core/failure/failure.dart'; -import 'package:common/core/result_type.dart'; - -import '../models/product.dart'; - -abstract class ProductRepository { - Future, Failure>> getProducts(); -} diff --git a/example/example_domain/lib/services/product_service.dart b/example/example_domain/lib/services/product_service.dart deleted file mode 100644 index c6df434..0000000 --- a/example/example_domain/lib/services/product_service.dart +++ /dev/null @@ -1,23 +0,0 @@ - - -import '../bloc/get_products/get_products_cubit.dart'; -import '../repositories/product_repository.dart'; - -class ProductService { - final ProductRepository _productRepository; - final GetProductsCubit _getProductsCubit; - - ProductService(this._productRepository, this._getProductsCubit) { - fetchProducts(); - } - - GetProductsCubit get productsCubit => _getProductsCubit; - - void fetchProducts() async { - _getProductsCubit.isLoading(); - final result = await _getProductsCubit.toCancelable( - _productRepository.getProducts(), - ); - _getProductsCubit.onResult(result); - } -} diff --git a/example/example_domain/pubspec.yaml b/example/example_domain/pubspec.yaml deleted file mode 100644 index 4468978..0000000 --- a/example/example_domain/pubspec.yaml +++ /dev/null @@ -1,57 +0,0 @@ -name: example_domain -description: "A new Flutter package project." -version: 0.0.1 -publish_to: none - -environment: - sdk: '>=3.3.3 <4.0.0' - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - common: - path: ../../modules/common - flutter_bloc: ^8.1.2 - get_it: ^7.6.0 -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^3.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/example/example_presentation/.gitignore b/example/example_presentation/.gitignore deleted file mode 100644 index ac5aa98..0000000 --- a/example/example_presentation/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -build/ diff --git a/example/example_presentation/.metadata b/example/example_presentation/.metadata deleted file mode 100644 index bc3f0ae..0000000 --- a/example/example_presentation/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "300451adae589accbece3490f4396f10bdf15e6e" - channel: "stable" - -project_type: package diff --git a/example/example_presentation/CHANGELOG.md b/example/example_presentation/CHANGELOG.md deleted file mode 100644 index 41cc7d8..0000000 --- a/example/example_presentation/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/example/example_presentation/LICENSE b/example/example_presentation/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/example/example_presentation/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/example/example_presentation/README.md b/example/example_presentation/README.md deleted file mode 100644 index 02fe8ec..0000000 --- a/example/example_presentation/README.md +++ /dev/null @@ -1,39 +0,0 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. - -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. diff --git a/example/example_presentation/analysis_options.yaml b/example/example_presentation/analysis_options.yaml deleted file mode 100644 index a5744c1..0000000 --- a/example/example_presentation/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/example/example_presentation/lib/ui/product/product_widget.dart b/example/example_presentation/lib/ui/product/product_widget.dart deleted file mode 100644 index 1a52d98..0000000 --- a/example/example_presentation/lib/ui/product/product_widget.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:example_domain/models/product.dart'; - -class ProductWidget extends StatelessWidget { - final Product product; - - const ProductWidget({super.key, required this.product}); - - @override - Widget build(BuildContext context) { - return Container( - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(8.0)), - color: Colors.green, - ), - padding: const EdgeInsets.all(8), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - product.title, - style: const TextStyle(fontSize: 18), - ), - const SizedBox(height: 16), - Text( - product.description, - style: const TextStyle(fontSize: 16), - ), - ], - ), - ), - const SizedBox(width: 16), - Image.network(product.thumbnail, width: 120), - ], - ), - ); - } -} diff --git a/example/example_presentation/lib/ui/product/products_list_widget.dart b/example/example_presentation/lib/ui/product/products_list_widget.dart deleted file mode 100644 index 704b105..0000000 --- a/example/example_presentation/lib/ui/product/products_list_widget.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:example_presentation/ui/product/product_widget.dart'; -import 'package:flutter/material.dart'; -import 'package:example_domain/models/product.dart'; - -class ProductsListWidget extends StatelessWidget { - final List products; - - const ProductsListWidget({super.key, required this.products}); - - @override - Widget build(BuildContext context) { - return ListView.separated( - padding: const EdgeInsets.all(8), - itemCount: products.length, - itemBuilder: (_, index) => ProductWidget( - product: products[index], - ), - separatorBuilder: (_, __) => const SizedBox(height: 8), - ); - } -} diff --git a/example/example_presentation/lib/ui/product/products_loading.dart b/example/example_presentation/lib/ui/product/products_loading.dart deleted file mode 100644 index 5e16010..0000000 --- a/example/example_presentation/lib/ui/product/products_loading.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart'; - -class ProductsLoading extends StatelessWidget { - const ProductsLoading({super.key}); - - @override - Widget build(BuildContext context) { - return const Center( - child: CircularProgressIndicator(), - ); - } -} diff --git a/example/example_presentation/pubspec.yaml b/example/example_presentation/pubspec.yaml deleted file mode 100644 index 3032222..0000000 --- a/example/example_presentation/pubspec.yaml +++ /dev/null @@ -1,57 +0,0 @@ -name: example_presentation -description: "A new Flutter package project." -version: 0.0.1 -publish_to: none -homepage: - -environment: - sdk: '>=3.3.3 <4.0.0' - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - example_domain: - path: ../example_domain - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^3.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/modules/common/lib/core/failure/failure.dart b/modules/common/lib/core/failure/failure.dart index 0b10585..b246d79 100644 --- a/modules/common/lib/core/failure/failure.dart +++ b/modules/common/lib/core/failure/failure.dart @@ -1,13 +1,9 @@ -sealed class Failure { +sealed class Failure implements Exception { String? message; Failure(this.message); } -class Exception extends Failure { - Exception([String? message]) : super(message); -} - class ConnectionFailure extends Failure { ConnectionFailure([String? message]) : super(message); } diff --git a/modules/common/lib/core/resource.dart b/modules/common/lib/core/resource.dart index 3fede0b..1846ced 100644 --- a/modules/common/lib/core/resource.dart +++ b/modules/common/lib/core/resource.dart @@ -1,15 +1,35 @@ -sealed class Resource {} +class Resource { + RState? state; + T? data; + Exception? exception; -class Loading extends Resource {} + Resource({this.state, this.data, this.exception}); -class Error extends Resource { - final E? exception; + RSuccess isSuccess(T data, {Exception? exception}) => + RSuccess(data: data); - Error({this.exception}); + RLoading isLoading() => RLoading(data: data); + + RError isError({Exception? exception}) => RError( + exception: exception, + data: data, + ); +} + +class RLoading extends Resource { + RLoading({super.state = RState.loading, super.data}); } -class Success extends Resource { - final T data; +class RSuccess extends Resource { + RSuccess({super.state = RState.success, required super.data}); +} + +class RError extends Resource { + RError({super.state = RState.error, super.data, required super.exception}); +} - Success(this.data); +enum RState { + loading, + success, + error; } diff --git a/modules/common/lib/core/result_type.dart b/modules/common/lib/core/result_type.dart index 0708c2c..77c23d2 100644 --- a/modules/common/lib/core/result_type.dart +++ b/modules/common/lib/core/result_type.dart @@ -1,39 +1,39 @@ -sealed class ResultType {} +sealed class ResultType {} -class TSuccess extends ResultType { +class TSuccess extends ResultType { final T data; TSuccess(this.data); } -class TError extends ResultType { - final E? error; +class TError extends ResultType { + final Exception? error; TError(this.error); } -extension ResultTypeExtension on ResultType { - ResultType map({ - required V Function(T data) success, - required B? Function(E? error) error, +extension ResultTypeExtension on ResultType { + ResultType map({ + required T Function(T data) success, + required Exception? Function(Exception? error) error, }) { return switch (this) { - TSuccess e => TSuccess(success(e.data)), - TError e => TError(error(e.error)), + TSuccess e => TSuccess(success(e.data)), + TError e => TError(error(e.error)), }; } - ResultType mapSuccess(V Function(T data) success) { + ResultType mapSuccess(Function(T data) success) { return switch (this) { - TSuccess e => TSuccess(success(e.data)), - TError e => TError(e.error), + TSuccess e => TSuccess(success(e.data)), + TError e => TError(e.error), }; } - ResultType mapError(B? Function(E? error) error) { + ResultType mapError(Function(Exception? error) error) { return switch (this) { - TSuccess e => TSuccess(e.data), - TError e => TError(error(e.error)), + TSuccess e => TSuccess(e.data), + TError e => TError(e.error), }; } } diff --git a/modules/data/lib/repositories/auth_repository_impl.dart b/modules/data/lib/repositories/auth_repository_impl.dart index 0f741ff..d0e117b 100644 --- a/modules/data/lib/repositories/auth_repository_impl.dart +++ b/modules/data/lib/repositories/auth_repository_impl.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:common/core/failure/failure.dart'; import 'package:common/core/result_type.dart'; import 'package:data/preferences/preferences.dart'; import 'package:domain/repositories/auth_repository.dart'; @@ -17,7 +16,7 @@ class AuthRepositoryImpl implements AuthRepository { } @override - Future> login( + Future> login( String username, String password, ) async { diff --git a/modules/domain/lib/bloc/auth/auth_cubit.dart b/modules/domain/lib/bloc/auth/auth_cubit.dart index 94d2f08..99f0f0d 100644 --- a/modules/domain/lib/bloc/auth/auth_cubit.dart +++ b/modules/domain/lib/bloc/auth/auth_cubit.dart @@ -1,20 +1,13 @@ -import 'package:common/core/failure/failure.dart'; import 'package:common/core/resource.dart'; -import 'package:domain/bloc/base_bloc_state.dart'; +import 'package:domain/bloc/base_cubit.dart'; import 'package:domain/bloc/auth/auth_state.dart'; -class AuthCubit extends BaseBlocState { - AuthCubit() : super(Success(AuthStateUnknown())); +class AuthCubit extends BaseCubit { + AuthCubit() : super(RSuccess(data: AuthStateUnknown())); - void isLogin() { - isSuccess(AuthStateAuthenticated()); - } + void isLogin() => isSuccess(AuthStateAuthenticated()); - void isLogOut() { - isSuccess(AuthStateUnauthenticated()); - } + void isLogOut() => isSuccess(AuthStateUnauthenticated()); - void isUnknown() { - isSuccess(AuthStateUnknown()); - } + void isUnknown() => isSuccess(AuthStateUnknown()); } diff --git a/modules/domain/lib/bloc/base_bloc_state.dart b/modules/domain/lib/bloc/base_bloc_state.dart deleted file mode 100644 index 138433f..0000000 --- a/modules/domain/lib/bloc/base_bloc_state.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:common/core/resource.dart'; -import 'package:common/core/result_type.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; - -class BaseBlocState extends Cubit { - BaseBlocState(super.initialState); - - void isLoading() { - emit(Loading()); - } - - void isSuccess(T data) { - emit(Success(data)); - } - - void isError(E? error) { - emit(Error(exception: error)); - } - - void onResult(ResultType result) { - switch (result) { - case TSuccess e: - isSuccess(e.data); - case TError e: - isError(e.error); - } - } -} diff --git a/modules/domain/lib/bloc/base_cubit.dart b/modules/domain/lib/bloc/base_cubit.dart new file mode 100644 index 0000000..5de7c1e --- /dev/null +++ b/modules/domain/lib/bloc/base_cubit.dart @@ -0,0 +1,28 @@ +import 'package:common/core/resource.dart'; +import 'package:common/core/result_type.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class BaseCubit extends Cubit> { + BaseCubit(super.initialState); + + void isLoading() { + emit(state.isLoading()); + } + + void isSuccess(T data) { + emit(state.isSuccess(data)); + } + + void isError(Exception? error) { + emit(state.isError(exception: error)); + } + + void onResult(ResultType result) { + switch (result) { + case TSuccess e: + isSuccess(e.data); + case TError e: + isError(e.error); + } + } +} diff --git a/modules/domain/lib/bloc/list_cubit.dart b/modules/domain/lib/bloc/list_cubit.dart new file mode 100644 index 0000000..2c7a5c0 --- /dev/null +++ b/modules/domain/lib/bloc/list_cubit.dart @@ -0,0 +1,23 @@ +import 'package:domain/bloc/base_cubit.dart'; + +class ListBlocState extends BaseCubit> { + ListBlocState(super.initialState); + + List get items => state.data ?? []; + + void addItem(T item) { + final currentList = List.from(state.data ?? []); + currentList.add(item); + isSuccess(currentList); + } + + void removeItem(T item) { + final currentList = List.from(state.data ?? []); + currentList.remove(item); + isSuccess(currentList); + } + + void clearList() => isSuccess([]); + + void setList(List items) => isSuccess(items); +} diff --git a/modules/domain/lib/repositories/auth_repository.dart b/modules/domain/lib/repositories/auth_repository.dart index 4212e85..e0f9117 100644 --- a/modules/domain/lib/repositories/auth_repository.dart +++ b/modules/domain/lib/repositories/auth_repository.dart @@ -1,12 +1,11 @@ import 'dart:async'; -import 'package:common/core/failure/failure.dart'; import 'package:common/core/result_type.dart'; abstract class AuthRepository { bool isLoggedIn(); - Future> login(String username, String password); + Future> login(String username, String password); Future logout(); } diff --git a/modules/domain/lib/services/auth_service.dart b/modules/domain/lib/services/auth_service.dart index 6680d3c..938828a 100644 --- a/modules/domain/lib/services/auth_service.dart +++ b/modules/domain/lib/services/auth_service.dart @@ -1,4 +1,3 @@ -import 'package:common/core/failure/failure.dart'; import 'package:common/core/result_type.dart'; import 'package:domain/bloc/auth/auth_cubit.dart'; import 'package:domain/repositories/auth_repository.dart'; @@ -13,9 +12,9 @@ class AuthService { _sessionCubit.isLoading(); final result = await _authRepository.login(username, password); switch (result) { - case TSuccess _: + case TSuccess _: _sessionCubit.isLogin(); - case TError _: + case TError _: _sessionCubit.isError(result.error); } } diff --git a/modules/domain/test/auth_cubit_test.dart b/modules/domain/test/auth_cubit_test.dart index 5c7d271..bf62fd8 100644 --- a/modules/domain/test/auth_cubit_test.dart +++ b/modules/domain/test/auth_cubit_test.dart @@ -18,9 +18,9 @@ void main() { test('emits AuthStateAuthenticated when isLogin is called', () { cubit.isLogin(); - expect(cubit.state, isA>()); + expect(cubit.state, isA>()); - final successState = cubit.state as Success; + final successState = cubit.state as RSuccess; expect(successState.data, isA()); }); @@ -28,9 +28,9 @@ void main() { test('emits AuthStateUnauthenticated when isLogOut is called', () { cubit.isLogOut(); - expect(cubit.state, isA>()); + expect(cubit.state, isA>()); - final successState = cubit.state as Success; + final successState = cubit.state as RSuccess; expect(successState.data, isA()); }); @@ -38,9 +38,9 @@ void main() { test('emits AuthStateUnknown when isUnknown is called', () { cubit.isUnknown(); - expect(cubit.state, isA>()); + expect(cubit.state, isA>()); - final successState = cubit.state as Success; + final successState = cubit.state as RSuccess; expect(successState.data, isA()); }); diff --git a/modules/domain/test/auth_service_test.dart b/modules/domain/test/auth_service_test.dart index 797d2b8..61d1796 100644 --- a/modules/domain/test/auth_service_test.dart +++ b/modules/domain/test/auth_service_test.dart @@ -1,4 +1,3 @@ -import 'package:common/core/failure/failure.dart'; import 'package:common/core/result_type.dart'; import 'package:domain/bloc/auth/auth_cubit.dart'; import 'package:domain/repositories/auth_repository.dart';