Skip to content

Commit c462799

Browse files
authored
Fix Chat integration unread count and refactor top header (#737)
* Update top header for the chat dialog * Fix unread count in the composable
1 parent 71e783d commit c462799

File tree

1 file changed

+40
-17
lines changed
  • dogfooding/src/main/kotlin/io/getstream/video/android/ui/call

1 file changed

+40
-17
lines changed

dogfooding/src/main/kotlin/io/getstream/video/android/ui/call/ChatDialog.kt

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,32 @@
1818

1919
package io.getstream.video.android.ui.call
2020

21-
import androidx.compose.foundation.layout.Box
21+
import androidx.compose.foundation.background
22+
import androidx.compose.foundation.clickable
23+
import androidx.compose.foundation.layout.Column
2224
import androidx.compose.foundation.layout.fillMaxWidth
2325
import androidx.compose.foundation.layout.height
26+
import androidx.compose.foundation.layout.padding
2427
import androidx.compose.foundation.shape.RoundedCornerShape
2528
import androidx.compose.material.ExperimentalMaterialApi
29+
import androidx.compose.material.Icon
2630
import androidx.compose.material.ModalBottomSheetLayout
2731
import androidx.compose.material.ModalBottomSheetState
2832
import androidx.compose.runtime.Composable
2933
import androidx.compose.runtime.LaunchedEffect
34+
import androidx.compose.runtime.remember
35+
import androidx.compose.ui.Alignment
3036
import androidx.compose.ui.Modifier
3137
import androidx.compose.ui.platform.LocalContext
38+
import androidx.compose.ui.res.painterResource
3239
import androidx.compose.ui.unit.dp
3340
import androidx.lifecycle.viewmodel.compose.viewModel
3441
import io.getstream.chat.android.compose.ui.messages.MessagesScreen
3542
import io.getstream.chat.android.compose.ui.theme.ChatTheme
3643
import io.getstream.chat.android.compose.viewmodel.messages.MessageListViewModel
3744
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
3845
import io.getstream.video.android.core.Call
46+
import io.getstream.video.android.ui.common.R
3947

4048
@Composable
4149
internal fun ChatDialog(
@@ -46,13 +54,14 @@ internal fun ChatDialog(
4654
onDismissed: () -> Unit,
4755
) {
4856
val context = LocalContext.current
49-
val viewModelFactory = MessagesViewModelFactory(
50-
context = context,
51-
channelId = "videocall:${call.id}",
52-
)
53-
57+
val viewModelFactory = remember {
58+
MessagesViewModelFactory(
59+
context = context,
60+
channelId = "videocall:${call.id}",
61+
)
62+
}
5463
val listViewModel = viewModel(MessageListViewModel::class.java, factory = viewModelFactory)
55-
val unreadCount: Int = listViewModel.currentMessagesState.unreadCount
64+
val unreadCount = listViewModel.currentMessagesState.unreadCount
5665

5766
LaunchedEffect(key1 = unreadCount) {
5867
updateUnreadCount.invoke(unreadCount)
@@ -64,16 +73,30 @@ internal fun ChatDialog(
6473
sheetShape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
6574
sheetState = state,
6675
sheetContent = {
67-
Box(
68-
modifier = Modifier
69-
.fillMaxWidth()
70-
.height(500.dp),
71-
) {
72-
MessagesScreen(
73-
viewModelFactory = viewModelFactory,
74-
onBackPressed = { onDismissed.invoke() },
75-
onHeaderActionClick = { onDismissed.invoke() },
76-
)
76+
if (state.isVisible) {
77+
Column(
78+
modifier = Modifier
79+
.background(ChatTheme.colors.appBackground)
80+
.fillMaxWidth()
81+
.height(500.dp),
82+
) {
83+
Icon(
84+
modifier = Modifier
85+
.align(Alignment.End)
86+
.padding(16.dp)
87+
.clickable { onDismissed.invoke() },
88+
tint = ChatTheme.colors.textHighEmphasis,
89+
painter = painterResource(id = R.drawable.stream_video_ic_close),
90+
contentDescription = null,
91+
)
92+
93+
MessagesScreen(
94+
showHeader = false,
95+
viewModelFactory = viewModelFactory,
96+
onBackPressed = { onDismissed.invoke() },
97+
onHeaderActionClick = { onDismissed.invoke() },
98+
)
99+
}
77100
}
78101
},
79102
content = content,

0 commit comments

Comments
 (0)