Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing a transitionDelegate to vrouter_delegate #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/src/core/vrouter_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class VRouterDelegate extends RouterDelegate<RouteInformation>
/// {@macro flutter.widgets.widgetsApp.navigatorObservers}
final List<NavigatorObserver> navigatorObservers;

final TransitionDelegate? transitionDelegate;

/// Build widget before the pages
/// The context can be used to access VRouter.of
final Widget Function(BuildContext context, Widget child)? builder;
Expand All @@ -79,6 +81,7 @@ class VRouterDelegate extends RouterDelegate<RouteInformation>
required this.routes,
this.builder,
this.navigatorObservers = const [],
this.transitionDelegate,
Future<void> Function(VRedirector vRedirector) beforeEnter =
VoidVGuard.voidBeforeEnter,
Future<void> Function(
Expand Down Expand Up @@ -1878,6 +1881,8 @@ class VRouterDelegate extends RouterDelegate<RouteInformation>
],
key: navigatorKey,
observers: [...navigatorObservers],
transitionDelegate:
transitionDelegate ?? DefaultTransitionDelegate(),
onPopPage: (_, data) {
// Try to pop a Nav1 page
if (navigatorKey.currentState!.isLastRouteNav1) {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/router_app/cupertino_vrouter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class CupertinoVRouter extends VRouterApp {
this.initialUrl = '/',
this.logs = VLogs.info,
this.navigatorObservers = const [],
this.transitionDelegate = const DefaultTransitionDelegate(),
this.builder,
@Deprecated('Please use navigatorKey instead.\n This has been removed because it is redundant with navigatorKey.')
this.appRouterKey,
Expand Down Expand Up @@ -133,6 +134,8 @@ class CupertinoVRouter extends VRouterApp {
@override
final List<NavigatorObserver> navigatorObservers;

final TransitionDelegate transitionDelegate;

@override
final Widget Function(BuildContext context, Widget child)? builder;

Expand Down
4 changes: 4 additions & 0 deletions lib/src/widgets/router_app/mixin/vrouter_app_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ abstract class VRouterApp extends StatefulWidget

/// {@macro flutter.widgets.widgetsApp.navigatorObservers}
List<NavigatorObserver> get navigatorObservers;

TransitionDelegate? get transitionDelegate;
}

/// A mixin to use on the [State]s which create the [VRouterDelegate]
Expand All @@ -127,6 +129,7 @@ mixin VRouterAppStateMixin<T extends VRouterApp> on State<T>
routes: widget.routes,
builder: widget.builder,
navigatorObservers: widget.navigatorObservers,
transitionDelegate: widget.transitionDelegate,
beforeEnter: widget.beforeEnter,
beforeLeave: widget.beforeLeave,
afterEnter: widget.afterEnter,
Expand All @@ -148,6 +151,7 @@ mixin VRouterAppStateMixin<T extends VRouterApp> on State<T>
routes: widget.routes,
builder: widget.builder,
navigatorObservers: widget.navigatorObservers,
transitionDelegate: widget.transitionDelegate,
beforeEnter: widget.beforeEnter,
beforeLeave: widget.beforeLeave,
afterEnter: widget.afterEnter,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/router_app/vrouter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class VRouter extends VRouterApp {
this.initialUrl = '/',
this.logs = VLogs.info,
this.navigatorObservers = const [],
this.transitionDelegate,
this.builder,
@Deprecated('Please use navigatorKey instead.\n This has been removed because it is redundant with navigatorKey.')
this.appRouterKey,
Expand Down Expand Up @@ -137,6 +138,8 @@ class VRouter extends VRouterApp {
@override
final List<NavigatorObserver> navigatorObservers;

final TransitionDelegate? transitionDelegate;

@override
final Widget Function(BuildContext context, Widget child)? builder;

Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/router_app/widgets_vrouter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class WidgetsVRouter extends VRouterApp {
this.initialUrl = '/',
this.logs = VLogs.info,
this.navigatorObservers = const [],
this.transitionDelegate,
this.builder,
@Deprecated('Please use navigatorKey instead.\n This has been removed because it is redundant with navigatorKey.')
this.appRouterKey,
Expand Down Expand Up @@ -133,6 +134,8 @@ class WidgetsVRouter extends VRouterApp {
@override
final List<NavigatorObserver> navigatorObservers;

final TransitionDelegate? transitionDelegate;

@override
final Widget Function(BuildContext context, Widget child)? builder;

Expand Down