mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
A Library artist now has an Albums | Songs switch. Songs lists every song of the artist by title, with Play, Shuffle and Save as playlist: the songs of the artist's albums and the songs whose artist tag names the artist beside others. The view chosen last is the one the next artist opens on. The Albums | Singles switch moves into a shared LibraryViewToggle, and the genre song reader into library_song_reads so both lists use one query.
59 lines
1.8 KiB
Dart
59 lines
1.8 KiB
Dart
import 'package:material_3_expressive/material_3_expressive.dart'
|
|
show
|
|
M3EButtonGroup,
|
|
M3EButtonGroupAction,
|
|
M3EButtonGroupType,
|
|
M3EButtonSize,
|
|
M3EButtonStyle;
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:mornye/theme/material_expressive.dart';
|
|
|
|
/// A switch between the views of a Library page, such as Albums | Singles:
|
|
/// a connected button group, or a segmented button where the expressive
|
|
/// components are off.
|
|
class LibraryViewToggle extends StatelessWidget {
|
|
const LibraryViewToggle({
|
|
super.key,
|
|
required this.labels,
|
|
required this.selected,
|
|
required this.onChanged,
|
|
});
|
|
|
|
final List<String> labels;
|
|
final int selected;
|
|
final ValueChanged<int> onChanged;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (materialExpressiveEnabled(context)) {
|
|
return MaterialExpressiveScope(
|
|
skipAutofocus: true,
|
|
child: M3EButtonGroup(
|
|
type: M3EButtonGroupType.connected,
|
|
style: M3EButtonStyle.filled,
|
|
// Connected segments get no inflated target; keep 48 dp.
|
|
size: M3EButtonSize.sm.copyWith(height: 48),
|
|
selectedIndex: selected,
|
|
selectionRequired: true,
|
|
onSelectedIndexChanged: (index) {
|
|
if (index != null) onChanged(index);
|
|
},
|
|
actions: [
|
|
for (final label in labels)
|
|
M3EButtonGroupAction(label: Text(label)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return SegmentedButton<int>(
|
|
showSelectedIcon: false,
|
|
segments: [
|
|
for (final (index, label) in labels.indexed)
|
|
ButtonSegment(value: index, label: Text(label)),
|
|
],
|
|
selected: {selected},
|
|
onSelectionChanged: (value) => onChanged(value.first),
|
|
);
|
|
}
|
|
}
|