mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-07 21:37:02 +09:00
DROID-3626 Chat space | Open chat screen on creation (#2499)
This commit is contained in:
parent
6f498b3bdf
commit
7517060aa9
5 changed files with 78 additions and 29 deletions
|
@ -21,6 +21,7 @@ import com.anytypeio.anytype.core_utils.ext.toast
|
|||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.spaces.CreateSpaceViewModel
|
||||
import com.anytypeio.anytype.ui.chats.ChatFragment
|
||||
import com.anytypeio.anytype.ui.editor.EditorFragment
|
||||
import com.anytypeio.anytype.ui.home.HomeScreenFragment
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
|
@ -86,24 +87,38 @@ class CreateSpaceFragment : BaseBottomSheetComposeFragment() {
|
|||
is CreateSpaceViewModel.Command.SwitchSpace -> {
|
||||
runCatching {
|
||||
findNavController().navigate(R.id.exitToVaultAction)
|
||||
findNavController().navigate(
|
||||
R.id.actionOpenSpaceFromVault,
|
||||
args = HomeScreenFragment.args(
|
||||
space = command.space.id,
|
||||
deeplink = null
|
||||
)
|
||||
)
|
||||
command.startingObject
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
?.let { startingObject ->
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
EditorFragment.args(
|
||||
ctx = startingObject,
|
||||
space = command.space.id
|
||||
)
|
||||
|
||||
// Check if this is a Chat space creation
|
||||
if (spaceType == TYPE_CHAT) {
|
||||
// For Chat spaces, navigate directly to chat screen
|
||||
findNavController().navigate(
|
||||
R.id.actionOpenChatFromVault,
|
||||
ChatFragment.args(
|
||||
space = command.space.id,
|
||||
ctx = command.space.id // Use space ID as chat context for new Chat spaces
|
||||
)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
// For regular spaces, use existing navigation logic
|
||||
findNavController().navigate(
|
||||
R.id.actionOpenSpaceFromVault,
|
||||
args = HomeScreenFragment.args(
|
||||
space = command.space.id,
|
||||
deeplink = null
|
||||
)
|
||||
)
|
||||
command.startingObject
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
?.let { startingObject ->
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
EditorFragment.args(
|
||||
ctx = startingObject,
|
||||
space = command.space.id
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while exiting to vault or opening created space")
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ class ChatViewModel @Inject constructor(
|
|||
val chatBoxMode = MutableStateFlow<ChatBoxMode>(ChatBoxMode.Default())
|
||||
val mentionPanelState = MutableStateFlow<MentionPanelState>(MentionPanelState.Hidden)
|
||||
val showNotificationPermissionDialog = MutableStateFlow(false)
|
||||
val canCreateInviteLink = MutableStateFlow(false)
|
||||
|
||||
private val dateFormatter = SimpleDateFormat("d MMMM YYYY")
|
||||
private val messageRateLimiter = MessageRateLimiter()
|
||||
|
@ -126,6 +127,8 @@ class ChatViewModel @Inject constructor(
|
|||
} else {
|
||||
chatBoxMode.value = ChatBoxMode.ReadOnly
|
||||
}
|
||||
// Update invite link creation permission (only owners can create invite links)
|
||||
canCreateInviteLink.value = permission?.isOwner() == true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +143,7 @@ class ChatViewModel @Inject constructor(
|
|||
builder = urlBuilder,
|
||||
spaceGradientProvider = SpaceGradientProvider.Default
|
||||
),
|
||||
showIcon = false
|
||||
showIcon = true
|
||||
)
|
||||
}.collect {
|
||||
header.value = it
|
||||
|
|
|
@ -88,7 +88,8 @@ fun ChatPreview() {
|
|||
onViewChatReaction = { a, b -> },
|
||||
onMemberIconClicked = {},
|
||||
onMentionClicked = {},
|
||||
onScrollToReplyClicked = {}
|
||||
onScrollToReplyClicked = {},
|
||||
onShareInviteClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -138,7 +139,8 @@ fun ChatPreview2() {
|
|||
onViewChatReaction = { a, b -> },
|
||||
onMemberIconClicked = {},
|
||||
onMentionClicked = {},
|
||||
onScrollToReplyClicked = {}
|
||||
onScrollToReplyClicked = {},
|
||||
onShareInviteClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -202,7 +204,8 @@ fun ChatScreenPreview() {
|
|||
onScrollToBottomClicked = {},
|
||||
onVisibleRangeChanged = { _, _ -> },
|
||||
onUrlInserted = {},
|
||||
onGoToMentionClicked = {}
|
||||
onGoToMentionClicked = {},
|
||||
onShareInviteClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ import com.anytypeio.anytype.core_ui.foundation.GRADIENT_TYPE_BLUE
|
|||
import com.anytypeio.anytype.core_ui.foundation.GRADIENT_TYPE_RED
|
||||
import com.anytypeio.anytype.core_ui.foundation.GenericAlert
|
||||
import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
|
||||
import com.anytypeio.anytype.core_ui.views.BodyRegular
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonSecondary
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonSize
|
||||
import com.anytypeio.anytype.core_ui.views.Caption1Medium
|
||||
import com.anytypeio.anytype.core_ui.views.Caption1Regular
|
||||
import com.anytypeio.anytype.core_ui.views.PreviewTitle2Regular
|
||||
|
@ -233,6 +236,8 @@ fun ChatScreenWrapper(
|
|||
onVisibleRangeChanged = vm::onVisibleRangeChanged,
|
||||
onUrlInserted = vm::onUrlPasted,
|
||||
onGoToMentionClicked = vm::onGoToMentionClicked,
|
||||
onShareInviteClicked = { /* TODO: implement share invite */ },
|
||||
canCreateInviteLink = vm.canCreateInviteLink.collectAsStateWithLifecycle().value,
|
||||
isReadOnly = vm.chatBoxMode
|
||||
.collectAsStateWithLifecycle()
|
||||
.value is ChatBoxMode.ReadOnly
|
||||
|
@ -381,6 +386,8 @@ fun ChatScreen(
|
|||
onVisibleRangeChanged: (Id, Id) -> Unit,
|
||||
onUrlInserted: (Url) -> Unit,
|
||||
onGoToMentionClicked: () -> Unit,
|
||||
onShareInviteClicked: () -> Unit,
|
||||
canCreateInviteLink: Boolean = false,
|
||||
isReadOnly: Boolean = false
|
||||
) {
|
||||
|
||||
|
@ -558,7 +565,9 @@ fun ChatScreen(
|
|||
onMemberIconClicked = onMemberIconClicked,
|
||||
onMentionClicked = onMentionClicked,
|
||||
onScrollToReplyClicked = onScrollToReplyClicked,
|
||||
isReadOnly = isReadOnly
|
||||
isReadOnly = isReadOnly,
|
||||
onShareInviteClicked = onShareInviteClicked,
|
||||
canCreateInviteLink = canCreateInviteLink
|
||||
)
|
||||
|
||||
GoToMentionButton(
|
||||
|
@ -809,6 +818,8 @@ fun Messages(
|
|||
onMemberIconClicked: (Id?) -> Unit,
|
||||
onMentionClicked: (Id) -> Unit,
|
||||
onScrollToReplyClicked: (Id) -> Unit,
|
||||
onShareInviteClicked: () -> Unit,
|
||||
canCreateInviteLink: Boolean = false,
|
||||
isReadOnly: Boolean = false
|
||||
) {
|
||||
// Timber.d("DROID-2966 Messages composition: ${messages.map { if (it is ChatView.Message) it.content.msg else it }}")
|
||||
|
@ -927,6 +938,8 @@ fun Messages(
|
|||
Column(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterStart)
|
||||
.padding(horizontal = 20.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
AlertIcon(
|
||||
icon = AlertConfig.Icon(
|
||||
|
@ -935,18 +948,30 @@ fun Messages(
|
|||
)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.chat_empty_state_message),
|
||||
style = Caption1Regular,
|
||||
text = stringResource(R.string.chat_empty_state_title),
|
||||
style = BodyRegular,
|
||||
color = colorResource(id = R.color.text_primary),
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 10.dp)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.chat_empty_state_subtitle),
|
||||
style = BodyRegular,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
start = 20.dp,
|
||||
end = 20.dp,
|
||||
top = 12.dp
|
||||
)
|
||||
)
|
||||
if (canCreateInviteLink) {
|
||||
ButtonSecondary(
|
||||
text = stringResource(R.string.chat_empty_state_share_invite_button),
|
||||
onClick = { onShareInviteClicked() },
|
||||
size = ButtonSize.SmallSecondary,
|
||||
modifier = Modifier.padding(top = 10.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1863,6 +1863,9 @@ Please provide specific details of your needs here.</string>
|
|||
<string name="chats_edit_message">Edit message</string>
|
||||
<string name="chats_message_edited">edited</string>
|
||||
<string name="chat_empty_state_message">There is no messages yet.\nBe the first to start a discussion.</string>
|
||||
<string name="chat_empty_state_title">This chat is empty.</string>
|
||||
<string name="chat_empty_state_subtitle">Invite people and start the conversation!</string>
|
||||
<string name="chat_empty_state_share_invite_button">Share invite link</string>
|
||||
<string name="write_a_message">Write a message...</string>
|
||||
|
||||
<string name="date_layout_mentioned_in">Mentions</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue