Skip to content

[Feature Request] Jetpack Compose Support for AuthUI #1917

Open
@jossiwolf

Description

@jossiwolf

I haven't worked with other FirebaseUI libraries, but I reckon that it'll be a feature request for most libraries :) I'm thinking that AuthUI could be a good place to start. Now that Compose is in beta, it'd be super awesome to provide experimental APIs for that.

Something like this:

@Composable
fun AppLoginScreen() {
    val navController = rememberNavController()
    FirebaseLoginScreen(
        onAuthenticated = { navController.navigate(...) }
    ) { authenticationMethods ->
        Column {
            Image(painterResource(R.drawable.bg_onboarding), contentDescription = null)
            Spacer(Modifier.height(32.dp))
            Text(stringResource(R.string.onboarding_title), style = titleTextStyle)
            Text(stringResource(R.string.onboarding_subtitle))
            authenticationMethods.forEach { method ->
                LoginButton(stringResource(method.name)) { requestAuthentication(method) }
            }
        }
    }
}

// API

@Composable
fun FirebaseLoginScreen(
    onAuthenticated: (response: IdpResponse) -> Unit,
    content: @Composable FirebaseLoginScreenScope.(
        authenticationMethods: List<AuthUI.IdpConfig>,
    ) -> Unit,
) {
    val authenticationMethods = listOf<AuthUI.IdpConfig>()
    FirebaseLoginScreenScope().content(authenticationMethods)
}

class FirebaseLoginScreenScope {

    fun requestAuthentication(method: AuthUI.IdpConfig) {
        ...
    }
}

I'd be super happy to contribute here if that's something you'd accept contributions for.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions