mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 19:57:15 +08:00
chore: 参数调整
This commit is contained in:
parent
ce3ca5a2aa
commit
3439e9527a
|
@ -3,8 +3,8 @@ package li.songe.gkd.ui.component
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.KeyboardArrowRight
|
import androidx.compose.material.icons.filled.KeyboardArrowRight
|
||||||
|
@ -30,7 +30,7 @@ fun SettingItem(
|
||||||
)
|
)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(10.dp, 10.dp)
|
.padding(10.dp, 10.dp)
|
||||||
.height(30.dp),
|
.defaultMinSize(minHeight = 30.dp),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -10,15 +10,12 @@ import com.ramcosta.composedestinations.spec.Direction
|
||||||
val LocalNavController =
|
val LocalNavController =
|
||||||
compositionLocalOf<NavHostController> { error("not found DestinationsNavigator") }
|
compositionLocalOf<NavHostController> { error("not found DestinationsNavigator") }
|
||||||
|
|
||||||
private var lastNavigateTime = -1L
|
private val navThrottle = useThrottle()
|
||||||
fun NavController.navigate(
|
fun NavController.navigate(
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
navOptionsBuilder: NavOptionsBuilder.() -> Unit = {},
|
navOptionsBuilder: NavOptionsBuilder.() -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val t = System.currentTimeMillis()
|
navThrottle {
|
||||||
if (t - lastNavigateTime < 1000) {
|
navigate(direction.route, navOptionsBuilder)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
lastNavigateTime = t
|
|
||||||
navigate(direction.route, navOptionsBuilder)
|
|
||||||
}
|
}
|
|
@ -34,4 +34,15 @@ fun Long.format(formatStr: String): String {
|
||||||
formatDateMap[formatStr] = df
|
formatDateMap[formatStr] = df
|
||||||
}
|
}
|
||||||
return df.format(this)
|
return df.format(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun useThrottle(interval: Long = 1000L): (fn: () -> Unit) -> Unit {
|
||||||
|
var lastTriggerTime = 0L
|
||||||
|
return { fn ->
|
||||||
|
val t = System.currentTimeMillis()
|
||||||
|
if (t - lastTriggerTime > interval) {
|
||||||
|
lastTriggerTime = t
|
||||||
|
fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user