Make custom transition transparent so we dont need a 'background'
This reduces the animation overhead and cleanup the code.
This commit is contained in:
@@ -2,14 +2,13 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
class AddPageTransition extends PageRouteBuilder {
|
class AddPageTransition extends PageRouteBuilder {
|
||||||
final Widget page;
|
final Widget page;
|
||||||
final Widget background;
|
|
||||||
|
|
||||||
AddPageTransition({this.page, this.background})
|
AddPageTransition({this.page})
|
||||||
: super(
|
: super(
|
||||||
transitionDuration: Duration(microseconds: 1),
|
transitionDuration: Duration(microseconds: 1),
|
||||||
pageBuilder: (context, animation1, animation2) => page,
|
pageBuilder: (context, animation1, animation2) => page,
|
||||||
transitionsBuilder: (context, animation1, animation, child) =>
|
transitionsBuilder: (context, animation1, animation, child) => child);
|
||||||
Stack(
|
|
||||||
children: <Widget>[background, child],
|
@override
|
||||||
));
|
bool get opaque => false;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -22,12 +22,18 @@ class MyApp extends StatelessWidget {
|
|||||||
onGenerateRoute: (settings) {
|
onGenerateRoute: (settings) {
|
||||||
if (settings.name == '/details') {
|
if (settings.name == '/details') {
|
||||||
DetailsParams params = settings.arguments;
|
DetailsParams params = settings.arguments;
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(builder: (BuildContext context) {
|
||||||
builder: (BuildContext context) {
|
|
||||||
return DetailsPage(
|
return DetailsPage(
|
||||||
params: params ,
|
params: params,
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
} else if (settings.name == '/add') {
|
||||||
|
Rect buttonRect = settings.arguments;
|
||||||
|
|
||||||
|
return AddPageTransition(
|
||||||
|
page: AddPage(
|
||||||
|
buttonRect: buttonRect,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -45,5 +51,3 @@ class MyApp extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
CurvedAnimation(parent: _controller, curve: Curves.fastOutSlowIn));
|
CurvedAnimation(parent: _controller, curve: Curves.fastOutSlowIn));
|
||||||
|
|
||||||
_controller.addListener(() {
|
_controller.addListener(() {
|
||||||
print(_controller.value);
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
_controller.addStatusListener((status) {
|
_controller.addStatusListener((status) {
|
||||||
@@ -285,7 +284,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
"year": today.year,
|
"year": today.year,
|
||||||
});
|
});
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
_controller.reverse();
|
||||||
} else {
|
} else {
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: Text("Select a value and a cagtegory")));
|
content: Text("Select a value and a cagtegory")));
|
||||||
|
|||||||
@@ -90,16 +90,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
buttonRect = RectGetter.getRectFromKey(globalKey);
|
buttonRect = RectGetter.getRectFromKey(globalKey);
|
||||||
|
|
||||||
print(buttonRect);
|
Navigator.of(context).pushNamed('/add', arguments: buttonRect);
|
||||||
|
|
||||||
var page = AddPageTransition(
|
|
||||||
background: widget,
|
|
||||||
page: AddPage(
|
|
||||||
buttonRect: buttonRect,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Navigator.of(context).push(page);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user