diff --git a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt index f8b41a3b7a..367b45aeb7 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt @@ -146,7 +146,8 @@ class HomeScreenFragment : BaseComposeFragment() { widget = command.widget, source = command.source, type = command.type, - layout = command.layout + layout = command.layout, + isInEditMode = command.isInEditMode ) ) } @@ -157,7 +158,8 @@ class HomeScreenFragment : BaseComposeFragment() { ctx = command.ctx, source = command.source, layout = command.layout, - target = command.target + target = command.target, + isInEditMode = command.isInEditMode ) ) } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/widgets/SelectWidgetTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/widgets/SelectWidgetTypeFragment.kt index a413d69793..d17e3d4781 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/widgets/SelectWidgetTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/widgets/SelectWidgetTypeFragment.kt @@ -34,6 +34,7 @@ class SelectWidgetTypeFragment : BaseBottomSheetComposeFragment() { private val sourceLayout: Int get() = arg(WIDGET_SOURCE_LAYOUT) private val target: Id? get() = argOrNull(TARGET_KEY) private val forExistingWidget: Boolean get() = arg(IS_FOR_EXISTING_WIDGET) + private val isInEditMode: Boolean get() = arg(IS_IN_EDIT_MODE_KEY) private val vm by viewModels { factory } @@ -56,7 +57,8 @@ class SelectWidgetTypeFragment : BaseBottomSheetComposeFragment() { ctx = ctx, view = view, widget = widget, - source = source + source = source, + isInEditMode = isInEditMode ) } else { vm.onWidgetTypeClicked( @@ -114,13 +116,15 @@ class SelectWidgetTypeFragment : BaseBottomSheetComposeFragment() { private const val WIDGET_SOURCE_LAYOUT = "arg.select-widget-type.widget-source-layout" private const val IS_FOR_EXISTING_WIDGET = "arg.select-widget-type.for-existing-widget" private const val TARGET_KEY = "arg.select-widget-type.target" + private const val IS_IN_EDIT_MODE_KEY = "arg.select-widget-type.is-in-edit-mode" fun args( ctx: Id, widget: Id, source: Id, type: Int, - layout: Int + layout: Int, + isInEditMode: Boolean ) = bundleOf( CTX_KEY to ctx, WIDGET_ID_KEY to widget, @@ -128,20 +132,23 @@ class SelectWidgetTypeFragment : BaseBottomSheetComposeFragment() { WIDGET_TYPE_KEY to type, IS_FOR_EXISTING_WIDGET to true, WIDGET_SOURCE_LAYOUT to layout, - TARGET_KEY to null + TARGET_KEY to null, + IS_IN_EDIT_MODE_KEY to isInEditMode ) fun args( ctx: Id, source: Id, layout: Int, - target: Id? + target: Id?, + isInEditMode: Boolean ) = bundleOf( CTX_KEY to ctx, WIDGET_SOURCE_KEY to source, WIDGET_SOURCE_LAYOUT to layout, IS_FOR_EXISTING_WIDGET to false, - TARGET_KEY to target + TARGET_KEY to target, + IS_IN_EDIT_MODE_KEY to isInEditMode ) } } \ No newline at end of file diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModel.kt index 57a4abf5bd..b4f7806997 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/home/HomeScreenViewModel.kt @@ -352,7 +352,8 @@ class HomeScreenViewModel( ctx = configStorage.get().widgets, source = dispatch.source, layout = dispatch.sourceLayout, - target = dispatch.target + target = dispatch.target, + isInEditMode = mode.value == InteractionMode.Edit ) ) } @@ -362,7 +363,8 @@ class HomeScreenViewModel( ctx = configStorage.get().widgets, source = dispatch.source, layout = ObjectType.Layout.SET.code, - target = dispatch.target + target = dispatch.target, + isInEditMode = mode.value == InteractionMode.Edit ) ) } @@ -664,7 +666,8 @@ class HomeScreenViewModel( is Widget.Source.Default -> { source.obj.layout?.code ?: UNDEFINED_LAYOUT_CODE } - } + }, + isInEditMode = mode.value == InteractionMode.Edit ) ) } @@ -1078,7 +1081,8 @@ sealed class Command { val ctx: Id, val source: Id, val target: Id?, - val layout: Int + val layout: Int, + val isInEditMode: Boolean ) : Command() data class ChangeWidgetSource( @@ -1093,7 +1097,8 @@ sealed class Command { val widget: Id, val source: Id, val type: Int, - val layout: Int + val layout: Int, + val isInEditMode: Boolean ) : Command() { companion object { const val TYPE_TREE = 0 diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/widgets/SelectWidgetTypeViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/widgets/SelectWidgetTypeViewModel.kt index 791839913e..f9628b62c5 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/widgets/SelectWidgetTypeViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/widgets/SelectWidgetTypeViewModel.kt @@ -83,7 +83,8 @@ class SelectWidgetTypeViewModel( ctx: Id, widget: Id, source: Id, - view: WidgetTypeView + view: WidgetTypeView, + isInEditMode: Boolean ) { if (!view.isSelected) { viewModelScope.launch { @@ -107,7 +108,8 @@ class SelectWidgetTypeViewModel( onSuccess = { sendChangeWidgetLayoutEvent( analytics = analytics, - layout = newLayout + layout = newLayout, + isInEditMode = isInEditMode ) payloadDispatcher.send(it).also { isDismissed.value = true