-
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.
This adds a loading screen component and integrates it into the OID4VCI flow.
- Loading branch information
1 parent
9505a1c
commit 9bdd703
Showing
7 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
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
90 changes: 90 additions & 0 deletions
90
example/src/main/java/com/spruceid/mobilesdkexample/LoadingView.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,90 @@ | ||
package com.spruceid.mobilesdkexample | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.compose.ui.viewinterop.AndroidView | ||
import app.rive.runtime.kotlin.RiveAnimationView | ||
import app.rive.runtime.kotlin.core.ExperimentalAssetLoader | ||
import com.spruceid.mobilesdkexample.ui.theme.CodeBorder | ||
import com.spruceid.mobilesdkexample.ui.theme.ColorBase800 | ||
import com.spruceid.mobilesdkexample.ui.theme.Inter | ||
|
||
@OptIn(ExperimentalAssetLoader::class) | ||
@Composable | ||
fun LoadingView( | ||
loadingText: String, | ||
cancelButtonLabel: String = "Cancel", | ||
onCancel: (() -> Unit)? = null | ||
) { | ||
Box(modifier = Modifier.fillMaxSize()) { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center | ||
) { | ||
AndroidView( | ||
modifier = Modifier.size(60.dp), | ||
factory = { context -> | ||
RiveAnimationView(context).also { | ||
it.setRiveResource( | ||
resId = R.raw.loading_spinner, | ||
) | ||
} | ||
} | ||
) | ||
Text( | ||
text = loadingText, | ||
fontFamily = Inter, | ||
fontWeight = FontWeight.Normal, | ||
color = ColorBase800, | ||
fontSize = 20.sp, | ||
modifier = Modifier.padding(top = 10.dp) | ||
) | ||
} | ||
if (onCancel != null) { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Bottom | ||
) { | ||
Button( | ||
onClick = { | ||
onCancel() | ||
}, | ||
shape = RoundedCornerShape(5.dp), | ||
colors = ButtonDefaults.buttonColors( | ||
containerColor = Color.Transparent, | ||
contentColor = Color.Black, | ||
), | ||
border = BorderStroke(1.dp, CodeBorder), | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
Text( | ||
text = cancelButtonLabel, | ||
fontFamily = Inter, | ||
fontWeight = FontWeight.SemiBold, | ||
color = Color.Black, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Binary file not shown.
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