diff --git a/README.md b/README.md index 5e80328..9f7e136 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ class StackedHookViewExample extends StackedView { const StackedHookViewExample({Key key}) : super(key: key); @override - Widget builder(BuildContext context, HomeViewModel model, Widget? child) { + Widget builder(BuildContext context, HomeViewModel viewModel, Widget? child) { return Scaffold( body: Center(child: _HookForm()), ); diff --git a/example/lib/app/app.locator.dart b/example/lib/app/app.locator.dart index 162263a..294a187 100644 --- a/example/lib/app/app.locator.dart +++ b/example/lib/app/app.locator.dart @@ -6,15 +6,17 @@ // ignore_for_file: public_member_api_docs, implementation_imports, depend_on_referenced_packages -import 'package:stacked_core/stacked_core.dart'; import 'package:stacked_services/src/bottom_sheet/bottom_sheet_service.dart'; import 'package:stacked_services/src/dialog/dialog_service.dart'; import 'package:stacked_services/src/navigation/navigation_service.dart'; +import 'package:stacked_shared/stacked_shared.dart'; final locator = StackedLocator.instance; -Future setupLocator( - {String? environment, EnvironmentFilter? environmentFilter}) async { +Future setupLocator({ + String? environment, + EnvironmentFilter? environmentFilter, +}) async { // Register environments locator.registerEnvironment( environment: environment, environmentFilter: environmentFilter); diff --git a/example/lib/app/app.router.dart b/example/lib/app/app.router.dart index 3f5d753..23a53f4 100644 --- a/example/lib/app/app.router.dart +++ b/example/lib/app/app.router.dart @@ -1,10 +1,11 @@ // GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** -// StackedRouterGenerator +// StackedNavigatorGenerator // ************************************************************************** // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:flutter/material.dart' as _i6; import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart' as _i1; import 'package:stacked_hooks_example/ui/views/home/home_view.dart' as _i3; @@ -14,7 +15,7 @@ import 'package:stacked_hooks_example/ui/views/with_stacked_hook/with_stacked_ho as _i4; import 'package:stacked_hooks_example/ui/views/without_stacked_hook/without_stacked_hook_view.dart' as _i5; -import 'package:stacked_services/stacked_services.dart' as _i6; +import 'package:stacked_services/stacked_services.dart' as _i7; class Routes { static const startupView = '/startup-view'; @@ -55,25 +56,25 @@ class StackedRouter extends _i1.RouterBase { final _pagesMap = { _i2.StartupView: (data) { - return MaterialPageRoute( + return _i6.MaterialPageRoute( builder: (context) => const _i2.StartupView(), settings: data, ); }, _i3.HomeView: (data) { - return MaterialPageRoute( + return _i6.MaterialPageRoute( builder: (context) => const _i3.HomeView(), settings: data, ); }, _i4.WithStackedHookView: (data) { - return MaterialPageRoute( + return _i6.MaterialPageRoute( builder: (context) => const _i4.WithStackedHookView(), settings: data, ); }, _i5.WithoutStackedHookView: (data) { - return MaterialPageRoute( + return _i6.MaterialPageRoute( builder: (context) => const _i5.WithoutStackedHookView(), settings: data, ); @@ -86,7 +87,7 @@ class StackedRouter extends _i1.RouterBase { Map get pagesMap => _pagesMap; } -extension NavigatorStateExtension on _i6.NavigationService { +extension NavigatorStateExtension on _i7.NavigationService { Future navigateToStartupView([ int? routerId, bool preventDuplicates = true, @@ -142,4 +143,60 @@ extension NavigatorStateExtension on _i6.NavigationService { parameters: parameters, transition: transition); } + + Future replaceWithStartupView([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(Routes.startupView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithHomeView([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(Routes.homeView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithWithStackedHookView([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(Routes.withStackedHookView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithWithoutStackedHookView([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(Routes.withoutStackedHookView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } } diff --git a/example/lib/ui/views/with_stacked_hook/with_stacked_hook_view.dart b/example/lib/ui/views/with_stacked_hook/with_stacked_hook_view.dart index 45533ef..db964be 100644 --- a/example/lib/ui/views/with_stacked_hook/with_stacked_hook_view.dart +++ b/example/lib/ui/views/with_stacked_hook/with_stacked_hook_view.dart @@ -33,13 +33,13 @@ class WithStackedHookView extends StackedView { class _HookForm extends StackedHookView { @override - Widget builder(BuildContext context, WithStackedHookViewModel model) { + Widget builder(BuildContext context, WithStackedHookViewModel viewModel) { final title = useTextEditingController(); return Column( mainAxisSize: MainAxisSize.min, children: [ - Text('Title: ${model.title}'), - TextField(controller: title, onChanged: model.updateTitle) + Text('Title: ${viewModel.title}'), + TextField(controller: title, onChanged: viewModel.updateTitle) ], ); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9c56e6e..cb5dd6e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -50,8 +50,8 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^1.0.0 build_runner: ^2.2.0 - - stacked_generator: ^0.8.1 + + stacked_generator: mockito: ^5.1.0 # For information on the generic Dart part of this file, see the diff --git a/example/test/helpers/test_helpers.dart b/example/test/helpers/test_helpers.dart index b168a35..3243b3a 100644 --- a/example/test/helpers/test_helpers.dart +++ b/example/test/helpers/test_helpers.dart @@ -55,8 +55,7 @@ MockBottomSheetService getAndRegisterBottomSheetService({ customData: anyNamed('customData'), data: anyNamed('data'), description: anyNamed('description'), - )).thenAnswer((realInvocation) => - Future.value(showCustomSheetResponse ?? SheetResponse())); + )).thenAnswer((realInvocation) => Future.value(showCustomSheetResponse ?? SheetResponse())); locator.registerSingleton(service); return service; diff --git a/example/test/helpers/test_helpers.mocks.dart b/example/test/helpers/test_helpers.mocks.dart index cb11b44..f3b0eb1 100644 --- a/example/test/helpers/test_helpers.mocks.dart +++ b/example/test/helpers/test_helpers.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.3.2 from annotations +// Mocks generated by Mockito 5.4.2 from annotations // in stacked_hooks_example/test/helpers/test_helpers.dart. // Do not manually edit this file. @@ -495,8 +495,7 @@ class MockDialogService extends _i1.Mock implements _i2.DialogService { _i3.BuildContext, _i2.DialogRequest, dynamic Function(_i2.DialogResponse), - )? - builder, + )? builder, }) => super.noSuchMethod( Invocation.method( @@ -591,7 +590,9 @@ class MockDialogService extends _i1.Mock implements _i2.DialogService { String? title, String? description, String? cancelTitle = r'Cancel', + _i5.Color? cancelTitleColor, String? confirmationTitle = r'Ok', + _i5.Color? confirmationTitleColor, bool? barrierDismissible = false, _i2.DialogPlatform? dialogPlatform, }) => @@ -603,7 +604,9 @@ class MockDialogService extends _i1.Mock implements _i2.DialogService { #title: title, #description: description, #cancelTitle: cancelTitle, + #cancelTitleColor: cancelTitleColor, #confirmationTitle: confirmationTitle, + #confirmationTitleColor: confirmationTitleColor, #barrierDismissible: barrierDismissible, #dialogPlatform: dialogPlatform, }, diff --git a/lib/src/_stacked_hook_view.dart b/lib/src/_stacked_hook_view.dart index 306c291..28da165 100644 --- a/lib/src/_stacked_hook_view.dart +++ b/lib/src/_stacked_hook_view.dart @@ -14,7 +14,7 @@ abstract class StackedHookView extends HookWidget { Provider.of(context, listen: reactive), ); - Widget builder(BuildContext context, T model); + Widget builder(BuildContext context, T viewModel); } @Deprecated(