Improve route animation.

This commit is contained in:
stonegate 2020-10-13 23:35:15 +08:00
parent 24861bf588
commit 974c2af18e
2 changed files with 84 additions and 119 deletions

View File

@ -85,6 +85,7 @@ class _PodcastDetailState extends State<PodcastDetail> {
bool _selectAll;
bool _selectBefore;
bool _selectAfter;
bool _loadEpisodes = false;
@override
void initState() {
@ -97,6 +98,8 @@ class _PodcastDetailState extends State<PodcastDetail> {
_selectAll = false;
_selectAfter = false;
_selectBefore = false;
Future.delayed(Duration(milliseconds: 200))
.then((value) => setState(() => _loadEpisodes = true));
}
@override
@ -434,57 +437,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
height: 30,
child: Row(
children: <Widget>[
//SizedBox(width: 10),
// _customPopupMenu(
// tooltip: s.homeSubMenuSortBy,
// child: Container(
// height: 30,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(100.0),
// border: Border.all(color: context.primaryColorDark),
// ),
// padding: EdgeInsets.symmetric(horizontal: 10),
// child: Row(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Text(s.homeSubMenuSortBy),
// SizedBox(width: 5),
// Icon(
// _reverse
// ? LineIcons.hourglass_start_solid
// : LineIcons.hourglass_end_solid,
// size: 18,
// )
// ],
// )),
// itemBuilder: [
// PopupMenuItem(
// value: 0,
// child: Row(
// children: [
// Text(s.newestFirst),
// Spacer(),
// if (!_reverse) DotIndicator()
// ],
// ),
// ),
// PopupMenuItem(
// value: 1,
// child: Row(
// children: [
// Text(s.oldestFirst),
// Spacer(),
// if (_reverse) DotIndicator()
// ],
// ),
// )
// ],
// onSelected: (value) {
// if (value == 0) {
// setState(() => _reverse = false);
// } else if (value == 1) setState(() => _reverse = true);
// },
// ),
SizedBox(width: 15),
_customPopupMenu(
tooltip: s.filter,
@ -858,6 +810,7 @@ class _PodcastDetailState extends State<PodcastDetail> {
child: _multiSelect
? Center()
: _actionBar(context)),
if (_loadEpisodes)
FutureBuilder<List<EpisodeBrief>>(
future: _getRssItem(widget.podcastLocal,
count: _top,

View File

@ -16,15 +16,27 @@ class SlideLeftRoute extends PageRouteBuilder {
animation,
secondaryAnimation,
child,
) =>
SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(animation),
child: child,
) {
var begin = Offset(1.0, 0.0);
var end = Offset.zero;
var curve = Curves.easeOutQuart;
var tween =
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
var tweenSequence = TweenSequence(<TweenSequenceItem<Offset>>[
TweenSequenceItem<Offset>(
tween: tween,
weight: 90.0,
),
TweenSequenceItem<Offset>(
tween: ConstantTween<Offset>(Offset.zero),
weight: 10.0,
),
]);
return SlideTransition(
position: animation.drive(tweenSequence),
child: child,
);
});
}
class SlideLeftHideRoute extends PageRouteBuilder {