mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 10:47:25 +01:00
Work tile: Refactor and add leading widget
This commit is contained in:
parent
db9f6a0eb4
commit
26b1f13c03
1 changed files with 12 additions and 14 deletions
|
|
@ -4,10 +4,12 @@ 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,
|
||||
});
|
||||
|
|
@ -24,21 +26,17 @@ class WorkTile extends StatelessWidget {
|
|||
return StreamBuilder<List<Person>>(
|
||||
stream: backend.db.composersByWork(workId).watch(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return ListTile(
|
||||
title: Text(titleText),
|
||||
subtitle: Text(snapshot.data
|
||||
final subtitleText = snapshot.hasData
|
||||
? snapshot.data
|
||||
.map((p) => '${p.firstName} ${p.lastName}')
|
||||
.join(', ')),
|
||||
onTap: onTap ?? null,
|
||||
);
|
||||
} else {
|
||||
return ListTile(
|
||||
title: Text(titleText),
|
||||
subtitle: Text('...'),
|
||||
onTap: onTap ?? null,
|
||||
);
|
||||
}
|
||||
.join(', ')
|
||||
: '...';
|
||||
return ListTile(
|
||||
leading: leading,
|
||||
title: Text(titleText),
|
||||
subtitle: Text(subtitleText),
|
||||
onTap: onTap ?? null,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue