pref: 状态屏点击事件

This commit is contained in:
HuanCheng65 2023-03-11 01:17:51 +08:00
parent 9a8e26e240
commit 3a897cd4d1
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
1 changed files with 7 additions and 3 deletions

View File

@ -37,18 +37,22 @@ fun StateScreen(
isEmpty: Boolean,
isError: Boolean,
isLoading: Boolean,
onReload: () -> Unit,
modifier: Modifier = Modifier,
onReload: (() -> Unit)? = null,
emptyScreen: @Composable () -> Unit = DefaultEmptyScreen,
errorScreen: @Composable () -> Unit = DefaultErrorScreen,
loadingScreen: @Composable () -> Unit = DefaultLoadingScreen,
content: @Composable () -> Unit,
) {
val clickableModifier = if (onReload != null) Modifier.clickable(
enabled = isEmpty && !isLoading,
onClick = onReload
) else Modifier
Box(
modifier = Modifier
.fillMaxSize()
.then(modifier)
.clickable(enabled = isEmpty && !isLoading, onClick = onReload),
then modifier
then clickableModifier,
contentAlignment = Alignment.Center
) {
if (!isEmpty) {