pref: 状态屏点击事件
This commit is contained in:
parent
9a8e26e240
commit
3a897cd4d1
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue