Jonny Borges

add transitions to nav 2 and GetNavigator

... ... @@ -21,6 +21,7 @@ class HomeView extends GetView<HomeController> {
}
return Scaffold(
body: GetRouterOutlet(
name: Routes.HOME,
emptyPage: (delegate) => DashboardView(),
pickPages: (currentNavStack) {
print('Home RouterOutlet: $currentNavStack');
... ...
... ... @@ -19,6 +19,7 @@ class RootView extends GetView<RootController> {
centerTitle: true,
),
body: GetRouterOutlet(
name: '/',
emptyPage: (delegate) {
return Center(
child: Column(
... ...
... ... @@ -42,12 +42,14 @@ class AppPages {
name: _Paths.PROFILE,
page: () => ProfileView(),
title: 'Profile',
transition: Transition.size,
binding: ProfileBinding(),
),
GetPage(
name: _Paths.PRODUCTS,
page: () => ProductsView(),
title: 'Products',
transition: Transition.zoom,
binding: ProductsBinding(),
children: [
GetPage(
... ...
... ... @@ -2,7 +2,6 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get_navigation/src/nav2/router_outlet.dart';
import '../../../get.dart';
import '../../../get_state_manager/src/simple/list_notifier.dart';
... ... @@ -343,3 +342,37 @@ class GetDelegate extends RouterDelegate<GetNavConfig>
return true;
}
}
class GetNavigator extends StatelessWidget {
const GetNavigator({
Key? key,
this.navigatorKey,
required this.onPopPage,
required this.pages,
this.observers,
this.transitionDelegate,
required this.name,
}) : super(key: key);
final GlobalKey<NavigatorState>? navigatorKey;
final bool Function(Route<dynamic>, dynamic) onPopPage;
final List<Page> pages;
final List<NavigatorObserver>? observers;
final TransitionDelegate? transitionDelegate;
final String name;
@override
Widget build(BuildContext context) {
Get.key;
return Navigator(
key: navigatorKey ?? Get.nestedKey(name),
onPopPage: onPopPage,
pages: pages,
observers: [
GetObserver(),
if (observers != null) ...observers!,
],
transitionDelegate:
transitionDelegate ?? const DefaultTransitionDelegate<dynamic>(),
);
}
}
... ...
... ... @@ -20,18 +20,17 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object>
RouterOutlet({
TDelegate? delegate,
required List<RouteSettings> Function(T currentNavStack) pickPages,
required List<GetPage> Function(T currentNavStack) pickPages,
required Widget Function(
BuildContext context,
TDelegate,
RouteSettings? page,
GetPage? page,
)
pageBuilder,
}) : this.builder(
builder: (context, rDelegate, currentConfig) {
final picked = currentConfig == null
? <RouteSettings>[]
: pickPages(currentConfig);
final picked =
currentConfig == null ? <GetPage>[] : pickPages(currentConfig);
if (picked.length == 0) {
return pageBuilder(context, rDelegate, null);
}
... ... @@ -92,15 +91,20 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> {
GetRouterOutlet({
Widget Function(GetDelegate delegate)? emptyPage,
required List<GetPage> Function(GetNavConfig currentNavStack) pickPages,
bool Function(Route<dynamic>, dynamic)? onPopPage,
required String name,
}) : super(
pageBuilder: (context, rDelegate, page) {
final pageRoute = rDelegate.getPageRoute(page);
if (page != null) {
//TODO: transitions go here !
return pageRoute.buildPage(
context,
pageRoute.animation,
pageRoute.secondaryAnimation,
return GetNavigator(
onPopPage: onPopPage ??
(a, c) {
return true;
},
pages: [page],
name: name,
);
}
... ...
... ... @@ -161,59 +161,4 @@ class GetPage<T> extends Page<T> {
unknownRoute,
).page<T>();
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other is GetPage<T>) {
print(other.path.hashCode == path.hashCode);
}
return other is GetPage<T> &&
other.page.runtimeType == page.runtimeType &&
other.popGesture == popGesture &&
// mapEquals(other.parameter, parameter) &&
other.preventDuplicates == preventDuplicates &&
other.title == title &&
other.transition == transition &&
other.curve == curve &&
other.alignment == alignment &&
other.maintainState == maintainState &&
other.opaque == opaque &&
other.binding == binding &&
// listEquals(other.bindings, bindings) &&
other.customTransition == customTransition &&
other.transitionDuration == transitionDuration &&
other.fullscreenDialog == fullscreenDialog &&
other.name == name &&
// listEquals(other.children, children) &&
// listEquals(other.middlewares, middlewares) &&
other.path == path &&
other.unknownRoute == unknownRoute;
}
@override
int get hashCode {
return //page.hashCode ^
popGesture.hashCode ^
// parameter.hashCode ^
preventDuplicates.hashCode ^
title.hashCode ^
transition.hashCode ^
curve.hashCode ^
alignment.hashCode ^
maintainState.hashCode ^
opaque.hashCode ^
binding.hashCode ^
// bindings.hashCode ^
customTransition.hashCode ^
transitionDuration.hashCode ^
fullscreenDialog.hashCode ^
name.hashCode ^
// children.hashCode ^
// middlewares.hashCode ^
path.hashCode ^
unknownRoute.hashCode;
}
}
... ...