2021-05-10 19:19:54 +02:00
|
|
|
import 'package:fimber/fimber.dart';
|
2020-03-20 16:17:02 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-04-09 17:50:28 +02:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2021-05-10 19:19:54 +02:00
|
|
|
import 'package:get_it/get_it.dart';
|
2020-03-25 17:00:00 +01:00
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
import '../../domain/entities/song.dart';
|
|
|
|
import '../state/audio_store.dart';
|
2021-06-19 20:37:21 +02:00
|
|
|
import '../state/music_data_store.dart';
|
|
|
|
import '../state/navigation_store.dart';
|
2020-12-31 17:52:20 +01:00
|
|
|
import '../theming.dart';
|
2020-03-25 17:00:00 +01:00
|
|
|
import '../widgets/album_art.dart';
|
2020-12-08 22:22:31 +01:00
|
|
|
import '../widgets/album_background.dart';
|
2021-05-08 23:46:23 +02:00
|
|
|
import '../widgets/currently_playing_header.dart';
|
2020-08-12 20:59:00 +02:00
|
|
|
import '../widgets/playback_control.dart';
|
2020-09-19 17:08:48 +02:00
|
|
|
import '../widgets/song_customization_buttons.dart';
|
2020-03-25 17:00:00 +01:00
|
|
|
import '../widgets/time_progress_indicator.dart';
|
2021-06-19 20:37:21 +02:00
|
|
|
import 'album_details_page.dart';
|
|
|
|
import 'artist_details_page.dart';
|
2020-08-24 12:01:01 +02:00
|
|
|
import 'queue_page.dart';
|
2020-03-20 16:17:02 +01:00
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
class CurrentlyPlayingPage extends StatelessWidget {
|
2021-06-20 13:49:21 +02:00
|
|
|
const CurrentlyPlayingPage({Key? key}) : super(key: key);
|
2020-03-20 16:17:02 +01:00
|
|
|
|
2021-05-10 19:19:54 +02:00
|
|
|
static final _log = FimberLog('CurrentlyPlayingPage');
|
2020-09-19 20:30:41 +02:00
|
|
|
|
2020-03-20 16:17:02 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-05-10 19:19:54 +02:00
|
|
|
_log.d('build started');
|
|
|
|
final AudioStore audioStore = GetIt.I<AudioStore>();
|
2020-04-09 17:50:28 +02:00
|
|
|
|
2021-05-17 21:44:59 +02:00
|
|
|
// TODO: everything wrapped in Observer and most components have Observer themselves
|
2020-03-20 16:17:02 +01:00
|
|
|
return Scaffold(
|
|
|
|
body: SafeArea(
|
2020-12-31 17:52:20 +01:00
|
|
|
child: GestureDetector(
|
|
|
|
onVerticalDragEnd: (dragEndDetails) {
|
2021-06-20 13:49:21 +02:00
|
|
|
if (dragEndDetails.primaryVelocity! < 0) {
|
2020-12-31 17:52:20 +01:00
|
|
|
_openQueue(context);
|
2021-06-20 13:49:21 +02:00
|
|
|
} else if (dragEndDetails.primaryVelocity! > 0) {
|
2020-12-31 17:52:20 +01:00
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Observer(
|
2020-04-09 17:50:28 +02:00
|
|
|
builder: (BuildContext context) {
|
2021-05-10 19:19:54 +02:00
|
|
|
_log.d('Observer.build');
|
2021-06-20 13:49:21 +02:00
|
|
|
final Song? song = audioStore.currentSongStream.value;
|
|
|
|
|
|
|
|
if (song == null) {
|
|
|
|
return Container();
|
|
|
|
}
|
2020-07-12 18:25:34 +02:00
|
|
|
|
2021-01-21 21:49:29 +01:00
|
|
|
return Stack(
|
|
|
|
children: [
|
|
|
|
AlbumBackground(
|
|
|
|
song: song,
|
2020-12-08 22:22:31 +01:00
|
|
|
),
|
2021-01-21 21:49:29 +01:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 12.0,
|
|
|
|
right: 12.0,
|
|
|
|
top: 8.0,
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2021-06-19 20:37:21 +02:00
|
|
|
CurrentlyPlayingHeader(
|
|
|
|
onTap: _openQueue,
|
|
|
|
onMoreTap: _openMoreMenu,
|
|
|
|
),
|
2021-01-21 21:49:29 +01:00
|
|
|
const Spacer(
|
2021-04-11 15:44:10 +02:00
|
|
|
flex: 10,
|
2021-01-21 21:49:29 +01:00
|
|
|
),
|
|
|
|
Expanded(
|
2021-04-11 15:44:10 +02:00
|
|
|
flex: 720,
|
2021-05-08 23:46:23 +02:00
|
|
|
child: Center(
|
2021-01-21 21:49:29 +01:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 8.0,
|
|
|
|
vertical: 0.0,
|
|
|
|
),
|
|
|
|
child: AlbumArt(
|
|
|
|
song: song,
|
|
|
|
),
|
2020-12-10 20:55:37 +01:00
|
|
|
),
|
|
|
|
),
|
2020-05-09 19:46:06 +02:00
|
|
|
),
|
2021-01-21 21:49:29 +01:00
|
|
|
const Spacer(
|
2021-04-11 15:44:10 +02:00
|
|
|
flex: 50,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
|
|
|
|
child: Center(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
song.title,
|
|
|
|
overflow: TextOverflow.fade,
|
|
|
|
softWrap: false,
|
|
|
|
maxLines: 1,
|
2021-05-08 23:46:23 +02:00
|
|
|
style: TEXT_BIG.copyWith(),
|
2021-04-11 15:44:10 +02:00
|
|
|
),
|
|
|
|
Text(
|
|
|
|
song.artist,
|
|
|
|
style: TEXT_SUBTITLE.copyWith(
|
|
|
|
color: Colors.grey[100],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Spacer(
|
|
|
|
flex: 50,
|
2021-01-21 21:49:29 +01:00
|
|
|
),
|
|
|
|
const Padding(
|
2021-04-11 15:44:10 +02:00
|
|
|
padding: EdgeInsets.only(left: 6.0, right: 6.0),
|
2021-05-08 23:46:23 +02:00
|
|
|
child: SongCustomizationButtons(),
|
2021-01-21 21:49:29 +01:00
|
|
|
),
|
|
|
|
const Spacer(
|
2021-04-11 15:44:10 +02:00
|
|
|
flex: 20,
|
2021-01-21 21:49:29 +01:00
|
|
|
),
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 2.0),
|
|
|
|
child: PlaybackControl(),
|
|
|
|
),
|
|
|
|
const Spacer(
|
|
|
|
flex: 30,
|
|
|
|
),
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 10.0),
|
|
|
|
child: TimeProgressIndicator(),
|
|
|
|
),
|
|
|
|
const Spacer(
|
2021-04-11 15:44:10 +02:00
|
|
|
flex: 60,
|
2021-01-21 21:49:29 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-12-08 22:22:31 +01:00
|
|
|
),
|
2021-01-21 21:49:29 +01:00
|
|
|
],
|
2020-04-09 17:50:28 +02:00
|
|
|
);
|
|
|
|
},
|
2020-03-28 09:39:59 +01:00
|
|
|
),
|
2020-03-20 16:17:02 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2020-08-12 20:59:00 +02:00
|
|
|
|
2020-12-31 17:52:20 +01:00
|
|
|
void _openQueue(BuildContext context) {
|
2020-08-24 12:01:01 +02:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute<Widget>(
|
|
|
|
builder: (BuildContext context) => const QueuePage(),
|
|
|
|
),
|
|
|
|
);
|
2020-08-12 20:59:00 +02:00
|
|
|
}
|
2021-06-19 20:37:21 +02:00
|
|
|
|
|
|
|
void _openMoreMenu(BuildContext context) {
|
|
|
|
final AudioStore audioStore = GetIt.I<AudioStore>();
|
|
|
|
final MusicDataStore musicDataStore = GetIt.I<MusicDataStore>();
|
|
|
|
final NavigationStore navStore = GetIt.I<NavigationStore>();
|
|
|
|
|
|
|
|
final song = audioStore.currentSongStream.value;
|
2021-06-20 13:49:21 +02:00
|
|
|
if (song == null)
|
|
|
|
return;
|
2021-06-19 20:37:21 +02:00
|
|
|
// EXPLORATORY
|
2021-06-20 13:49:21 +02:00
|
|
|
final albums = musicDataStore.albumStream.value ?? [];
|
2021-06-19 20:37:21 +02:00
|
|
|
final album = albums.singleWhere((a) => a.title == song.album);
|
|
|
|
|
2021-06-20 13:49:21 +02:00
|
|
|
final artists = musicDataStore.artistStream.value ?? [];
|
2021-06-19 20:37:21 +02:00
|
|
|
final artist = artists.singleWhere((a) => a.name == album.artist);
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
useRootNavigator: true,
|
|
|
|
backgroundColor: DARK2,
|
|
|
|
builder: (context) {
|
|
|
|
return Container(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: 2,
|
|
|
|
color: LIGHT1,
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: const Text('Go to artist'),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
navStore.pushOnLibrary(
|
|
|
|
MaterialPageRoute<Widget>(
|
|
|
|
builder: (BuildContext context) => ArtistDetailsPage(
|
|
|
|
artist: artist,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
title: const Text('Go to album'),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
navStore.pushOnLibrary(
|
|
|
|
MaterialPageRoute<Widget>(
|
|
|
|
builder: (BuildContext context) => AlbumDetailsPage(
|
|
|
|
album: album,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2020-03-20 16:17:02 +01:00
|
|
|
}
|