diff --git a/common/lib/src/backend.dart b/common/lib/src/backend.dart index 225b5ec..1236554 100644 --- a/common/lib/src/backend.dart +++ b/common/lib/src/backend.dart @@ -181,6 +181,9 @@ class MusicusBackendState extends State { basePath: serverSettings.apiPath, credentials: settings.account.value, ); + + // TODO: Maybe don't change the client in the middle of synchronization. + db.client = client; } @override diff --git a/common/lib/src/editors/ensemble.dart b/common/lib/src/editors/ensemble.dart index 3a0b2d7..9ea9d8c 100644 --- a/common/lib/src/editors/ensemble.dart +++ b/common/lib/src/editors/ensemble.dart @@ -18,6 +18,7 @@ class _EnsembleEditorState extends State { final nameController = TextEditingController(); bool uploading = false; + bool _sync = true; @override void initState() { @@ -59,6 +60,8 @@ class _EnsembleEditorState extends State { 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 { ), body: ListView( children: [ + 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( diff --git a/common/lib/src/editors/instrument.dart b/common/lib/src/editors/instrument.dart index 5c057c8..b48eb99 100644 --- a/common/lib/src/editors/instrument.dart +++ b/common/lib/src/editors/instrument.dart @@ -18,6 +18,7 @@ class _InstrumentEditorState extends State { final nameController = TextEditingController(); bool uploading = false; + bool _sync = true; @override void initState() { @@ -59,6 +60,8 @@ class _InstrumentEditorState extends State { 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 { ), body: ListView( children: [ + 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( diff --git a/common/lib/src/editors/person.dart b/common/lib/src/editors/person.dart index 0b8a993..c91bf47 100644 --- a/common/lib/src/editors/person.dart +++ b/common/lib/src/editors/person.dart @@ -19,6 +19,7 @@ class _PersonEditorState extends State { final lastNameController = TextEditingController(); bool uploading = false; + bool _sync = true; @override void initState() { @@ -62,6 +63,8 @@ class _PersonEditorState extends State { 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 { ), body: ListView( children: [ + 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( diff --git a/common/lib/src/editors/recording.dart b/common/lib/src/editors/recording.dart index 73065ee..fa83ef8 100644 --- a/common/lib/src/editors/recording.dart +++ b/common/lib/src/editors/recording.dart @@ -29,6 +29,7 @@ class _RecordingEditorState extends State { MusicusBackendState _backend; bool _uploading = false; + bool _sync = true; WorkInfo _workInfo; List _performanceInfos = []; @@ -137,6 +138,8 @@ class _RecordingEditorState extends State { generateId(), work: _workInfo.work.id, comment: _commentController.text, + sync: _sync, + synced: false, ), performances: _performanceInfos, ); @@ -167,6 +170,18 @@ class _RecordingEditorState extends State { ), body: ListView( children: [ + 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), diff --git a/common/lib/src/editors/work.dart b/common/lib/src/editors/work.dart index 8160c30..a4e4e03 100644 --- a/common/lib/src/editors/work.dart +++ b/common/lib/src/editors/work.dart @@ -179,6 +179,7 @@ class _WorkEditorState extends State { final titleController = TextEditingController(); bool uploading = false; + bool _sync = true; Person composer; List instruments = []; List parts = []; @@ -310,6 +311,8 @@ class _WorkEditorState extends State { 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 { header: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + 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,