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, isEmpty: Boolean,
isError: Boolean, isError: Boolean,
isLoading: Boolean, isLoading: Boolean,
onReload: () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onReload: (() -> Unit)? = null,
emptyScreen: @Composable () -> Unit = DefaultEmptyScreen, emptyScreen: @Composable () -> Unit = DefaultEmptyScreen,
errorScreen: @Composable () -> Unit = DefaultErrorScreen, errorScreen: @Composable () -> Unit = DefaultErrorScreen,
loadingScreen: @Composable () -> Unit = DefaultLoadingScreen, loadingScreen: @Composable () -> Unit = DefaultLoadingScreen,
content: @Composable () -> Unit, content: @Composable () -> Unit,
) { ) {
val clickableModifier = if (onReload != null) Modifier.clickable(
enabled = isEmpty && !isLoading,
onClick = onReload
) else Modifier
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.then(modifier) then modifier
.clickable(enabled = isEmpty && !isLoading, onClick = onReload), then clickableModifier,
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
if (!isEmpty) { if (!isEmpty) {