mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-25 19:27:24 +02:00
common: Expose sync property in editors
This commit is contained in:
parent
6c7891de14
commit
322ed3f81e
6 changed files with 78 additions and 0 deletions
|
|
@ -181,6 +181,9 @@ class MusicusBackendState extends State<MusicusBackend> {
|
|||
basePath: serverSettings.apiPath,
|
||||
credentials: settings.account.value,
|
||||
);
|
||||
|
||||
// TODO: Maybe don't change the client in the middle of synchronization.
|
||||
db.client = client;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class _EnsembleEditorState extends State<EnsembleEditor> {
|
|||
final nameController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
bool _sync = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -59,6 +60,8 @@ class _EnsembleEditorState extends State<EnsembleEditor> {
|
|||
final ensemble = Ensemble(
|
||||
id: widget.ensemble?.id ?? generateId(),
|
||||
name: nameController.text,
|
||||
sync: _sync,
|
||||
synced: false,
|
||||
);
|
||||
|
||||
final success = await backend.client.putEnsemble(ensemble);
|
||||
|
|
@ -80,6 +83,18 @@ class _EnsembleEditorState extends State<EnsembleEditor> {
|
|||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text('Synchronize changes'),
|
||||
subtitle: Text(_sync
|
||||
? 'Publish changes on the server'
|
||||
: 'Keep changes private'),
|
||||
value: _sync,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_sync = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextField(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class _InstrumentEditorState extends State<InstrumentEditor> {
|
|||
final nameController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
bool _sync = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -59,6 +60,8 @@ class _InstrumentEditorState extends State<InstrumentEditor> {
|
|||
final instrument = Instrument(
|
||||
id: widget.instrument?.id ?? generateId(),
|
||||
name: nameController.text,
|
||||
sync: _sync,
|
||||
synced: false,
|
||||
);
|
||||
|
||||
final success =
|
||||
|
|
@ -81,6 +84,18 @@ class _InstrumentEditorState extends State<InstrumentEditor> {
|
|||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text('Synchronize changes'),
|
||||
subtitle: Text(_sync
|
||||
? 'Publish changes on the server'
|
||||
: 'Keep changes private'),
|
||||
value: _sync,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_sync = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextField(
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class _PersonEditorState extends State<PersonEditor> {
|
|||
final lastNameController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
bool _sync = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -62,6 +63,8 @@ class _PersonEditorState extends State<PersonEditor> {
|
|||
id: widget.person?.id ?? generateId(),
|
||||
firstName: firstNameController.text,
|
||||
lastName: lastNameController.text,
|
||||
sync: _sync,
|
||||
synced: false,
|
||||
);
|
||||
|
||||
final success = await backend.client.putPerson(person);
|
||||
|
|
@ -83,6 +86,18 @@ class _PersonEditorState extends State<PersonEditor> {
|
|||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text('Synchronize changes'),
|
||||
subtitle: Text(_sync
|
||||
? 'Publish changes on the server'
|
||||
: 'Keep changes private'),
|
||||
value: _sync,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_sync = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextField(
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
|
||||
MusicusBackendState _backend;
|
||||
bool _uploading = false;
|
||||
bool _sync = true;
|
||||
WorkInfo _workInfo;
|
||||
List<PerformanceInfo> _performanceInfos = [];
|
||||
|
||||
|
|
@ -137,6 +138,8 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
generateId(),
|
||||
work: _workInfo.work.id,
|
||||
comment: _commentController.text,
|
||||
sync: _sync,
|
||||
synced: false,
|
||||
),
|
||||
performances: _performanceInfos,
|
||||
);
|
||||
|
|
@ -167,6 +170,18 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text('Synchronize changes'),
|
||||
subtitle: Text(_sync
|
||||
? 'Publish changes on the server'
|
||||
: 'Keep changes private'),
|
||||
value: _sync,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_sync = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
_workInfo != null
|
||||
? ListTile(
|
||||
title: Text(_workInfo.work.title),
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
final titleController = TextEditingController();
|
||||
|
||||
bool uploading = false;
|
||||
bool _sync = true;
|
||||
Person composer;
|
||||
List<Instrument> instruments = [];
|
||||
List<PartData> parts = [];
|
||||
|
|
@ -310,6 +311,8 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
id: workId,
|
||||
title: titleController.text,
|
||||
composer: composer?.id,
|
||||
sync: _sync,
|
||||
synced: false,
|
||||
),
|
||||
instruments: instruments,
|
||||
// TODO: Theoretically, this should include all composers
|
||||
|
|
@ -340,6 +343,18 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
header: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
SwitchListTile(
|
||||
title: Text('Synchronize changes'),
|
||||
subtitle: Text(_sync
|
||||
? 'Publish changes on the server'
|
||||
: 'Keep changes private'),
|
||||
value: _sync,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_sync = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
WorkProperties(
|
||||
titleController: titleController,
|
||||
composer: composer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue