From 14bd005c057c27a0eefd7b850710f53d85a8e992 Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Thu, 21 Dec 2023 23:28:47 +0400 Subject: [PATCH] Fix category push product --- example/lib/src/feature/shop/widget/category_screen.dart | 2 +- lib/src/controller/information_provider.dart | 5 +++-- lib/src/util/state_util.dart | 4 +++- lib/src/widget/navigator.dart | 4 +--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/example/lib/src/feature/shop/widget/category_screen.dart b/example/lib/src/feature/shop/widget/category_screen.dart index 75bd190..ecd80c5 100644 --- a/example/lib/src/feature/shop/widget/category_screen.dart +++ b/example/lib/src/feature/shop/widget/category_screen.dart @@ -245,7 +245,7 @@ class _ProductTile extends StatelessWidget { highlightColor: theme.highlightColor, onTap: () => onTap == null ? Octopus.of(context).setState((state) => state - ..findByName('basket-tab')?.add(Routes.product.node( + ..findByName('catalog-tab')?.add(Routes.product.node( arguments: { 'id': product.id.toString() }))) diff --git a/lib/src/controller/information_provider.dart b/lib/src/controller/information_provider.dart index 059cf8f..975b3fd 100644 --- a/lib/src/controller/information_provider.dart +++ b/lib/src/controller/information_provider.dart @@ -117,14 +117,15 @@ class OctopusInformationProvider extends RouteInformationProvider } // If the route is different from the current route, then update the engine. - //if (!kIsWeb || routeInformation.uri != _value.uri) { + /* if (kIsWeb && routeInformation.uri == _value.uri) { + config('Uri: ${routeInformation.uri}'); + } */ SystemNavigator.selectMultiEntryHistory(); // selectSingleEntryHistory SystemNavigator.routeInformationUpdated( uri: routeInformation.uri, state: routeInformation.state, replace: replace, ); - //} _value = _valueInEngine = routeInformation; } diff --git a/lib/src/util/state_util.dart b/lib/src/util/state_util.dart index 06f70b0..edb4f4e 100644 --- a/lib/src/util/state_util.dart +++ b/lib/src/util/state_util.dart @@ -79,7 +79,9 @@ abstract final class StateUtil { for (final node in state.children) { encodeNode(node, 0); } + return Uri( + /* path: segments.join('/'), */ pathSegments: segments, queryParameters: state.arguments.isEmpty ? null : state.arguments, //fragment: , @@ -162,7 +164,7 @@ abstract final class StateUtil { arguments: kMeasureEnabled ? {'uri': uri.toString()} : null, ); - /// Represent state as string. + /// Represent state as string tree. /// {@nodoc} @internal static String stateToString(OctopusState state) => diff --git a/lib/src/widget/navigator.dart b/lib/src/widget/navigator.dart index c4ea3de..b461f8b 100644 --- a/lib/src/widget/navigator.dart +++ b/lib/src/widget/navigator.dart @@ -261,9 +261,7 @@ class _OctopusNestedNavigatorBuilderState parent.children.add( OctopusNode.immutable( bucket, - children: [ - widget.defaultRoute.node(), - ], + children: [widget.defaultRoute.node()], ), ); return state;