mucke/lib/presentation/widgets/currently_playing_bar.dart

102 lines
3.4 KiB
Dart
Raw Normal View History

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) {
2021-02-26 22:07:18 +01:00
if (audioStore.currentSongStream != null) {
final Song song = audioStore.currentSongStream.value;
final Duration position = audioStore.currentPositionStream?.value ?? const Duration(seconds: 0);
if (song != null) {
return Column(
verticalDirection: VerticalDirection.up,
children: <Widget>[
GestureDetector(
onTap: () => _onTap(context),
child: Container(
color: Colors.transparent,
child: Row(
children: <Widget>[
Image(
image: getAlbumImage(song.albumArtPath),
height: 64.0,
),
Container(
width: 10.0,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
song.title,
overflow: TextOverflow.ellipsis,
maxLines: 2,
2021-01-27 18:13:21 +01:00
),
2021-02-26 22:07:18 +01:00
Text(
song.artist,
style: const TextStyle(
fontSize: 12.0,
color: Colors.white70,
),
)
],
),
2021-01-27 18:13:21 +01:00
),
2021-02-26 22:07:18 +01:00
const PlayPauseButton(
circle: false,
),
const NextButton(),
],
),
2020-12-24 14:31:04 +01:00
),
2020-04-09 17:50:28 +02:00
),
2021-02-26 22:07:18 +01:00
Container(
child: LinearProgressIndicator(
value: position.inMilliseconds / song.duration,
valueColor: const AlwaysStoppedAnimation<Color>(Colors.white),
backgroundColor: Colors.white10,
),
height: 2,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(color: Theme.of(context).primaryColor, blurRadius: 1),
],
),
2021-01-27 18:13:21 +01:00
),
2021-02-26 22:07:18 +01:00
],
);
}
return Container(
height: 0,
2020-04-09 17:50:28 +02:00
);
}
2021-02-26 22:07:18 +01:00
return Container();
2020-04-09 17:50:28 +02:00
},
);
}
Future<void> _onTap(BuildContext context) async {
Navigator.push(
context,
MaterialPageRoute<Widget>(
builder: (BuildContext context) => const CurrentlyPlayingPage(),
),
);
}
}