mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-22 07:06:05 +00:00
animations
This commit is contained in:
parent
8e849a7bbe
commit
5428bc9a03
@ -1,8 +1,11 @@
|
||||
package com.bitchat.android.core.ui.component.button
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@ -12,8 +15,9 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.Dp
|
||||
@ -45,34 +49,44 @@ fun BitChatBrandButton(
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
val pressScale = rememberPressScale(interactionSource)
|
||||
|
||||
IconButton(
|
||||
onClick = {
|
||||
tapCount += 1
|
||||
resetJob?.cancel()
|
||||
// A plain Box rather than an IconButton: IconButton insists on drawing a ripple, which was the
|
||||
// only press background left in the header once every other control moved to scale-only
|
||||
// feedback.
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(CircleShape)
|
||||
.clickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = null,
|
||||
onClickLabel = contentDescription
|
||||
) {
|
||||
tapCount += 1
|
||||
resetJob?.cancel()
|
||||
|
||||
if (tapCount == 3) {
|
||||
tapCount = 0
|
||||
resetJob = null
|
||||
currentOnTripleClick()
|
||||
} else {
|
||||
resetJob = coroutineScope.launch {
|
||||
delay(MultiClickThreshold)
|
||||
if (tapCount == 1) {
|
||||
currentOnClick()
|
||||
}
|
||||
if (tapCount == 3) {
|
||||
tapCount = 0
|
||||
resetJob = null
|
||||
currentOnTripleClick()
|
||||
} else {
|
||||
resetJob = coroutineScope.launch {
|
||||
delay(MultiClickThreshold)
|
||||
if (tapCount == 1) {
|
||||
currentOnClick()
|
||||
}
|
||||
tapCount = 0
|
||||
resetJob = null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = modifier.scale(pressScale),
|
||||
interactionSource = interactionSource,
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
imageVector = BitChatIcon,
|
||||
contentDescription = contentDescription,
|
||||
tint = tint,
|
||||
modifier = Modifier.size(iconSize),
|
||||
modifier = Modifier
|
||||
.size(iconSize)
|
||||
.scale(pressScale),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,6 @@ fun BitchatBottomSheet(
|
||||
runCatching { sheetState.hide() }
|
||||
onDismissRequest()
|
||||
}
|
||||
Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -452,21 +452,25 @@ private fun ChannelHeader(
|
||||
.align(Alignment.Center)
|
||||
.clip(HeaderClusterShape)
|
||||
.pressScaleClickable(onClick = onSidebarClick)
|
||||
.padding(horizontal = 8.dp, vertical = 4.dp)
|
||||
.heightIn(min = HeaderTapTarget)
|
||||
.wrapContentHeight(Alignment.CenterVertically)
|
||||
.padding(horizontal = 10.dp)
|
||||
)
|
||||
|
||||
// Leave button - positioned on the right
|
||||
TextButton(
|
||||
onClick = onLeaveChannel,
|
||||
modifier = Modifier.align(Alignment.CenterEnd)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.chat_leave),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontSize = 15.sp,
|
||||
color = palette.accentRed
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = stringResource(R.string.chat_leave),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontSize = 15.sp,
|
||||
color = palette.accentRed,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.clip(HeaderClusterShape)
|
||||
.pressScaleClickable(onClick = onLeaveChannel)
|
||||
.heightIn(min = HeaderTapTarget)
|
||||
.wrapContentHeight(Alignment.CenterVertically)
|
||||
.padding(horizontal = 10.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,7 +636,10 @@ private fun LocationChannelsButton(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
modifier = Modifier
|
||||
.clip(HeaderClusterShape)
|
||||
.clickable(onClickLabel = stringResource(R.string.location_channels_title)) { onClick() }
|
||||
.pressScaleClickable(
|
||||
onClick = onClick,
|
||||
onClickLabel = stringResource(R.string.location_channels_title)
|
||||
)
|
||||
.height(HeaderTapTarget)
|
||||
// No start padding: the notes icon is paired directly to the left; keep end
|
||||
// padding so the gap to PeerCounter matches other cluster separations.
|
||||
|
||||
@ -169,7 +169,6 @@ fun LocationChannelsSheet(
|
||||
delay(SelectionConfirmDelayMs)
|
||||
animatedDismiss?.invoke() ?: onDismiss()
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
|
||||
@ -2,7 +2,6 @@ package com.bitchat.android.ui
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Description
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@ -63,7 +62,7 @@ fun LocationNotesButton(
|
||||
modifier = modifier
|
||||
.size(44.dp)
|
||||
.clip(CircleShape)
|
||||
.clickable(onClickLabel = contentDescription) { onClick() },
|
||||
.pressScaleClickable(onClick = onClick, onClickLabel = contentDescription),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
TorAwareHeaderIcon(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user