redesign app phase 1
This commit is contained in:
@@ -13,15 +13,16 @@ import '../screens/player_screen.dart';
|
||||
import 'PlayerScreen/progress_slider.dart';
|
||||
|
||||
class NowPlayingBar extends StatelessWidget {
|
||||
const NowPlayingBar({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
const NowPlayingBar({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// BottomNavBar's default elevation is 8 (https://api.flutter.dev/flutter/material/BottomNavigationBar/elevation.html)
|
||||
const elevation = 8.0;
|
||||
final color = Theme.of(context).bottomNavigationBarTheme.backgroundColor;
|
||||
final theme = Theme.of(context);
|
||||
final colorScheme = theme.colorScheme;
|
||||
final barColor = Color.alphaBlend(
|
||||
colorScheme.primary.withOpacity(0.08),
|
||||
colorScheme.surface,
|
||||
);
|
||||
|
||||
final audioHandler = GetIt.instance<MusicPlayerBackgroundTask>();
|
||||
|
||||
@@ -41,106 +42,151 @@ class NowPlayingBar extends StatelessWidget {
|
||||
// the now playing bar.
|
||||
if (snapshot.data!.mediaItem != null) {
|
||||
final item = BaseItemDto.fromJson(
|
||||
snapshot.data!.mediaItem!.extras!["itemJson"]);
|
||||
snapshot.data!.mediaItem!.extras!["itemJson"],
|
||||
);
|
||||
|
||||
return Material(
|
||||
color: color,
|
||||
elevation: elevation,
|
||||
child: SafeArea(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Stack(
|
||||
children: [
|
||||
const ProgressSlider(
|
||||
allowSeeking: false,
|
||||
showBuffer: false,
|
||||
showDuration: false,
|
||||
showPlaceholder: false,
|
||||
),
|
||||
Dismissible(
|
||||
key: const Key("NowPlayingBar"),
|
||||
direction: FinampSettingsHelper.finampSettings.disableGesture ? DismissDirection.none : DismissDirection.horizontal,
|
||||
confirmDismiss: (direction) async {
|
||||
if (direction == DismissDirection.endToStart) {
|
||||
audioHandler.skipToNext();
|
||||
} else {
|
||||
audioHandler.skipToPrevious();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
background: const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fitHeight,
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Icon(Icons.skip_previous),
|
||||
return SafeArea(
|
||||
minimum: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: barColor,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
border: Border.all(
|
||||
color: colorScheme.outlineVariant.withOpacity(0.45),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: colorScheme.shadow.withOpacity(0.16),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: 78,
|
||||
child: Stack(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Opacity(
|
||||
opacity: 0.9,
|
||||
child: const ProgressSlider(
|
||||
allowSeeking: false,
|
||||
showBuffer: false,
|
||||
showDuration: false,
|
||||
showPlaceholder: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
Dismissible(
|
||||
key: const Key("NowPlayingBar"),
|
||||
direction:
|
||||
FinampSettingsHelper
|
||||
.finampSettings
|
||||
.disableGesture
|
||||
? DismissDirection.none
|
||||
: DismissDirection.horizontal,
|
||||
confirmDismiss: (direction) async {
|
||||
if (direction == DismissDirection.endToStart) {
|
||||
audioHandler.skipToNext();
|
||||
} else {
|
||||
audioHandler.skipToPrevious();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
background: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.skip_previous,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
Icon(
|
||||
Icons.skip_next,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.fromLTRB(
|
||||
12,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
),
|
||||
minLeadingWidth: 0,
|
||||
onTap: () => Navigator.of(
|
||||
context,
|
||||
).pushNamed(PlayerScreen.routeName),
|
||||
leading: SizedBox(
|
||||
height: 54,
|
||||
width: 54,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: AlbumImage(item: item),
|
||||
),
|
||||
),
|
||||
AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fitHeight,
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Icon(Icons.skip_next),
|
||||
),
|
||||
title: Text(
|
||||
snapshot.data!.mediaItem!.title,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.fade,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(PlayerScreen.routeName),
|
||||
leading: AlbumImage(item: item),
|
||||
title: Text(
|
||||
snapshot.data!.mediaItem!.title,
|
||||
softWrap: false,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
subtitle: Text(
|
||||
processArtist(
|
||||
snapshot.data!.mediaItem!.artist, context),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (snapshot
|
||||
.data!.playbackState.processingState !=
|
||||
AudioProcessingState.idle)
|
||||
IconButton(
|
||||
// We have a key here because otherwise the
|
||||
// InkWell moves over to the play/pause button
|
||||
key: const ValueKey("StopButton"),
|
||||
icon: const Icon(Icons.stop),
|
||||
onPressed: () => audioHandler.stop(),
|
||||
subtitle: Text(
|
||||
processArtist(
|
||||
snapshot.data!.mediaItem!.artist,
|
||||
context,
|
||||
),
|
||||
playing
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.pause),
|
||||
onPressed: () => audioHandler.pause(),
|
||||
)
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
onPressed: () => audioHandler.play(),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (snapshot
|
||||
.data!
|
||||
.playbackState
|
||||
.processingState !=
|
||||
AudioProcessingState.idle)
|
||||
IconButton(
|
||||
key: const ValueKey("StopButton"),
|
||||
icon: const Icon(Icons.stop_rounded),
|
||||
onPressed: () => audioHandler.stop(),
|
||||
),
|
||||
],
|
||||
IconButton.filled(
|
||||
icon: Icon(
|
||||
playing
|
||||
? Icons.pause_rounded
|
||||
: Icons.play_arrow_rounded,
|
||||
),
|
||||
onPressed: playing
|
||||
? () => audioHandler.pause()
|
||||
: () => audioHandler.play(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -155,4 +201,4 @@ class NowPlayingBar extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user