@@ -3,7 +3,21 @@ package com.chatgptlite.wanted.ui.common
3
3
import androidx.compose.foundation.Image
4
4
import androidx.compose.foundation.background
5
5
import androidx.compose.foundation.clickable
6
- import androidx.compose.foundation.layout.*
6
+ import androidx.compose.foundation.layout.Arrangement
7
+ import androidx.compose.foundation.layout.Box
8
+ import androidx.compose.foundation.layout.Column
9
+ import androidx.compose.foundation.layout.ColumnScope
10
+ import androidx.compose.foundation.layout.Row
11
+ import androidx.compose.foundation.layout.Spacer
12
+ import androidx.compose.foundation.layout.WindowInsets
13
+ import androidx.compose.foundation.layout.fillMaxSize
14
+ import androidx.compose.foundation.layout.fillMaxWidth
15
+ import androidx.compose.foundation.layout.height
16
+ import androidx.compose.foundation.layout.heightIn
17
+ import androidx.compose.foundation.layout.padding
18
+ import androidx.compose.foundation.layout.size
19
+ import androidx.compose.foundation.layout.statusBars
20
+ import androidx.compose.foundation.layout.windowInsetsTopHeight
7
21
import androidx.compose.foundation.lazy.LazyColumn
8
22
import androidx.compose.foundation.shape.CircleShape
9
23
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -13,7 +27,11 @@ import androidx.compose.material.icons.filled.Message
13
27
import androidx.compose.material.icons.filled.Settings
14
28
import androidx.compose.material.icons.filled.WbSunny
15
29
import androidx.compose.material.icons.outlined.AddComment
16
- import androidx.compose.material3.*
30
+ import androidx.compose.material3.Divider
31
+ import androidx.compose.material3.Icon
32
+ import androidx.compose.material3.IconButton
33
+ import androidx.compose.material3.MaterialTheme
34
+ import androidx.compose.material3.Text
17
35
import androidx.compose.runtime.Composable
18
36
import androidx.compose.runtime.collectAsState
19
37
import androidx.compose.runtime.getValue
@@ -38,47 +56,47 @@ import com.chatgptlite.wanted.constants.urlToImageAuthor
38
56
import com.chatgptlite.wanted.helpers.UrlLauncher
39
57
import com.chatgptlite.wanted.models.ConversationModel
40
58
import com.chatgptlite.wanted.ui.conversations.ConversationViewModel
41
- import com.chatgptlite.wanted.ui.theme.ChatGPTLiteTheme
42
59
import kotlinx.coroutines.launch
43
60
44
61
@Composable
45
62
fun AppDrawer (
46
63
onChatClicked : (String ) -> Unit ,
47
64
onNewChatClicked : () -> Unit ,
48
65
conversationViewModel : ConversationViewModel = hiltViewModel(),
66
+ onIconClicked : () -> Unit = {}
49
67
) {
50
68
val context = LocalContext .current
51
69
52
- ChatGPTLiteTheme () {
53
- Column (
54
- modifier = Modifier
55
- .fillMaxSize()
56
- .background(MaterialTheme .colorScheme.background)
70
+ Column (
71
+ modifier = Modifier
72
+ .fillMaxSize()
73
+ .background(MaterialTheme .colorScheme.background)
74
+ ) {
75
+ Spacer (Modifier .windowInsetsTopHeight(WindowInsets .statusBars))
76
+ DrawerHeader (clickAction = onIconClicked)
77
+ DividerItem ()
78
+ DrawerItemHeader (" Chats" )
79
+ ChatItem (" New Chat" , Icons .Outlined .AddComment , false ) {
80
+ onNewChatClicked()
81
+ conversationViewModel.newConversation()
82
+ }
83
+ HistoryConversations (onChatClicked)
84
+ DividerItem (modifier = Modifier .padding(horizontal = 28 .dp))
85
+ DrawerItemHeader (" Settings" )
86
+ ChatItem (" Settings" , Icons .Filled .Settings , false ) { onChatClicked(" Settings" ) }
87
+ ProfileItem (
88
+ " lambiengcode (author)" ,
89
+ urlToImageAuthor,
57
90
) {
58
- Spacer (Modifier .windowInsetsTopHeight(WindowInsets .statusBars))
59
- DrawerHeader ()
60
- DividerItem ()
61
- DrawerItemHeader (" Chats" )
62
- ChatItem (" New Chat" , Icons .Outlined .AddComment , false ) {
63
- onNewChatClicked()
64
- conversationViewModel.newConversation()
65
- }
66
- HistoryConversations (onChatClicked)
67
- DividerItem (modifier = Modifier .padding(horizontal = 28 .dp))
68
- DrawerItemHeader (" Settings" )
69
- ChatItem (" Settings" , Icons .Filled .Settings , false ) { onChatClicked(" Settings" ) }
70
- ProfileItem (
71
- " lambiengcode (author)" ,
72
- urlToImageAuthor,
73
- ) {
74
- UrlLauncher ().openUrl(context = context, urlToGithub)
75
- }
91
+ UrlLauncher ().openUrl(context = context, urlToGithub)
76
92
}
77
93
}
78
94
}
79
95
80
96
@Composable
81
- private fun DrawerHeader () {
97
+ private fun DrawerHeader (
98
+ clickAction : () -> Unit = {}
99
+ ) {
82
100
val paddingSizeModifier = Modifier
83
101
.padding(start = 16 .dp, top = 16 .dp, bottom = 16 .dp)
84
102
.size(34 .dp)
@@ -113,6 +131,7 @@ private fun DrawerHeader() {
113
131
114
132
IconButton (
115
133
onClick = {
134
+ clickAction.invoke()
116
135
},
117
136
) {
118
137
Icon (
0 commit comments