musicus_mobile/musicus/lib/screens/work.dart

63 lines
1.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import '../backend.dart';
import '../database.dart';
2020-03-21 15:06:38 +01:00
import '../editors/work.dart';
2020-04-19 18:36:46 +02:00
import '../widgets/texts.dart';
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-04-19 18:36:46 +02:00
body: StreamBuilder<List<Recording>>(
stream: backend.db.recordingsByWork(work.id).watch(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
2020-04-19 18:36:46 +02:00
final recording = snapshot.data[index];
return ListTile(
2020-04-19 18:36:46 +02:00
title: PerformancesText(recording.id),
onTap: () async {
// TODO: Play recording.
},
);
},
);
} else {
return Container();
}
},
),
);
}
}