From 84922e6e892a4ce1d80c789b8fa25f04d3430671 Mon Sep 17 00:00:00 2001 From: Jesse Horne Date: Sat, 25 Nov 2023 22:44:33 -0500 Subject: [PATCH] playing around with splitter for group and individual convos --- .../common/views/chatlist/ChatListView.kt | 70 ++++++++++++++++++- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt index 301f090336..02337ad6e2 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.lazy.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.* +import androidx.compose.material.icons.Icons import androidx.compose.runtime.* import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment @@ -24,6 +25,7 @@ import chat.simplex.common.views.onboarding.WhatsNewView import chat.simplex.common.views.onboarding.shouldShowWhatsNew import chat.simplex.common.views.usersettings.SettingsView import chat.simplex.common.platform.* +import chat.simplex.common.views.localauth.VerticalDivider import chat.simplex.common.views.newchat.* import chat.simplex.res.MR import kotlinx.coroutines.* @@ -40,6 +42,9 @@ fun ChatListView(chatModel: ChatModel, settingsState: SettingsViewState, setPerf if (animated) newChatSheetState.value = AnimatedViewState.HIDING else newChatSheetState.value = AnimatedViewState.GONE } + + val inDMs = remember { mutableStateOf(true) } + LaunchedEffect(Unit) { if (shouldShowWhatsNew(chatModel)) { delay(1000L) @@ -102,8 +107,59 @@ fun ChatListView(chatModel: ChatModel, settingsState: SettingsViewState, setPerf modifier = Modifier .fillMaxSize() ) { + + // Direct Messages or Groups toggle + Box ( + modifier = Modifier.fillMaxWidth().height(48.dp) + ){ + Row( + modifier = Modifier + .fillMaxWidth(), + horizontalArrangement = Arrangement.Center + ) { + IconButton( + modifier = Modifier.size(48.dp).weight(1f), + onClick = { inDMs.value = true } + ) { + Icon( + painterResource(MR.images.ic_person), + contentDescription = null, + tint = if (inDMs.value) MaterialTheme.colors.primary else MaterialTheme.colors.secondary, + modifier = Modifier + .padding(3.dp) + .padding(3.dp) + .size(34.dp) + .weight(1f) + ) + } + + VerticalDivider( + startIndent = 8.dp + ) + + IconButton( + modifier = Modifier.size(48.dp).weight(1f), + onClick = { inDMs.value = false } + ) { + Icon( + painterResource(MR.images.ic_group), + contentDescription = null, + tint = if (!inDMs.value) MaterialTheme.colors.primary else MaterialTheme.colors.secondary, + modifier = Modifier + .padding(3.dp) + .padding(3.dp) + .size(34.dp) + .weight(1f) + ) + } + } + } + Divider() + + + // Chat list if (chatModel.chats.isNotEmpty()) { - ChatList(chatModel, search = searchInList) + ChatList(chatModel, search = searchInList, inDMs=inDMs.value) } else if (!switchingUsersAndHosts.value) { Box(Modifier.fillMaxSize()) { if (!stopped && !newChatSheetState.collectAsState().value.isVisible()) { @@ -332,7 +388,7 @@ fun connectIfOpenedViaUri(rhId: Long?, uri: URI, chatModel: ChatModel) { private var lazyListState = 0 to 0 @Composable -private fun ChatList(chatModel: ChatModel, search: String) { +private fun ChatList(chatModel: ChatModel, search: String, inDMs: Boolean) { val listState = rememberLazyListState(lazyListState.first, lazyListState.second) DisposableEffect(Unit) { onDispose { lazyListState = listState.firstVisibleItemIndex to listState.firstVisibleItemScrollOffset } @@ -348,7 +404,15 @@ private fun ChatList(chatModel: ChatModel, search: String) { listState ) { items(chats) { chat -> - ChatListNavLinkView(chat, chatModel) + if (inDMs) { + if (chat.chatInfo.chatType == ChatType.Direct) { + ChatListNavLinkView(chat, chatModel) + } + } else { + if (chat.chatInfo.chatType == ChatType.Group) { + ChatListNavLinkView(chat, chatModel) + } + } } } if (chats.isEmpty() && !chatModel.chats.isEmpty()) {