fix for #22; fix for persistent queue

This commit is contained in:
Moritz Weber 2022-03-05 22:59:55 +01:00
parent e920f77b30
commit 9a046bdaba
3 changed files with 36 additions and 19 deletions

View file

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:get_it/get_it.dart';
import '../../constants.dart';
@ -21,24 +20,20 @@ class LikeButton extends StatelessWidget {
Widget build(BuildContext context) {
final MusicDataStore musicDataStore = GetIt.I<MusicDataStore>();
return Observer(
builder: (BuildContext context) {
return IconButton(
icon: Icon(
likeCountIcon(song.likeCount),
size: iconSize,
color: likeCountColor(song.likeCount),
),
onPressed: () {
if (song.likeCount < MAX_LIKE_COUNT) {
musicDataStore.incrementLikeCount(song);
} else {
musicDataStore.resetLikeCount(song);
}
},
visualDensity: VisualDensity.compact,
);
return IconButton(
icon: Icon(
likeCountIcon(song.likeCount),
size: iconSize,
color: likeCountColor(song.likeCount),
),
onPressed: () {
if (song.likeCount < MAX_LIKE_COUNT) {
musicDataStore.incrementLikeCount(song);
} else {
musicDataStore.resetLikeCount(song);
}
},
visualDensity: VisualDensity.compact,
);
}
}
}

View file

@ -81,6 +81,7 @@ class PersistentStateDao extends DatabaseAccessor<MoorDatabase>
SongModel.fromMoor(row.readTable(songs)),
originalIndex: row.readTable(availableSongEntries).originalIndex,
source: row.readTable(availableSongEntries).type.toQueueItemType(),
isAvailable: row.readTable(availableSongEntries).isAvailable,
);
}).toList());
}

View file

@ -51,6 +51,27 @@ class PlatformIntegrationDataSourceImpl extends BaseAudioHandler
));
}
@override
Future<void> click([MediaButton button = MediaButton.media]) async {
switch (button) {
case MediaButton.media:
// this paused the playback when connecting a bluetooth speaker via NFC
// find another solution if this turns out to break other things
// if (playbackState.value.playing == true) {
// await pause();
// } else {
// await play();
// }
// break;
case MediaButton.next:
await skipToNext();
break;
case MediaButton.previous:
await skipToPrevious();
break;
}
}
// PlatformIntegrationDataSource interface
@override