@@ -11,34 +11,27 @@ package com.nextcloud.android.common.ui.share.component
1111
1212import androidx.compose.animation.AnimatedVisibility
1313import androidx.compose.foundation.background
14- import androidx.compose.foundation.combinedClickable
14+ import androidx.compose.foundation.clickable
1515import androidx.compose.foundation.layout.Box
1616import androidx.compose.foundation.layout.Column
17- import androidx.compose.foundation.layout.Row
1817import androidx.compose.foundation.layout.fillMaxWidth
1918import androidx.compose.foundation.layout.size
2019import androidx.compose.material.icons.Icons
20+ import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
2121import androidx.compose.material.icons.filled.KeyboardArrowDown
22- import androidx.compose.material.icons.filled.MoreVert
2322import androidx.compose.material3.Icon
2423import androidx.compose.material3.IconButton
2524import androidx.compose.material3.ListItem
2625import androidx.compose.material3.ListItemDefaults
2726import androidx.compose.material3.MaterialTheme
2827import androidx.compose.material3.Text
2928import androidx.compose.runtime.Composable
30- import androidx.compose.runtime.getValue
3129import androidx.compose.runtime.key
32- import androidx.compose.runtime.mutableStateOf
33- import androidx.compose.runtime.remember
34- import androidx.compose.runtime.setValue
3530import androidx.compose.ui.Alignment
3631import androidx.compose.ui.Modifier
3732import androidx.compose.ui.draw.clip
3833import androidx.compose.ui.draw.rotate
3934import androidx.compose.ui.graphics.Color
40- import androidx.compose.ui.hapticfeedback.HapticFeedbackType
41- import androidx.compose.ui.platform.LocalHapticFeedback
4235import androidx.compose.ui.res.stringResource
4336import androidx.compose.ui.text.style.TextOverflow
4437import androidx.compose.ui.unit.dp
@@ -60,8 +53,6 @@ private val LEADING_ICON_SIZE = 24.dp
6053@Composable
6154fun ShareListItem (state : ShareListItemState , permissionPresets : List <PermissionPreset >, actions : ShareListItemActions ) {
6255 val share = state.share
63- var contextMenuExpanded by remember { mutableStateOf(false ) }
64- val haptics = LocalHapticFeedback .current
6556
6657 Column (
6758 modifier = Modifier
@@ -70,13 +61,7 @@ fun ShareListItem(state: ShareListItemState, permissionPresets: List<PermissionP
7061 .background(MaterialTheme .colorScheme.surfaceVariant.copy(alpha = CONTAINER_ALPHA ))
7162 ) {
7263 ListItem (
73- modifier = Modifier .combinedClickable(
74- onClick = { actions.onSelectShare(share) },
75- onLongClick = {
76- haptics.performHapticFeedback(HapticFeedbackType .LongPress )
77- contextMenuExpanded = true
78- }
79- ),
64+ modifier = Modifier .clickable { actions.onSelectShare(share) },
8065 headlineContent = {
8166 Text (
8267 text = state.title,
@@ -85,22 +70,15 @@ fun ShareListItem(state: ShareListItemState, permissionPresets: List<PermissionP
8570 overflow = TextOverflow .Ellipsis
8671 )
8772 },
88- leadingContent = { ShareItemLeadingContent (share) },
73+ leadingContent = { ShareItemLeadingContent (share = share, isExpanded = state.isExpanded ) },
8974 supportingContent = {
9075 SharePermissionChip (
9176 options = PermissionPresetOption .optionsFor(share, permissionPresets),
9277 selectedOption = PermissionPresetOption .from(share.permissionPreset, permissionPresets),
9378 onClick = { actions.onShowOverlay(ShareOverlay .QuickShare (share.id)) }
9479 )
9580 },
96- trailingContent = {
97- ShareItemTrailingContent (
98- state = state,
99- isContextMenuExpanded = contextMenuExpanded,
100- onContextMenuExpandedChange = { contextMenuExpanded = it },
101- actions = actions
102- )
103- },
81+ trailingContent = { ShareItemTrailingContent (state = state, actions = actions) },
10482 colors = ListItemDefaults .colors(containerColor = Color .Transparent )
10583 )
10684
@@ -115,35 +93,20 @@ fun ShareListItem(state: ShareListItemState, permissionPresets: List<PermissionP
11593}
11694
11795@Composable
118- private fun ShareItemTrailingContent (
119- state : ShareListItemState ,
120- isContextMenuExpanded : Boolean ,
121- onContextMenuExpandedChange : (Boolean ) -> Unit ,
122- actions : ShareListItemActions
123- ) {
124- Row (verticalAlignment = Alignment .CenterVertically ) {
125- if (state.share.hasMultipleRecipients) {
126- ExpandRecipientsButton (
127- isExpanded = state.isExpanded,
128- onClick = { actions.onToggleExpanded(state.share) }
129- )
130- }
131-
132- Box {
133- IconButton (onClick = { onContextMenuExpandedChange(true ) }) {
134- Icon (
135- imageVector = Icons .Default .MoreVert ,
136- contentDescription = stringResource(R .string.share_view_list_item_more_options)
137- )
138- }
139-
140- ShareContextMenu (
141- expanded = isContextMenuExpanded,
142- onDismiss = { onContextMenuExpandedChange(false ) },
143- onEdit = { actions.onSelectShare(state.share) }
144- )
145- }
96+ private fun ShareItemTrailingContent (state : ShareListItemState , actions : ShareListItemActions ) {
97+ if (state.share.hasMultipleRecipients) {
98+ ExpandRecipientsButton (
99+ isExpanded = state.isExpanded,
100+ onClick = { actions.onToggleExpanded(state.share) }
101+ )
102+ return
146103 }
104+
105+ Icon (
106+ imageVector = Icons .AutoMirrored .Filled .KeyboardArrowRight ,
107+ contentDescription = null ,
108+ tint = MaterialTheme .colorScheme.onSurfaceVariant
109+ )
147110}
148111
149112@Composable
@@ -164,18 +127,19 @@ private fun ShareRecipientList(share: Share, permissionPresets: List<PermissionP
164127 recipientInstance = recipient.instance
165128 )
166129 )
167- },
168- onRemove = { actions.onRemoveRecipient(share, recipient) }
130+ }
169131 )
170132 }
171133 }
172134 }
173135}
174136
175137@Composable
176- private fun ShareItemLeadingContent (share : Share ) {
138+ private fun ShareItemLeadingContent (share : Share , isExpanded : Boolean ) {
177139 if (share.hasMultipleRecipients) {
178- RecipientAvatarStack (recipients = share.recipients)
140+ if (! isExpanded) {
141+ RecipientAvatarStack (recipients = share.recipients)
142+ }
179143 return
180144 }
181145
0 commit comments