From ba791859994ac25babcc6796f157c5e667a0b94b Mon Sep 17 00:00:00 2001 From: Cagatay Ulusoy Date: Tue, 13 Aug 2024 23:29:06 +0300 Subject: [PATCH 1/3] Remove provider dependency from coffee maker nav2 example --- coffee_maker_navigator_2/lib/app.dart | 19 +- ..._maker_app_level_dependency_container.dart | 2 +- .../lib/domain/auth/auth_service.dart | 7 + coffee_maker_navigator_2/lib/main.dart | 6 +- .../di/add_water_dependency_container.dart | 18 +- .../ui/add_water/view/add_water_screen.dart | 73 ++++---- .../view_model/add_water_view_model.dart | 8 +- .../di/auth_screen_dependency_container.dart | 5 +- .../lib/ui/auth/view/auth_screen.dart | 97 +++++----- .../view_model/auth_screen_view_model.dart | 7 +- .../lib/ui/extensions/context_extensions.dart | 10 + .../view/onboarding_modal_sheet_page.dart | 10 +- .../di/orders_dependency_container.dart | 8 +- .../grind/grind_or_reject_modal_page.dart | 12 +- .../grind/reject_order_modal_page.dart | 13 +- .../offer_recommendation_modal_page.dart | 11 +- .../ready/serve_or_offer_modal_page.dart | 10 +- .../lib/ui/orders/view/orders_screen.dart | 175 +++++++++--------- .../coffee_order_list_view_for_step.dart | 42 ++--- .../view_model/orders_screen_view_model.dart | 21 +-- .../lib/ui/orders/widgets/top_bar.dart | 26 +-- .../ui/router/entities/app_route_page.dart | 10 +- .../entities/router_view_model_state.dart | 38 ---- .../ui/router/view/app_router_delegate.dart | 43 +++-- .../router/view_model/router_view_model.dart | 107 ++++------- .../ui/tutorials/view/tutorials_screen.dart | 5 +- .../lib/ui/widgets/app_navigation_drawer.dart | 9 +- coffee_maker_navigator_2/pubspec.yaml | 1 - ...pendency_container_subscription_mixin.dart | 33 ---- wolt_di/lib/src/dependency_injector.dart | 13 +- .../dependency_container_subscriber.dart | 8 + ...pendency_container_subscription_mixin.dart | 74 ++++++++ ..._with_view_model_dependency_container.dart | 8 + ...pendency_container_subscription_mixin.dart | 29 +++ .../lib/src/view_model/wolt_view_model.dart | 8 + wolt_di/lib/wolt_di.dart | 6 +- wolt_di/pubspec.yaml | 1 - 37 files changed, 498 insertions(+), 475 deletions(-) rename coffee_maker_navigator_2/lib/{ => ui/add_water}/di/add_water_dependency_container.dart (75%) rename coffee_maker_navigator_2/lib/{ => ui/auth}/di/auth_screen_dependency_container.dart (84%) create mode 100644 coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart rename coffee_maker_navigator_2/lib/{ => ui/orders}/di/orders_dependency_container.dart (75%) delete mode 100644 coffee_maker_navigator_2/lib/ui/router/entities/router_view_model_state.dart delete mode 100644 wolt_di/lib/src/dependency_container_subscription_mixin.dart create mode 100644 wolt_di/lib/src/subscriber/dependency_container_subscriber.dart create mode 100644 wolt_di/lib/src/subscriber/dependency_container_subscription_mixin.dart create mode 100644 wolt_di/lib/src/view_model/feature_with_view_model_dependency_container.dart create mode 100644 wolt_di/lib/src/view_model/feature_with_view_model_dependency_container_subscription_mixin.dart create mode 100644 wolt_di/lib/src/view_model/wolt_view_model.dart diff --git a/coffee_maker_navigator_2/lib/app.dart b/coffee_maker_navigator_2/lib/app.dart index b0cf4a0e..8d799f68 100644 --- a/coffee_maker_navigator_2/lib/app.dart +++ b/coffee_maker_navigator_2/lib/app.dart @@ -1,9 +1,7 @@ import 'package:wolt_di/wolt_di.dart'; import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; class CoffeeMakerApp extends StatelessWidget { const CoffeeMakerApp({Key? key}) : super(key: key); @@ -15,17 +13,12 @@ class CoffeeMakerApp extends StatelessWidget { final appLevelDependencyContainer = DependencyInjector.container< CoffeeMakerAppLevelDependencyContainer>(context); - return ChangeNotifierProvider( - create: (_) => appLevelDependencyContainer.routerViewModel, - builder: (context, _) { - return MaterialApp.router( - debugShowCheckedModeBanner: false, - theme: AppThemeData.themeData(context), - routerDelegate: appLevelDependencyContainer.appRouterDelegate, - backButtonDispatcher: - appLevelDependencyContainer.backButtonDispatcher, - ); - }, + return MaterialApp.router( + debugShowCheckedModeBanner: false, + theme: AppThemeData.themeData(context), + routerDelegate: appLevelDependencyContainer.appRouterDelegate, + backButtonDispatcher: + appLevelDependencyContainer.backButtonDispatcher, ); }), ); diff --git a/coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart b/coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart index 6104bf2b..5736ea45 100644 --- a/coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart @@ -78,6 +78,6 @@ class CoffeeMakerAppLevelDependencyContainer onboardingService: _onboardingService, isUserLoggedIn: _authService.authStateListenable.value ?? false, isTutorialShown: _onboardingService.isTutorialShown(), - )..onInit(); + ); } } diff --git a/coffee_maker_navigator_2/lib/domain/auth/auth_service.dart b/coffee_maker_navigator_2/lib/domain/auth/auth_service.dart index 67269c80..fd60aa39 100644 --- a/coffee_maker_navigator_2/lib/domain/auth/auth_service.dart +++ b/coffee_maker_navigator_2/lib/domain/auth/auth_service.dart @@ -11,6 +11,8 @@ abstract interface class AuthService { Future logOut(); Future logIn(String email, String password); + + void dispose(); } class AuthServiceImpl implements AuthService { @@ -50,4 +52,9 @@ class AuthServiceImpl implements AuthService { _authStateNotifier.value = false; } } + + @override + void dispose() { + _authStateNotifier.dispose(); + } } diff --git a/coffee_maker_navigator_2/lib/main.dart b/coffee_maker_navigator_2/lib/main.dart index 2c5d564b..01ead23b 100644 --- a/coffee_maker_navigator_2/lib/main.dart +++ b/coffee_maker_navigator_2/lib/main.dart @@ -1,9 +1,9 @@ import 'package:coffee_maker_navigator_2/app.dart'; import 'package:wolt_di/wolt_di.dart'; -import 'package:coffee_maker_navigator_2/di/add_water_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/di/auth_screen_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/add_water/di/add_water_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/auth/di/auth_screen_dependency_container.dart'; import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/di/orders_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/di/orders_dependency_container.dart'; import 'package:flutter/material.dart'; void _registerDependencyContainerFactories(DependencyContainerManager manager) { diff --git a/coffee_maker_navigator_2/lib/di/add_water_dependency_container.dart b/coffee_maker_navigator_2/lib/ui/add_water/di/add_water_dependency_container.dart similarity index 75% rename from coffee_maker_navigator_2/lib/di/add_water_dependency_container.dart rename to coffee_maker_navigator_2/lib/ui/add_water/di/add_water_dependency_container.dart index 45646b4b..3badc93c 100644 --- a/coffee_maker_navigator_2/lib/di/add_water_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/ui/add_water/di/add_water_dependency_container.dart @@ -1,10 +1,11 @@ import 'package:wolt_di/wolt_di.dart'; -import 'package:coffee_maker_navigator_2/di/orders_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/di/orders_dependency_container.dart'; import 'package:coffee_maker_navigator_2/domain/add_water/add_water_service.dart'; import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; import 'package:coffee_maker_navigator_2/ui/add_water/view_model/add_water_view_model.dart'; -class AddWaterDependencyContainer extends FeatureLevelDependencyContainer { +class AddWaterDependencyContainer + extends FeatureWithViewModelDependencyContainer { // Just in the sake to show that we can use a method here to make the service lazily initialized. late final AddWaterService _addWaterService = _createAddWaterService(); // This is an example to non-lazy initialization. @@ -15,17 +16,16 @@ class AddWaterDependencyContainer extends FeatureLevelDependencyContainer { _ordersService = orderDependencies.ordersService; } - AddWaterViewModel createViewModel() { - return AddWaterViewModel( - addWaterService: _addWaterService, - ordersService: _ordersService, - ); - } - AddWaterService _createAddWaterService() { return AddWaterService(); } + @override + AddWaterViewModel createViewModel() => AddWaterViewModel( + addWaterService: _addWaterService, + ordersService: _ordersService, + ); + @override void dispose() { // Only unbind, without disposing OrdersDependencyContainer, because we are using but not owning. diff --git a/coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart b/coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart index a5054ace..3d133ffe 100644 --- a/coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart +++ b/coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart @@ -1,12 +1,11 @@ -import 'package:coffee_maker_navigator_2/di/add_water_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/add_water/di/add_water_dependency_container.dart'; import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_source.dart'; import 'package:coffee_maker_navigator_2/ui/add_water/view_model/add_water_view_model.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_di/wolt_di.dart'; class AddWaterScreen extends StatefulWidget { @@ -22,6 +21,17 @@ class _AddWaterScreenState extends State with DependencyContainerSubscriptionMixin { + late AddWaterViewModel _viewModel; + + @override + void initState() { + super.initState(); + final dependencyContainer = + DependencyInjector.container(context); + _viewModel = dependencyContainer.createViewModel() + ..onInit(widget.coffeeOrderId); + } + @override Widget build(BuildContext context) { return SystemUIAnnotationWrapper( @@ -29,30 +39,22 @@ class _AddWaterScreenState extends State resizeToAvoidBottomInset: false, body: SafeArea( top: false, - child: ChangeNotifierProvider( - create: (context) => - DependencyInjector.container( - context) - .createViewModel() - ..onInit(widget.coffeeOrderId), - builder: (context, _) { - final viewModel = context.read(); - return Stack( - children: [ - _AddWaterScreenContent( - onWaterQuantityUpdated: viewModel.onWaterQuantityUpdated, - onWaterSourceUpdated: viewModel.onWaterSourceUpdated, - onWaterTemperatureUpdated: - viewModel.onWaterTemperatureUpdated, - ), - const _AddWaterScreenBackButton(), - _AddWaterScreenFooter( - viewModel.isReadyToAddWater, - viewModel.errorMessage, - ), - ], - ); - }), + child: Stack( + children: [ + _AddWaterScreenContent( + onWaterQuantityUpdated: _viewModel.onWaterQuantityUpdated, + onWaterSourceUpdated: _viewModel.onWaterSourceUpdated, + onWaterTemperatureUpdated: _viewModel.onWaterTemperatureUpdated, + ), + const _AddWaterScreenBackButton(), + _AddWaterScreenFooter( + _viewModel.isReadyToAddWater, + _viewModel.errorMessage, + _viewModel.onCheckValidityPressed, + _viewModel.onAddWaterPressed, + ), + ], + ), ), ), ); @@ -179,10 +181,17 @@ class _AddWaterScreenBackButton extends StatelessWidget { } class _AddWaterScreenFooter extends StatelessWidget { - const _AddWaterScreenFooter(this.isReadyToAddWater, this.errorMessage); + const _AddWaterScreenFooter( + this.isReadyToAddWater, + this.errorMessage, + this.onCheckValidity, + this.onAddWater, + ); final ValueListenable isReadyToAddWater; final ValueListenable errorMessage; + final VoidCallback onCheckValidity; + final VoidCallback onAddWater; @override Widget build(BuildContext context) { @@ -207,9 +216,7 @@ class _AddWaterScreenFooter extends StatelessWidget { ); }), WoltElevatedButton( - onPressed: () { - context.read().checkValidity(); - }, + onPressed: onCheckValidity, child: const Text('Check '), ), const SizedBox(height: 12), @@ -219,8 +226,8 @@ class _AddWaterScreenFooter extends StatelessWidget { return WoltElevatedButton( enabled: isEnabled, onPressed: () { - context.read().addWater(); - context.read().onAddWaterStepCompleted(); + onAddWater(); + context.routerViewModel.onAddWaterStepCompleted(); }, child: const Text('Add water'), ); diff --git a/coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart b/coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart index 25449680..e4e9891b 100644 --- a/coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart +++ b/coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart @@ -4,8 +4,9 @@ import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_source. import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; import 'package:flutter/foundation.dart'; +import 'package:wolt_di/wolt_di.dart'; -class AddWaterViewModel extends ChangeNotifier { +class AddWaterViewModel extends WoltViewModel { final AddWaterService _addWaterService; final OrdersService _ordersService; String _waterQuantityInMl = ''; @@ -63,7 +64,6 @@ class AddWaterViewModel extends ChangeNotifier { void dispose() { isReadyToAddWater.dispose(); _errorMessage.dispose(); - super.dispose(); } ValueListenable get isAddWaterButtonEnabled => isReadyToAddWater; @@ -71,7 +71,7 @@ class AddWaterViewModel extends ChangeNotifier { ValueListenable get errorMessage => _errorMessage; // Method to check the validity of the current state - void checkValidity() { + void onCheckValidityPressed() { _errorMessage.value = null; // Clear previous errors double? quantity = double.tryParse(_waterQuantityInMl); double? temperature = double.tryParse(_waterTemperatureInC); @@ -95,7 +95,7 @@ class AddWaterViewModel extends ChangeNotifier { } } - void addWater() { + void onAddWaterPressed() { _ordersService.updateOrder(_orderId, CoffeeMakerStep.ready); } } diff --git a/coffee_maker_navigator_2/lib/di/auth_screen_dependency_container.dart b/coffee_maker_navigator_2/lib/ui/auth/di/auth_screen_dependency_container.dart similarity index 84% rename from coffee_maker_navigator_2/lib/di/auth_screen_dependency_container.dart rename to coffee_maker_navigator_2/lib/ui/auth/di/auth_screen_dependency_container.dart index 4509d55e..c66fe516 100644 --- a/coffee_maker_navigator_2/lib/di/auth_screen_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/ui/auth/di/auth_screen_dependency_container.dart @@ -3,7 +3,8 @@ import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; import 'package:coffee_maker_navigator_2/ui/auth/view_model/auth_screen_view_model.dart'; import 'package:wolt_di/wolt_di.dart'; -class AuthScreenDependencyContainer extends FeatureLevelDependencyContainer { +class AuthScreenDependencyContainer + extends FeatureWithViewModelDependencyContainer { late final AuthService _authService; AuthScreenDependencyContainer() { @@ -12,6 +13,8 @@ class AuthScreenDependencyContainer extends FeatureLevelDependencyContainer { _authService = appLevelDependencies.authService; } + // ViewModel should always be created lazily. + @override AuthScreenViewModel createViewModel() { return AuthScreenViewModel(authService: _authService); } diff --git a/coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart b/coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart index 97fe2b94..decefed9 100644 --- a/coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart +++ b/coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart @@ -1,8 +1,7 @@ -import 'package:coffee_maker_navigator_2/di/auth_screen_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/auth/di/auth_screen_dependency_container.dart'; import 'package:coffee_maker_navigator_2/ui/auth/view_model/auth_screen_view_model.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_di/wolt_di.dart'; class AuthScreen extends StatefulWidget { @@ -16,6 +15,16 @@ class _AuthScreenState extends State with DependencyContainerSubscriptionMixin { + late AuthScreenViewModel _viewModel; + + @override + void initState() { + super.initState(); + final dependencyContainer = + DependencyInjector.container(context); + _viewModel = dependencyContainer.createViewModel(); + } + @override Widget build(BuildContext context) { final textTheme = Theme.of(context).textTheme; @@ -23,52 +32,46 @@ class _AuthScreenState extends State return Scaffold( body: SafeArea( child: Center( - child: ChangeNotifierProvider( - create: (context) => - DependencyInjector.container( - context) - .createViewModel(), - builder: (context, _) { - return SingleChildScrollView( - padding: const EdgeInsets.symmetric(horizontal: 40), - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Image( - image: - AssetImage('lib/assets/images/dash_coffee.webp'), - fit: BoxFit.cover, - height: 216, - width: 384, - ), - Text('Welcome to Coffee Maker!', - style: textTheme.titleLarge!), - const SizedBox(height: 50), - const AppTextFormField( - labelText: 'Username', - textInputType: TextInputType.emailAddress, - ), - const SizedBox(height: 20), - const AppTextFormField( - labelText: 'Password', - obscureText: true, - autocorrect: false, - textInputType: TextInputType.visiblePassword, - ), - const SizedBox(height: 30), - WoltElevatedButton( - onPressed: () => context - .read() - .onLoginPressed('email', 'password'), - child: const Text('Sign in'), - ), - ], - ), + child: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 40), + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Image( + image: AssetImage('lib/assets/images/dash_coffee.webp'), + fit: BoxFit.cover, + height: 216, + width: 384, + ), + Text( + 'Welcome to Coffee Maker!', + style: textTheme.titleLarge!, + ), + const SizedBox(height: 50), + const AppTextFormField( + labelText: 'Username', + textInputType: TextInputType.emailAddress, + ), + const SizedBox(height: 20), + const AppTextFormField( + labelText: 'Password', + obscureText: true, + autocorrect: false, + textInputType: TextInputType.visiblePassword, + ), + const SizedBox(height: 30), + WoltElevatedButton( + onPressed: () { + _viewModel.onLoginPressed('email', 'password'); + }, + child: const Text('Sign in'), ), - ); - }), + ], + ), + ), + ), ), ), ); diff --git a/coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart b/coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart index 9246e1ce..e854119f 100644 --- a/coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart +++ b/coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart @@ -1,7 +1,7 @@ import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:wolt_di/wolt_di.dart'; -class AuthScreenViewModel extends ChangeNotifier { +class AuthScreenViewModel extends WoltViewModel { final AuthService authService; AuthScreenViewModel({required this.authService}); @@ -9,4 +9,7 @@ class AuthScreenViewModel extends ChangeNotifier { Future onLoginPressed(String email, String password) async { await authService.logIn(email, password); } + + @override + void dispose() {} } diff --git a/coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart b/coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart new file mode 100644 index 00000000..841aa286 --- /dev/null +++ b/coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart @@ -0,0 +1,10 @@ +import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:wolt_di/wolt_di.dart'; + +extension AppLevelDependencyContainerExtensions on BuildContext { + RouterViewModel get routerViewModel => + DependencyInjector.container(this) + .routerViewModel; +} diff --git a/coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart b/coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart index d553a3fe..11a2a500 100644 --- a/coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart +++ b/coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart @@ -1,7 +1,6 @@ -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; class OnboardingModalSheetPage extends WoltModalSheetPage { @@ -30,9 +29,7 @@ We're excited to assist you with the orders. To ensure you get the most out of o Builder(builder: (context) { return WoltElevatedButton( onPressed: () { - context - .read() - .onCloseOnboardingModalSheet(); + context.routerViewModel.onCloseOnboardingModalSheet(); }, theme: WoltElevatedButtonTheme.secondary, child: const Text('Show me later'), @@ -42,8 +39,7 @@ We're excited to assist you with the orders. To ensure you get the most out of o Builder(builder: (context) { return WoltElevatedButton( onPressed: () { - context - .read() + context.routerViewModel .onUserRequestedTutorialFromOnboardingModal(); }, child: const Text('Show me tutorials!'), diff --git a/coffee_maker_navigator_2/lib/di/orders_dependency_container.dart b/coffee_maker_navigator_2/lib/ui/orders/di/orders_dependency_container.dart similarity index 75% rename from coffee_maker_navigator_2/lib/di/orders_dependency_container.dart rename to coffee_maker_navigator_2/lib/ui/orders/di/orders_dependency_container.dart index 6e7058fe..245b62db 100644 --- a/coffee_maker_navigator_2/lib/di/orders_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/di/orders_dependency_container.dart @@ -4,11 +4,14 @@ import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; import 'package:wolt_di/wolt_di.dart'; -class OrdersDependencyContainer extends FeatureLevelDependencyContainer { +class OrdersDependencyContainer + extends FeatureWithViewModelDependencyContainer { late final OrdersRemoteDataSource _ordersRemoteDataSource; late final OrdersRepository _ordersRepository; late final OrdersService _ordersService; + /// This is an example of exposing a getter for the use of other dependency containers. + /// [AddWaterDependencyContainer] binds with [OrdersDependencyContainer] and uses this getter. OrdersService get ordersService => _ordersService; OrdersDependencyContainer() { @@ -19,7 +22,8 @@ class OrdersDependencyContainer extends FeatureLevelDependencyContainer { _ordersService = OrdersService(ordersRepository: _ordersRepository); } - OrdersScreenViewModel createOrderScreenViewModel() { + @override + OrdersScreenViewModel createViewModel() { return OrdersScreenViewModel(ordersService: _ordersService); } diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart index 09525de6..ab83b1f2 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart @@ -1,15 +1,14 @@ import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; class GrindOrRejectModalPage extends WoltModalSheetPage { GrindOrRejectModalPage( String coffeeOrderId, - void Function(String orderId, CoffeeMakerStep? newStep) - onCoffeeOrderStatusChange, + OnCoffeeOrderStatusChange onCoffeeOrderStatusChange, ) : super( child: const Padding( padding: EdgeInsets.only( @@ -42,9 +41,8 @@ class GrindOrRejectModalPage extends WoltModalSheetPage { onPressed: () { onCoffeeOrderStatusChange( coffeeOrderId, CoffeeMakerStep.addWater); - context.read().onGrindStepExit( - hasStartedGrinding: true, - ); + context.routerViewModel + .onGrindStepExit(hasStartedGrinding: true); }, child: const Text('Start grinding'), ); diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart index 4027f01a..0df80480 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart @@ -1,9 +1,8 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/grind/reject_order_reason.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; class RejectOrderModalPage extends WoltModalSheetPage { @@ -11,8 +10,7 @@ class RejectOrderModalPage extends WoltModalSheetPage { RejectOrderModalPage( String coffeeOrderId, - void Function(String orderId, [CoffeeMakerStep? newStep]) - onCoffeeOrderStatusChange, + OnCoffeeOrderStatusChange onCoffeeOrderStatusChange, ) : super( stickyActionBar: ValueListenableBuilder( valueListenable: _buttonEnabledListener, @@ -23,9 +21,8 @@ class RejectOrderModalPage extends WoltModalSheetPage { return WoltElevatedButton( onPressed: () { onCoffeeOrderStatusChange(coffeeOrderId); - context.read().onGrindStepExit( - hasStartedGrinding: false, - ); + context.routerViewModel + .onGrindStepExit(hasStartedGrinding: false); }, theme: WoltElevatedButtonTheme.secondary, colorName: WoltColorName.red, diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart index 5f1632d4..7cd6e6ce 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart @@ -1,15 +1,17 @@ import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/extra_recommendation.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/extra_recommendation_tile.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; class OfferRecommendationModalPage { OfferRecommendationModalPage._(); - static SliverWoltModalSheetPage build({required String coffeeOrderId}) { + static SliverWoltModalSheetPage build( + OnCoffeeOrderStatusChange onCoffeeOrderStatusChange, + String coffeeOrderId, + ) { final selectedItemCountListener = ValueNotifier(0); const pageTitle = 'Recommendations'; const allRecommendations = ExtraRecommendation.values; @@ -31,10 +33,9 @@ class OfferRecommendationModalPage { return Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), child: Builder(builder: (context) { - final model = context.read(); return WoltElevatedButton( onPressed: () { - model.onCoffeeOrderStatusChange(coffeeOrderId); + onCoffeeOrderStatusChange(coffeeOrderId); Navigator.pop(context); }, enabled: count > 0, diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart index 042cef99..9cfc6ea7 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart @@ -1,13 +1,14 @@ -import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; class ServeOrOfferModalPage { ServeOrOfferModalPage._(); - static WoltModalSheetPage build({required String coffeeOrderId}) { + static WoltModalSheetPage build( + OnCoffeeOrderStatusChange onCoffeeOrderStatusChange, + String coffeeOrderId) { return WoltModalSheetPage( heroImage: const Image( image: AssetImage('lib/assets/images/coffee_is_ready.png'), @@ -18,10 +19,9 @@ class ServeOrOfferModalPage { child: Column( children: [ Builder(builder: (context) { - final model = context.read(); return WoltElevatedButton( onPressed: () { - model.onCoffeeOrderStatusChange(coffeeOrderId); + onCoffeeOrderStatusChange(coffeeOrderId); Navigator.pop(context); }, theme: WoltElevatedButtonTheme.secondary, diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart b/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart index fb50f532..f78213d6 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart @@ -1,14 +1,15 @@ -import 'package:coffee_maker_navigator_2/di/orders_dependency_container.dart'; import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/di/orders_dependency_container.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/coffee_order_list_view_for_step.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/orders_screen_bottom_navigation_bar.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; import 'package:coffee_maker_navigator_2/ui/orders/widgets/top_bar.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; import 'package:coffee_maker_navigator_2/ui/widgets/app_navigation_drawer.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_di/wolt_di.dart'; typedef OnCoffeeOrderStatusChange = Function(String coffeeOrderId, @@ -23,110 +24,108 @@ class OrdersScreen extends StatefulWidget { class _OrdersScreenState extends State with - DependencyContainerSubscriptionMixin { - final List _stepLists = [ - const GrindStepList(), - const AddWaterStepList(), - const ReadyStepList(), - ]; + FeatureWithViewModelDependencyContainerSubscriptionMixin< + OrdersDependencyContainer, OrdersScreenViewModel, OrdersScreen> { + ValueListenable get selectedStepListenable => + context.routerViewModel.bottomNavigationTabInOrdersPage; @override Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (context) => - DependencyInjector.container(context) - .createOrderScreenViewModel() - ..onInit(), - builder: (context, _) { - final viewModel = context.watch(); - - return SystemUIAnnotationWrapper( - hasBottomNavigationBar: true, - child: Builder(builder: (context) { - final routerViewModel = context.watch(); - final selectedBottomNavigationTab = - routerViewModel.state.bottomNavigationTabInOrdersPage; - - return Scaffold( - body: SafeArea( - child: Column( - children: [ - TopBar( - selectedStepForBottomNavigationBar: - selectedBottomNavigationTab, - ), - Expanded( - child: Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: double.infinity, - padding: const EdgeInsets.symmetric(horizontal: 16), - color: WoltColors.black8, - child: IndexedStack( - index: selectedBottomNavigationTab.index, - children: _stepLists, - ), - ), + return SystemUIAnnotationWrapper( + hasBottomNavigationBar: true, + child: Scaffold( + body: SafeArea( + child: ValueListenableBuilder( + valueListenable: selectedStepListenable, + builder: (context, selectedTab, _) { + return Column( + children: [ + TopBar(selectedTab: selectedTab), + Expanded( + child: _CoffeeStepList( + selectedTab, + viewModel.groupedCoffeeOrders, + viewModel.onCoffeeOrderStatusChange, ), - ], - ), - ), - drawer: const AppNavigationDrawer(selectedIndex: 0), - bottomNavigationBar: OrdersScreenBottomNavigationBar( - groupedCoffeeOrders: viewModel.groupedCoffeeOrders, - selectedStep: selectedBottomNavigationTab, - onSelected: (selectedStep) { - routerViewModel - .onOrdersScreenSelectedBottomNavBarUpdated(selectedStep); - }, - ), - ); - }), - ); - }, + ), + ], + ); + }, + ), + ), + drawer: const AppNavigationDrawer(selectedIndex: 0), + bottomNavigationBar: _BottomNavigationBar( + viewModel.groupedCoffeeOrders, + ), + ), ); } } -class GrindStepList extends StatelessWidget { - const GrindStepList({super.key}); +class _CoffeeStepList extends StatelessWidget { + const _CoffeeStepList( + this.selectedStep, + this.groupedCoffeeOrders, + this.onCoffeeOrderStatusChange, + ); - @override - Widget build(BuildContext context) { - final viewModel = context.watch(); - - return CoffeeOrderListViewForStep( - groupedCoffeeOrders: viewModel.groupedCoffeeOrders, - selectedStep: CoffeeMakerStep.grind, - ); - } -} - -class AddWaterStepList extends StatelessWidget { - const AddWaterStepList({super.key}); + final ValueListenable groupedCoffeeOrders; + final OnCoffeeOrderStatusChange onCoffeeOrderStatusChange; + final CoffeeMakerStep selectedStep; @override Widget build(BuildContext context) { - final viewModel = context.watch(); - - return CoffeeOrderListViewForStep( - groupedCoffeeOrders: viewModel.groupedCoffeeOrders, - selectedStep: CoffeeMakerStep.addWater, + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 16), + child: ValueListenableBuilder( + valueListenable: + context.routerViewModel.bottomNavigationTabInOrdersPage, + builder: (context, selectedTab, __) { + return KeyedSubtree( + key: PageStorageKey(selectedTab), + child: ValueListenableBuilder( + valueListenable: groupedCoffeeOrders, + builder: (context, orders, _) { + return CoffeeOrderListViewForStep( + groupedCoffeeOrders: orders, + selectedStep: selectedStep, + onCoffeeOrderStatusChange: onCoffeeOrderStatusChange, + ); + }, + )); + }, + ), ); } } -class ReadyStepList extends StatelessWidget { - const ReadyStepList({super.key}); +class _BottomNavigationBar extends StatelessWidget { + const _BottomNavigationBar(this.groupedCoffeeOrders); + + final ValueListenable groupedCoffeeOrders; @override Widget build(BuildContext context) { - final viewModel = context.watch(); - - return CoffeeOrderListViewForStep( - groupedCoffeeOrders: viewModel.groupedCoffeeOrders, - selectedStep: CoffeeMakerStep.ready, + return ValueListenableBuilder( + valueListenable: context.routerViewModel.bottomNavigationTabInOrdersPage, + builder: (context, selectedTab, _) { + return ValueListenableBuilder( + valueListenable: groupedCoffeeOrders, + builder: (context, orders, _) { + return OrdersScreenBottomNavigationBar( + groupedCoffeeOrders: orders, + selectedStep: selectedTab, + onSelected: (selectedStep) { + context.routerViewModel + .onOrdersScreenBottomNavBarUpdated(selectedStep); + }, + ); + }, + ); + }, ); } } diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart b/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart index 5d2e1f2a..562af8a7 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart @@ -1,15 +1,14 @@ import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/coffee_order_list_item_tile.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/empty_coffee_order_list_view.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; import 'package:wolt_responsive_layout_grid/wolt_responsive_layout_grid.dart'; @@ -22,10 +21,12 @@ class CoffeeOrderListViewForStep extends StatelessWidget { super.key, required this.selectedStep, required this.groupedCoffeeOrders, + required this.onCoffeeOrderStatusChange, }); final CoffeeMakerStep selectedStep; final GroupedCoffeeOrders groupedCoffeeOrders; + final OnCoffeeOrderStatusChange onCoffeeOrderStatusChange; static const String modalRouteSettingName = "stepModalRouteName"; @@ -36,12 +37,15 @@ class CoffeeOrderListViewForStep extends StatelessWidget { return _CoffeeOrderListView( coffeeOrders: groupedCoffeeOrders.grindStateOrders, coffeeMakerStep: CoffeeMakerStep.grind, - onCoffeeOrderSelected: (id) => context - .read() - .onGrindStepEntering( + onCoffeeOrderSelected: (id) { + context.routerViewModel.onGrindStepEntering( + id, + onCoffeeOrderStatusChange( id, - context.read().onCoffeeOrderStatusChange, + CoffeeMakerStep.addWater, ), + ); + }, ); case CoffeeMakerStep.addWater: return _CoffeeOrderListView( @@ -54,8 +58,8 @@ class CoffeeOrderListViewForStep extends StatelessWidget { return _CoffeeOrderListView( coffeeOrders: groupedCoffeeOrders.readyStateOrders, coffeeMakerStep: CoffeeMakerStep.ready, - onCoffeeOrderSelected: (id) => - _onCoffeeOrderSelectedInReadyState(context, id), + onCoffeeOrderSelected: (id) => _onCoffeeOrderSelectedInReadyState( + context, onCoffeeOrderStatusChange, id), ); } } @@ -63,27 +67,23 @@ class CoffeeOrderListViewForStep extends StatelessWidget { void _onCoffeeOrderSelectedInAddWaterState( BuildContext context, String coffeeOrderId) { - context.read().onAddWaterStepEntering(coffeeOrderId); + context.routerViewModel.onAddWaterStepEntering(coffeeOrderId); } void _onCoffeeOrderSelectedInReadyState( - BuildContext context, String coffeeOrderId) { - final model = context.read(); - + BuildContext context, + OnCoffeeOrderStatusChange onCoffeeOrderStatusChange, + String coffeeOrderId, +) { WoltModalSheet.show( settings: const RouteSettings( name: CoffeeOrderListViewForStep.modalRouteSettingName), context: context, pageListBuilder: (context) => [ - ServeOrOfferModalPage.build(coffeeOrderId: coffeeOrderId), - OfferRecommendationModalPage.build(coffeeOrderId: coffeeOrderId) + ServeOrOfferModalPage.build(onCoffeeOrderStatusChange, coffeeOrderId), + OfferRecommendationModalPage.build( + onCoffeeOrderStatusChange, coffeeOrderId) ], - pageContentDecorator: (child) { - return ChangeNotifierProvider.value( - value: model, - builder: (_, __) => child, - ); - }, modalTypeBuilder: _modalTypeBuilder, ); } diff --git a/coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart b/coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart index 870594d6..ca2099f2 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart @@ -1,35 +1,30 @@ -import 'dart:async'; - import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:wolt_di/wolt_di.dart'; -class OrdersScreenViewModel extends ChangeNotifier { +class OrdersScreenViewModel implements WoltViewModel { final OrdersService _ordersService; - GroupedCoffeeOrders groupedCoffeeOrders = GroupedCoffeeOrders.empty(); + final groupedCoffeeOrders = ValueNotifier(GroupedCoffeeOrders.empty()); OrdersScreenViewModel({ required OrdersService ordersService, - }) : _ordersService = ordersService; - - Future onInit() async { + }) : _ordersService = ordersService { final currentOrders = _ordersService.receiveOrders().value; - groupedCoffeeOrders = GroupedCoffeeOrders.fromCoffeeOrders(currentOrders); - notifyListeners(); + groupedCoffeeOrders.value = + GroupedCoffeeOrders.fromCoffeeOrders(currentOrders); _ordersService.receiveOrders().addListener(_onOrdersReceived); } @override void dispose() { _ordersService.receiveOrders().removeListener(_onOrdersReceived); - super.dispose(); } void _onOrdersReceived() { final orders = _ordersService.receiveOrders().value; - groupedCoffeeOrders = GroupedCoffeeOrders.fromCoffeeOrders(orders); - notifyListeners(); + groupedCoffeeOrders.value = GroupedCoffeeOrders.fromCoffeeOrders(orders); } void onCoffeeOrderStatusChange( diff --git a/coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart b/coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart index 6a687f8e..e3b1d9b3 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart @@ -2,34 +2,17 @@ import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_ste import 'package:coffee_maker_navigator_2/ui/orders/widgets/coffee_maker_custom_divider.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:wolt_responsive_layout_grid/wolt_responsive_layout_grid.dart'; class TopBar extends StatelessWidget { const TopBar({ - CoffeeMakerStep? selectedStepForBottomNavigationBar, - Widget? trailing, + required CoffeeMakerStep selectedTab, super.key, - }) : _selectedStepForBottomNavigationBar = - selectedStepForBottomNavigationBar, - _trailing = trailing; + }) : _selectedTab = selectedTab; - final CoffeeMakerStep? _selectedStepForBottomNavigationBar; - final Widget? _trailing; + final CoffeeMakerStep _selectedTab; @override Widget build(BuildContext context) { - const store = 'Coffee Maker'; - final selectedStep = _selectedStepForBottomNavigationBar; - late String title; - switch (context.screenSize) { - case WoltScreenSize.small: - title = selectedStep?.stepName ?? store; - break; - case WoltScreenSize.large: - title = store; - break; - } - return ColoredBox( color: Colors.white, child: Column( @@ -45,13 +28,12 @@ class TopBar extends StatelessWidget { const SizedBox(width: 16), Expanded( child: Text( - title, + _selectedTab.stepName, style: Theme.of(context).textTheme.headlineMedium, maxLines: 1, overflow: TextOverflow.ellipsis, ), ), - if (_trailing != null) _trailing!, ], ), ), diff --git a/coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart b/coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart index 4f9c6d73..b5999715 100644 --- a/coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart +++ b/coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart @@ -1,16 +1,15 @@ import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; import 'package:coffee_maker_navigator_2/ui/add_water/view/add_water_screen.dart'; import 'package:coffee_maker_navigator_2/ui/auth/view/auth_screen.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:coffee_maker_navigator_2/ui/onboarding/view/onboarding_modal_sheet_page.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_settings_name.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; import 'package:coffee_maker_navigator_2/ui/tutorials/view/single_tutorial_screen.dart'; import 'package:coffee_maker_navigator_2/ui/tutorials/view/tutorials_screen.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; sealed class AppRoutePage extends Page { @@ -115,9 +114,9 @@ class OnboardingModalRoutePage extends AppRoutePage { (context) => [OnboardingModalSheetPage()], ), onModalDismissedWithDrag: - context.read().onCloseOnboardingModalSheet, + context.routerViewModel.onCloseOnboardingModalSheet, onModalDismissedWithBarrierTap: - context.read().onCloseOnboardingModalSheet, + context.routerViewModel.onCloseOnboardingModalSheet, ); } } @@ -127,8 +126,7 @@ class GrindCoffeeModalRoutePage extends AppRoutePage { String get name => RouteSettingsName.onboarding.routeName; final String coffeeOrderId; - final void Function(String orderId, [CoffeeMakerStep? newStep]) - onCoffeeOrderStatusChange; + final OnCoffeeOrderStatusChange onCoffeeOrderStatusChange; GrindCoffeeModalRoutePage( this.coffeeOrderId, diff --git a/coffee_maker_navigator_2/lib/ui/router/entities/router_view_model_state.dart b/coffee_maker_navigator_2/lib/ui/router/entities/router_view_model_state.dart deleted file mode 100644 index 9d4bef77..00000000 --- a/coffee_maker_navigator_2/lib/ui/router/entities/router_view_model_state.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_page.dart'; - -class RouterViewModelState { - final List pages; - final CoffeeMakerStep bottomNavigationTabInOrdersPage; - - const RouterViewModelState({ - required this.pages, - required this.bottomNavigationTabInOrdersPage, - }); - - factory RouterViewModelState.initial({ - required bool isLoggedIn, - required bool isTutorialModalShown, - }) { - return RouterViewModelState( - pages: isLoggedIn - ? [ - const OrdersRoutePage(), - if (!isTutorialModalShown) const OnboardingModalRoutePage(), - ] - : const [AuthRoutePage()], - bottomNavigationTabInOrdersPage: CoffeeMakerStep.grind, - ); - } - - RouterViewModelState copyWith({ - List? pages, - CoffeeMakerStep? bottomNavigationTabInOrdersPage, - }) { - return RouterViewModelState( - bottomNavigationTabInOrdersPage: bottomNavigationTabInOrdersPage ?? - this.bottomNavigationTabInOrdersPage, - pages: pages ?? this.pages, - ); - } -} diff --git a/coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart b/coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart index 6598c3a5..02b5a917 100644 --- a/coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart +++ b/coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart @@ -1,36 +1,36 @@ import 'dart:async'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/coffee_order_list_view_for_step.dart'; import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_page.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; class AppRouterDelegate extends RouterDelegate with ChangeNotifier { GlobalKey navigatorKey = GlobalKey(); @override Widget build(BuildContext context) { - final routerViewModel = context.watch(); - final pages = routerViewModel.state.pages; - - return Navigator( - key: navigatorKey, - pages: pages, - onPopPage: (route, result) { - final context = navigatorKey.currentContext; - final name = route.settings.name; - - if (context != null && name != null) { - context - .read() - .onPagePoppedImperatively(poppingPageName: name); - } - - return route.didPop(result); + return ValueListenableBuilder>( + valueListenable: context.routerViewModel.pages, + builder: (context, pages, __) { + return Navigator( + key: navigatorKey, + pages: pages, + onPopPage: (route, result) { + final context = navigatorKey.currentContext; + final name = route.settings.name; + + if (context != null && name != null) { + context.routerViewModel + .onPagePoppedImperatively(poppingPageName: name); + } + + return route.didPop(result); + }, + observers: [_AppRouteObserver(Theme.of(context).colorScheme)], + ); }, - observers: [_AppRouteObserver(Theme.of(context).colorScheme)], ); } @@ -43,8 +43,7 @@ class AppRouterDelegate extends RouterDelegate with ChangeNotifier { if (_isImperativePopFromOrderScreenModals(currentContext)) { return Future.value(true); } - return currentContext - .read() + return currentContext.routerViewModel .onPagePoppedWithOperatingSystemIntent(); } diff --git a/coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart b/coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart index 642e4f58..5215930c 100644 --- a/coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart +++ b/coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart @@ -3,95 +3,81 @@ import 'dart:async'; import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; import 'package:coffee_maker_navigator_2/domain/onboarding/onboarding_service.dart'; import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_page.dart'; import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_settings_name.dart'; -import 'package:coffee_maker_navigator_2/ui/router/entities/router_view_model_state.dart'; import 'package:coffee_maker_navigator_2/ui/widgets/app_navigation_drawer.dart'; import 'package:flutter/material.dart'; -class RouterViewModel extends ChangeNotifier { +class RouterViewModel { final AuthService authService; final OnboardingService onboardingService; + late final ValueNotifier> pages = ValueNotifier([]); + final ValueNotifier bottomNavigationTabInOrdersPage = + ValueNotifier(CoffeeMakerStep.grind); - RouterViewModelState state; + final ValueNotifier isTutorialModalShown = ValueNotifier(false); RouterViewModel({ required bool isUserLoggedIn, required bool isTutorialShown, required this.authService, required this.onboardingService, - }) : state = RouterViewModelState.initial( - isLoggedIn: isUserLoggedIn, - isTutorialModalShown: isTutorialShown, - ); - - void onInit() { + }) { + pages.value = [ + if (isUserLoggedIn) const OrdersRoutePage() else const AuthRoutePage(), + if (isUserLoggedIn && !isTutorialShown) const OnboardingModalRoutePage(), + ]; authService.authStateListenable.addListener(_authStateChangeSubscription); } - @override void dispose() { authService.authStateListenable .removeListener(_authStateChangeSubscription); - super.dispose(); + pages.dispose(); + bottomNavigationTabInOrdersPage.dispose(); } void _authStateChangeSubscription() { final isLoggedIn = authService.authStateListenable.value ?? false; if (isLoggedIn) { final shouldShowTutorial = !onboardingService.isTutorialShown(); - state = state.copyWith( - pages: [ - const OrdersRoutePage(), - if (shouldShowTutorial) const OnboardingModalRoutePage(), - ], - ); + pages.value = [ + const OrdersRoutePage(), + if (shouldShowTutorial) const OnboardingModalRoutePage(), + ]; } else { - state = state.copyWith(pages: [const AuthRoutePage()]); + pages.value = [const AuthRoutePage()]; } - notifyListeners(); } void _navigateToOrdersScreen({ CoffeeMakerStep? destinationBottomNavBarTab, }) { - state = state.copyWith( - pages: [const OrdersRoutePage()], - bottomNavigationTabInOrdersPage: - destinationBottomNavBarTab ?? state.bottomNavigationTabInOrdersPage, - ); - notifyListeners(); + pages.value = [const OrdersRoutePage()]; + if (destinationBottomNavBarTab != null) { + bottomNavigationTabInOrdersPage.value = destinationBottomNavBarTab; + } } void _navigateToTutorialsScreen() { - state = state.copyWith( - pages: [ - const TutorialsRoutePage(), - ], - ); - notifyListeners(); + pages.value = [const TutorialsRoutePage()]; } void _navigateToSingleTutorialScreen( CoffeeMakerStep coffeeMakerStep, ) { - state = state.copyWith( - pages: [ - const TutorialsRoutePage(), - SingleTutorialRoutePage(coffeeMakerStep), - ], - ); - notifyListeners(); + pages.value = [ + const TutorialsRoutePage(), + SingleTutorialRoutePage(coffeeMakerStep), + ]; } void _navigateToAddWaterScreen(String coffeeOrderId) { - state = state.copyWith( - pages: [ - const OrdersRoutePage(), - AddWaterRoutePage(coffeeOrderId), - ], - ); - notifyListeners(); + pages.value = [ + const OrdersRoutePage(), + AddWaterRoutePage(coffeeOrderId), + ]; } void onPagePoppedImperatively({required String poppingPageName}) { @@ -116,7 +102,7 @@ class RouterViewModel extends ChangeNotifier { /// is handled in here instead of Navigator's onPopPage callback. /// Returning false will cause the entire app to be popped. Future onPagePoppedWithOperatingSystemIntent() { - switch (state.pages.last) { + switch (pages.value.last) { case AuthRoutePage(): case OrdersRoutePage(): // false means the entire app will be popped. @@ -176,33 +162,22 @@ class RouterViewModel extends ChangeNotifier { _navigateToAddWaterScreen(coffeeOrderId); } - void onOrdersScreenSelectedBottomNavBarUpdated(CoffeeMakerStep selectedStep) { - state = state.copyWith(bottomNavigationTabInOrdersPage: selectedStep); - notifyListeners(); + void onOrdersScreenBottomNavBarUpdated(CoffeeMakerStep selectedStep) { + bottomNavigationTabInOrdersPage.value = selectedStep; } void onGrindStepEntering( String id, - void Function(String orderId, [CoffeeMakerStep? newStep]) - onCoffeeOrderStatusChange, + OnCoffeeOrderStatusChange onCoffeeOrderStatusChange, ) { - state = state.copyWith( - pages: [ - const OrdersRoutePage(), - GrindCoffeeModalRoutePage(id, onCoffeeOrderStatusChange), - ], - ); - notifyListeners(); + pages.value = [ + const OrdersRoutePage(), + GrindCoffeeModalRoutePage(id, onCoffeeOrderStatusChange), + ]; } void onGrindStepExit({required bool hasStartedGrinding}) { - state = state.copyWith( - pages: [ - const OrdersRoutePage(), - ], - bottomNavigationTabInOrdersPage: - hasStartedGrinding ? CoffeeMakerStep.addWater : CoffeeMakerStep.grind, - ); - notifyListeners(); + bottomNavigationTabInOrdersPage.value = + hasStartedGrinding ? CoffeeMakerStep.addWater : CoffeeMakerStep.grind; } } diff --git a/coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart b/coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart index a9d52c13..8fbc50e6 100644 --- a/coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart +++ b/coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart @@ -1,8 +1,8 @@ import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import '../../widgets/app_navigation_drawer.dart'; @@ -67,8 +67,7 @@ We're excited to assist you with the orders. To ensure you get the most out of o ], ), onSelectionUpdateInSingleSelectionList: (item) { - context - .read() + context.routerViewModel .onTutorialDetailSelected(item.value); }, ), diff --git a/coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart b/coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart index b923524e..c7dc74d3 100644 --- a/coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart +++ b/coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart @@ -1,6 +1,5 @@ -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; enum AppNavigationDrawerDestination { ordersScreen(label: Text("Orders"), icon: Icon(Icons.coffee)), @@ -71,9 +70,9 @@ class AppNavigationDrawer extends StatelessWidget { ), ], onDestinationSelected: (int index) { - context.read().onDrawerDestinationSelected( - AppNavigationDrawerDestination.fromIndex(index), - ); + context.routerViewModel.onDrawerDestinationSelected( + AppNavigationDrawerDestination.fromIndex(index), + ); }, ), ); diff --git a/coffee_maker_navigator_2/pubspec.yaml b/coffee_maker_navigator_2/pubspec.yaml index bc4c3fbb..9261791e 100644 --- a/coffee_maker_navigator_2/pubspec.yaml +++ b/coffee_maker_navigator_2/pubspec.yaml @@ -10,7 +10,6 @@ dependencies: flutter: sdk: flutter equatable: ^2.0.5 - provider: ^6.0.5 shared_preferences: ^2.2.1 wolt_responsive_layout_grid: ^0.0.3 wolt_di: diff --git a/wolt_di/lib/src/dependency_container_subscription_mixin.dart b/wolt_di/lib/src/dependency_container_subscription_mixin.dart deleted file mode 100644 index 29ac910d..00000000 --- a/wolt_di/lib/src/dependency_container_subscription_mixin.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:flutter/widgets.dart'; -import 'package:wolt_di/wolt_di.dart'; - -/// A mixin that subscribes the state of the `StatefulWidget` to a dependency container and manages -/// its lifecycle. -/// -/// This mixin automatically subscribes the stateful widget to a container of type [C] when the -/// widget is initialized, and unsubscribes from the container when the widget is disposed. This -/// ensures that the container remains active as long as the widget is part of the widget tree -/// and is -/// disposed of properly when the widget is removed. -/// -/// This mixin should be used with `State` classes of `StatefulWidget` to manage -/// their dependency containers seamlessly. -mixin DependencyContainerSubscriptionMixin - on State { - late DependencyInjector _injector; - - @override - void initState() { - super.initState(); - _injector = DependencyInjector.of(context); - _injector.subscribeToDependencyContainer(this); - } - - @override - void dispose() { - // Use the stored Injector reference to unsubscribe. This avoids accessing context in an - // unstable state during widget disposal. - _injector.unsubscribeFromDependencyContainer(this); - super.dispose(); - } -} diff --git a/wolt_di/lib/src/dependency_injector.dart b/wolt_di/lib/src/dependency_injector.dart index 63f6d0d7..e0ab5fe5 100644 --- a/wolt_di/lib/src/dependency_injector.dart +++ b/wolt_di/lib/src/dependency_injector.dart @@ -1,7 +1,6 @@ import 'package:flutter/widgets.dart'; import 'package:wolt_di/src/manager/dependency_container_manager.dart'; -import 'package:wolt_di/src/dependency_container_subscription_mixin.dart'; -import 'package:meta/meta.dart'; +import 'package:wolt_di/wolt_di.dart'; /// A widget that proxies requests to [DependencyContainerResolver]. /// @@ -62,10 +61,9 @@ class DependencyInjector extends InheritedWidget { /// This method adds the subscriber to the container, ensuring that the container /// remains active as long as there are subscribers. /// - /// [subscriber]: The [DependencyContainerSubscriptionMixin] mixin subscribing to the container. - @internal + /// [subscriber]: The [DependencyContainerSubscriber] mixin subscribing to the container. void subscribeToDependencyContainer( - DependencyContainerSubscriptionMixin subscriber) { + DependencyContainerSubscriber subscriber) { _resolver.subscribeToContainer(subscriber); } @@ -74,10 +72,9 @@ class DependencyInjector extends InheritedWidget { /// This method removes the subscriber from the container, and if there are no /// more subscribers, the container may be disposed of. /// - /// [subscriber]: The [DependencyContainerSubscriptionMixin] mixin unsubscribing from the container. - @internal + /// [subscriber]: The [DependencyContainerSubscriber] mixin unsubscribing from the container. void unsubscribeFromDependencyContainer( - DependencyContainerSubscriptionMixin subscriber) { + DependencyContainerSubscriber subscriber) { _resolver.unsubscribeFromContainer(subscriber); } diff --git a/wolt_di/lib/src/subscriber/dependency_container_subscriber.dart b/wolt_di/lib/src/subscriber/dependency_container_subscriber.dart new file mode 100644 index 00000000..48d85536 --- /dev/null +++ b/wolt_di/lib/src/subscriber/dependency_container_subscriber.dart @@ -0,0 +1,8 @@ +import 'package:wolt_di/src/dependency_injector.dart'; + +/// An abstract interface for a dependency container subscription mixin. +/// +/// This serves as a marker to indicate that the implementing class +/// is capable of subscribing to updates related to a specific dependency type [C] inside the +/// [DependencyInjector] widget. +abstract interface class DependencyContainerSubscriber {} diff --git a/wolt_di/lib/src/subscriber/dependency_container_subscription_mixin.dart b/wolt_di/lib/src/subscriber/dependency_container_subscription_mixin.dart new file mode 100644 index 00000000..2e6036f0 --- /dev/null +++ b/wolt_di/lib/src/subscriber/dependency_container_subscription_mixin.dart @@ -0,0 +1,74 @@ +import 'package:flutter/widgets.dart'; +import 'package:wolt_di/wolt_di.dart'; + +/// A mixin that manages subscription to a dependency container within +/// a widget's state, making it possible for the state to respond to +/// changes in dependencies managed by the [DependencyInjector]. +/// +/// It is meant to be used with state classes of [StatefulWidget]s. +/// +/// Generic parameters: +/// - [C] - The type of the dependency that the subscriber is interested in. +/// - [T] - The type of [StatefulWidget] that this state belongs to. +/// +/// Implements [DependencyContainerSubscriber] to indicate that +/// this mixin is a subscriber for dependencies of type [C]. +mixin DependencyContainerSubscriptionMixin + on State implements DependencyContainerSubscriber { + /// The instance of [DependencyInjector] used to manage and subscribe + /// to dependencies. It will be initialized when subscribing. + late DependencyInjector _injector; + + /// Subscribes this state object to the dependency container for type [C]. + /// + /// It obtains the [DependencyInjector] instance from the current widget's + /// context and subscribes the state object to updates for dependencies of + /// type [C]. This ensures that the state object will receive updates when + /// the dependency changes. + void subscribeToDependencyContainer() { + // Retrieve the DependencyInjector instance from the widget's context. + _injector = DependencyInjector.of(context); + + // Subscribe to updates for dependencies of type [C]. + _injector.subscribeToDependencyContainer(this); + } + + /// Unsubscribes this state object from the dependency container for type [C]. + /// + /// It calls the unsubscribe method on the [DependencyInjector], ensuring + /// that the state object no longer receives updates for dependencies of + /// type [C]. This is important for preventing memory leaks and unnecessary + /// updates after the state object has been disposed of. + void unsubscribeFromDependencyContainer() { + // Unsubscribe from updates for dependencies of type [C]. + _injector.unsubscribeFromDependencyContainer(this); + } + + /// Initializes the state object. + /// + /// This is called when the state object is created. It is overridden to + /// include the subscription logic, ensuring that the state object starts + /// receiving updates from the dependency container as soon as it is initialized. + @override + void initState() { + super.initState(); // Call the superclass's initState method. + + // Begin subscription to the dependency container. + subscribeToDependencyContainer(); + } + + /// Disposes of the state object. + /// + /// This is called when the state object is removed from the widget tree. + /// It is overridden to include the unsubscription logic, which helps in + /// cleaning up resources and preventing memory leaks by unsubscribing from + /// the dependency container. + @override + void dispose() { + // End subscription to the dependency container. + unsubscribeFromDependencyContainer(); + + // Call the superclass's dispose method. + super.dispose(); + } +} diff --git a/wolt_di/lib/src/view_model/feature_with_view_model_dependency_container.dart b/wolt_di/lib/src/view_model/feature_with_view_model_dependency_container.dart new file mode 100644 index 00000000..ae88751f --- /dev/null +++ b/wolt_di/lib/src/view_model/feature_with_view_model_dependency_container.dart @@ -0,0 +1,8 @@ +import 'package:wolt_di/wolt_di.dart'; + +/// An abstract base class for a feature level dependency container that provides a view model. +abstract class FeatureWithViewModelDependencyContainer + extends FeatureLevelDependencyContainer { + /// Creates a new view model instance. + VM createViewModel(); +} diff --git a/wolt_di/lib/src/view_model/feature_with_view_model_dependency_container_subscription_mixin.dart b/wolt_di/lib/src/view_model/feature_with_view_model_dependency_container_subscription_mixin.dart new file mode 100644 index 00000000..e23b5c3e --- /dev/null +++ b/wolt_di/lib/src/view_model/feature_with_view_model_dependency_container_subscription_mixin.dart @@ -0,0 +1,29 @@ +import 'package:flutter/widgets.dart'; +import 'package:wolt_di/wolt_di.dart'; + +mixin FeatureWithViewModelDependencyContainerSubscriptionMixin< + C extends FeatureWithViewModelDependencyContainer, + VM extends WoltViewModel, + T extends StatefulWidget> on State + implements DependencyContainerSubscriber { + late DependencyInjector _injector; + late VM _viewModel; + + VM get viewModel => _viewModel; + + @override + void initState() { + super.initState(); + _injector = DependencyInjector.of(context); + _injector.subscribeToDependencyContainer(this); + _viewModel = + DependencyInjector.container(context).createViewModel() as VM; + } + + @override + void dispose() { + _injector.unsubscribeFromDependencyContainer(this); + _viewModel.dispose(); + super.dispose(); + } +} diff --git a/wolt_di/lib/src/view_model/wolt_view_model.dart b/wolt_di/lib/src/view_model/wolt_view_model.dart new file mode 100644 index 00000000..32903c41 --- /dev/null +++ b/wolt_di/lib/src/view_model/wolt_view_model.dart @@ -0,0 +1,8 @@ +import 'package:flutter/widgets.dart'; + +abstract class WoltViewModel { + /// Discards any resources used by the view model classes. This method should called in the + /// dispose method of the [StatefulWidget]. After this is called, the object is not in a usable + /// state. + void dispose(); +} diff --git a/wolt_di/lib/wolt_di.dart b/wolt_di/lib/wolt_di.dart index 9c1b644f..126c515a 100644 --- a/wolt_di/lib/wolt_di.dart +++ b/wolt_di/lib/wolt_di.dart @@ -1,5 +1,9 @@ export 'src/dependency_container.dart'; export 'src/manager/dependency_container_manager.dart' hide DependencyContainerResolver, DependencyContainerRegistrar; -export 'src/dependency_container_subscription_mixin.dart'; +export 'src/subscriber/dependency_container_subscription_mixin.dart'; +export 'src/subscriber/dependency_container_subscriber.dart'; +export 'src/view_model/feature_with_view_model_dependency_container.dart'; +export 'src/view_model/wolt_view_model.dart'; +export 'src/view_model/feature_with_view_model_dependency_container_subscription_mixin.dart'; export 'src/dependency_injector.dart'; diff --git a/wolt_di/pubspec.yaml b/wolt_di/pubspec.yaml index a0ae90c5..0eadbbb6 100644 --- a/wolt_di/pubspec.yaml +++ b/wolt_di/pubspec.yaml @@ -8,7 +8,6 @@ environment: dependencies: flutter: sdk: flutter - meta: ^1.3.0 dev_dependencies: flutter_lints: ^2.0.1 From 435088112a71144ee25a5009b11d209fe2297697 Mon Sep 17 00:00:00 2001 From: Cagatay Ulusoy Date: Fri, 16 Aug 2024 18:46:23 +0300 Subject: [PATCH 2/3] use late for selectedStepListenable --- .../lib/ui/orders/view/orders_screen.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart b/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart index f78213d6..f64fee92 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart +++ b/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart @@ -26,8 +26,14 @@ class _OrdersScreenState extends State with FeatureWithViewModelDependencyContainerSubscriptionMixin< OrdersDependencyContainer, OrdersScreenViewModel, OrdersScreen> { - ValueListenable get selectedStepListenable => - context.routerViewModel.bottomNavigationTabInOrdersPage; + late ValueListenable selectedStepListenable; + + @override + void initState() { + super.initState(); + selectedStepListenable = + context.routerViewModel.bottomNavigationTabInOrdersPage; + } @override Widget build(BuildContext context) { From 65a11a20c872b4828a93511e357297ade924fd9d Mon Sep 17 00:00:00 2001 From: Cagatay Ulusoy Date: Sat, 17 Aug 2024 23:31:09 +0300 Subject: [PATCH 3/3] re-organize the app level and feature level folders --- .../lib/{ => app}/app.dart | 2 +- .../data}/local/auth_local_data_source.dart | 0 .../data}/repository/auth_repository.dart | 2 +- .../auth/domain}/auth_service.dart | 2 +- ..._maker_app_level_dependency_container.dart | 16 +++++------ .../router/entities/app_route_page.dart | 24 ++++++++-------- .../entities/app_route_settings_name.dart | 0 .../router/view/app_router_delegate.dart | 6 ++-- .../router/view_model/router_view_model.dart | 14 +++++----- .../ui/widgets/app_navigation_drawer.dart | 2 +- .../di/add_water_dependency_container.dart | 8 +++--- .../add_water/domain}/add_water_service.dart | 6 ++-- .../domain}/entities/coffee_season.dart | 0 .../entities/water_acceptance_result.dart | 0 .../domain}/entities/water_source.dart | 0 .../add_water/ui}/view/add_water_screen.dart | 8 +++--- .../ui}/view_model/add_water_view_model.dart | 10 +++---- .../login_screen_dependency_container.dart} | 14 +++++----- .../login/ui/view/login_screen.dart} | 28 ++++++------------- .../view_model/login_screen_view_model.dart} | 6 ++-- .../local/onboarding_local_data_source.dart | 0 .../repository/onboarding_repository.dart | 2 +- .../domain}/onboarding_service.dart | 2 +- .../ui}/view/onboarding_modal_sheet_page.dart | 2 +- .../remote/orders_remote_data_source.dart | 4 +-- .../data}/repository/orders_repository.dart | 5 ++-- .../di/orders_dependency_container.dart | 8 +++--- .../domain}/entities/coffee_maker_step.dart | 0 .../orders/domain}/entities/coffee_order.dart | 2 +- .../entities/grouped_coffee_orders.dart | 4 +-- .../orders/domain}/orders_service.dart | 6 ++-- .../grind/grind_or_reject_modal_page.dart | 6 ++-- .../grind/reject_order_modal_page.dart | 6 ++-- .../grind/reject_order_reason.dart | 0 .../ready/extra_recommendation.dart | 0 .../ready/extra_recommendation_tile.dart | 4 +-- .../offer_recommendation_modal_page.dart | 6 ++-- .../ready/serve_or_offer_modal_page.dart | 2 +- .../orders/ui}/view/orders_screen.dart | 18 ++++++------ .../widgets/coffee_order_list_item_tile.dart | 2 +- .../coffee_order_list_view_for_step.dart | 18 ++++++------ .../widgets/empty_coffee_order_list_view.dart | 2 +- .../orders_screen_bottom_navigation_bar.dart | 6 ++-- .../view_model/orders_screen_view_model.dart | 6 ++-- .../widgets/coffee_maker_custom_divider.dart | 0 .../ui}/widgets/grid_layout_button.dart | 0 .../widgets/store_online_status_button.dart | 0 .../orders/ui}/widgets/top_bar.dart | 4 +-- .../view/single_tutorial_screen.dart | 2 +- .../tutorial}/view/tutorials_screen.dart | 8 ++---- coffee_maker_navigator_2/lib/main.dart | 14 +++++----- .../extensions/context_extensions.dart | 4 +-- 52 files changed, 140 insertions(+), 151 deletions(-) rename coffee_maker_navigator_2/lib/{ => app}/app.dart (89%) rename coffee_maker_navigator_2/lib/{data/auth => app/auth/data}/local/auth_local_data_source.dart (100%) rename coffee_maker_navigator_2/lib/{data/auth => app/auth/data}/repository/auth_repository.dart (87%) rename coffee_maker_navigator_2/lib/{domain/auth => app/auth/domain}/auth_service.dart (93%) rename coffee_maker_navigator_2/lib/{ => app}/di/coffee_maker_app_level_dependency_container.dart (77%) rename coffee_maker_navigator_2/lib/{ui => app}/router/entities/app_route_page.dart (77%) rename coffee_maker_navigator_2/lib/{ui => app}/router/entities/app_route_settings_name.dart (100%) rename coffee_maker_navigator_2/lib/{ui => app}/router/view/app_router_delegate.dart (92%) rename coffee_maker_navigator_2/lib/{ui => app}/router/view_model/router_view_model.dart (89%) rename coffee_maker_navigator_2/lib/{ => app}/ui/widgets/app_navigation_drawer.dart (97%) rename coffee_maker_navigator_2/lib/{ui => features}/add_water/di/add_water_dependency_container.dart (73%) rename coffee_maker_navigator_2/lib/{domain/add_water => features/add_water/domain}/add_water_service.dart (86%) rename coffee_maker_navigator_2/lib/{domain/add_water => features/add_water/domain}/entities/coffee_season.dart (100%) rename coffee_maker_navigator_2/lib/{domain/add_water => features/add_water/domain}/entities/water_acceptance_result.dart (100%) rename coffee_maker_navigator_2/lib/{domain/add_water => features/add_water/domain}/entities/water_source.dart (100%) rename coffee_maker_navigator_2/lib/{ui/add_water => features/add_water/ui}/view/add_water_screen.dart (95%) rename coffee_maker_navigator_2/lib/{ui/add_water => features/add_water/ui}/view_model/add_water_view_model.dart (85%) rename coffee_maker_navigator_2/lib/{ui/auth/di/auth_screen_dependency_container.dart => features/login/di/login_screen_dependency_container.dart} (54%) rename coffee_maker_navigator_2/lib/{ui/auth/view/auth_screen.dart => features/login/ui/view/login_screen.dart} (69%) rename coffee_maker_navigator_2/lib/{ui/auth/view_model/auth_screen_view_model.dart => features/login/ui/view_model/login_screen_view_model.dart} (55%) rename coffee_maker_navigator_2/lib/{data/onboarding => features/onboarding/data}/local/onboarding_local_data_source.dart (100%) rename coffee_maker_navigator_2/lib/{data/onboarding => features/onboarding/data}/repository/onboarding_repository.dart (75%) rename coffee_maker_navigator_2/lib/{domain/onboarding => features/onboarding/domain}/onboarding_service.dart (78%) rename coffee_maker_navigator_2/lib/{ui/onboarding => features/onboarding/ui}/view/onboarding_modal_sheet_page.dart (96%) rename coffee_maker_navigator_2/lib/{data/orders => features/orders/data}/remote/orders_remote_data_source.dart (93%) rename coffee_maker_navigator_2/lib/{data/orders => features/orders/data}/repository/orders_repository.dart (75%) rename coffee_maker_navigator_2/lib/{ui => features}/orders/di/orders_dependency_container.dart (71%) rename coffee_maker_navigator_2/lib/{domain/orders => features/orders/domain}/entities/coffee_maker_step.dart (100%) rename coffee_maker_navigator_2/lib/{domain/orders => features/orders/domain}/entities/coffee_order.dart (91%) rename coffee_maker_navigator_2/lib/{domain/orders => features/orders/domain}/entities/grouped_coffee_orders.dart (92%) rename coffee_maker_navigator_2/lib/{domain/orders => features/orders/domain}/orders_service.dart (85%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/grind/grind_or_reject_modal_page.dart (88%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/grind/reject_order_modal_page.dart (91%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/grind/reject_order_reason.dart (100%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/ready/extra_recommendation.dart (100%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/ready/extra_recommendation_tile.dart (94%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/ready/offer_recommendation_modal_page.dart (91%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/modal_pages/ready/serve_or_offer_modal_page.dart (95%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/orders_screen.dart (81%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/widgets/coffee_order_list_item_tile.dart (97%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/widgets/coffee_order_list_view_for_step.dart (83%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/widgets/empty_coffee_order_list_view.dart (94%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view/widgets/orders_screen_bottom_navigation_bar.dart (93%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/view_model/orders_screen_view_model.dart (77%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/widgets/coffee_maker_custom_divider.dart (100%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/widgets/grid_layout_button.dart (100%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/widgets/store_online_status_button.dart (100%) rename coffee_maker_navigator_2/lib/{ui/orders => features/orders/ui}/widgets/top_bar.dart (85%) rename coffee_maker_navigator_2/lib/{ui/tutorials => features/tutorial}/view/single_tutorial_screen.dart (96%) rename coffee_maker_navigator_2/lib/{ui/tutorials => features/tutorial}/view/tutorials_screen.dart (92%) rename coffee_maker_navigator_2/lib/{ui => utils}/extensions/context_extensions.dart (61%) diff --git a/coffee_maker_navigator_2/lib/app.dart b/coffee_maker_navigator_2/lib/app/app.dart similarity index 89% rename from coffee_maker_navigator_2/lib/app.dart rename to coffee_maker_navigator_2/lib/app/app.dart index 8d799f68..e197ba0e 100644 --- a/coffee_maker_navigator_2/lib/app.dart +++ b/coffee_maker_navigator_2/lib/app/app.dart @@ -1,5 +1,5 @@ import 'package:wolt_di/wolt_di.dart'; -import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/app/di/coffee_maker_app_level_dependency_container.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/data/auth/local/auth_local_data_source.dart b/coffee_maker_navigator_2/lib/app/auth/data/local/auth_local_data_source.dart similarity index 100% rename from coffee_maker_navigator_2/lib/data/auth/local/auth_local_data_source.dart rename to coffee_maker_navigator_2/lib/app/auth/data/local/auth_local_data_source.dart diff --git a/coffee_maker_navigator_2/lib/data/auth/repository/auth_repository.dart b/coffee_maker_navigator_2/lib/app/auth/data/repository/auth_repository.dart similarity index 87% rename from coffee_maker_navigator_2/lib/data/auth/repository/auth_repository.dart rename to coffee_maker_navigator_2/lib/app/auth/data/repository/auth_repository.dart index fa0ed71c..4b284097 100644 --- a/coffee_maker_navigator_2/lib/data/auth/repository/auth_repository.dart +++ b/coffee_maker_navigator_2/lib/app/auth/data/repository/auth_repository.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:coffee_maker_navigator_2/data/auth/local/auth_local_data_source.dart'; +import 'package:coffee_maker_navigator_2/app/auth/data/local/auth_local_data_source.dart'; class AuthRepository { final AuthLocalDataSource localAuthDataSource; diff --git a/coffee_maker_navigator_2/lib/domain/auth/auth_service.dart b/coffee_maker_navigator_2/lib/app/auth/domain/auth_service.dart similarity index 93% rename from coffee_maker_navigator_2/lib/domain/auth/auth_service.dart rename to coffee_maker_navigator_2/lib/app/auth/domain/auth_service.dart index fd60aa39..f907e70f 100644 --- a/coffee_maker_navigator_2/lib/domain/auth/auth_service.dart +++ b/coffee_maker_navigator_2/lib/app/auth/domain/auth_service.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:coffee_maker_navigator_2/data/auth/repository/auth_repository.dart'; +import 'package:coffee_maker_navigator_2/app/auth/data/repository/auth_repository.dart'; import 'package:flutter/foundation.dart'; abstract interface class AuthService { diff --git a/coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart b/coffee_maker_navigator_2/lib/app/di/coffee_maker_app_level_dependency_container.dart similarity index 77% rename from coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart rename to coffee_maker_navigator_2/lib/app/di/coffee_maker_app_level_dependency_container.dart index 5736ea45..bc850cf9 100644 --- a/coffee_maker_navigator_2/lib/di/coffee_maker_app_level_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/app/di/coffee_maker_app_level_dependency_container.dart @@ -1,11 +1,11 @@ -import 'package:coffee_maker_navigator_2/data/auth/local/auth_local_data_source.dart'; -import 'package:coffee_maker_navigator_2/data/auth/repository/auth_repository.dart'; -import 'package:coffee_maker_navigator_2/data/onboarding/local/onboarding_local_data_source.dart'; -import 'package:coffee_maker_navigator_2/data/onboarding/repository/onboarding_repository.dart'; -import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; -import 'package:coffee_maker_navigator_2/domain/onboarding/onboarding_service.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view/app_router_delegate.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/app/auth/data/local/auth_local_data_source.dart'; +import 'package:coffee_maker_navigator_2/app/auth/data/repository/auth_repository.dart'; +import 'package:coffee_maker_navigator_2/app/auth/domain/auth_service.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/data/local/onboarding_local_data_source.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/data/repository/onboarding_repository.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/domain/onboarding_service.dart'; +import 'package:coffee_maker_navigator_2/app/router/view/app_router_delegate.dart'; +import 'package:coffee_maker_navigator_2/app/router/view_model/router_view_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart b/coffee_maker_navigator_2/lib/app/router/entities/app_route_page.dart similarity index 77% rename from coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart rename to coffee_maker_navigator_2/lib/app/router/entities/app_route_page.dart index b5999715..e29c2748 100644 --- a/coffee_maker_navigator_2/lib/ui/router/entities/app_route_page.dart +++ b/coffee_maker_navigator_2/lib/app/router/entities/app_route_page.dart @@ -1,14 +1,14 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/add_water/view/add_water_screen.dart'; -import 'package:coffee_maker_navigator_2/ui/auth/view/auth_screen.dart'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/onboarding/view/onboarding_modal_sheet_page.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; -import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_settings_name.dart'; -import 'package:coffee_maker_navigator_2/ui/tutorials/view/single_tutorial_screen.dart'; -import 'package:coffee_maker_navigator_2/ui/tutorials/view/tutorials_screen.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/ui/view/add_water_screen.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/tutorial/view/single_tutorial_screen.dart'; +import 'package:coffee_maker_navigator_2/features/tutorial/view/tutorials_screen.dart'; +import 'package:coffee_maker_navigator_2/features/login/ui/view/login_screen.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/ui/view/onboarding_modal_sheet_page.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/grind/grind_or_reject_modal_page.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/grind/reject_order_modal_page.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/app/router/entities/app_route_settings_name.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; @@ -25,7 +25,7 @@ class AuthRoutePage extends AppRoutePage { @override Route createRoute(BuildContext context) { return MaterialPageRoute( - builder: (context) => const AuthScreen(), + builder: (context) => const LoginScreen(), settings: this, ); } diff --git a/coffee_maker_navigator_2/lib/ui/router/entities/app_route_settings_name.dart b/coffee_maker_navigator_2/lib/app/router/entities/app_route_settings_name.dart similarity index 100% rename from coffee_maker_navigator_2/lib/ui/router/entities/app_route_settings_name.dart rename to coffee_maker_navigator_2/lib/app/router/entities/app_route_settings_name.dart diff --git a/coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart b/coffee_maker_navigator_2/lib/app/router/view/app_router_delegate.dart similarity index 92% rename from coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart rename to coffee_maker_navigator_2/lib/app/router/view/app_router_delegate.dart index 02b5a917..ee38601c 100644 --- a/coffee_maker_navigator_2/lib/ui/router/view/app_router_delegate.dart +++ b/coffee_maker_navigator_2/lib/app/router/view/app_router_delegate.dart @@ -1,8 +1,8 @@ import 'dart:async'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/coffee_order_list_view_for_step.dart'; -import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_page.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/widgets/coffee_order_list_view_for_step.dart'; +import 'package:coffee_maker_navigator_2/app/router/entities/app_route_page.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart b/coffee_maker_navigator_2/lib/app/router/view_model/router_view_model.dart similarity index 89% rename from coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart rename to coffee_maker_navigator_2/lib/app/router/view_model/router_view_model.dart index 5215930c..8515f861 100644 --- a/coffee_maker_navigator_2/lib/ui/router/view_model/router_view_model.dart +++ b/coffee_maker_navigator_2/lib/app/router/view_model/router_view_model.dart @@ -1,12 +1,12 @@ import 'dart:async'; -import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; -import 'package:coffee_maker_navigator_2/domain/onboarding/onboarding_service.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; -import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_page.dart'; -import 'package:coffee_maker_navigator_2/ui/router/entities/app_route_settings_name.dart'; -import 'package:coffee_maker_navigator_2/ui/widgets/app_navigation_drawer.dart'; +import 'package:coffee_maker_navigator_2/app/auth/domain/auth_service.dart'; +import 'package:coffee_maker_navigator_2/app/ui/widgets/app_navigation_drawer.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/domain/onboarding_service.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/app/router/entities/app_route_page.dart'; +import 'package:coffee_maker_navigator_2/app/router/entities/app_route_settings_name.dart'; import 'package:flutter/material.dart'; class RouterViewModel { diff --git a/coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart b/coffee_maker_navigator_2/lib/app/ui/widgets/app_navigation_drawer.dart similarity index 97% rename from coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart rename to coffee_maker_navigator_2/lib/app/ui/widgets/app_navigation_drawer.dart index c7dc74d3..0a4ab5d0 100644 --- a/coffee_maker_navigator_2/lib/ui/widgets/app_navigation_drawer.dart +++ b/coffee_maker_navigator_2/lib/app/ui/widgets/app_navigation_drawer.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:flutter/material.dart'; enum AppNavigationDrawerDestination { diff --git a/coffee_maker_navigator_2/lib/ui/add_water/di/add_water_dependency_container.dart b/coffee_maker_navigator_2/lib/features/add_water/di/add_water_dependency_container.dart similarity index 73% rename from coffee_maker_navigator_2/lib/ui/add_water/di/add_water_dependency_container.dart rename to coffee_maker_navigator_2/lib/features/add_water/di/add_water_dependency_container.dart index 3badc93c..bbc776b1 100644 --- a/coffee_maker_navigator_2/lib/ui/add_water/di/add_water_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/features/add_water/di/add_water_dependency_container.dart @@ -1,8 +1,8 @@ import 'package:wolt_di/wolt_di.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/di/orders_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/domain/add_water/add_water_service.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; -import 'package:coffee_maker_navigator_2/ui/add_water/view_model/add_water_view_model.dart'; +import 'package:coffee_maker_navigator_2/features/orders/di/orders_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/add_water_service.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/orders_service.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/ui/view_model/add_water_view_model.dart'; class AddWaterDependencyContainer extends FeatureWithViewModelDependencyContainer { diff --git a/coffee_maker_navigator_2/lib/domain/add_water/add_water_service.dart b/coffee_maker_navigator_2/lib/features/add_water/domain/add_water_service.dart similarity index 86% rename from coffee_maker_navigator_2/lib/domain/add_water/add_water_service.dart rename to coffee_maker_navigator_2/lib/features/add_water/domain/add_water_service.dart index 98460017..779a1089 100644 --- a/coffee_maker_navigator_2/lib/domain/add_water/add_water_service.dart +++ b/coffee_maker_navigator_2/lib/features/add_water/domain/add_water_service.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/domain/add_water/entities/coffee_season.dart'; -import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_acceptance_result.dart'; -import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_source.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/coffee_season.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/water_acceptance_result.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/water_source.dart'; class AddWaterService { // We keep the business logic in client without any data source layer operations. diff --git a/coffee_maker_navigator_2/lib/domain/add_water/entities/coffee_season.dart b/coffee_maker_navigator_2/lib/features/add_water/domain/entities/coffee_season.dart similarity index 100% rename from coffee_maker_navigator_2/lib/domain/add_water/entities/coffee_season.dart rename to coffee_maker_navigator_2/lib/features/add_water/domain/entities/coffee_season.dart diff --git a/coffee_maker_navigator_2/lib/domain/add_water/entities/water_acceptance_result.dart b/coffee_maker_navigator_2/lib/features/add_water/domain/entities/water_acceptance_result.dart similarity index 100% rename from coffee_maker_navigator_2/lib/domain/add_water/entities/water_acceptance_result.dart rename to coffee_maker_navigator_2/lib/features/add_water/domain/entities/water_acceptance_result.dart diff --git a/coffee_maker_navigator_2/lib/domain/add_water/entities/water_source.dart b/coffee_maker_navigator_2/lib/features/add_water/domain/entities/water_source.dart similarity index 100% rename from coffee_maker_navigator_2/lib/domain/add_water/entities/water_source.dart rename to coffee_maker_navigator_2/lib/features/add_water/domain/entities/water_source.dart diff --git a/coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart b/coffee_maker_navigator_2/lib/features/add_water/ui/view/add_water_screen.dart similarity index 95% rename from coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart rename to coffee_maker_navigator_2/lib/features/add_water/ui/view/add_water_screen.dart index 3d133ffe..2d0897ee 100644 --- a/coffee_maker_navigator_2/lib/ui/add_water/view/add_water_screen.dart +++ b/coffee_maker_navigator_2/lib/features/add_water/ui/view/add_water_screen.dart @@ -1,7 +1,7 @@ -import 'package:coffee_maker_navigator_2/ui/add_water/di/add_water_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_source.dart'; -import 'package:coffee_maker_navigator_2/ui/add_water/view_model/add_water_view_model.dart'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/di/add_water_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/water_source.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/ui/view_model/add_water_view_model.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart b/coffee_maker_navigator_2/lib/features/add_water/ui/view_model/add_water_view_model.dart similarity index 85% rename from coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart rename to coffee_maker_navigator_2/lib/features/add_water/ui/view_model/add_water_view_model.dart index e4e9891b..1f88af53 100644 --- a/coffee_maker_navigator_2/lib/ui/add_water/view_model/add_water_view_model.dart +++ b/coffee_maker_navigator_2/lib/features/add_water/ui/view_model/add_water_view_model.dart @@ -1,8 +1,8 @@ -import 'package:coffee_maker_navigator_2/domain/add_water/add_water_service.dart'; -import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_acceptance_result.dart'; -import 'package:coffee_maker_navigator_2/domain/add_water/entities/water_source.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/add_water_service.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/water_acceptance_result.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/water_source.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/orders_service.dart'; import 'package:flutter/foundation.dart'; import 'package:wolt_di/wolt_di.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/auth/di/auth_screen_dependency_container.dart b/coffee_maker_navigator_2/lib/features/login/di/login_screen_dependency_container.dart similarity index 54% rename from coffee_maker_navigator_2/lib/ui/auth/di/auth_screen_dependency_container.dart rename to coffee_maker_navigator_2/lib/features/login/di/login_screen_dependency_container.dart index c66fe516..038ec4a8 100644 --- a/coffee_maker_navigator_2/lib/ui/auth/di/auth_screen_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/features/login/di/login_screen_dependency_container.dart @@ -1,13 +1,13 @@ -import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; -import 'package:coffee_maker_navigator_2/ui/auth/view_model/auth_screen_view_model.dart'; +import 'package:coffee_maker_navigator_2/app/di/coffee_maker_app_level_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/app/auth/domain/auth_service.dart'; +import 'package:coffee_maker_navigator_2/features/login/ui/view_model/login_screen_view_model.dart'; import 'package:wolt_di/wolt_di.dart'; -class AuthScreenDependencyContainer +class LoginScreenDependencyContainer extends FeatureWithViewModelDependencyContainer { late final AuthService _authService; - AuthScreenDependencyContainer() { + LoginScreenDependencyContainer() { final appLevelDependencies = bindWith(); _authService = appLevelDependencies.authService; @@ -15,8 +15,8 @@ class AuthScreenDependencyContainer // ViewModel should always be created lazily. @override - AuthScreenViewModel createViewModel() { - return AuthScreenViewModel(authService: _authService); + LoginScreenViewModel createViewModel() { + return LoginScreenViewModel(authService: _authService); } @override diff --git a/coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart b/coffee_maker_navigator_2/lib/features/login/ui/view/login_screen.dart similarity index 69% rename from coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart rename to coffee_maker_navigator_2/lib/features/login/ui/view/login_screen.dart index decefed9..42f4ed32 100644 --- a/coffee_maker_navigator_2/lib/ui/auth/view/auth_screen.dart +++ b/coffee_maker_navigator_2/lib/features/login/ui/view/login_screen.dart @@ -1,30 +1,20 @@ -import 'package:coffee_maker_navigator_2/ui/auth/di/auth_screen_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/ui/auth/view_model/auth_screen_view_model.dart'; +import 'package:coffee_maker_navigator_2/features/login/di/login_screen_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/login/ui/view_model/login_screen_view_model.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_di/wolt_di.dart'; -class AuthScreen extends StatefulWidget { - const AuthScreen({super.key}); +class LoginScreen extends StatefulWidget { + const LoginScreen({super.key}); @override - State createState() => _AuthScreenState(); + State createState() => _LoginScreenState(); } -class _AuthScreenState extends State +class _LoginScreenState extends State with - DependencyContainerSubscriptionMixin { - late AuthScreenViewModel _viewModel; - - @override - void initState() { - super.initState(); - final dependencyContainer = - DependencyInjector.container(context); - _viewModel = dependencyContainer.createViewModel(); - } - + FeatureWithViewModelDependencyContainerSubscriptionMixin< + LoginScreenDependencyContainer, LoginScreenViewModel, LoginScreen> { @override Widget build(BuildContext context) { final textTheme = Theme.of(context).textTheme; @@ -64,7 +54,7 @@ class _AuthScreenState extends State const SizedBox(height: 30), WoltElevatedButton( onPressed: () { - _viewModel.onLoginPressed('email', 'password'); + viewModel.onLoginPressed('email', 'password'); }, child: const Text('Sign in'), ), diff --git a/coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart b/coffee_maker_navigator_2/lib/features/login/ui/view_model/login_screen_view_model.dart similarity index 55% rename from coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart rename to coffee_maker_navigator_2/lib/features/login/ui/view_model/login_screen_view_model.dart index e854119f..80eb0a7c 100644 --- a/coffee_maker_navigator_2/lib/ui/auth/view_model/auth_screen_view_model.dart +++ b/coffee_maker_navigator_2/lib/features/login/ui/view_model/login_screen_view_model.dart @@ -1,10 +1,10 @@ -import 'package:coffee_maker_navigator_2/domain/auth/auth_service.dart'; +import 'package:coffee_maker_navigator_2/app/auth/domain/auth_service.dart'; import 'package:wolt_di/wolt_di.dart'; -class AuthScreenViewModel extends WoltViewModel { +class LoginScreenViewModel extends WoltViewModel { final AuthService authService; - AuthScreenViewModel({required this.authService}); + LoginScreenViewModel({required this.authService}); Future onLoginPressed(String email, String password) async { await authService.logIn(email, password); diff --git a/coffee_maker_navigator_2/lib/data/onboarding/local/onboarding_local_data_source.dart b/coffee_maker_navigator_2/lib/features/onboarding/data/local/onboarding_local_data_source.dart similarity index 100% rename from coffee_maker_navigator_2/lib/data/onboarding/local/onboarding_local_data_source.dart rename to coffee_maker_navigator_2/lib/features/onboarding/data/local/onboarding_local_data_source.dart diff --git a/coffee_maker_navigator_2/lib/data/onboarding/repository/onboarding_repository.dart b/coffee_maker_navigator_2/lib/features/onboarding/data/repository/onboarding_repository.dart similarity index 75% rename from coffee_maker_navigator_2/lib/data/onboarding/repository/onboarding_repository.dart rename to coffee_maker_navigator_2/lib/features/onboarding/data/repository/onboarding_repository.dart index 281c856f..9da15101 100644 --- a/coffee_maker_navigator_2/lib/data/onboarding/repository/onboarding_repository.dart +++ b/coffee_maker_navigator_2/lib/features/onboarding/data/repository/onboarding_repository.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:coffee_maker_navigator_2/data/onboarding/local/onboarding_local_data_source.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/data/local/onboarding_local_data_source.dart'; class OnboardingRepository { final OnboardingLocalDataSource localDataSource; diff --git a/coffee_maker_navigator_2/lib/domain/onboarding/onboarding_service.dart b/coffee_maker_navigator_2/lib/features/onboarding/domain/onboarding_service.dart similarity index 78% rename from coffee_maker_navigator_2/lib/domain/onboarding/onboarding_service.dart rename to coffee_maker_navigator_2/lib/features/onboarding/domain/onboarding_service.dart index cf45ecb3..8afa3786 100644 --- a/coffee_maker_navigator_2/lib/domain/onboarding/onboarding_service.dart +++ b/coffee_maker_navigator_2/lib/features/onboarding/domain/onboarding_service.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/data/onboarding/repository/onboarding_repository.dart'; +import 'package:coffee_maker_navigator_2/features/onboarding/data/repository/onboarding_repository.dart'; class OnboardingService { final OnboardingRepository _tutorialRepository; diff --git a/coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart b/coffee_maker_navigator_2/lib/features/onboarding/ui/view/onboarding_modal_sheet_page.dart similarity index 96% rename from coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart rename to coffee_maker_navigator_2/lib/features/onboarding/ui/view/onboarding_modal_sheet_page.dart index 11a2a500..c7d8b778 100644 --- a/coffee_maker_navigator_2/lib/ui/onboarding/view/onboarding_modal_sheet_page.dart +++ b/coffee_maker_navigator_2/lib/features/onboarding/ui/view/onboarding_modal_sheet_page.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; diff --git a/coffee_maker_navigator_2/lib/data/orders/remote/orders_remote_data_source.dart b/coffee_maker_navigator_2/lib/features/orders/data/remote/orders_remote_data_source.dart similarity index 93% rename from coffee_maker_navigator_2/lib/data/orders/remote/orders_remote_data_source.dart rename to coffee_maker_navigator_2/lib/features/orders/data/remote/orders_remote_data_source.dart index cc6c0119..00a3d58a 100644 --- a/coffee_maker_navigator_2/lib/data/orders/remote/orders_remote_data_source.dart +++ b/coffee_maker_navigator_2/lib/features/orders/data/remote/orders_remote_data_source.dart @@ -1,7 +1,7 @@ import 'dart:async'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_order.dart'; import 'package:flutter/foundation.dart'; abstract interface class OrdersRemoteDataSource { diff --git a/coffee_maker_navigator_2/lib/data/orders/repository/orders_repository.dart b/coffee_maker_navigator_2/lib/features/orders/data/repository/orders_repository.dart similarity index 75% rename from coffee_maker_navigator_2/lib/data/orders/repository/orders_repository.dart rename to coffee_maker_navigator_2/lib/features/orders/data/repository/orders_repository.dart index f86892cd..78f46d9f 100644 --- a/coffee_maker_navigator_2/lib/data/orders/repository/orders_repository.dart +++ b/coffee_maker_navigator_2/lib/features/orders/data/repository/orders_repository.dart @@ -1,5 +1,6 @@ -import 'package:coffee_maker_navigator_2/data/orders/remote/orders_remote_data_source.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; +import 'package:coffee_maker_navigator_2/features/orders/data/remote/orders_remote_data_source.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_order.dart'; + import 'package:flutter/foundation.dart'; class OrdersRepository { diff --git a/coffee_maker_navigator_2/lib/ui/orders/di/orders_dependency_container.dart b/coffee_maker_navigator_2/lib/features/orders/di/orders_dependency_container.dart similarity index 71% rename from coffee_maker_navigator_2/lib/ui/orders/di/orders_dependency_container.dart rename to coffee_maker_navigator_2/lib/features/orders/di/orders_dependency_container.dart index 245b62db..53487fe7 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/di/orders_dependency_container.dart +++ b/coffee_maker_navigator_2/lib/features/orders/di/orders_dependency_container.dart @@ -1,7 +1,7 @@ -import 'package:coffee_maker_navigator_2/data/orders/remote/orders_remote_data_source.dart'; -import 'package:coffee_maker_navigator_2/data/orders/repository/orders_repository.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; +import 'package:coffee_maker_navigator_2/features/orders/data/remote/orders_remote_data_source.dart'; +import 'package:coffee_maker_navigator_2/features/orders/data/repository/orders_repository.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/orders_service.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view_model/orders_screen_view_model.dart'; import 'package:wolt_di/wolt_di.dart'; class OrdersDependencyContainer diff --git a/coffee_maker_navigator_2/lib/domain/orders/entities/coffee_maker_step.dart b/coffee_maker_navigator_2/lib/features/orders/domain/entities/coffee_maker_step.dart similarity index 100% rename from coffee_maker_navigator_2/lib/domain/orders/entities/coffee_maker_step.dart rename to coffee_maker_navigator_2/lib/features/orders/domain/entities/coffee_maker_step.dart diff --git a/coffee_maker_navigator_2/lib/domain/orders/entities/coffee_order.dart b/coffee_maker_navigator_2/lib/features/orders/domain/entities/coffee_order.dart similarity index 91% rename from coffee_maker_navigator_2/lib/domain/orders/entities/coffee_order.dart rename to coffee_maker_navigator_2/lib/features/orders/domain/entities/coffee_order.dart index faf50cdd..ff82cd46 100644 --- a/coffee_maker_navigator_2/lib/domain/orders/entities/coffee_order.dart +++ b/coffee_maker_navigator_2/lib/features/orders/domain/entities/coffee_order.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; import 'package:equatable/equatable.dart'; /// Represents a coffee order in the CoffeeMaker demo app. diff --git a/coffee_maker_navigator_2/lib/domain/orders/entities/grouped_coffee_orders.dart b/coffee_maker_navigator_2/lib/features/orders/domain/entities/grouped_coffee_orders.dart similarity index 92% rename from coffee_maker_navigator_2/lib/domain/orders/entities/grouped_coffee_orders.dart rename to coffee_maker_navigator_2/lib/features/orders/domain/entities/grouped_coffee_orders.dart index 976429ef..597429b0 100644 --- a/coffee_maker_navigator_2/lib/domain/orders/entities/grouped_coffee_orders.dart +++ b/coffee_maker_navigator_2/lib/features/orders/domain/entities/grouped_coffee_orders.dart @@ -1,5 +1,5 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_order.dart'; import 'package:equatable/equatable.dart'; /// Represents a group of coffee orders categorized by their current coffee maker step. diff --git a/coffee_maker_navigator_2/lib/domain/orders/orders_service.dart b/coffee_maker_navigator_2/lib/features/orders/domain/orders_service.dart similarity index 85% rename from coffee_maker_navigator_2/lib/domain/orders/orders_service.dart rename to coffee_maker_navigator_2/lib/features/orders/domain/orders_service.dart index 81a3050e..3a8bfe97 100644 --- a/coffee_maker_navigator_2/lib/domain/orders/orders_service.dart +++ b/coffee_maker_navigator_2/lib/features/orders/domain/orders_service.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/data/orders/repository/orders_repository.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; +import 'package:coffee_maker_navigator_2/features/orders/data/repository/orders_repository.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_order.dart'; import 'package:flutter/foundation.dart'; class OrdersService { diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/grind_or_reject_modal_page.dart similarity index 88% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/grind_or_reject_modal_page.dart index ab83b1f2..78b60574 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/grind_or_reject_modal_page.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/grind_or_reject_modal_page.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/reject_order_modal_page.dart similarity index 91% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/reject_order_modal_page.dart index 0df80480..0658e85d 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_modal_page.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/reject_order_modal_page.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/grind/reject_order_reason.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/grind/reject_order_reason.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_reason.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/reject_order_reason.dart similarity index 100% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/grind/reject_order_reason.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/grind/reject_order_reason.dart diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/extra_recommendation.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/extra_recommendation.dart similarity index 100% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/extra_recommendation.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/extra_recommendation.dart diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/extra_recommendation_tile.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/extra_recommendation_tile.dart similarity index 94% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/extra_recommendation_tile.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/extra_recommendation_tile.dart index c828df38..88ab87b7 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/extra_recommendation_tile.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/extra_recommendation_tile.dart @@ -1,5 +1,5 @@ -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/extra_recommendation.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/widgets/coffee_maker_custom_divider.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/ready/extra_recommendation.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/widgets/coffee_maker_custom_divider.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/offer_recommendation_modal_page.dart similarity index 91% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/offer_recommendation_modal_page.dart index 7cd6e6ce..fd4fcbf4 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/offer_recommendation_modal_page.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/extra_recommendation.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/extra_recommendation_tile.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/ready/extra_recommendation.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/ready/extra_recommendation_tile.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/serve_or_offer_modal_page.dart similarity index 95% rename from coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/serve_or_offer_modal_page.dart index 9cfc6ea7..b8042d60 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/modal_pages/ready/serve_or_offer_modal_page.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/orders_screen.dart similarity index 81% rename from coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/orders_screen.dart index f64fee92..fe84f071 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/orders_screen.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/orders_screen.dart @@ -1,12 +1,12 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/di/orders_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/coffee_order_list_view_for_step.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/orders_screen_bottom_navigation_bar.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view_model/orders_screen_view_model.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/widgets/top_bar.dart'; -import 'package:coffee_maker_navigator_2/ui/widgets/app_navigation_drawer.dart'; +import 'package:coffee_maker_navigator_2/app/ui/widgets/app_navigation_drawer.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/grouped_coffee_orders.dart'; +import 'package:coffee_maker_navigator_2/features/orders/di/orders_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/widgets/coffee_order_list_view_for_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/widgets/orders_screen_bottom_navigation_bar.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view_model/orders_screen_view_model.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/widgets/top_bar.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_item_tile.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/coffee_order_list_item_tile.dart similarity index 97% rename from coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_item_tile.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/coffee_order_list_item_tile.dart index 8276745f..8052a3e1 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_item_tile.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/coffee_order_list_item_tile.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_order.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/coffee_order_list_view_for_step.dart similarity index 83% rename from coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/coffee_order_list_view_for_step.dart index 562af8a7..c97a5c79 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/coffee_order_list_view_for_step.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/coffee_order_list_view_for_step.dart @@ -1,12 +1,12 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_order.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/offer_recommendation_modal_page.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/modal_pages/ready/serve_or_offer_modal_page.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/orders_screen.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/coffee_order_list_item_tile.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/view/widgets/empty_coffee_order_list_view.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_order.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/grouped_coffee_orders.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/ready/offer_recommendation_modal_page.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/modal_pages/ready/serve_or_offer_modal_page.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/orders_screen.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/widgets/coffee_order_list_item_tile.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/view/widgets/empty_coffee_order_list_view.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/empty_coffee_order_list_view.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/empty_coffee_order_list_view.dart similarity index 94% rename from coffee_maker_navigator_2/lib/ui/orders/view/widgets/empty_coffee_order_list_view.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/empty_coffee_order_list_view.dart index a8d54c9c..d65414e4 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/empty_coffee_order_list_view.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/empty_coffee_order_list_view.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; import 'package:flutter/material.dart'; import 'package:wolt_responsive_layout_grid/wolt_responsive_layout_grid.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/orders_screen_bottom_navigation_bar.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/orders_screen_bottom_navigation_bar.dart similarity index 93% rename from coffee_maker_navigator_2/lib/ui/orders/view/widgets/orders_screen_bottom_navigation_bar.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/orders_screen_bottom_navigation_bar.dart index 918d9126..153b912e 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view/widgets/orders_screen_bottom_navigation_bar.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view/widgets/orders_screen_bottom_navigation_bar.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/widgets/coffee_maker_custom_divider.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/grouped_coffee_orders.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/widgets/coffee_maker_custom_divider.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart b/coffee_maker_navigator_2/lib/features/orders/ui/view_model/orders_screen_view_model.dart similarity index 77% rename from coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/view_model/orders_screen_view_model.dart index ca2099f2..0a056514 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/view_model/orders_screen_view_model.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/view_model/orders_screen_view_model.dart @@ -1,6 +1,6 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/entities/grouped_coffee_orders.dart'; -import 'package:coffee_maker_navigator_2/domain/orders/orders_service.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/grouped_coffee_orders.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/orders_service.dart'; import 'package:flutter/cupertino.dart'; import 'package:wolt_di/wolt_di.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/orders/widgets/coffee_maker_custom_divider.dart b/coffee_maker_navigator_2/lib/features/orders/ui/widgets/coffee_maker_custom_divider.dart similarity index 100% rename from coffee_maker_navigator_2/lib/ui/orders/widgets/coffee_maker_custom_divider.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/widgets/coffee_maker_custom_divider.dart diff --git a/coffee_maker_navigator_2/lib/ui/orders/widgets/grid_layout_button.dart b/coffee_maker_navigator_2/lib/features/orders/ui/widgets/grid_layout_button.dart similarity index 100% rename from coffee_maker_navigator_2/lib/ui/orders/widgets/grid_layout_button.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/widgets/grid_layout_button.dart diff --git a/coffee_maker_navigator_2/lib/ui/orders/widgets/store_online_status_button.dart b/coffee_maker_navigator_2/lib/features/orders/ui/widgets/store_online_status_button.dart similarity index 100% rename from coffee_maker_navigator_2/lib/ui/orders/widgets/store_online_status_button.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/widgets/store_online_status_button.dart diff --git a/coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart b/coffee_maker_navigator_2/lib/features/orders/ui/widgets/top_bar.dart similarity index 85% rename from coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart rename to coffee_maker_navigator_2/lib/features/orders/ui/widgets/top_bar.dart index e3b1d9b3..c517abef 100644 --- a/coffee_maker_navigator_2/lib/ui/orders/widgets/top_bar.dart +++ b/coffee_maker_navigator_2/lib/features/orders/ui/widgets/top_bar.dart @@ -1,5 +1,5 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/widgets/coffee_maker_custom_divider.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/ui/widgets/coffee_maker_custom_divider.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/tutorials/view/single_tutorial_screen.dart b/coffee_maker_navigator_2/lib/features/tutorial/view/single_tutorial_screen.dart similarity index 96% rename from coffee_maker_navigator_2/lib/ui/tutorials/view/single_tutorial_screen.dart rename to coffee_maker_navigator_2/lib/features/tutorial/view/single_tutorial_screen.dart index 8c28b254..4e774fe7 100644 --- a/coffee_maker_navigator_2/lib/ui/tutorials/view/single_tutorial_screen.dart +++ b/coffee_maker_navigator_2/lib/features/tutorial/view/single_tutorial_screen.dart @@ -1,4 +1,4 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; diff --git a/coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart b/coffee_maker_navigator_2/lib/features/tutorial/view/tutorials_screen.dart similarity index 92% rename from coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart rename to coffee_maker_navigator_2/lib/features/tutorial/view/tutorials_screen.dart index 8fbc50e6..7eeffc08 100644 --- a/coffee_maker_navigator_2/lib/ui/tutorials/view/tutorials_screen.dart +++ b/coffee_maker_navigator_2/lib/features/tutorial/view/tutorials_screen.dart @@ -1,11 +1,9 @@ -import 'package:coffee_maker_navigator_2/domain/orders/entities/coffee_maker_step.dart'; -import 'package:coffee_maker_navigator_2/ui/extensions/context_extensions.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/app/ui/widgets/app_navigation_drawer.dart'; +import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart'; +import 'package:coffee_maker_navigator_2/utils/extensions/context_extensions.dart'; import 'package:demo_ui_components/demo_ui_components.dart'; import 'package:flutter/material.dart'; -import '../../widgets/app_navigation_drawer.dart'; - class TutorialsScreen extends StatelessWidget { const TutorialsScreen({super.key}); diff --git a/coffee_maker_navigator_2/lib/main.dart b/coffee_maker_navigator_2/lib/main.dart index 01ead23b..bdf6784b 100644 --- a/coffee_maker_navigator_2/lib/main.dart +++ b/coffee_maker_navigator_2/lib/main.dart @@ -1,9 +1,9 @@ -import 'package:coffee_maker_navigator_2/app.dart'; +import 'package:coffee_maker_navigator_2/app/app.dart'; import 'package:wolt_di/wolt_di.dart'; -import 'package:coffee_maker_navigator_2/ui/add_water/di/add_water_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/ui/auth/di/auth_screen_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/ui/orders/di/orders_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/add_water/di/add_water_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/login/di/login_screen_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/app/di/coffee_maker_app_level_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/features/orders/di/orders_dependency_container.dart'; import 'package:flutter/material.dart'; void _registerDependencyContainerFactories(DependencyContainerManager manager) { @@ -12,8 +12,8 @@ void _registerDependencyContainerFactories(DependencyContainerManager manager) { () => OrdersDependencyContainer()) ..registerContainerFactory( () => AddWaterDependencyContainer()) - ..registerContainerFactory( - () => AuthScreenDependencyContainer()); + ..registerContainerFactory( + () => LoginScreenDependencyContainer()); } Future main() async { diff --git a/coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart b/coffee_maker_navigator_2/lib/utils/extensions/context_extensions.dart similarity index 61% rename from coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart rename to coffee_maker_navigator_2/lib/utils/extensions/context_extensions.dart index 841aa286..607b0178 100644 --- a/coffee_maker_navigator_2/lib/ui/extensions/context_extensions.dart +++ b/coffee_maker_navigator_2/lib/utils/extensions/context_extensions.dart @@ -1,5 +1,5 @@ -import 'package:coffee_maker_navigator_2/di/coffee_maker_app_level_dependency_container.dart'; -import 'package:coffee_maker_navigator_2/ui/router/view_model/router_view_model.dart'; +import 'package:coffee_maker_navigator_2/app/di/coffee_maker_app_level_dependency_container.dart'; +import 'package:coffee_maker_navigator_2/app/router/view_model/router_view_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:wolt_di/wolt_di.dart';