Fixing Options Button
This commit is contained in:
@@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.material.ripple.rememberRipple
|
import androidx.compose.material.ripple.rememberRipple
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size24dp
|
import com.vitorpamplona.amethyst.ui.theme.Size24dp
|
||||||
@@ -43,6 +44,7 @@ fun ClickableBox(
|
|||||||
indication = rememberRipple(bounded = false, radius = Size24dp),
|
indication = rememberRipple(bounded = false, radius = Size24dp),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
),
|
),
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.ui.note
|
|||||||
|
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -31,17 +31,12 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.MilitaryTech
|
import androidx.compose.material.icons.filled.MilitaryTech
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -49,14 +44,12 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.routeFor
|
import com.vitorpamplona.amethyst.ui.navigation.routeFor
|
||||||
import com.vitorpamplona.amethyst.ui.note.elements.NoteDropDownMenu
|
import com.vitorpamplona.amethyst.ui.note.elements.MoreOptionsButton
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.BadgeDisplay
|
import com.vitorpamplona.amethyst.ui.note.types.BadgeDisplay
|
||||||
import com.vitorpamplona.amethyst.ui.screen.BadgeCard
|
import com.vitorpamplona.amethyst.ui.screen.BadgeCard
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
|
||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -75,11 +68,6 @@ fun BadgeCompose(
|
|||||||
|
|
||||||
val context = LocalContext.current.applicationContext
|
val context = LocalContext.current.applicationContext
|
||||||
|
|
||||||
val popupExpanded = remember { mutableStateOf(false) }
|
|
||||||
val enablePopup = remember { { popupExpanded.value = true } }
|
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
|
|
||||||
if (note == null) {
|
if (note == null) {
|
||||||
BlankNote(Modifier)
|
BlankNote(Modifier)
|
||||||
} else {
|
} else {
|
||||||
@@ -94,16 +82,13 @@ fun BadgeCompose(
|
|||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.background(backgroundColor.value)
|
.background(backgroundColor.value)
|
||||||
.combinedClickable(
|
.clickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
scope.launch {
|
|
||||||
routeFor(
|
routeFor(
|
||||||
note,
|
note,
|
||||||
accountViewModel.userProfile(),
|
accountViewModel.userProfile(),
|
||||||
)?.let { nav(it) }
|
)?.let { nav(it) }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onLongClick = enablePopup,
|
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
@@ -142,19 +127,7 @@ fun BadgeCompose(
|
|||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
IconButton(
|
MoreOptionsButton(note, null, accountViewModel, nav)
|
||||||
modifier = Modifier.then(Modifier.size(24.dp)),
|
|
||||||
onClick = enablePopup,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.MoreVert,
|
|
||||||
contentDescription = stringRes(id = R.string.more_options),
|
|
||||||
modifier = Size15Modifier,
|
|
||||||
tint = MaterialTheme.colorScheme.placeholderText,
|
|
||||||
)
|
|
||||||
|
|
||||||
NoteDropDownMenu(note, popupExpanded, null, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
note.replyTo?.firstOrNull()?.let {
|
note.replyTo?.firstOrNull()?.let {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ import com.vitorpamplona.amethyst.commons.icons.Zap
|
|||||||
import com.vitorpamplona.amethyst.commons.icons.ZapSplit
|
import com.vitorpamplona.amethyst.commons.icons.ZapSplit
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size18Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size19Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size30Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size30Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.grayText
|
import com.vitorpamplona.amethyst.ui.theme.grayText
|
||||||
@@ -508,11 +508,11 @@ fun LinkIcon(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun VerticalDotsIcon(contentDescriptor: Int? = null) {
|
fun VerticalDotsIcon() {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.MoreVert,
|
imageVector = Icons.Default.MoreVert,
|
||||||
contentDescription = contentDescriptor?.let { stringRes(id = it) },
|
contentDescription = stringRes(id = R.string.note_options),
|
||||||
modifier = Size18Modifier,
|
modifier = Size19Modifier,
|
||||||
tint = MaterialTheme.colorScheme.placeholderText,
|
tint = MaterialTheme.colorScheme.placeholderText,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,25 +68,23 @@ fun MessageSetCompose(
|
|||||||
|
|
||||||
val columnModifier =
|
val columnModifier =
|
||||||
remember(backgroundColor.value) {
|
remember(backgroundColor.value) {
|
||||||
Modifier.background(backgroundColor.value)
|
Modifier
|
||||||
|
.background(backgroundColor.value)
|
||||||
.padding(
|
.padding(
|
||||||
start = 12.dp,
|
start = 12.dp,
|
||||||
end = 12.dp,
|
end = 12.dp,
|
||||||
top = 10.dp,
|
top = 10.dp,
|
||||||
)
|
).combinedClickable(
|
||||||
.combinedClickable(
|
|
||||||
onClick = {
|
onClick = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
routeFor(
|
routeFor(
|
||||||
baseNote,
|
baseNote,
|
||||||
accountViewModel.userProfile(),
|
accountViewModel.userProfile(),
|
||||||
)
|
)?.let { nav(it) }
|
||||||
?.let { nav(it) }
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongClick = enablePopup,
|
onLongClick = enablePopup,
|
||||||
)
|
).fillMaxWidth()
|
||||||
.fillMaxWidth()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(columnModifier) {
|
Column(columnModifier) {
|
||||||
@@ -111,7 +109,9 @@ fun MessageSetCompose(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|
||||||
NoteDropDownMenu(baseNote, popupExpanded, null, accountViewModel, nav)
|
if (popupExpanded.value) {
|
||||||
|
NoteDropDownMenu(baseNote, { popupExpanded.value = false }, null, accountViewModel, nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ fun MultiSetCompose(
|
|||||||
val baseNote = remember { multiSetCard.note }
|
val baseNote = remember { multiSetCard.note }
|
||||||
|
|
||||||
val popupExpanded = remember { mutableStateOf(false) }
|
val popupExpanded = remember { mutableStateOf(false) }
|
||||||
val enablePopup = remember { { popupExpanded.value = true } }
|
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ fun MultiSetCompose(
|
|||||||
onClick = {
|
onClick = {
|
||||||
scope.launch { routeFor(baseNote, accountViewModel.userProfile())?.let { nav(it) } }
|
scope.launch { routeFor(baseNote, accountViewModel.userProfile())?.let { nav(it) } }
|
||||||
},
|
},
|
||||||
onLongClick = enablePopup,
|
onLongClick = { popupExpanded.value = true },
|
||||||
).padding(
|
).padding(
|
||||||
start = 12.dp,
|
start = 12.dp,
|
||||||
end = 12.dp,
|
end = 12.dp,
|
||||||
@@ -152,7 +151,9 @@ fun MultiSetCompose(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
|
|
||||||
NoteDropDownMenu(baseNote, popupExpanded, null, accountViewModel, nav)
|
if (popupExpanded.value) {
|
||||||
|
NoteDropDownMenu(baseNote, { popupExpanded.value = false }, null, accountViewModel, nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.MutableState
|
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
@@ -71,16 +70,18 @@ fun MoreOptionsButton(
|
|||||||
modifier = Size24Modifier,
|
modifier = Size24Modifier,
|
||||||
onClick = { popupExpanded.value = true },
|
onClick = { popupExpanded.value = true },
|
||||||
) {
|
) {
|
||||||
VerticalDotsIcon(R.string.note_options)
|
VerticalDotsIcon()
|
||||||
|
|
||||||
|
if (popupExpanded.value) {
|
||||||
NoteDropDownMenu(
|
NoteDropDownMenu(
|
||||||
baseNote,
|
note = baseNote,
|
||||||
popupExpanded,
|
onDismiss = { popupExpanded.value = false },
|
||||||
editState,
|
editState = editState,
|
||||||
accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -96,7 +97,7 @@ data class DropDownParams(
|
|||||||
@Composable
|
@Composable
|
||||||
fun NoteDropDownMenu(
|
fun NoteDropDownMenu(
|
||||||
note: Note,
|
note: Note,
|
||||||
popupExpanded: MutableState<Boolean>,
|
onDismiss: () -> Unit,
|
||||||
editState: State<GenericLoadable<EditState>>? = null,
|
editState: State<GenericLoadable<EditState>>? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
@@ -116,8 +117,6 @@ fun NoteDropDownMenu(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val onDismiss = remember(popupExpanded) { { popupExpanded.value = false } }
|
|
||||||
|
|
||||||
val wantsToEditPost =
|
val wantsToEditPost =
|
||||||
remember {
|
remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
@@ -137,7 +136,7 @@ fun NoteDropDownMenu(
|
|||||||
|
|
||||||
EditPostView(
|
EditPostView(
|
||||||
onClose = {
|
onClose = {
|
||||||
popupExpanded.value = false
|
onDismiss()
|
||||||
wantsToEditPost.value = false
|
wantsToEditPost.value = false
|
||||||
},
|
},
|
||||||
edit = note,
|
edit = note,
|
||||||
@@ -150,7 +149,7 @@ fun NoteDropDownMenu(
|
|||||||
if (wantsToEditDraft.value) {
|
if (wantsToEditDraft.value) {
|
||||||
NewPostView(
|
NewPostView(
|
||||||
onClose = {
|
onClose = {
|
||||||
popupExpanded.value = false
|
onDismiss()
|
||||||
wantsToEditDraft.value = false
|
wantsToEditDraft.value = false
|
||||||
},
|
},
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
@@ -160,7 +159,7 @@ fun NoteDropDownMenu(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
expanded = popupExpanded.value,
|
expanded = true,
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
) {
|
) {
|
||||||
val clipboardManager = LocalClipboardManager.current
|
val clipboardManager = LocalClipboardManager.current
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import androidx.compose.foundation.pager.rememberPagerState
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
@@ -63,6 +62,7 @@ import com.vitorpamplona.amethyst.model.Note
|
|||||||
import com.vitorpamplona.amethyst.service.NostrVideoDataSource
|
import com.vitorpamplona.amethyst.service.NostrVideoDataSource
|
||||||
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
||||||
import com.vitorpamplona.amethyst.ui.actions.NewPostView
|
import com.vitorpamplona.amethyst.ui.actions.NewPostView
|
||||||
|
import com.vitorpamplona.amethyst.ui.components.ClickableBox
|
||||||
import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status
|
import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.routeFor
|
import com.vitorpamplona.amethyst.ui.navigation.routeFor
|
||||||
import com.vitorpamplona.amethyst.ui.note.BoostReaction
|
import com.vitorpamplona.amethyst.ui.note.BoostReaction
|
||||||
@@ -89,6 +89,8 @@ import com.vitorpamplona.amethyst.ui.screen.rememberForeverPagerState
|
|||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.AuthorInfoVideoFeed
|
import com.vitorpamplona.amethyst.ui.theme.AuthorInfoVideoFeed
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size22Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size40Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size40Modifier
|
||||||
@@ -343,27 +345,28 @@ private fun VideoUserOptionAction(
|
|||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
val popupExpanded = remember { mutableStateOf(false) }
|
val popupExpanded = remember { mutableStateOf(false) }
|
||||||
val enablePopup = remember { { popupExpanded.value = true } }
|
|
||||||
|
|
||||||
IconButton(
|
ClickableBox(
|
||||||
modifier = remember { Modifier.size(22.dp) },
|
modifier = Size22Modifier,
|
||||||
onClick = enablePopup,
|
onClick = { popupExpanded.value = true },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.MoreVert,
|
imageVector = Icons.Default.MoreVert,
|
||||||
contentDescription = stringRes(id = R.string.more_options),
|
contentDescription = stringRes(id = R.string.more_options),
|
||||||
modifier = remember { Modifier.size(20.dp) },
|
modifier = Size20Modifier,
|
||||||
tint = MaterialTheme.colorScheme.placeholderText,
|
tint = MaterialTheme.colorScheme.placeholderText,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (popupExpanded.value) {
|
||||||
NoteDropDownMenu(
|
NoteDropDownMenu(
|
||||||
note,
|
note,
|
||||||
popupExpanded,
|
{ popupExpanded.value = false },
|
||||||
null,
|
null,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user