mucke/lib/presentation/widgets/next_song.dart
2021-06-20 13:49:21 +02:00

52 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:get_it/get_it.dart';
import '../../domain/entities/song.dart';
import '../state/audio_store.dart';
class NextSong extends StatelessWidget {
const NextSong({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Observer(builder: (BuildContext context) {
final audioStore = GetIt.I<AudioStore>();
final List<Song>? queue = audioStore.queueStream.value;
final int? index = audioStore.queueIndexStream.value;
if (index != null && queue != null && index < queue.length - 1) {
final Song song = queue[index + 1];
return RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: const TextStyle(
fontSize: 14,
color: Colors.white70,
),
children: [
TextSpan(
text: '${song.title}',
style: const TextStyle(
fontWeight: FontWeight.w300,
),
),
const TextSpan(text: ''),
TextSpan(
text: '${song.artist}',
style: const TextStyle(
fontWeight: FontWeight.w300,
),
),
],
),
);
} else {
return Container(
height: 16.0,
);
}
});
}
}