2020-04-09 17:50:28 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../domain/entities/song.dart';
|
|
|
|
import '../pages/currently_playing.dart';
|
|
|
|
import '../state/audio_store.dart';
|
|
|
|
import '../utils.dart';
|
2020-08-12 20:59:00 +02:00
|
|
|
import 'next_button.dart';
|
2020-04-10 20:12:26 +02:00
|
|
|
import 'play_pause_button.dart';
|
2020-04-09 17:50:28 +02:00
|
|
|
|
|
|
|
class CurrentlyPlayingBar extends StatelessWidget {
|
|
|
|
const CurrentlyPlayingBar({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final AudioStore audioStore = Provider.of<AudioStore>(context);
|
|
|
|
|
|
|
|
return Observer(
|
|
|
|
builder: (BuildContext context) {
|
2020-11-15 16:36:50 +01:00
|
|
|
if (audioStore.currentSong != null) {
|
|
|
|
final Song song = audioStore.currentSong;
|
2020-04-09 17:50:28 +02:00
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
2020-04-11 20:23:02 +02:00
|
|
|
child: LinearProgressIndicator(
|
2020-11-15 16:36:50 +01:00
|
|
|
value: audioStore.currentPositionStream.value / audioStore.currentSong.duration,
|
2020-04-09 17:50:28 +02:00
|
|
|
),
|
|
|
|
height: 2,
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () => _onTap(context),
|
2020-12-24 14:31:04 +01:00
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Image(
|
|
|
|
image: getAlbumImage(song.albumArtPath),
|
|
|
|
height: 64.0,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: 10.0,
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(song.title),
|
|
|
|
Text(
|
|
|
|
song.artist,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 12.0,
|
|
|
|
color: Colors.white70,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
const PlayPauseButton(
|
|
|
|
circle: false,
|
|
|
|
),
|
|
|
|
const NextButton(),
|
|
|
|
],
|
|
|
|
),
|
2020-04-09 17:50:28 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container(
|
|
|
|
height: 0,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onTap(BuildContext context) async {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute<Widget>(
|
|
|
|
builder: (BuildContext context) => const CurrentlyPlayingPage(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|