diff --git a/app/src/main/kotlin/net/primal/android/core/compose/PrimalNavigationBar.kt b/app/src/main/kotlin/net/primal/android/core/compose/PrimalNavigationBar.kt index 7379c97f3..200c1f823 100644 --- a/app/src/main/kotlin/net/primal/android/core/compose/PrimalNavigationBar.kt +++ b/app/src/main/kotlin/net/primal/android/core/compose/PrimalNavigationBar.kt @@ -72,7 +72,7 @@ private fun RowScope.PrimalNavigationBarItem( badge: Int = 0, ) { val selected = primaryDestination == activeDestination - val clickDebounce by remember { mutableStateOf(ClickDebounce(timeoutMillis = 750L)) } + val clickDebounce by remember { mutableStateOf(ClickDebounce()) } NavigationBarItem( selected = selected, onClick = { clickDebounce.processEvent(onClick) }, diff --git a/app/src/main/kotlin/net/primal/android/core/compose/PrimalTopAppBar.kt b/app/src/main/kotlin/net/primal/android/core/compose/PrimalTopAppBar.kt index c62bfdf09..5ac47a5bd 100644 --- a/app/src/main/kotlin/net/primal/android/core/compose/PrimalTopAppBar.kt +++ b/app/src/main/kotlin/net/primal/android/core/compose/PrimalTopAppBar.kt @@ -12,10 +12,14 @@ import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp +import net.primal.android.core.compose.foundation.ClickDebounce import net.primal.android.theme.AppTheme @ExperimentalMaterial3Api @@ -47,9 +51,10 @@ fun PrimalTopAppBar( ) } } else if (navigationIcon != null) { + val clickDebounce by remember { mutableStateOf(ClickDebounce()) } AppBarIcon( icon = navigationIcon, - onClick = onNavigationIconClick, + onClick = { clickDebounce.processEvent(onNavigationIconClick) }, ) } }, diff --git a/app/src/main/kotlin/net/primal/android/core/compose/foundation/ClickDebounce.kt b/app/src/main/kotlin/net/primal/android/core/compose/foundation/ClickDebounce.kt index 039ce970b..ffd69813c 100644 --- a/app/src/main/kotlin/net/primal/android/core/compose/foundation/ClickDebounce.kt +++ b/app/src/main/kotlin/net/primal/android/core/compose/foundation/ClickDebounce.kt @@ -1,6 +1,6 @@ package net.primal.android.core.compose.foundation -class ClickDebounce(private val timeoutMillis: Long) { +class ClickDebounce(private val timeoutMillis: Long = 500L) { private val now: Long get() = System.currentTimeMillis() private var lastEventTimeInMillis: Long = 0 diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt b/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt index a25c3afa6..4471711a2 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt @@ -94,6 +94,7 @@ import net.primal.android.core.compose.PrimalDivider import net.primal.android.core.compose.button.PrimalFilledButton import net.primal.android.core.compose.button.PrimalOutlinedButton import net.primal.android.core.compose.feed.FeedLazyColumn +import net.primal.android.core.compose.foundation.ClickDebounce import net.primal.android.core.compose.foundation.rememberLazyListStatePagingWorkaround import net.primal.android.core.compose.icons.PrimalIcons import net.primal.android.core.compose.icons.primaliconpack.ArrowBack @@ -303,11 +304,12 @@ fun ProfileScreen( avatarPadding = with(density) { (maxAvatarSizePx - avatarSizePx.floatValue).toDp() }, avatarOffsetY = with(density) { (maxAvatarSizePx * 0.65f).toDp() }, navigationIcon = { + val clickDebounce by remember { mutableStateOf(ClickDebounce()) } AppBarIcon( icon = PrimalIcons.ArrowBack, backgroundColor = Color.Black.copy(alpha = 0.5f), tint = Color.White, - onClick = onClose, + onClick = { clickDebounce.processEvent(onClose) }, ) }, title = {