mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 10:47:25 +01:00
mobile: Check server errors in editors
This commit is contained in:
parent
00c31296e5
commit
9d4554b67f
6 changed files with 247 additions and 91 deletions
|
|
@ -25,6 +25,13 @@ class App extends StatelessWidget {
|
|||
primary: Colors.amber,
|
||||
secondary: Colors.amber,
|
||||
),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
backgroundColor: Colors.grey[800],
|
||||
contentTextStyle: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
),
|
||||
fontFamily: 'Libertinus Sans',
|
||||
),
|
||||
home: Builder(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ class EnsembleEditor extends StatefulWidget {
|
|||
class _EnsembleEditorState extends State<EnsembleEditor> {
|
||||
final nameController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -34,18 +36,46 @@ class _EnsembleEditorState extends State<EnsembleEditor> {
|
|||
appBar: AppBar(
|
||||
title: Text('Ensemble'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
uploading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: FlatButton(
|
||||
child: Text('DONE'),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
uploading = true;
|
||||
});
|
||||
|
||||
final ensemble = Ensemble(
|
||||
id: widget.ensemble?.id ?? generateId(),
|
||||
name: nameController.text,
|
||||
);
|
||||
|
||||
await backend.client.putEnsemble(ensemble);
|
||||
final success = await backend.client.putEnsemble(ensemble);
|
||||
|
||||
setState(() {
|
||||
uploading = false;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
Navigator.pop(context, ensemble);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Failed to upload'),
|
||||
));
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ class InstrumentEditor extends StatefulWidget {
|
|||
class _InstrumentEditorState extends State<InstrumentEditor> {
|
||||
final nameController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -34,18 +36,47 @@ class _InstrumentEditorState extends State<InstrumentEditor> {
|
|||
appBar: AppBar(
|
||||
title: Text('Instrument/Role'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
uploading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: FlatButton(
|
||||
child: Text('DONE'),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
uploading = true;
|
||||
});
|
||||
|
||||
final instrument = Instrument(
|
||||
id: widget.instrument?.id ?? generateId(),
|
||||
name: nameController.text,
|
||||
);
|
||||
|
||||
final success =
|
||||
await backend.client.putInstrument(instrument);
|
||||
|
||||
setState(() {
|
||||
uploading = false;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
Navigator.pop(context, instrument);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Failed to upload'),
|
||||
));
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class _PersonEditorState extends State<PersonEditor> {
|
|||
final firstNameController = TextEditingController();
|
||||
final lastNameController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -36,17 +38,45 @@ class _PersonEditorState extends State<PersonEditor> {
|
|||
appBar: AppBar(
|
||||
title: Text('Person'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
uploading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: FlatButton(
|
||||
child: Text('DONE'),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
uploading = true;
|
||||
});
|
||||
|
||||
final person = Person(
|
||||
id: widget.person?.id ?? generateId(),
|
||||
firstName: firstNameController.text,
|
||||
lastName: lastNameController.text,
|
||||
);
|
||||
|
||||
await backend.client.putPerson(person);
|
||||
final success = await backend.client.putPerson(person);
|
||||
|
||||
setState(() {
|
||||
uploading = false;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
Navigator.pop(context, person);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Failed to upload'),
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class RecordingEditor extends StatefulWidget {
|
|||
class _RecordingEditorState extends State<RecordingEditor> {
|
||||
final commentController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
WorkInfo workInfo;
|
||||
List<PerformanceInfo> performanceInfos = [];
|
||||
|
||||
|
|
@ -103,20 +104,44 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
appBar: AppBar(
|
||||
title: Text('Recording'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
uploading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: FlatButton(
|
||||
child: Text('DONE'),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
uploading = true;
|
||||
});
|
||||
|
||||
final recordingInfo = RecordingInfo(
|
||||
recording: Recording(
|
||||
id: widget?.recordingInfo?.recording?.id ?? generateId(),
|
||||
id: widget?.recordingInfo?.recording?.id ??
|
||||
generateId(),
|
||||
work: workInfo.work.id,
|
||||
comment: commentController.text,
|
||||
),
|
||||
performances: performanceInfos,
|
||||
);
|
||||
|
||||
final success =
|
||||
await backend.client.putRecording(recordingInfo);
|
||||
|
||||
setState(() {
|
||||
uploading = false;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
Navigator.pop(
|
||||
context,
|
||||
RecordingSelectorResult(
|
||||
|
|
@ -124,8 +149,13 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
recordingInfo: recordingInfo,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Failed to upload'),
|
||||
));
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ class WorkEditor extends StatefulWidget {
|
|||
class _WorkEditorState extends State<WorkEditor> {
|
||||
final titleController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
Person composer;
|
||||
List<Instrument> instruments = [];
|
||||
List<PartData> parts = [];
|
||||
|
|
@ -249,9 +250,26 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
appBar: AppBar(
|
||||
title: Text('Work'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
uploading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: FlatButton(
|
||||
child: Text('DONE'),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
uploading = true;
|
||||
});
|
||||
|
||||
final workId = widget?.workInfo?.work?.id ?? generateId();
|
||||
|
||||
List<PartInfo> partInfos = [];
|
||||
|
|
@ -277,15 +295,25 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
composer: composer?.id,
|
||||
),
|
||||
instruments: instruments,
|
||||
// TODO: Theoretically, this should include all composers from
|
||||
// the parts.
|
||||
// TODO: Theoretically, this should include all composers
|
||||
// from the parts.
|
||||
composers: [composer],
|
||||
parts: partInfos,
|
||||
);
|
||||
|
||||
await backend.client.putWork(workInfo);
|
||||
final success = await backend.client.putWork(workInfo);
|
||||
|
||||
setState(() {
|
||||
uploading = false;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
Navigator.pop(context, workInfo);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Failed to upload'),
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue