-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for 10.0.0-beta05 release (#174)
* Remove Polling (#169) * Add Async Enhanced KYC endpoint (#168) * Add Async Enhanced KYC endpoint * Fix URL * Setting up loading button (#170) * setting up loading button * fixed pr comments * loading button tests * Include ID Info in Document Verification network request (#173) * Include ID Info in network request * Update CHANGELOG * Fix test * Update CHANGELOG --------- Co-authored-by: Juma Allan <[email protected]>
- Loading branch information
Showing
34 changed files
with
1,966 additions
and
444 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
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
58 changes: 58 additions & 0 deletions
58
lib/src/androidTest/java/com/smileidentity/compose/components/LoadingButtonTest.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,58 @@ | ||
package com.smileidentity.compose.components | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsNotDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import org.junit.Assert | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class LoadingButtonTest { | ||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testContinueButtonIsClickable() { | ||
// given | ||
var callbackInvoked = false | ||
val onConfirmButtonClicked = { callbackInvoked = true } | ||
val continueButtonText = "Continue" | ||
|
||
// when | ||
composeTestRule.setContent { | ||
LoadingButton( | ||
continueButtonText, | ||
onClick = onConfirmButtonClicked, | ||
) | ||
} | ||
composeTestRule.onNodeWithText(continueButtonText).performClick() | ||
|
||
// then | ||
Assert.assertTrue(callbackInvoked) | ||
} | ||
|
||
@Test | ||
fun testContinueButtonShowsLoadingStateWhenClicked() { | ||
// given | ||
var callbackInvoked = false | ||
val onConfirmButtonClicked = { callbackInvoked = true } | ||
val continueButtonText = "Continue" | ||
|
||
// when | ||
composeTestRule.setContent { | ||
LoadingButton( | ||
continueButtonText, | ||
onClick = onConfirmButtonClicked, | ||
) | ||
} | ||
composeTestRule.onNodeWithText(continueButtonText).performClick() | ||
|
||
// then | ||
Assert.assertTrue(callbackInvoked) | ||
composeTestRule.onNodeWithText(continueButtonText).assertIsNotDisplayed() | ||
composeTestRule.onNodeWithTag("circular_loading_indicator").assertIsDisplayed() | ||
} | ||
} |
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
54 changes: 54 additions & 0 deletions
54
lib/src/main/java/com/smileidentity/compose/components/LoadingButton.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,54 @@ | ||
package com.smileidentity.compose.components | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.CircularProgressIndicator | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.unit.dp | ||
import com.smileidentity.R | ||
import com.smileidentity.compose.preview.SmilePreviews | ||
|
||
@Composable | ||
fun LoadingButton( | ||
buttonText: String, | ||
modifier: Modifier = Modifier, | ||
loading: Boolean = false, | ||
onClick: () -> Unit, | ||
) { | ||
Button( | ||
onClick = onClick, | ||
modifier = modifier.fillMaxWidth(), | ||
enabled = !loading, | ||
) { | ||
Box { | ||
if (loading) { | ||
CircularProgressIndicator( | ||
color = colorResource(id = R.color.si_color_accent), | ||
strokeWidth = 2.dp, | ||
modifier = Modifier | ||
.size(15.dp) | ||
.align(Alignment.Center) | ||
.testTag("circular_loading_indicator"), | ||
) | ||
} else { | ||
Text(text = buttonText) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@SmilePreviews | ||
@Composable | ||
fun LoadingButtonPreview() { | ||
LoadingButton( | ||
buttonText = "Continue", | ||
onClick = {}, | ||
) | ||
} |
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
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
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
Oops, something went wrong.