mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3381 Widgets | Fix | Automatically apply link layout for widgets where source is image, file, video or space member (#2090)
This commit is contained in:
parent
f9023db279
commit
0d9bb86ccf
3 changed files with 12 additions and 5 deletions
|
@ -116,6 +116,7 @@ import com.anytypeio.anytype.presentation.widgets.TreeWidgetContainer
|
|||
import com.anytypeio.anytype.presentation.widgets.ViewId
|
||||
import com.anytypeio.anytype.presentation.widgets.Widget
|
||||
import com.anytypeio.anytype.presentation.widgets.WidgetActiveViewStateHolder
|
||||
import com.anytypeio.anytype.presentation.widgets.WidgetConfig
|
||||
import com.anytypeio.anytype.presentation.widgets.WidgetContainer
|
||||
import com.anytypeio.anytype.presentation.widgets.WidgetDispatchEvent
|
||||
import com.anytypeio.anytype.presentation.widgets.WidgetId
|
||||
|
@ -673,8 +674,7 @@ class HomeScreenViewModel(
|
|||
.withLatestFrom(spaceManager.observe()) { dispatch, config ->
|
||||
when (dispatch) {
|
||||
is WidgetDispatchEvent.SourcePicked.Default -> {
|
||||
if (dispatch.sourceLayout == ObjectType.Layout.DATE.code ||
|
||||
dispatch.sourceLayout == ObjectType.Layout.PARTICIPANT.code) {
|
||||
if (WidgetConfig.isLinkOnlyLayout(dispatch.sourceLayout)) {
|
||||
proceedWithCreatingWidget(
|
||||
ctx = config.widgets,
|
||||
source = dispatch.source,
|
||||
|
|
|
@ -208,9 +208,7 @@ class SelectWidgetSourceViewModel(
|
|||
isInEditMode = curr.isInEditMode
|
||||
)
|
||||
}
|
||||
if (view.layout == ObjectType.Layout.DATE ||
|
||||
view.layout == ObjectType.Layout.PARTICIPANT
|
||||
) {
|
||||
if (view.layout != null && WidgetConfig.isLinkOnlyLayout(view.layout.code)) {
|
||||
isDismissed.value = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.anytypeio.anytype.presentation.widgets
|
||||
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
|
@ -26,6 +27,14 @@ object WidgetConfig {
|
|||
&& SupportedLayouts.isSupportedForWidgets(obj.layout)
|
||||
}
|
||||
|
||||
fun isLinkOnlyLayout(code: Int): Boolean {
|
||||
return code == ObjectType.Layout.DATE.code ||
|
||||
code == ObjectType.Layout.PARTICIPANT.code ||
|
||||
code == ObjectType.Layout.IMAGE.code ||
|
||||
code == ObjectType.Layout.VIDEO.code ||
|
||||
code == ObjectType.Layout.FILE.code
|
||||
}
|
||||
|
||||
fun resolveListWidgetLimit(
|
||||
isCompact: Boolean,
|
||||
isGallery: Boolean = false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue