mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Add recording selector
As a proof of concept some widgets were seperated. The home screen now links to this instead of the recording editor.
This commit is contained in:
parent
a6d795ef3c
commit
0438296bcc
6 changed files with 308 additions and 4 deletions
26
lib/widgets/ensemble_text.dart
Normal file
26
lib/widgets/ensemble_text.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../backend.dart';
|
||||
import '../database.dart';
|
||||
|
||||
class EnsembleText extends StatelessWidget {
|
||||
final int ensembleId;
|
||||
|
||||
EnsembleText(this.ensembleId);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final backend = Backend.of(context);
|
||||
|
||||
return StreamBuilder<Ensemble>(
|
||||
stream: backend.db.ensembleById(ensembleId).watchSingle(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Text(snapshot.data.name);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
42
lib/widgets/performance_row.dart
Normal file
42
lib/widgets/performance_row.dart
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../backend.dart';
|
||||
import '../database.dart';
|
||||
|
||||
import 'person_text.dart';
|
||||
import 'ensemble_text.dart';
|
||||
|
||||
class PerformanceRow extends StatelessWidget {
|
||||
final Performance performance;
|
||||
|
||||
PerformanceRow(this.performance);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final backend = Backend.of(context);
|
||||
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
if (performance.person != null)
|
||||
PersonText(performance.person)
|
||||
else if (performance.ensemble != null)
|
||||
EnsembleText(performance.ensemble),
|
||||
if (performance.role != null) ...[
|
||||
SizedBox(
|
||||
width: 4.0,
|
||||
),
|
||||
StreamBuilder<Instrument>(
|
||||
stream: backend.db.instrumentById(performance.role).watchSingle(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Text('(${snapshot.data.name})');
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
26
lib/widgets/person_text.dart
Normal file
26
lib/widgets/person_text.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../backend.dart';
|
||||
import '../database.dart';
|
||||
|
||||
class PersonText extends StatelessWidget {
|
||||
final int personId;
|
||||
|
||||
PersonText(this.personId);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final backend = Backend.of(context);
|
||||
|
||||
return StreamBuilder<Person>(
|
||||
stream: backend.db.personById(personId).watchSingle(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Text('${snapshot.data.firstName} ${snapshot.data.lastName}');
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
39
lib/widgets/works_by_composer.dart
Normal file
39
lib/widgets/works_by_composer.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../backend.dart';
|
||||
import '../database.dart';
|
||||
|
||||
class WorksByComposer extends StatelessWidget {
|
||||
final int personId;
|
||||
final void Function(Work work) onTap;
|
||||
|
||||
WorksByComposer({
|
||||
this.personId,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final backend = Backend.of(context);
|
||||
|
||||
return StreamBuilder<List<Work>>(
|
||||
stream: backend.db.worksByComposer(personId).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),
|
||||
onTap: () => onTap(work),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue