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

bug fixed: Transition.downToUp have a black background container #1560 #2864

Open
wants to merge 3 commits into
base: master
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
9 changes: 8 additions & 1 deletion lib/get_navigation/src/extension_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ extension GetNavigationExt on GetInterface {
///
/// [id] is for when you are using nested navigation,
/// as explained in documentation
///
/// [oldPage] is the page widget that you want to replace with the new one
/// when you use a custom [transition], we need to change the old page exit transition,
/// otherwise it will show black container in some case, it fixes the bug:
/// https://github.com/jonataslaw/getx/issues/1560
///
/// If you want the same behavior of ios that pops a route when the user drag,
/// you can set [popGesture] to true
Expand All @@ -504,7 +509,8 @@ extension GetNavigationExt on GetInterface {
/// By default, GetX will prevent you from push a route that you already in,
/// if you want to push anyway, set [preventDuplicates] to false
Future<T?>? to<T>(Widget Function() page,
{bool? opaque,
{Widget? oldPage,
bool? opaque,
Transition? transition,
Curve? curve,
Duration? duration,
Expand All @@ -522,6 +528,7 @@ extension GetNavigationExt on GetInterface {
PreventDuplicateHandlingMode.reorderRoutes}) {
return searchDelegate(id).to(
page,
oldPage: oldPage,
opaque: opaque,
transition: transition,
curve: curve,
Expand Down
237 changes: 154 additions & 83 deletions lib/get_navigation/src/routes/default_transitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ class LeftToRightFadeTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: FadeTransition(
opacity: animation,
child: SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(1.0, 0.0),
).animate(secondaryAnimation),
child: child),
),
);
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null) oldPage,
SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: FadeTransition(
opacity: animation,
child: SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(1.0, 0.0),
).animate(secondaryAnimation),
child: child),
),
)
]);
}
}

Expand All @@ -36,22 +40,26 @@ class RightToLeftFadeTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: FadeTransition(
opacity: animation,
child: SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(-1.0, 0.0),
).animate(secondaryAnimation),
child: child),
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null) oldPage,
SlideTransition(
position: Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: FadeTransition(
opacity: animation,
child: SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(-1.0, 0.0),
).animate(secondaryAnimation),
child: child),
),
),
);
]);
}
}

Expand All @@ -74,8 +82,16 @@ class FadeInTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return FadeTransition(opacity: animation, child: child);
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null)
FadeTransition(
opacity: Tween<double>(begin: 1, end: 0).animate(animation),
child: oldPage,
),
FadeTransition(opacity: animation, child: child)
]);
}
}

Expand All @@ -86,14 +102,25 @@ class SlideDownTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, 1.0),
end: Offset.zero,
).animate(animation),
child: child,
);
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null)
SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(0.0, -1.0),
).animate(animation),
child: oldPage,
),
SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, 1.0),
end: Offset.zero,
).animate(animation),
child: child,
),
]);
}
}

Expand All @@ -104,13 +131,26 @@ class SlideLeftTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
Widget child,
Widget? oldPage) {
return Stack(
children: [
if (oldPage != null)
SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(1.0, 0.0),
).animate(animation),
child: oldPage,
),
SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
)
],
);
}
}
Expand All @@ -122,32 +162,55 @@ class SlideRightTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
);
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null)
SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(-1.0, 0.0),
).animate(animation),
child: oldPage,
),
SlideTransition(
position: Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
),
]);
}
}

class SlideTopTransition {
Widget buildTransitions(
BuildContext context,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, -1.0),
end: Offset.zero,
).animate(animation),
child: child,
);
BuildContext context,
Curve? curve,
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
Widget? oldPage,
) {
return Stack(children: [
if (oldPage != null)
SlideTransition(
position: Tween<Offset>(
begin: Offset.zero,
end: const Offset(0.0, 1.0),
).animate(animation),
child: oldPage,
),
SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, -1.0),
end: Offset.zero,
).animate(animation),
child: child,
),
]);
}
}

Expand All @@ -158,11 +221,15 @@ class ZoomInTransition {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return ScaleTransition(
scale: animation,
child: child,
);
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null) oldPage,
ScaleTransition(
scale: animation,
child: child,
),
]);
}
}

Expand All @@ -173,17 +240,21 @@ class SizeTransitions {
Alignment? alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return Align(
alignment: Alignment.center,
child: SizeTransition(
sizeFactor: CurvedAnimation(
parent: animation,
curve: curve,
Widget child,
Widget? oldPage) {
return Stack(children: [
if (oldPage != null) oldPage,
Align(
alignment: Alignment.center,
child: SizeTransition(
sizeFactor: CurvedAnimation(
parent: animation,
curve: curve,
),
child: child,
),
child: child,
),
);
]);
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/get_navigation/src/routes/get_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import '../../get_navigation.dart';

class GetPage<T> extends Page<T> {
final GetPageBuilder page;
final Widget? oldPage;
final bool? popGesture;
final Map<String, String>? parameters;
final String? title;
Expand Down Expand Up @@ -56,6 +57,7 @@ class GetPage<T> extends Page<T> {
GetPage({
required this.name,
required this.page,
this.oldPage,
this.title,
this.participatesInRootNavigator,
this.gestureWidth,
Expand Down Expand Up @@ -99,6 +101,7 @@ class GetPage<T> extends Page<T> {
LocalKey? key,
String? name,
GetPageBuilder? page,
Widget? oldPage,
bool? popGesture,
Map<String, String>? parameters,
String? title,
Expand Down Expand Up @@ -133,6 +136,7 @@ class GetPage<T> extends Page<T> {
preventDuplicates: preventDuplicates ?? this.preventDuplicates,
name: name ?? this.name,
page: page ?? this.page,
oldPage: oldPage ?? this.oldPage,
popGesture: popGesture ?? this.popGesture,
parameters: parameters ?? this.parameters,
title: title ?? this.title,
Expand Down
2 changes: 2 additions & 0 deletions lib/get_navigation/src/routes/get_router_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
@override
Future<T?> to<T>(
Widget Function() page, {
Widget? oldPage,
bool? opaque,
Transition? transition,
Curve? curve,
Expand Down Expand Up @@ -385,6 +386,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
name: routeName,
opaque: opaque ?? true,
page: page,
oldPage: oldPage,
gestureWidth: gestureWidth,
showCupertinoParallax: showCupertinoParallax,
popGesture: popGesture ?? Get.defaultPopGesture,
Expand Down
Loading