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

feat(now_playing_bar): slide up transition animation #1075

Open
wants to merge 3 commits into
base: redesign
Choose a base branch
from
Open
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
39 changes: 36 additions & 3 deletions lib/components/now_playing_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,34 @@ class NowPlayingBar extends ConsumerWidget {

final progressBackgroundColor = getProgressBackgroundColor(context);

Future openPlayerScreen() => Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) =>
const PlayerScreen(),
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
const begin = Offset(0.0, 1.0);
const end = Offset.zero;

var tween = Tween(begin: begin, end: end)
.chain(CurveTween(curve: Curves.easeInOutQuad));
var offsetAnimation = animation.drive(tween);

if (animation.status == AnimationStatus.reverse) {
// dismiss animation
return FadeTransition(
opacity: animation,
child: child,
);
} else {
return SlideTransition(position: offsetAnimation, child: child);
}

},
settings: const RouteSettings(name: PlayerScreen.routeName),
),
);

return SafeArea(
child: Padding(
padding: const EdgeInsets.only(left: 12.0, bottom: 12.0, right: 12.0),
Expand All @@ -156,20 +184,25 @@ class NowPlayingBar extends ConsumerWidget {
button: true,
),
child: SimpleGestureDetector(
onTap: () => Navigator.of(context).pushNamed(PlayerScreen.routeName),
onTap: openPlayerScreen,
child: Dismissible(
key: const Key("NowPlayingBarDismiss"),
direction: FinampSettingsHelper.finampSettings.disableGesture
? DismissDirection.none
: DismissDirection.down,
: DismissDirection.vertical,
confirmDismiss: (direction) async {
if (direction == DismissDirection.down) {
final queueService = GetIt.instance<QueueService>();
await queueService.stopPlayback();
} else {
await openPlayerScreen();
}
return false;
},
dismissThresholds: const {DismissDirection.down: 0.7},
dismissThresholds: const {
DismissDirection.up: 0.15,
DismissDirection.down: 0.7
},
child: Container(
clipBehavior: Clip.antiAlias,
decoration: getShadow(context),
Expand Down