-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for autofill / focus lifecycle handling, added Paparazzi snapsh…
…ot test (#4)
- Loading branch information
Showing
12 changed files
with
110 additions
and
55 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
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
24 changes: 0 additions & 24 deletions
24
ccp/src/androidTest/java/com/togitech/ccp/ExampleInstrumentedTest.kt
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.togitech.ccp | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
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.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import app.cash.paparazzi.DeviceConfig.Companion.PIXEL_5 | ||
import app.cash.paparazzi.Paparazzi | ||
import com.togitech.ccp.component.TogiCountryCodePicker | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class CountryCodePickTest { | ||
@get:Rule | ||
val paparazzi = Paparazzi( | ||
deviceConfig = PIXEL_5, | ||
theme = "android:Theme.Material.Light.NoActionBar", | ||
) | ||
|
||
@Test | ||
fun test() { | ||
paparazzi.snapshot { | ||
Column( | ||
modifier = Modifier | ||
.verticalScroll(rememberScrollState()) | ||
.fillMaxSize(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
val phoneNumber = rememberSaveable { mutableStateOf("") } | ||
val fullPhoneNumber = rememberSaveable { mutableStateOf("") } | ||
var isNumberValid: Boolean by rememberSaveable { mutableStateOf(false) } | ||
|
||
TogiCountryCodePicker( | ||
text = "text", | ||
onValueChange = { (code, phone), isValid -> | ||
phoneNumber.value = phone | ||
fullPhoneNumber.value = code + phone | ||
isNumberValid = isValid | ||
}, | ||
) | ||
Spacer(modifier = Modifier.height(10.dp)) | ||
|
||
Text( | ||
text = "Full Phone Number: ${fullPhoneNumber.value}", | ||
color = if (!isNumberValid) Color.Red else Color.Green, | ||
) | ||
|
||
Text( | ||
text = "Only Phone Number: ${phoneNumber.value}", | ||
color = if (!isNumberValid) Color.Red else Color.Green, | ||
) | ||
} | ||
} | ||
} | ||
} |
Binary file added
BIN
+18.4 KB
ccp/src/test/snapshots/images/com.togitech.ccp_CountryCodePickTest_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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