11package com.troplo.privateuploader.components.chat
22
3+ import androidx.compose.foundation.layout.Arrangement
4+ import androidx.compose.foundation.layout.Column
5+ import androidx.compose.foundation.layout.Row
6+ import androidx.compose.foundation.layout.fillMaxSize
7+ import androidx.compose.foundation.layout.padding
8+ import androidx.compose.material.icons.Icons
9+ import androidx.compose.material.icons.filled.PushPin
10+ import androidx.compose.material.icons.filled.Search
11+ import androidx.compose.material.icons.filled.Settings
312import androidx.compose.material3.ExperimentalMaterial3Api
13+ import androidx.compose.material3.Icon
14+ import androidx.compose.material3.IconButton
415import androidx.compose.material3.ListItem
516import androidx.compose.material3.NavigationDrawerItem
617import androidx.compose.material3.Text
@@ -10,48 +21,97 @@ import androidx.compose.runtime.collectAsState
1021import androidx.compose.runtime.derivedStateOf
1122import androidx.compose.runtime.mutableStateOf
1223import androidx.compose.runtime.remember
24+ import androidx.compose.ui.Alignment
25+ import androidx.compose.ui.Modifier
26+ import androidx.compose.ui.unit.dp
1327import com.troplo.privateuploader.api.ChatStore
1428import com.troplo.privateuploader.api.TpuFunctions
29+ import com.troplo.privateuploader.components.chat.dialogs.PinsDialog
1530import com.troplo.privateuploader.components.core.UserAvatar
1631import com.troplo.privateuploader.components.user.PopupRequiredUser
1732import com.troplo.privateuploader.components.user.UserPopup
18- import com.troplo.privateuploader.data.model.User
1933
2034@OptIn(ExperimentalMaterial3Api ::class )
2135@Composable
2236fun MemberSidebar () {
23- ListItem (
24- headlineContent = { Text (" Members" ) }
25- )
37+ val chatActions = remember { mutableStateOf(false ) }
2638 val chatId = ChatStore .associationId.collectAsState()
2739 val chats = ChatStore .chats.collectAsState()
2840 val chat =
2941 remember { derivedStateOf { chats.value.find { it.association?.id == chatId.value } } }
3042 val user: MutableState <PopupRequiredUser ?> = remember { mutableStateOf(null ) }
3143 val popup = remember { mutableStateOf(false ) }
44+ val pins = remember { mutableStateOf(false ) }
3245
3346 if (popup.value) {
3447 UserPopup (user = user, openBottomSheet = popup)
3548 }
3649
37- if (chat.value != null ) {
38- chat.value?.users?.forEach { association ->
39- NavigationDrawerItem (
40- icon = {
41- UserAvatar (
42- avatar = association.user.avatar,
43- username = association.user.username
44- )
45- },
46- label = { Text (TpuFunctions .getName(association.user)) },
47- onClick = {
48- if (association.legacyUser == null ) {
49- user.value = PopupRequiredUser (association.user.username)
50- popup.value = true
51- }
52- },
53- selected = false
54- )
50+ if (chatActions.value) {
51+ ChatActions (chat, chatActions)
52+ }
53+
54+ if (pins.value) {
55+ PinsDialog (pins)
56+ }
57+
58+ Column {
59+ Row (
60+ horizontalArrangement = Arrangement .Center ,
61+ verticalAlignment = Alignment .CenterVertically ,
62+ modifier = Modifier
63+ .fillMaxSize()
64+ ) {
65+ IconButton (
66+ onClick = { ChatStore .searchPanel.value = true },
67+ modifier = Modifier .padding(start = 16 .dp, end = 16 .dp)
68+ ) {
69+ Icon (
70+ imageVector = Icons .Default .Search ,
71+ contentDescription = " Search"
72+ )
73+ }
74+ IconButton (
75+ onClick = { pins.value = true },
76+ modifier = Modifier .padding(start = 16 .dp, end = 16 .dp)
77+ ) {
78+ Icon (
79+ imageVector = Icons .Default .PushPin ,
80+ contentDescription = " Pins"
81+ )
82+ }
83+ IconButton (onClick = {
84+ chatActions.value = ! chatActions.value
85+ }, modifier = Modifier .padding(start = 16 .dp, end = 16 .dp)) {
86+ Icon (
87+ imageVector = Icons .Default .Settings ,
88+ contentDescription = " Options"
89+ )
90+ }
91+ }
92+ ListItem (
93+ headlineContent = { Text (" Members" ) }
94+ )
95+
96+ if (chat.value != null ) {
97+ chat.value?.users?.forEach { association ->
98+ NavigationDrawerItem (
99+ icon = {
100+ UserAvatar (
101+ avatar = association.user.avatar,
102+ username = association.user.username
103+ )
104+ },
105+ label = { Text (TpuFunctions .getName(association.user)) },
106+ onClick = {
107+ if (association.legacyUser == null ) {
108+ user.value = PopupRequiredUser (association.user.username)
109+ popup.value = true
110+ }
111+ },
112+ selected = false
113+ )
114+ }
55115 }
56116 }
57117}
0 commit comments