mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57: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';
|
import '../database.dart';
|
||||||
|
|
||||||
class WorkTile extends StatelessWidget {
|
class WorkTile extends StatelessWidget {
|
||||||
|
final Widget leading;
|
||||||
final int workId;
|
final int workId;
|
||||||
final void Function() onTap;
|
final void Function() onTap;
|
||||||
|
|
||||||
WorkTile({
|
WorkTile({
|
||||||
|
this.leading,
|
||||||
this.workId,
|
this.workId,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
});
|
});
|
||||||
|
|
@ -24,21 +26,17 @@ class WorkTile extends StatelessWidget {
|
||||||
return StreamBuilder<List<Person>>(
|
return StreamBuilder<List<Person>>(
|
||||||
stream: backend.db.composersByWork(workId).watch(),
|
stream: backend.db.composersByWork(workId).watch(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
final subtitleText = snapshot.hasData
|
||||||
return ListTile(
|
? snapshot.data
|
||||||
title: Text(titleText),
|
|
||||||
subtitle: Text(snapshot.data
|
|
||||||
.map((p) => '${p.firstName} ${p.lastName}')
|
.map((p) => '${p.firstName} ${p.lastName}')
|
||||||
.join(', ')),
|
.join(', ')
|
||||||
onTap: onTap ?? null,
|
: '...';
|
||||||
);
|
return ListTile(
|
||||||
} else {
|
leading: leading,
|
||||||
return ListTile(
|
title: Text(titleText),
|
||||||
title: Text(titleText),
|
subtitle: Text(subtitleText),
|
||||||
subtitle: Text('...'),
|
onTap: onTap ?? null,
|
||||||
onTap: onTap ?? null,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue