1
1
package com.chatgptlite.wanted.ui.conversations
2
2
3
+ import androidx.compose.animation.animateContentSize
3
4
import androidx.compose.foundation.layout.*
4
5
import androidx.compose.foundation.lazy.LazyColumn
5
6
import androidx.compose.foundation.lazy.rememberLazyListState
7
+ import androidx.compose.foundation.shape.RoundedCornerShape
8
+ import androidx.compose.material.icons.Icons
9
+ import androidx.compose.material.icons.filled.Stop
10
+ import androidx.compose.material3.ExtendedFloatingActionButton
11
+ import androidx.compose.material3.Icon
6
12
import androidx.compose.material3.Surface
13
+ import androidx.compose.material3.Text
7
14
import androidx.compose.runtime.Composable
8
15
import androidx.compose.runtime.collectAsState
9
16
import androidx.compose.runtime.getValue
17
+ import androidx.compose.ui.Alignment
10
18
import androidx.compose.ui.Modifier
19
+ import androidx.compose.ui.graphics.Color
11
20
import androidx.compose.ui.platform.testTag
12
21
import androidx.compose.ui.tooling.preview.Preview
13
22
import androidx.compose.ui.unit.dp
14
23
import androidx.hilt.navigation.compose.hiltViewModel
24
+ import com.chatgptlite.wanted.constants.ConversationTestTag
15
25
import com.chatgptlite.wanted.models.MessageModel
16
26
import com.chatgptlite.wanted.ui.conversations.components.MessageCard
17
27
import com.chatgptlite.wanted.ui.conversations.components.TextInput
@@ -27,19 +37,18 @@ fun Conversation() {
27
37
) {
28
38
Box (Modifier .fillMaxSize()) {
29
39
Column (Modifier .fillMaxSize()) {
30
- MessageList (modifier = Modifier
31
- .weight(1f )
32
- .padding(horizontal = 16 .dp))
40
+ MessageList (
41
+ modifier = Modifier
42
+ .weight(1f )
43
+ .padding(horizontal = 16 .dp)
44
+ )
33
45
TextInput ()
34
46
}
35
47
}
36
48
}
37
49
}
38
50
}
39
51
40
-
41
- const val ConversationTestTag = " ConversationTestTag"
42
-
43
52
@Composable
44
53
fun MessageList (
45
54
modifier : Modifier = Modifier ,
@@ -49,6 +58,7 @@ fun MessageList(
49
58
50
59
val conversationId by conversationViewModel.currentConversationState.collectAsState()
51
60
val messagesMap by conversationViewModel.messagesState.collectAsState()
61
+ val isFabExpanded by conversationViewModel.isFabExpanded.collectAsState()
52
62
53
63
val messages: List <MessageModel > =
54
64
if (messagesMap[conversationId] == null ) listOf () else messagesMap[conversationId]!!
@@ -76,11 +86,33 @@ fun MessageList(
76
86
}
77
87
}
78
88
}
89
+ ExtendedFloatingActionButton (
90
+ text = {
91
+ Text (text = " Stop Generating" , color = Color .White )
92
+ },
93
+ icon = {
94
+ Icon (
95
+ imageVector = Icons .Default .Stop ,
96
+ contentDescription = " Stop Generating" ,
97
+ tint = Color .White ,
98
+ modifier = Modifier
99
+ .size(35 .dp)
100
+ )
101
+ },
102
+ onClick = {
103
+ conversationViewModel.stopReceivingResults()
104
+ },
105
+ shape = RoundedCornerShape (16 .dp),
106
+ modifier = Modifier
107
+ .align(Alignment .BottomEnd )
108
+ .padding(bottom = 16 .dp)
109
+ .animateContentSize(),
110
+ expanded = isFabExpanded,
111
+ )
79
112
}
80
113
}
81
114
82
115
83
-
84
116
@Preview(showBackground = true )
85
117
@Composable
86
118
fun DefaultPreview2 () {
0 commit comments