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:
parent
fdad393eac
commit
fd5fcb50e8
5 changed files with 80 additions and 7 deletions
|
@ -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}")
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue