mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2603 Widgets | Fix | Simplify object creation inside widget + other minor fixes (#1879)
This commit is contained in:
parent
f2da5b615c
commit
b9a38a4fb2
6 changed files with 27 additions and 11 deletions
|
@ -104,7 +104,7 @@ fun DataViewListWidgetCard(
|
|||
WidgetHeader(
|
||||
title = when (val name = item.name) {
|
||||
is WidgetView.Name.Default -> {
|
||||
name.prettyPrintName ?: stringResource(id = R.string.untitled)
|
||||
name.prettyPrintName.ifEmpty { stringResource(id = R.string.untitled) }
|
||||
}
|
||||
is WidgetView.Name.Bundled -> {
|
||||
stringResource(id = name.source.res())
|
||||
|
@ -237,7 +237,7 @@ fun GalleryWidgetCard(
|
|||
WidgetHeader(
|
||||
title = when (val source = item.name) {
|
||||
is WidgetView.Name.Default -> {
|
||||
source.prettyPrintName ?: stringResource(id = R.string.untitled)
|
||||
source.prettyPrintName.ifEmpty { stringResource(id = R.string.untitled) }
|
||||
}
|
||||
is WidgetView.Name.Bundled -> {
|
||||
stringResource(id = source.source.res())
|
||||
|
|
|
@ -93,7 +93,7 @@ fun LinkWidgetCard(
|
|||
text = when(val name = item.name) {
|
||||
is WidgetView.Name.Bundled -> stringResource(id = name.source.res())
|
||||
is WidgetView.Name.Default -> {
|
||||
name.prettyPrintName ?: stringResource(id = R.string.untitled)
|
||||
name.prettyPrintName.ifEmpty { stringResource(id = R.string.untitled) }
|
||||
}
|
||||
},
|
||||
maxLines = 1,
|
||||
|
|
|
@ -103,7 +103,7 @@ fun TreeWidgetCard(
|
|||
WidgetHeader(
|
||||
title = when (val name = item.name) {
|
||||
is WidgetView.Name.Default -> {
|
||||
name.prettyPrintName ?: stringResource(id = R.string.untitled)
|
||||
name.prettyPrintName.ifEmpty { stringResource(id = R.string.untitled) }
|
||||
}
|
||||
is WidgetView.Name.Bundled -> { stringResource(id = name.source.res()) }
|
||||
},
|
||||
|
@ -227,7 +227,7 @@ private fun TreeWidgetTreeItems(
|
|||
)
|
||||
}
|
||||
Text(
|
||||
text = element.name.prettyPrintName ?: stringResource(id = R.string.untitled),
|
||||
text = element.name.prettyPrintName.ifEmpty { stringResource(id = R.string.untitled) },
|
||||
modifier = Modifier
|
||||
.padding(start = 8.dp)
|
||||
.fillMaxWidth(),
|
||||
|
|
|
@ -1933,12 +1933,19 @@ class HomeScreenViewModel(
|
|||
if (source is Widget.Source.Default) {
|
||||
if (!source.obj.layout.isDataView()) {
|
||||
viewModelScope.launch {
|
||||
commands.emit(
|
||||
Command.CreateObjectForWidget(
|
||||
createObject.async(
|
||||
params = CreateObject.Param(
|
||||
space = SpaceId(target.config.space),
|
||||
widget = target.id,
|
||||
source = target.source.id
|
||||
type = TypeKey(ObjectTypeUniqueKeys.PAGE)
|
||||
)
|
||||
).fold(
|
||||
onSuccess = { result ->
|
||||
proceedWithCreatingLinkToNewObject(source.id, result)
|
||||
proceedWithNavigation(result.obj.navigation())
|
||||
},
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while creating object")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ sealed class WidgetView {
|
|||
|
||||
sealed interface Name {
|
||||
data class Bundled(val source: Widget.Source.Bundled): Name
|
||||
data class Default(val prettyPrintName: String?): Name
|
||||
data class Default(val prettyPrintName: String): Name
|
||||
}
|
||||
|
||||
interface Element {
|
||||
|
|
|
@ -49,6 +49,8 @@ import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
|||
import com.anytypeio.anytype.domain.misc.AppActionManager
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.multiplayer.GetSpaceInviteLink
|
||||
import com.anytypeio.anytype.domain.multiplayer.SpaceInviteResolver
|
||||
import com.anytypeio.anytype.domain.multiplayer.UserPermissionProvider
|
||||
import com.anytypeio.anytype.domain.`object`.GetObject
|
||||
import com.anytypeio.anytype.domain.`object`.OpenObject
|
||||
|
@ -259,6 +261,12 @@ class HomeScreenViewModelTest {
|
|||
@Mock
|
||||
lateinit var featureToggles: FeatureToggles
|
||||
|
||||
@Mock
|
||||
lateinit var spaceInviteResolver: SpaceInviteResolver
|
||||
|
||||
@Mock
|
||||
lateinit var getSpaceInviteLink: GetSpaceInviteLink
|
||||
|
||||
lateinit var userPermissionProvider: UserPermissionProvider
|
||||
|
||||
private val objectPayloadDispatcher = Dispatcher.Default<Payload>()
|
||||
|
@ -3047,7 +3055,8 @@ class HomeScreenViewModelTest {
|
|||
manager = spaceManager
|
||||
),
|
||||
featureToggles = featureToggles,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
spaceInviteResolver = spaceInviteResolver
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue