mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-07 21:37:02 +09:00
DROID-3626 Space chat | Ui fixes + proper chat space creation (#2508)
This commit is contained in:
parent
cc8fe0f379
commit
6343b80d7d
10 changed files with 59 additions and 20 deletions
|
@ -176,9 +176,11 @@ fun CreateSpaceScreen(
|
|||
}
|
||||
ButtonPrimaryLoading(
|
||||
onClick = {
|
||||
focusManager.clearFocus()
|
||||
keyboardController?.hide()
|
||||
onCreate(innerValue.text)
|
||||
if (isChatSpace || innerValue.text.isNotEmpty()) {
|
||||
focusManager.clearFocus()
|
||||
keyboardController?.hide()
|
||||
onCreate(innerValue.text)
|
||||
}
|
||||
},
|
||||
text = stringResource(id = R.string.create),
|
||||
size = ButtonSize.Large,
|
||||
|
@ -191,7 +193,7 @@ fun CreateSpaceScreen(
|
|||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp),
|
||||
loading = isLoading.value,
|
||||
enabled = innerValue.text.isNotEmpty()
|
||||
enabled = isChatSpace || innerValue.text.isNotEmpty()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
|
|||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Scaffold
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -101,15 +102,14 @@ fun VaultScreen(
|
|||
Scaffold(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(
|
||||
color = colorResource(id = R.color.background_primary)
|
||||
)
|
||||
.background(color = colorResource(id = R.color.background_primary))
|
||||
.then(
|
||||
if (SDK_INT >= EDGE_TO_EDGE_MIN_SDK)
|
||||
Modifier.windowInsetsPadding(WindowInsets.systemBars)
|
||||
else
|
||||
Modifier
|
||||
),
|
||||
backgroundColor = colorResource(id = R.color.background_primary),
|
||||
topBar = {
|
||||
VaultScreenToolbar(
|
||||
profile = profile,
|
||||
|
@ -163,7 +163,9 @@ fun VaultScreen(
|
|||
creatorName = item.creatorName,
|
||||
messageText = item.messageText,
|
||||
messageTime = item.messageTime,
|
||||
chatPreview = item.chatPreview
|
||||
chatPreview = item.chatPreview,
|
||||
unreadMessageCount = item.unreadMessageCount,
|
||||
unreadMentionCount = item.unreadMentionCount
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -478,7 +478,7 @@ sealed class Command {
|
|||
data class CreateSpace(
|
||||
val details: Struct,
|
||||
val withChat: Boolean,
|
||||
val shouldApplyEmptyUseCase: Boolean
|
||||
val useCase: SpaceCreationUseCase
|
||||
) {
|
||||
data class Result(
|
||||
val space: SpaceId,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.anytypeio.anytype.core_models
|
||||
|
||||
/**
|
||||
* Space creation use case enum that corresponds to Rpc.Object.ImportUseCase.Request.UseCase
|
||||
*/
|
||||
enum class SpaceCreationUseCase(val value: Int) {
|
||||
NONE(0),
|
||||
GET_STARTED(1),
|
||||
EMPTY(2),
|
||||
GUIDE_ONLY(3),
|
||||
GET_STARTED_MOBILE(4),
|
||||
EMPTY_MOBILE(5)
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.domain.spaces
|
|||
|
||||
import com.anytypeio.anytype.core_models.Command
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.SpaceCreationUseCase
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.base.ResultInteractor
|
||||
|
@ -17,13 +18,13 @@ class CreateSpace @Inject constructor(
|
|||
command = Command.CreateSpace(
|
||||
details = params.details,
|
||||
withChat = params.withChat,
|
||||
shouldApplyEmptyUseCase = params.shouldApplyEmptyUseCase
|
||||
useCase = params.useCase
|
||||
)
|
||||
)
|
||||
|
||||
data class Params(
|
||||
val details: Struct,
|
||||
val withChat: Boolean = false,
|
||||
val shouldApplyEmptyUseCase: Boolean = false
|
||||
val useCase: SpaceCreationUseCase = SpaceCreationUseCase.GET_STARTED_MOBILE
|
||||
)
|
||||
}
|
|
@ -14,6 +14,8 @@ import com.anytypeio.anytype.analytics.props.Props
|
|||
import com.anytypeio.anytype.core_models.ManifestInfo
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.SpaceCreationUseCase
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceUxType
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
|
@ -128,9 +130,11 @@ class GalleryInstallationViewModel(
|
|||
val params = CreateSpace.Params(
|
||||
details = mapOf(
|
||||
Relations.NAME to manifestInfo.title,
|
||||
Relations.ICON_OPTION to spaceGradientProvider.randomId().toDouble()
|
||||
Relations.ICON_OPTION to spaceGradientProvider.randomId().toDouble(),
|
||||
Relations.SPACE_UX_TYPE to SpaceUxType.DATA.code.toDouble(),
|
||||
),
|
||||
shouldApplyEmptyUseCase = true
|
||||
withChat = false,
|
||||
useCase = SpaceCreationUseCase.EMPTY_MOBILE
|
||||
)
|
||||
createSpace.async(params).fold(
|
||||
onSuccess = { result ->
|
||||
|
|
|
@ -1973,10 +1973,7 @@ class Middleware @Inject constructor(
|
|||
fun workspaceCreate(command: Command.CreateSpace): Command.CreateSpace.Result {
|
||||
val request = Rpc.Workspace.Create.Request(
|
||||
details = command.details,
|
||||
useCase = if (command.shouldApplyEmptyUseCase)
|
||||
Rpc.Object.ImportUseCase.Request.UseCase.EMPTY_MOBILE
|
||||
else
|
||||
Rpc.Object.ImportUseCase.Request.UseCase.GET_STARTED_MOBILE,
|
||||
useCase = command.useCase.toMiddlewareModel(),
|
||||
withChat = command.withChat
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.anytypeio.anytype.core_models.membership.MembershipPaymentMethod
|
|||
import com.anytypeio.anytype.core_models.membership.NameServiceNameType
|
||||
import com.anytypeio.anytype.core_models.multiplayer.InviteType
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
import com.anytypeio.anytype.core_models.SpaceCreationUseCase
|
||||
|
||||
|
||||
// ---------------------- BLOCKS ------------------------
|
||||
|
@ -644,3 +645,12 @@ fun InviteType.toMiddleware(): MInviteType = when (this) {
|
|||
InviteType.WITHOUT_APPROVE -> MInviteType.WithoutApprove
|
||||
}
|
||||
|
||||
fun SpaceCreationUseCase.toMiddlewareModel(): Rpc.Object.ImportUseCase.Request.UseCase = when (this) {
|
||||
SpaceCreationUseCase.NONE -> Rpc.Object.ImportUseCase.Request.UseCase.NONE
|
||||
SpaceCreationUseCase.GET_STARTED -> Rpc.Object.ImportUseCase.Request.UseCase.GET_STARTED
|
||||
SpaceCreationUseCase.EMPTY -> Rpc.Object.ImportUseCase.Request.UseCase.EMPTY
|
||||
SpaceCreationUseCase.GUIDE_ONLY -> Rpc.Object.ImportUseCase.Request.UseCase.GUIDE_ONLY
|
||||
SpaceCreationUseCase.GET_STARTED_MOBILE -> Rpc.Object.ImportUseCase.Request.UseCase.GET_STARTED_MOBILE
|
||||
SpaceCreationUseCase.EMPTY_MOBILE -> Rpc.Object.ImportUseCase.Request.UseCase.EMPTY_MOBILE
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,11 @@ import com.anytypeio.anytype.analytics.base.sendEvent
|
|||
import com.anytypeio.anytype.analytics.props.Props
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.SpaceCreationUseCase
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.SystemColor
|
||||
import com.anytypeio.anytype.core_models.Url
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceUxType
|
||||
import com.anytypeio.anytype.core_models.primitives.Space
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
import com.anytypeio.anytype.domain.media.UploadFile
|
||||
|
@ -66,6 +68,11 @@ class CreateSpaceViewModel(
|
|||
sendToast("Please wait...")
|
||||
return
|
||||
}
|
||||
val (uxType, useCase) = if (withChat) {
|
||||
SpaceUxType.CHAT to SpaceCreationUseCase.NONE
|
||||
} else {
|
||||
SpaceUxType.DATA to SpaceCreationUseCase.EMPTY_MOBILE
|
||||
}
|
||||
viewModelScope.launch {
|
||||
val params = CreateSpace.Params(
|
||||
details = mapOf(
|
||||
|
@ -73,9 +80,10 @@ class CreateSpaceViewModel(
|
|||
Relations.ICON_OPTION to when (val icon = spaceIconView.value) {
|
||||
is SpaceIconView.Placeholder -> icon.color.index.toDouble()
|
||||
else -> SystemColor.SKY.index.toDouble()
|
||||
}
|
||||
},
|
||||
Relations.SPACE_UX_TYPE to uxType.code.toDouble()
|
||||
),
|
||||
shouldApplyEmptyUseCase = true,
|
||||
useCase = useCase,
|
||||
withChat = withChat
|
||||
)
|
||||
createSpace.stream(params = params).collect { result ->
|
||||
|
|
|
@ -203,7 +203,9 @@ class VaultViewModel(
|
|||
previewText = previewText,
|
||||
creatorName = creatorName,
|
||||
messageText = messageText,
|
||||
messageTime = messageTime
|
||||
messageTime = messageTime,
|
||||
unreadMessageCount = chatPreview.state?.unreadMessages?.counter ?: 0,
|
||||
unreadMentionCount = chatPreview.state?.unreadMentions?.counter ?: 0
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue