mucke/lib/presentation/pages/currently_playing.dart

145 lines
5 KiB
Dart
Raw Normal View History

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';
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';
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 {
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
2020-03-20 16:17:02 +01:00
return Scaffold(
body: SafeArea(
2020-12-31 17:52:20 +01:00
child: GestureDetector(
onVerticalDragEnd: (dragEndDetails) {
if (dragEndDetails.primaryVelocity < 0) {
_openQueue(context);
} else if (dragEndDetails.primaryVelocity > 0) {
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');
final Song song = audioStore.currentSongStream.value;
2020-07-12 18:25:34 +02:00
return Stack(
children: [
AlbumBackground(
song: song,
2020-12-08 22:22:31 +01:00
),
Padding(
padding: const EdgeInsets.only(
left: 12.0,
right: 12.0,
top: 8.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2021-05-08 23:46:23 +02:00
CurrentlyPlayingHeader(onTap: _openQueue),
const Spacer(
2021-04-11 15:44:10 +02:00
flex: 10,
),
Expanded(
2021-04-11 15:44:10 +02:00
flex: 720,
2021-05-08 23:46:23 +02:00
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 0.0,
),
child: AlbumArt(
song: song,
),
),
),
2020-05-09 19:46:06 +02: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,
),
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(),
),
const Spacer(
2021-04-11 15:44:10 +02:00
flex: 20,
),
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,
),
],
),
2020-12-08 22:22:31 +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
}
2020-03-20 16:17:02 +01:00
}