@@ -3,7 +3,21 @@ package com.chatgptlite.wanted.ui.common
33import androidx.compose.foundation.Image
44import androidx.compose.foundation.background
55import 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
721import androidx.compose.foundation.lazy.LazyColumn
822import androidx.compose.foundation.shape.CircleShape
923import androidx.compose.foundation.shape.RoundedCornerShape
@@ -13,7 +27,11 @@ import androidx.compose.material.icons.filled.Message
1327import androidx.compose.material.icons.filled.Settings
1428import androidx.compose.material.icons.filled.WbSunny
1529import 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
1735import androidx.compose.runtime.Composable
1836import androidx.compose.runtime.collectAsState
1937import androidx.compose.runtime.getValue
@@ -38,47 +56,47 @@ import com.chatgptlite.wanted.constants.urlToImageAuthor
3856import com.chatgptlite.wanted.helpers.UrlLauncher
3957import com.chatgptlite.wanted.models.ConversationModel
4058import com.chatgptlite.wanted.ui.conversations.ConversationViewModel
41- import com.chatgptlite.wanted.ui.theme.ChatGPTLiteTheme
4259import kotlinx.coroutines.launch
4360
4461@Composable
4562fun AppDrawer (
4663 onChatClicked : (String ) -> Unit ,
4764 onNewChatClicked : () -> Unit ,
4865 conversationViewModel : ConversationViewModel = hiltViewModel(),
66+ onIconClicked : () -> Unit = {}
4967) {
5068 val context = LocalContext .current
5169
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,
5790 ) {
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)
7692 }
7793 }
7894}
7995
8096@Composable
81- private fun DrawerHeader () {
97+ private fun DrawerHeader (
98+ clickAction : () -> Unit = {}
99+ ) {
82100 val paddingSizeModifier = Modifier
83101 .padding(start = 16 .dp, top = 16 .dp, bottom = 16 .dp)
84102 .size(34 .dp)
@@ -113,6 +131,7 @@ private fun DrawerHeader() {
113131
114132 IconButton (
115133 onClick = {
134+ clickAction.invoke()
116135 },
117136 ) {
118137 Icon (
0 commit comments