Compare commits
1 Commits
stable-and
...
jh/split-g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84922e6e89 |
@@ -6,6 +6,7 @@ import androidx.compose.foundation.lazy.*
|
|||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.ui.Alignment
|
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.onboarding.shouldShowWhatsNew
|
||||||
import chat.simplex.common.views.usersettings.SettingsView
|
import chat.simplex.common.views.usersettings.SettingsView
|
||||||
import chat.simplex.common.platform.*
|
import chat.simplex.common.platform.*
|
||||||
|
import chat.simplex.common.views.localauth.VerticalDivider
|
||||||
import chat.simplex.common.views.newchat.*
|
import chat.simplex.common.views.newchat.*
|
||||||
import chat.simplex.res.MR
|
import chat.simplex.res.MR
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@@ -40,6 +42,9 @@ fun ChatListView(chatModel: ChatModel, settingsState: SettingsViewState, setPerf
|
|||||||
if (animated) newChatSheetState.value = AnimatedViewState.HIDING
|
if (animated) newChatSheetState.value = AnimatedViewState.HIDING
|
||||||
else newChatSheetState.value = AnimatedViewState.GONE
|
else newChatSheetState.value = AnimatedViewState.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val inDMs = remember { mutableStateOf(true) }
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
if (shouldShowWhatsNew(chatModel)) {
|
if (shouldShowWhatsNew(chatModel)) {
|
||||||
delay(1000L)
|
delay(1000L)
|
||||||
@@ -102,8 +107,59 @@ fun ChatListView(chatModel: ChatModel, settingsState: SettingsViewState, setPerf
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.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()) {
|
if (chatModel.chats.isNotEmpty()) {
|
||||||
ChatList(chatModel, search = searchInList)
|
ChatList(chatModel, search = searchInList, inDMs=inDMs.value)
|
||||||
} else if (!switchingUsersAndHosts.value) {
|
} else if (!switchingUsersAndHosts.value) {
|
||||||
Box(Modifier.fillMaxSize()) {
|
Box(Modifier.fillMaxSize()) {
|
||||||
if (!stopped && !newChatSheetState.collectAsState().value.isVisible()) {
|
if (!stopped && !newChatSheetState.collectAsState().value.isVisible()) {
|
||||||
@@ -332,7 +388,7 @@ fun connectIfOpenedViaUri(rhId: Long?, uri: URI, chatModel: ChatModel) {
|
|||||||
private var lazyListState = 0 to 0
|
private var lazyListState = 0 to 0
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ChatList(chatModel: ChatModel, search: String) {
|
private fun ChatList(chatModel: ChatModel, search: String, inDMs: Boolean) {
|
||||||
val listState = rememberLazyListState(lazyListState.first, lazyListState.second)
|
val listState = rememberLazyListState(lazyListState.first, lazyListState.second)
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
onDispose { lazyListState = listState.firstVisibleItemIndex to listState.firstVisibleItemScrollOffset }
|
onDispose { lazyListState = listState.firstVisibleItemIndex to listState.firstVisibleItemScrollOffset }
|
||||||
@@ -348,8 +404,16 @@ private fun ChatList(chatModel: ChatModel, search: String) {
|
|||||||
listState
|
listState
|
||||||
) {
|
) {
|
||||||
items(chats) { chat ->
|
items(chats) { chat ->
|
||||||
|
if (inDMs) {
|
||||||
|
if (chat.chatInfo.chatType == ChatType.Direct) {
|
||||||
ChatListNavLinkView(chat, chatModel)
|
ChatListNavLinkView(chat, chatModel)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (chat.chatInfo.chatType == ChatType.Group) {
|
||||||
|
ChatListNavLinkView(chat, chatModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (chats.isEmpty() && !chatModel.chats.isEmpty()) {
|
if (chats.isEmpty() && !chatModel.chats.isEmpty()) {
|
||||||
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||||
|
|||||||
Reference in New Issue
Block a user