2019-12-15 12:22:39 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-04-24 22:41:52 +02:00
|
|
|
import 'package:musicus_database/musicus_database.dart';
|
2019-12-15 12:22:39 +01:00
|
|
|
|
|
|
|
|
import '../backend.dart';
|
2020-03-21 15:06:38 +01:00
|
|
|
import '../editors/person.dart';
|
2019-12-15 12:22:39 +01:00
|
|
|
|
2020-03-21 15:01:51 +01:00
|
|
|
import 'work.dart';
|
|
|
|
|
|
2019-12-15 12:22:39 +01:00
|
|
|
class PersonScreen extends StatelessWidget {
|
|
|
|
|
final Person person;
|
|
|
|
|
|
|
|
|
|
PersonScreen({
|
|
|
|
|
this.person,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final backend = Backend.of(context);
|
2020-04-26 17:26:19 +02:00
|
|
|
|
2019-12-15 12:22:39 +01:00
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: Text('${person.firstName} ${person.lastName}'),
|
2020-03-21 15:06:38 +01:00
|
|
|
actions: <Widget>[
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.edit),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => PersonEditor(
|
|
|
|
|
person: person,
|
|
|
|
|
),
|
|
|
|
|
fullscreenDialog: true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
2019-12-15 12:22:39 +01:00
|
|
|
),
|
|
|
|
|
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),
|
2020-04-26 17:26:19 +02:00
|
|
|
onTap: () async {
|
|
|
|
|
final workInfo = await backend.db.getWorkInfo(work);
|
|
|
|
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => WorkScreen(
|
|
|
|
|
workInfo: workInfo,
|
|
|
|
|
),
|
2020-03-21 15:01:51 +01:00
|
|
|
),
|
2020-04-26 17:26:19 +02:00
|
|
|
);
|
|
|
|
|
},
|
2019-12-15 12:22:39 +01:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Container();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|