mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
56 lines
1.5 KiB
Dart
56 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../backend.dart';
|
|
import '../database.dart';
|
|
|
|
class WorkTile extends StatelessWidget {
|
|
final Widget leading;
|
|
final int workId;
|
|
final void Function() onTap;
|
|
|
|
WorkTile({
|
|
this.leading,
|
|
this.workId,
|
|
this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final backend = Backend.of(context);
|
|
|
|
return StreamBuilder<Work>(
|
|
stream: backend.db.workById(workId).watchSingle(),
|
|
builder: (context, snapshot) {
|
|
final titleText = snapshot.data?.title ?? '...';
|
|
|
|
return StreamBuilder<List<Person>>(
|
|
stream: backend.db.composersByWork(workId).watch(),
|
|
builder: (context, snapshot) {
|
|
final subtitleText = snapshot.hasData
|
|
? snapshot.data
|
|
.map((p) => '${p.firstName} ${p.lastName}')
|
|
.join(', ')
|
|
: '...';
|
|
return ListTile(
|
|
leading: leading,
|
|
title: DefaultTextStyle(
|
|
style: Theme.of(context).textTheme.bodyText2,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Text(
|
|
subtitleText,
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
Text(titleText),
|
|
],
|
|
),
|
|
),
|
|
onTap: onTap ?? null,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|