-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b88943
commit 731e8dc
Showing
3 changed files
with
59 additions
and
40 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/paulcoding/hviewer/ui/component/HEmpty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.paulcoding.hviewer.ui.component | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.unit.dp | ||
import com.airbnb.lottie.compose.LottieAnimation | ||
import com.airbnb.lottie.compose.LottieCompositionSpec | ||
import com.airbnb.lottie.compose.animateLottieCompositionAsState | ||
import com.airbnb.lottie.compose.rememberLottieComposition | ||
import com.paulcoding.hviewer.R | ||
|
||
@Composable | ||
fun HEmpty(title: String? = null, message: String? = null, block: () -> Unit) { | ||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.empty)) | ||
val progress by animateLottieCompositionAsState(composition) | ||
|
||
Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxSize()) { | ||
LottieAnimation( | ||
composition = composition, | ||
progress = { progress }, | ||
) | ||
Spacer(modifier = Modifier.height(16.dp)) | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
if (title != null) { | ||
Text(title) | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
} | ||
if (message != null) | ||
Text( | ||
message, | ||
modifier = Modifier.clickable { block() }, | ||
textDecoration = TextDecoration.Underline | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters