mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 02:37:25 +01:00
Support work sections
This commit is contained in:
parent
813fa2e47a
commit
93a5a06b55
6 changed files with 134 additions and 51 deletions
|
|
@ -79,6 +79,9 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
|||
// This will contain information on the last new work.
|
||||
WorkInfo workInfo;
|
||||
|
||||
// The index of the last displayed section.
|
||||
int lastSectionIndex;
|
||||
|
||||
for (var i = 0; i < playlist.length; i++) {
|
||||
// The widgets displayed for this track.
|
||||
List<Widget> children = [];
|
||||
|
|
@ -113,6 +116,18 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
|||
for (final partId in partIds) {
|
||||
final partInfo = workInfo.parts[partId];
|
||||
|
||||
final sectionIndex = workInfo.sections
|
||||
.lastIndexWhere((s) => s.beforePartIndex <= partId);
|
||||
if (sectionIndex != lastSectionIndex) {
|
||||
lastSectionIndex = sectionIndex;
|
||||
children.add(Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 8.0,
|
||||
),
|
||||
child: Text(workInfo.sections[sectionIndex].title),
|
||||
));
|
||||
}
|
||||
|
||||
children.add(Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8.0,
|
||||
|
|
@ -183,21 +198,20 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
|||
},
|
||||
onLongPress: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SimpleDialog(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text('Remove from playlist'),
|
||||
onTap: () {
|
||||
backend.playback.removeTrack(index);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SimpleDialog(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text('Remove from playlist'),
|
||||
onTap: () {
|
||||
backend.playback.removeTrack(index);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -61,6 +61,15 @@ class _PlayerBarState extends State<PlayerBar> {
|
|||
|
||||
if (_partIds.isNotEmpty) {
|
||||
subtitleBuffer.write(': ');
|
||||
|
||||
final section = _workInfo.sections
|
||||
.lastWhere((s) => s.beforePartIndex <= _partIds[0]);
|
||||
|
||||
if (section != null) {
|
||||
subtitleBuffer.write(section.title);
|
||||
subtitleBuffer.write(': ');
|
||||
}
|
||||
|
||||
subtitleBuffer.write(
|
||||
_partIds.map((i) => _workInfo.parts[i].part.title).join(', '));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue