Add person screen

This just displays a list of the persons works for now. It can be
reached from the home screens list of persons.
This commit is contained in:
Elias Projahn 2019-12-15 12:22:39 +01:00
parent 07e7e38a9b
commit 25e4267cb8
2 changed files with 50 additions and 0 deletions

41
lib/screens/person.dart Normal file
View file

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import '../backend.dart';
import '../database.dart';
class PersonScreen extends StatelessWidget {
final Person person;
PersonScreen({
this.person,
});
@override
Widget build(BuildContext context) {
final backend = Backend.of(context);
return Scaffold(
appBar: AppBar(
title: Text('${person.firstName} ${person.lastName}'),
),
body: StreamBuilder<List<Work>>(
stream: backend.db.worksByComposer(person.id).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),
);
},
);
} else {
return Container();
}
},
),
);
}
}