mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
39 lines
969 B
Dart
39 lines
969 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:musicus_database/musicus_database.dart';
|
|
|
|
import '../backend.dart';
|
|
|
|
class WorksByComposer extends StatelessWidget {
|
|
final int personId;
|
|
final void Function(Work work) onTap;
|
|
|
|
WorksByComposer({
|
|
this.personId,
|
|
this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final backend = Backend.of(context);
|
|
|
|
return StreamBuilder<List<Work>>(
|
|
stream: backend.db.worksByComposer(personId).watch(),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.hasData) {
|
|
return ListView.builder(
|
|
itemCount: snapshot.data.length,
|
|
itemBuilder: (context, index) {
|
|
final work = snapshot.data[index];
|
|
return ListTile(
|
|
title: Text(work.title),
|
|
onTap: () => onTap(work),
|
|
);
|
|
},
|
|
);
|
|
} else {
|
|
return Container();
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|