1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-3362 Widgets | Fix | Add "Plus" button to widgets with "View" layout (#2429)

This commit is contained in:
Evgenii Kozlov 2025-05-22 11:45:23 +02:00 committed by GitHub
parent fdad393eac
commit fd5fcb50e8
Signed by: github
GPG key ID: B5690EEEBB952194
5 changed files with 80 additions and 7 deletions

View file

@ -2554,6 +2554,55 @@ class HomeScreenViewModel(
}
}
}
is WidgetView.Gallery -> {
viewModelScope.launch {
val source = view.source
if (source is Widget.Source.Default) {
when (source.obj.layout) {
ObjectType.Layout.OBJECT_TYPE -> {
val wrapper = ObjectWrapper.Type(source.obj.map)
val space = SpaceId(spaceManager.get())
val startTime = System.currentTimeMillis()
createObject.async(
params = CreateObject.Param(
space = space,
type = TypeKey(wrapper.uniqueKey),
prefilled = mapOf(Relations.IS_FAVORITE to true)
)
).onSuccess { result ->
sendAnalyticsObjectCreateEvent(
objType = wrapper.uniqueKey,
analytics = analytics,
route = EventsDictionary.Routes.widget,
startTime = startTime,
view = null,
spaceParams = provideParams(space.id)
)
proceedWithNavigation(result.obj.navigation())
}
}
ObjectType.Layout.COLLECTION -> {
onCreateDataViewObject(
widget = view.id,
view = null,
navigate = true
)
}
ObjectType.Layout.SET -> {
onCreateDataViewObject(
widget = view.id,
view = null,
navigate = true
)
}
else -> {
Timber.w("Unexpected source layout: ${source.obj.layout}")
}
}
}
}
}
else -> {
Timber.w("Unexpected widget type: ${view::class.java.simpleName}")

View file

@ -119,7 +119,26 @@ sealed class WidgetView {
val isExpanded: Boolean,
val showIcon: Boolean = false,
val showCover: Boolean = false
) : WidgetView(), Draggable
) : WidgetView(), Draggable {
val canCreateObjectOfType : Boolean get() {
return when(source) {
Widget.Source.Bundled.AllObjects -> false
Widget.Source.Bundled.Chat -> false
Widget.Source.Bundled.Bin -> false
Widget.Source.Bundled.Favorites -> true
Widget.Source.Bundled.Recent -> false
Widget.Source.Bundled.RecentLocal -> false
is Widget.Source.Default -> {
if (source.obj.layout == ObjectType.Layout.OBJECT_TYPE) {
val wrapper = ObjectWrapper.Type(source.obj.map)
SupportedLayouts.createObjectLayouts.contains(wrapper.recommendedLayout)
} else {
true
}
}
}
}
}
data class ListOfObjects(
override val id: Id,