mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix(android): system navigator back doesn't close player
This commit is contained in:
parent
e5d0aaf80d
commit
20d70927c9
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
|||||||
"program": "lib/main.dart",
|
"program": "lib/main.dart",
|
||||||
"args": [
|
"args": [
|
||||||
"--flavor",
|
"--flavor",
|
||||||
"nightly"
|
"dev"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -82,6 +82,12 @@ android {
|
|||||||
applicationIdSuffix ".nightly"
|
applicationIdSuffix ".nightly"
|
||||||
versionNameSuffix "-nightly"
|
versionNameSuffix "-nightly"
|
||||||
}
|
}
|
||||||
|
dev {
|
||||||
|
dimension "default"
|
||||||
|
resValue "string", "app_name", "Spotube Dev"
|
||||||
|
applicationIdSuffix ".dev"
|
||||||
|
versionNameSuffix "-dev"
|
||||||
|
}
|
||||||
stable {
|
stable {
|
||||||
dimension "default"
|
dimension "default"
|
||||||
resValue "string", "app_name", "Spotube"
|
resValue "string", "app_name", "Spotube"
|
||||||
|
@ -75,247 +75,257 @@ class PlayerView extends HookConsumerWidget {
|
|||||||
noSetBGColor: true,
|
noSetBGColor: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
return IconTheme(
|
return WillPopScope(
|
||||||
data: theme.iconTheme.copyWith(color: bodyTextColor),
|
onWillPop: () async {
|
||||||
child: Scaffold(
|
onClosePage();
|
||||||
appBar: PreferredSize(
|
return false;
|
||||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
},
|
||||||
child: SafeArea(
|
child: IconTheme(
|
||||||
minimum: const EdgeInsets.only(top: 30),
|
data: theme.iconTheme.copyWith(color: bodyTextColor),
|
||||||
child: PageWindowTitleBar(
|
child: Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
appBar: PreferredSize(
|
||||||
foregroundColor: titleTextColor,
|
preferredSize: const Size.fromHeight(kToolbarHeight),
|
||||||
toolbarOpacity: 1,
|
child: SafeArea(
|
||||||
leading: IconButton(
|
minimum: const EdgeInsets.only(top: 30),
|
||||||
icon: const Icon(SpotubeIcons.angleDown, size: 18),
|
child: PageWindowTitleBar(
|
||||||
onPressed: onClosePage,
|
backgroundColor: Colors.transparent,
|
||||||
|
foregroundColor: titleTextColor,
|
||||||
|
toolbarOpacity: 1,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(SpotubeIcons.angleDown, size: 18),
|
||||||
|
onPressed: onClosePage,
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(SpotubeIcons.info, size: 18),
|
||||||
|
tooltip: context.l10n.details,
|
||||||
|
style: IconButton.styleFrom(foregroundColor: bodyTextColor),
|
||||||
|
onPressed: currentTrack == null
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return TrackDetailsDialog(
|
||||||
|
track: currentTrack,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(SpotubeIcons.info, size: 18),
|
|
||||||
tooltip: context.l10n.details,
|
|
||||||
style: IconButton.styleFrom(foregroundColor: bodyTextColor),
|
|
||||||
onPressed: currentTrack == null
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return TrackDetailsDialog(
|
|
||||||
track: currentTrack,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
extendBodyBehindAppBar: true,
|
||||||
extendBodyBehindAppBar: true,
|
body: AnimateGradient(
|
||||||
body: AnimateGradient(
|
animateAlignments: true,
|
||||||
animateAlignments: true,
|
primaryBegin: Alignment.topLeft,
|
||||||
primaryBegin: Alignment.topLeft,
|
primaryEnd: Alignment.bottomLeft,
|
||||||
primaryEnd: Alignment.bottomLeft,
|
secondaryBegin: Alignment.bottomRight,
|
||||||
secondaryBegin: Alignment.bottomRight,
|
secondaryEnd: Alignment.topRight,
|
||||||
secondaryEnd: Alignment.topRight,
|
duration: const Duration(seconds: 15),
|
||||||
duration: const Duration(seconds: 15),
|
primaryColors: [
|
||||||
primaryColors: [
|
palette.dominantColor?.color ?? theme.colorScheme.primary,
|
||||||
palette.dominantColor?.color ?? theme.colorScheme.primary,
|
palette.mutedColor?.color ?? theme.colorScheme.secondary,
|
||||||
palette.mutedColor?.color ?? theme.colorScheme.secondary,
|
],
|
||||||
],
|
secondaryColors: [
|
||||||
secondaryColors: [
|
(palette.darkVibrantColor ?? palette.lightVibrantColor)?.color ??
|
||||||
(palette.darkVibrantColor ?? palette.lightVibrantColor)?.color ??
|
theme.colorScheme.primaryContainer,
|
||||||
theme.colorScheme.primaryContainer,
|
(palette.darkMutedColor ?? palette.lightMutedColor)?.color ??
|
||||||
(palette.darkMutedColor ?? palette.lightMutedColor)?.color ??
|
theme.colorScheme.secondaryContainer,
|
||||||
theme.colorScheme.secondaryContainer,
|
],
|
||||||
],
|
child: SingleChildScrollView(
|
||||||
child: SingleChildScrollView(
|
child: Container(
|
||||||
child: Container(
|
alignment: Alignment.center,
|
||||||
alignment: Alignment.center,
|
width: double.infinity,
|
||||||
width: double.infinity,
|
child: ConstrainedBox(
|
||||||
child: ConstrainedBox(
|
constraints: const BoxConstraints(maxWidth: 580),
|
||||||
constraints: const BoxConstraints(maxWidth: 580),
|
child: SafeArea(
|
||||||
child: SafeArea(
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(8.0),
|
||||||
padding: const EdgeInsets.all(8.0),
|
child: Column(
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Container(
|
||||||
Container(
|
margin: const EdgeInsets.all(8),
|
||||||
margin: const EdgeInsets.all(8),
|
constraints: const BoxConstraints(
|
||||||
constraints: const BoxConstraints(
|
maxHeight: 300, maxWidth: 300),
|
||||||
maxHeight: 300, maxWidth: 300),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
borderRadius: BorderRadius.circular(20),
|
||||||
borderRadius: BorderRadius.circular(20),
|
boxShadow: const [
|
||||||
boxShadow: const [
|
BoxShadow(
|
||||||
BoxShadow(
|
color: Colors.black26,
|
||||||
color: Colors.black26,
|
spreadRadius: 2,
|
||||||
spreadRadius: 2,
|
blurRadius: 10,
|
||||||
blurRadius: 10,
|
offset: Offset(0, 0),
|
||||||
offset: Offset(0, 0),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
child: UniversalImage(
|
||||||
|
path: albumArt,
|
||||||
|
placeholder: Assets.albumPlaceholder.path,
|
||||||
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
child: UniversalImage(
|
|
||||||
path: albumArt,
|
|
||||||
placeholder: Assets.albumPlaceholder.path,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 60),
|
||||||
const SizedBox(height: 60),
|
Container(
|
||||||
Container(
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
alignment: Alignment.centerLeft,
|
||||||
alignment: Alignment.centerLeft,
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
children: [
|
AutoSizeText(
|
||||||
AutoSizeText(
|
currentTrack?.name ?? "Not playing",
|
||||||
currentTrack?.name ?? "Not playing",
|
style: TextStyle(
|
||||||
style: TextStyle(
|
color: titleTextColor,
|
||||||
color: titleTextColor,
|
fontSize: 22,
|
||||||
fontSize: 22,
|
),
|
||||||
|
maxFontSize: 22,
|
||||||
|
maxLines: 1,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
),
|
),
|
||||||
maxFontSize: 22,
|
if (isLocalTrack)
|
||||||
maxLines: 1,
|
Text(
|
||||||
textAlign: TextAlign.start,
|
TypeConversionUtils.artists_X_String<
|
||||||
),
|
Artist>(
|
||||||
if (isLocalTrack)
|
currentTrack?.artists ?? [],
|
||||||
Text(
|
|
||||||
TypeConversionUtils.artists_X_String<Artist>(
|
|
||||||
currentTrack?.artists ?? [],
|
|
||||||
),
|
|
||||||
style: theme.textTheme.bodyMedium!.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: bodyTextColor,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
TypeConversionUtils.artists_X_ClickableArtists(
|
|
||||||
currentTrack?.artists ?? [],
|
|
||||||
textStyle:
|
|
||||||
theme.textTheme.bodyMedium!.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: bodyTextColor,
|
|
||||||
),
|
|
||||||
onRouteChange: (route) {
|
|
||||||
onClosePage();
|
|
||||||
GoRouter.of(context).push(route);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
PlayerControls(palette: palette),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
PlayerActions(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
showQueue: false,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: OutlinedButton.icon(
|
|
||||||
icon: const Icon(SpotubeIcons.queue),
|
|
||||||
label: Text(context.l10n.queue),
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
foregroundColor: bodyTextColor,
|
|
||||||
side: BorderSide(
|
|
||||||
color: bodyTextColor ?? Colors.white,
|
|
||||||
),
|
),
|
||||||
|
style: theme.textTheme.bodyMedium!.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: bodyTextColor,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
TypeConversionUtils
|
||||||
|
.artists_X_ClickableArtists(
|
||||||
|
currentTrack?.artists ?? [],
|
||||||
|
textStyle:
|
||||||
|
theme.textTheme.bodyMedium!.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: bodyTextColor,
|
||||||
|
),
|
||||||
|
onRouteChange: (route) {
|
||||||
|
onClosePage();
|
||||||
|
GoRouter.of(context).push(route);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onPressed: currentTrack != null
|
],
|
||||||
? () {
|
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
isDismissible: true,
|
|
||||||
enableDrag: true,
|
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: Colors.black12,
|
|
||||||
barrierColor: Colors.black12,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: MediaQuery.of(context)
|
|
||||||
.size
|
|
||||||
.height *
|
|
||||||
.7,
|
|
||||||
),
|
|
||||||
builder: (context) {
|
|
||||||
return const PlayerQueue(
|
|
||||||
floating: false);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
: null),
|
|
||||||
),
|
),
|
||||||
if (auth != null) const SizedBox(width: 10),
|
),
|
||||||
if (auth != null)
|
const SizedBox(height: 10),
|
||||||
|
PlayerControls(palette: palette),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
PlayerActions(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
showQueue: false,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: OutlinedButton.icon(
|
child: OutlinedButton.icon(
|
||||||
label: Text(context.l10n.lyrics),
|
icon: const Icon(SpotubeIcons.queue),
|
||||||
icon: const Icon(SpotubeIcons.music),
|
label: Text(context.l10n.queue),
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
foregroundColor: bodyTextColor,
|
foregroundColor: bodyTextColor,
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: bodyTextColor ?? Colors.white,
|
color: bodyTextColor ?? Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
onPressed: currentTrack != null
|
||||||
onPressed: () {
|
? () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isDismissible: true,
|
isDismissible: true,
|
||||||
enableDrag: true,
|
enableDrag: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.black38,
|
backgroundColor: Colors.black12,
|
||||||
barrierColor: Colors.black12,
|
barrierColor: Colors.black12,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius:
|
||||||
topLeft: Radius.circular(20),
|
BorderRadius.circular(10),
|
||||||
topRight: Radius.circular(20),
|
),
|
||||||
),
|
constraints: BoxConstraints(
|
||||||
),
|
maxHeight:
|
||||||
constraints: BoxConstraints(
|
MediaQuery.of(context)
|
||||||
maxHeight:
|
.size
|
||||||
MediaQuery.of(context).size.height *
|
.height *
|
||||||
0.8,
|
.7,
|
||||||
),
|
),
|
||||||
builder: (context) =>
|
builder: (context) {
|
||||||
const LyricsPage(isModal: true),
|
return const PlayerQueue(
|
||||||
);
|
floating: false);
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
: null),
|
||||||
|
),
|
||||||
|
if (auth != null) const SizedBox(width: 10),
|
||||||
|
if (auth != null)
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
label: Text(context.l10n.lyrics),
|
||||||
|
icon: const Icon(SpotubeIcons.music),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
foregroundColor: bodyTextColor,
|
||||||
|
side: BorderSide(
|
||||||
|
color: bodyTextColor ?? Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isDismissible: true,
|
||||||
|
enableDrag: true,
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.black38,
|
||||||
|
barrierColor: Colors.black12,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(20),
|
||||||
|
topRight: Radius.circular(20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: MediaQuery.of(context)
|
||||||
|
.size
|
||||||
|
.height *
|
||||||
|
0.8,
|
||||||
|
),
|
||||||
|
builder: (context) =>
|
||||||
|
const LyricsPage(isModal: true),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
SliderTheme(
|
||||||
|
data: theme.sliderTheme.copyWith(
|
||||||
|
activeTrackColor: titleTextColor,
|
||||||
|
inactiveTrackColor: bodyTextColor,
|
||||||
|
thumbColor: titleTextColor,
|
||||||
|
overlayColor: titleTextColor?.withOpacity(0.2),
|
||||||
|
trackHeight: 2,
|
||||||
|
thumbShape: const RoundSliderThumbShape(
|
||||||
|
enabledThumbRadius: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: VolumeSlider(
|
||||||
|
fullWidth: true,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
SliderTheme(
|
|
||||||
data: theme.sliderTheme.copyWith(
|
|
||||||
activeTrackColor: titleTextColor,
|
|
||||||
inactiveTrackColor: bodyTextColor,
|
|
||||||
thumbColor: titleTextColor,
|
|
||||||
overlayColor: titleTextColor?.withOpacity(0.2),
|
|
||||||
trackHeight: 2,
|
|
||||||
thumbShape: const RoundSliderThumbShape(
|
|
||||||
enabledThumbRadius: 8,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: const Padding(
|
],
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
),
|
||||||
child: VolumeSlider(
|
|
||||||
fullWidth: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user