2020-03-21 15:01:51 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import '../backend.dart';
|
|
|
|
|
import '../database.dart';
|
2020-03-21 15:06:38 +01:00
|
|
|
import '../editors/work.dart';
|
2020-03-21 15:01:51 +01:00
|
|
|
|
|
|
|
|
class WorkScreen extends StatelessWidget {
|
|
|
|
|
final Work work;
|
|
|
|
|
|
|
|
|
|
WorkScreen({
|
|
|
|
|
this.work,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final backend = Backend.of(context);
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: Text(work.title),
|
2020-03-21 15:06:38 +01:00
|
|
|
actions: <Widget>[
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.edit),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => WorkEditor(
|
|
|
|
|
work: work,
|
|
|
|
|
),
|
|
|
|
|
fullscreenDialog: true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
2020-03-21 15:01:51 +01:00
|
|
|
),
|
|
|
|
|
body: StreamBuilder<List<Work>>(
|
|
|
|
|
stream: backend.db.workParts(work.id).watch(),
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
itemCount: snapshot.data.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
final part = snapshot.data[index];
|
|
|
|
|
return ListTile(
|
|
|
|
|
title: Text(part.title),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Container();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|