joelkanyi / kompose-country-code-picker

Kompose Country Code Picker is a Jetpack Compose library based on Material 3 (M3) that provides a country code picker for Android apps.
https://joelkanyi.github.io/kompose-country-code-picker/
Apache License 2.0
114 stars 13 forks source link

Can not preview the Country Code Picker. #37

Closed morarafrank closed 1 month ago

morarafrank commented 3 months ago

Kccp

morarafrank commented 3 months ago

java.lang.AssertionError: Unsupported Service: phone

joelkanyi commented 3 months ago

Thank you for reporting the issue, can you share a reproducible sample

joelkanyi commented 3 months ago

@morarafrank no need of sharing a sample, the issue is with compose previews and I have reported the issue to Google, lets see how it goes:

https://issuetracker.google.com/u/1/issues/333219064

joelkanyi commented 1 month ago

Hey @morarafrank because we cannot use TelephonyManager on preview, with the latest version of the library, on your preview just a default country code, it should work.

Example:

@Preview
@Composable
private fun Preview() {
    ComposePickerTheme {
        val state = rememberKomposeCountryCodePickerState(
            defaultCountryCode = "ke",
        )
        KomposeCountryCodePicker(
            modifier = Modifier.fillMaxWidth(),
            text = "",
            onValueChange = {},
            state = state,
        )
    }
}
Screenshot 2024-06-08 at 20 51 35