tryStartEditing method

Future<bool> tryStartEditing(
  1. BuildContext context
)

Implementation

Future<bool> tryStartEditing(BuildContext context) async {
  FocusNode().requestFocus();
  var loading = LoadingWidgetService.instance.show();

  if (lockService != null) {
    try {
      var isLocked = await lockService!.isLocked(
        databaseCollection.collectionName,
        updateItemFrame.editableItem.id,
        catchExceptions: false,
      );
      if (isLocked) {
        loading.deactivate();
        await SplitRouterDelegate.instance.pushDialog(DefaultDialog(
          title: Text("Dieser Eintrag wird zurzeit bearbeitet"),
          buttons: [
            DefaultDialogButton(
              titel: Text("Verstanden"),
            )
          ],
        ));
        return false;
      }
    } catch (e) {
      loading.deactivate();
      SnackBarController.showText("Verbindung fehlgeschlagen");
      return false;
    }
  }

  lockService?.setLock(
      databaseCollection.collectionName, updateItemFrame.editableItem.id);

  LockNavigatorService.instance.lockForTopPage();
  updateItemFrame.setEditable(true);
  loading.deactivate();
  updateNotifier.update();
  return true;
}