diff --git a/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt index 3ae6704889..723946e0fe 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt @@ -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") } diff --git a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt index fa325020dc..7afb8ef4af 100644 --- a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt +++ b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt @@ -105,6 +105,7 @@ class ChatViewModel @Inject constructor( val chatBoxMode = MutableStateFlow(ChatBoxMode.Default()) val mentionPanelState = MutableStateFlow(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 diff --git a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatPreviews.kt b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatPreviews.kt index f92c519317..2d9387c410 100644 --- a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatPreviews.kt +++ b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatPreviews.kt @@ -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 = {} ) } diff --git a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatScreen.kt b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatScreen.kt index 8c0f7ab860..141dd82cdb 100644 --- a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatScreen.kt +++ b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/ui/ChatScreen.kt @@ -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) + ) + } } } } diff --git a/localization/src/main/res/values/strings.xml b/localization/src/main/res/values/strings.xml index 84ae133434..037c2f49e2 100644 --- a/localization/src/main/res/values/strings.xml +++ b/localization/src/main/res/values/strings.xml @@ -1863,6 +1863,9 @@ Please provide specific details of your needs here. Edit message edited There is no messages yet.\nBe the first to start a discussion. + This chat is empty. + Invite people and start the conversation! + Share invite link Write a message... Mentions