change player open episode page animation.

This commit is contained in:
stonegate 2020-07-30 18:23:56 +08:00
parent 9b8ef2d770
commit b510472443
2 changed files with 67 additions and 16 deletions

View File

@ -222,9 +222,14 @@ class PlayerWidget extends StatelessWidget {
: AudioPanel(
key: playerKey,
miniPanel: _miniPanel(context),
expandedPanel: ControlPanel(onTap: () {
expandedPanel: ControlPanel(
onExpand: () {
playerKey.currentState.scrollToTop();
}));
},
onClose: () {
playerKey.currentState.backToMini();
},
));
},
);
}
@ -605,7 +610,9 @@ class SleepModeState extends State<SleepMode>
AnimationController(vsync: this, duration: Duration(milliseconds: 400));
_animation = Tween<double>(begin: 0.0, end: 1.0).animate(_controller)
..addListener(() {
if (mounted) {
setState(() {});
}
});
_controller.addStatusListener((status) {
@ -835,19 +842,19 @@ class SleepModeState extends State<SleepMode>
)
],
),
if (fraction > 0)
if (move > 0)
Positioned(
bottom: 120,
left: width / 2 - 100,
width: 200,
child: Center(
child: Transform.translate(
offset: Offset(0, -50 * fraction),
offset: Offset(0, -50 * move),
child: Text(s.goodNight,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.white.withOpacity(fraction))),
color: Colors.white.withOpacity(move))),
),
),
),
@ -863,8 +870,9 @@ class SleepModeState extends State<SleepMode>
}
class ControlPanel extends StatefulWidget {
ControlPanel({this.onTap, Key key}) : super(key: key);
final VoidCallback onTap;
ControlPanel({this.onExpand, this.onClose, Key key}) : super(key: key);
final VoidCallback onExpand;
final VoidCallback onClose;
@override
_ControlPanelState createState() => _ControlPanelState();
}
@ -1237,12 +1245,24 @@ class _ControlPanelState extends State<ControlPanel>
if (_setSpeed == 0)
Expanded(
child: InkWell(
onTap: () => Navigator.push(
onTap: () async {
widget.onClose();
Navigator.push(
context,
SlideUptRoute(
FadeRoute(
page: EpisodeDetail(
episodeItem: data.item1,
heroTag: 'playpanel'))),
heroTag: 'playpanel'))
// PageRouteBuilder( pageBuilder: (context,
// animation,
// secondAnimation) =>
// EpisodeDetail(
// episodeItem:
// data.item1,
// heroTag:
// 'playpanel'))
);
},
child: Row(
children: [
SizedBox(
@ -1386,7 +1406,7 @@ class _ControlPanelState extends State<ControlPanel>
color: context.textColor)),
),
),
onTap: widget.onTap),
onTap: widget.onExpand),
),
if (_setSpeed == 0 && maxHeight > 300)
Transform.translate(

View File

@ -112,3 +112,34 @@ class ScaleRoute extends PageRouteBuilder {
),
);
}
class FadeRoute extends PageRouteBuilder {
final Widget page;
FadeRoute({this.page})
: super(
pageBuilder: (
context,
animation,
secondaryAnimation,
) =>
page,
transitionsBuilder: (
context,
animation,
secondaryAnimation,
child,
) =>
FadeTransition(
opacity: Tween<double>(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Curves.easeInCubic,
),
),
child: child,
),
);
}