fixed NextSong not updating properly
This commit is contained in:
parent
16b8e10938
commit
ffc5845a62
7 changed files with 61 additions and 60 deletions
|
@ -5,7 +5,13 @@ import '../usecases/seek_to_next.dart';
|
|||
import '../usecases/seek_to_previous.dart';
|
||||
|
||||
class PlatformIntegrationActor {
|
||||
PlatformIntegrationActor(this._platformIntegrationInfoRepository, this._pause, this._play, this._seekToNext, this._seekToPrevious) {
|
||||
PlatformIntegrationActor(
|
||||
this._platformIntegrationInfoRepository,
|
||||
this._pause,
|
||||
this._play,
|
||||
this._seekToNext,
|
||||
this._seekToPrevious,
|
||||
) {
|
||||
_platformIntegrationInfoRepository.eventStream
|
||||
.listen((event) => _handlePlatformIntegrationEvent(event));
|
||||
}
|
||||
|
|
|
@ -37,12 +37,11 @@ class ManagedQueue implements ManagedQueueInfo {
|
|||
|
||||
final MusicDataInfoRepository _musicDataRepository;
|
||||
|
||||
// die brauch ich aktuell für den originalIndex für neue Songs
|
||||
List<Song> _originalSongs = [];
|
||||
List<Song> _addedSongs = [];
|
||||
// this resembles the queue in AudioPlayer
|
||||
// QueueItems are needed to determine the original position of the current song
|
||||
List<QueueItem> _queue;
|
||||
List<Song> _originalSongs = [];
|
||||
List<Song> _addedSongs = [];
|
||||
|
||||
void addToQueue(Song song) {
|
||||
_addedSongs.add(song);
|
||||
|
@ -265,7 +264,7 @@ class ManagedQueue implements ManagedQueueInfo {
|
|||
final List<Song> songs = [];
|
||||
Song currentSong = song;
|
||||
|
||||
while (currentSong.previous != null) {
|
||||
while (currentSong.previous != '') {
|
||||
currentSong = await _musicDataRepository.getSongByPath(currentSong.previous);
|
||||
songs.add(currentSong);
|
||||
}
|
||||
|
@ -277,7 +276,7 @@ class ManagedQueue implements ManagedQueueInfo {
|
|||
final List<Song> songs = [];
|
||||
Song currentSong = song;
|
||||
|
||||
while (currentSong.next != null) {
|
||||
while (currentSong.next != '') {
|
||||
currentSong = await _musicDataRepository.getSongByPath(currentSong.next);
|
||||
songs.add(currentSong);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,12 @@ class InitQueue {
|
|||
|
||||
final AudioPlayerRepository _audioPlayerRepository;
|
||||
|
||||
Future<void> call(List<QueueItem> queueItems, List<Song> originalSongs, List<Song> addedSongs, int index) async {
|
||||
Future<void> call(
|
||||
List<QueueItem> queueItems,
|
||||
List<Song> originalSongs,
|
||||
List<Song> addedSongs,
|
||||
int index,
|
||||
) async {
|
||||
await _audioPlayerRepository.initQueue(queueItems, originalSongs, addedSongs, index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class CurrentlyPlayingPage extends StatelessWidget {
|
|||
_log.d('build started');
|
||||
final AudioStore audioStore = GetIt.I<AudioStore>();
|
||||
|
||||
// TODO: everything wrapped in Observer and most components have Observer themselves
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: GestureDetector(
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import '../state/audio_store.dart';
|
||||
import '../theming.dart';
|
||||
import 'next_song.dart';
|
||||
|
||||
|
@ -12,8 +10,6 @@ class CurrentlyPlayingHeader extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AudioStore audioStore = GetIt.I<AudioStore>();
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
IconButton(
|
||||
|
@ -34,10 +30,7 @@ class CurrentlyPlayingHeader extends StatelessWidget {
|
|||
'Next up'.toUpperCase(),
|
||||
style: TEXT_SMALL_HEADLINE,
|
||||
),
|
||||
NextSong(
|
||||
queue: audioStore.queueStream.value,
|
||||
index: audioStore.queueIndexStream.value,
|
||||
)
|
||||
const NextSong(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import '../state/audio_store.dart';
|
||||
import 'next_song.dart';
|
||||
|
||||
class NextIndicator extends StatelessWidget {
|
||||
|
@ -12,13 +10,8 @@ class NextIndicator extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AudioStore audioStore = GetIt.I<AudioStore>();
|
||||
|
||||
return Observer(
|
||||
builder: (BuildContext context) {
|
||||
final queue = audioStore.queueStream.value;
|
||||
final int index = audioStore.queueIndexStream.value;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onTapAction(context),
|
||||
child: Container(
|
||||
|
@ -34,10 +27,7 @@ class NextIndicator extends StatelessWidget {
|
|||
Icons.expand_less,
|
||||
color: Colors.white70,
|
||||
),
|
||||
NextSong(
|
||||
queue: queue,
|
||||
index: index,
|
||||
),
|
||||
const NextSong(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1,45 +1,52 @@
|
|||
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, this.queue, this.index}) : super(key: key);
|
||||
|
||||
final List<Song> queue;
|
||||
final int index;
|
||||
const NextSong({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (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,
|
||||
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 < 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
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,
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
return Container(
|
||||
height: 16.0,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue