@@ -14,8 +14,8 @@ import androidx.compose.foundation.layout.Row
14
14
import androidx.compose.foundation.layout.fillMaxSize
15
15
import androidx.compose.foundation.layout.fillMaxWidth
16
16
import androidx.compose.foundation.layout.padding
17
+ import androidx.compose.foundation.lazy.LazyListState
17
18
import androidx.compose.foundation.lazy.rememberLazyListState
18
- import androidx.compose.material3.ExperimentalMaterial3Api
19
19
import androidx.compose.material3.MaterialTheme
20
20
import androidx.compose.material3.Text
21
21
import androidx.compose.material3.TextButton
@@ -31,6 +31,7 @@ import androidx.compose.ui.Modifier
31
31
import androidx.compose.ui.graphics.Color
32
32
import androidx.compose.ui.unit.dp
33
33
import com.example.call.state.CallState
34
+ import kotlinx.coroutines.CoroutineScope
34
35
import kotlinx.coroutines.launch
35
36
36
37
sealed interface ChatMessage {
@@ -88,60 +89,19 @@ fun Chatting(
88
89
enter = slideInVertically(initialOffsetY = { it }) + fadeIn(),
89
90
exit = slideOutVertically(targetOffsetY = { it }) + fadeOut(),
90
91
) {
91
- Box (
92
- modifier = Modifier
93
- .fillMaxWidth()
94
- .background(MaterialTheme .colorScheme.secondary)
95
- .padding(8 .dp)
96
- ) {
97
- Row (
98
- horizontalArrangement = Arrangement .SpaceBetween ,
99
- verticalAlignment = Alignment .CenterVertically ,
100
- modifier = Modifier .fillMaxWidth()
101
- ) {
102
- Text (
103
- text = " other user on input" ,
104
- color = MaterialTheme .colorScheme.onSecondary,
105
- style = MaterialTheme .typography.bodyMedium
106
- )
107
- }
108
- }
92
+ OtherUserOnInputNotification ()
109
93
}
110
94
AnimatedVisibility (
111
95
visible = showNewMessageNotification,
112
96
enter = slideInVertically(initialOffsetY = { it }) + fadeIn(),
113
97
exit = slideOutVertically(targetOffsetY = { it }) + fadeOut(),
114
98
) {
115
- Box (
116
- modifier = Modifier
117
- .fillMaxWidth()
118
- .background(MaterialTheme .colorScheme.secondary)
119
- .padding(8 .dp)
120
- ) {
121
- Row (
122
- horizontalArrangement = Arrangement .SpaceBetween ,
123
- verticalAlignment = Alignment .CenterVertically ,
124
- modifier = Modifier .fillMaxWidth()
125
- ) {
126
- val message = state.messages[state.messages.size - 1 ]
127
-
128
- if (message is ChatMessage .TextMessage ) {
129
- Text (
130
- text = message.message ? : " " ,
131
- color = MaterialTheme .colorScheme.onSecondary,
132
- style = MaterialTheme .typography.bodyMedium
133
- )
134
- }
135
- TextButton (onClick = {
136
- scope.launch {
137
- lazyListState.animateScrollToItem(state.messages.size - 1 )
138
- }
139
- showNewMessageNotification = false
140
- }) {
141
- Text (" View" , color = Color .White )
142
- }
143
- }
144
- }
99
+ NewMessageReceivedNotification (
100
+ state = state,
101
+ scope = scope,
102
+ lazyListState = lazyListState,
103
+ onClick = { showNewMessageNotification = false }
104
+ )
145
105
}
146
106
ChatMessageInput (
147
107
onMessage = {
0 commit comments