diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoTabs.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoTabs.kt index cf577c144a..96ab604f4f 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoTabs.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoTabs.kt @@ -41,6 +41,7 @@ import chat.simplex.common.views.helpers.* import chat.simplex.common.views.usersettings.SettingsActionItem import chat.simplex.common.views.usersettings.SettingsActionItemWithContent import chat.simplex.res.MR +import dev.icerock.moko.resources.ImageResource import dev.icerock.moko.resources.StringResource import dev.icerock.moko.resources.compose.painterResource import dev.icerock.moko.resources.compose.stringResource @@ -50,9 +51,9 @@ enum class GroupInfoTab { Members, Images, Videos, - Links, Files, - Voices + Links, + Voice } fun LazyListScope.GroupChatInfoTabs( @@ -73,37 +74,40 @@ fun LazyListScope.GroupChatInfoTabs( ) { item { - SectionSpacer() - - val scrollState = rememberScrollState() - Column { - Row( - Modifier - .fillMaxWidth() - .horizontalScroll(scrollState), - horizontalArrangement = Arrangement.Start - ) { - GroupInfoTab.values().forEach { tab -> - Tab( - selected = selectedTab.value == tab, - onClick = { selectedTab.value = tab }, - text = { Text(tabTitle(tab), fontSize = 13.sp) }, - selectedContentColor = MaterialTheme.colors.primary, - unselectedContentColor = MaterialTheme.colors.secondary, - ) - } + TabRow( + modifier = Modifier.padding(top = DEFAULT_PADDING_HALF, bottom = DEFAULT_PADDING), + selectedTabIndex = GroupInfoTab.entries.indexOf(selectedTab.value), + backgroundColor = Color.Transparent, + contentColor = MaterialTheme.colors.primary, + ) { + GroupInfoTab.entries.forEachIndexed { index, tab -> + val isSelected = selectedTab.value == tab + LeadingIconTab( + selected = isSelected, + onClick = { selectedTab.value = tab }, + text = { Text("") }, + icon = { + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Icon( + painterResource(tabLabel(tab).first), + contentDescription = tab.name, + modifier = Modifier.size(24.dp), + tint = if (isSelected) MaterialTheme.colors.primary else MaterialTheme.colors.secondary + ) + // TODO make it conditional on the actual tab count + if (GroupInfoTab.entries.size <= 4) { + Text(generalGetString(tabLabel(tab).second), modifier = Modifier.padding(top = 2.dp, bottom = 6.dp), fontSize = 10.sp, softWrap = false, overflow = TextOverflow.Ellipsis) + } + } + }, + selectedContentColor = MaterialTheme.colors.primary, + unselectedContentColor = MaterialTheme.colors.secondary, + ) } - // Simple indicator line - Box( - Modifier - .fillMaxWidth() - .height(2.dp) - .background(MaterialTheme.colors.surface) - ) } - Divider() - - SectionSpacer() } when (selectedTab.value) { @@ -125,9 +129,9 @@ fun LazyListScope.GroupChatInfoTabs( } GroupInfoTab.Images, GroupInfoTab.Videos, - GroupInfoTab.Links, GroupInfoTab.Files, - GroupInfoTab.Voices -> { + GroupInfoTab.Links, + GroupInfoTab.Voice -> { ContentItemsTab( filteredChatItems = filteredChatItems, scrollToItemId = scrollToItemId @@ -281,14 +285,14 @@ private fun LazyListScope.ContentItemsTab( @Composable -private fun tabTitle(tab: GroupInfoTab): String { +private fun tabLabel(tab: GroupInfoTab): Pair { return when (tab) { - GroupInfoTab.Members -> stringResource(MR.strings.group_info_tab_members) - GroupInfoTab.Images -> stringResource(MR.strings.group_info_tab_images) - GroupInfoTab.Videos -> stringResource(MR.strings.group_info_tab_videos) - GroupInfoTab.Links -> stringResource(MR.strings.group_info_tab_links) - GroupInfoTab.Files -> stringResource(MR.strings.group_info_tab_files) - GroupInfoTab.Voices -> stringResource(MR.strings.group_info_tab_voices) + GroupInfoTab.Members -> MR.images.ic_group to MR.strings.group_info_tab_members + GroupInfoTab.Images -> MR.images.ic_image to MR.strings.group_info_tab_images + GroupInfoTab.Videos -> MR.images.ic_videocam to MR.strings.group_info_tab_videos + GroupInfoTab.Voice -> MR.images.ic_mic_filled to MR.strings.group_info_tab_voice + GroupInfoTab.Files -> MR.images.ic_draft to MR.strings.group_info_tab_files + GroupInfoTab.Links -> MR.images.ic_link to MR.strings.group_info_tab_links } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt index 2b641ae8ef..f3d64e3192 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt @@ -353,10 +353,11 @@ fun SettingsButton( groupInfo: GroupInfo, onClick: () -> Unit ) { + val isOwner = groupInfo.isOwner && groupInfo.businessChat?.chatType == null InfoViewActionButton( modifier = modifier, - icon = painterResource(MR.images.ic_settings), - title = generalGetString(MR.strings.icon_descr_settings), + icon = if (isOwner) painterResource(MR.images.ic_edit) else painterResource(MR.images.ic_info), + title = if (isOwner) generalGetString(MR.strings.edit_verb) else generalGetString(MR.strings.info_menu), disabled = !groupInfo.ready, disabledLook = !groupInfo.ready, onClick = onClick @@ -473,13 +474,13 @@ fun ModalData.GroupChatInfoLayout( GroupInfoTab.Videos -> chat.chatItems.filter { it.content.msgContent is MsgContent.MCVideo && it.meta.itemDeleted == null } - GroupInfoTab.Links -> chat.chatItems.filter { - it.content.msgContent is MsgContent.MCLink && it.meta.itemDeleted == null - } GroupInfoTab.Files -> chat.chatItems.filter { it.content.msgContent is MsgContent.MCFile && it.meta.itemDeleted == null } - GroupInfoTab.Voices -> chat.chatItems.filter { + GroupInfoTab.Links -> chat.chatItems.filter { + it.content.msgContent is MsgContent.MCLink && it.meta.itemDeleted == null + } + GroupInfoTab.Voice -> chat.chatItems.filter { it.content.msgContent is MsgContent.MCVoice && it.meta.itemDeleted == null } } @@ -570,13 +571,6 @@ fun ModalData.GroupChatInfoLayout( ) item { - if (developerTools) { - SectionDividerSpaced() - SectionView(title = stringResource(MR.strings.section_title_for_console)) { - InfoRow(stringResource(MR.strings.info_row_local_name), groupInfo.localDisplayName) - InfoRow(stringResource(MR.strings.info_row_database_id), groupInfo.apiId.toString()) - } - } SectionBottomSpacer() } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupSettingsView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupSettingsView.kt index 94e927a4c3..3d45e5cb24 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupSettingsView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupSettingsView.kt @@ -1,5 +1,6 @@ package chat.simplex.common.views.chat.group +import InfoRow import SectionBottomSpacer import SectionDividerSpaced import SectionTextFooter @@ -35,6 +36,7 @@ fun GroupSettingsView( val groupInfo = c.chatInfo.groupInfo val currentUser = m.currentUser.value ?: return + val developerTools = m.controller.appPrefs.developerTools.get() val sendReceipts = remember { mutableStateOf(SendReceipts.fromBool(groupInfo.chatSettings.sendRcpts, currentUser.sendRcptsSmallGroups)) } val chatItemTTL = rememberSaveable(groupInfo.id) { mutableStateOf(if (groupInfo.chatItemTTL != null) ChatItemTTL.fromSeconds(groupInfo.chatItemTTL) else null) } @@ -63,6 +65,7 @@ fun GroupSettingsView( chatItemTTL = chatItemTTL, setChatItemTTL = ::setChatItemTTL, deletingItems = deletingItems, + developerTools = developerTools, editGroupProfile = { ModalManager.end.showCustomModal { closeModal -> GroupProfileView(rhId, groupInfo, m, closeModal) @@ -96,6 +99,7 @@ private fun GroupSettingsLayout( chatItemTTL: MutableState, setChatItemTTL: (ChatItemTTL?) -> Unit, deletingItems: MutableState, + developerTools: Boolean, editGroupProfile: () -> Unit, addOrEditWelcomeMessage: () -> Unit, openPreferences: () -> Unit, @@ -160,6 +164,14 @@ private fun GroupSettingsLayout( } } + if (developerTools) { + SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false) + SectionView(title = stringResource(MR.strings.section_title_for_console)) { + InfoRow(stringResource(MR.strings.info_row_local_name), groupInfo.localDisplayName) + InfoRow(stringResource(MR.strings.info_row_database_id), groupInfo.apiId.toString()) + } + } + SectionBottomSpacer() } } diff --git a/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml b/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml index d47e9174e4..a7d58dbe1a 100644 --- a/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml +++ b/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml @@ -1789,12 +1789,12 @@ Add team members Add friends %1$s MEMBERS - MEMBERS - IMAGES - VIDEOS - LINKS - FILES - VOICES + Members + Images + Videos + Links + Files + Voice you: %1$s Delete group Delete chat @@ -2786,4 +2786,4 @@ You can mention up to %1$s members per message! - \ No newline at end of file +