@@ -9,12 +9,16 @@ import androidx.activity.enableEdgeToEdge
99import androidx.compose.foundation.layout.Column
1010import androidx.compose.foundation.layout.fillMaxSize
1111import androidx.compose.foundation.layout.padding
12+ import androidx.compose.material3.AlertDialog
1213import androidx.compose.material3.Button
1314import androidx.compose.material3.Scaffold
1415import androidx.compose.material3.Text
16+ import androidx.compose.material3.TextButton
1517import androidx.compose.material3.TextField
18+ import androidx.compose.runtime.getValue
1619import androidx.compose.runtime.mutableStateOf
1720import androidx.compose.runtime.remember
21+ import androidx.compose.runtime.setValue
1822import androidx.compose.ui.Modifier
1923import androidx.lifecycle.lifecycleScope
2024import com.opacitylabs.opacitycore.JsonConverter
@@ -59,6 +63,22 @@ class MainActivity : ComponentActivity() {
5963 enableEdgeToEdge()
6064 setContent {
6165 OpacityCoreExampleTheme {
66+ var showSuccessDialog by remember { mutableStateOf(false ) }
67+
68+ // Success dialog
69+ if (showSuccessDialog) {
70+ AlertDialog (
71+ onDismissRequest = { showSuccessDialog = false },
72+ title = { Text (" Success" ) },
73+ text = { Text (" Test flow completed successfully!" ) },
74+ confirmButton = {
75+ TextButton (onClick = { showSuccessDialog = false }) {
76+ Text (" OK" )
77+ }
78+ }
79+ )
80+ }
81+
6282 Scaffold (
6383 modifier = Modifier .fillMaxSize(),
6484 containerColor = androidx.compose.ui.graphics.Color .Black
@@ -174,6 +194,32 @@ class MainActivity : ComponentActivity() {
174194 }
175195 },
176196 ) { Text (text = " Uber Rider Profile" ) }
197+ Button (
198+ onClick = {
199+ lifecycleScope.launch {
200+ val res =
201+ OpacityCore .get(" test:open_browser_must_succeed" , null )
202+ res.fold(
203+ onSuccess = { value ->
204+ Log .e(
205+ " MainActivity" ,
206+ " Res: ${value} value"
207+ )
208+ showSuccessDialog = true
209+ },
210+ onFailure = {
211+ when (it) {
212+ is OpacityError -> Log .e(
213+ " MainActivity" ,
214+ " code: ${it.code} , message: ${it.message} "
215+ )
216+
217+ else -> Log .e(" MainActivity" , it.toString())
218+ }
219+ })
220+ }
221+ },
222+ ) { Text (text = " Test flow always succeeds" ) }
177223 }
178224 }
179225 }
0 commit comments