Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions app/src/main/java/com/auth0/android/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class MainActivity : ComponentActivity() {
val webAuthProvider by lazy {
WebAuthProvider.login(account)
.withScheme(getString(R.string.com_auth0_scheme))
.withAudience(audience)
}

private val logoutBuilder by lazy {
Expand Down Expand Up @@ -211,9 +210,16 @@ fun SampleApp(
onContinueWithEmail = { email, password ->
when {
email.isBlank() -> authViewModel.sendLoginError("Email is required")
!android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() -> authViewModel.sendLoginError("Enter a valid email address")
!android.util.Patterns.EMAIL_ADDRESS.matcher(email)
.matches() -> authViewModel.sendLoginError("Enter a valid email address")

password.isBlank() -> authViewModel.sendLoginError("Password is required")
else -> authViewModel.loginWithPassword(email, password, authClient, audience)
else -> authViewModel.loginWithPassword(
email,
password,
authClient,
audience
)
}
},
onOtherMethods = { navController.navigate(AppRoute.ExploreLogin) },
Expand All @@ -228,9 +234,6 @@ fun SampleApp(
)
}

composable<AppRoute.GoogleLogin> {
// Add support for Google Login
}

composable<AppRoute.Dashboard> {
DashboardScreen(
Expand Down Expand Up @@ -271,7 +274,11 @@ fun SampleApp(
}

composable<AppRoute.UpdateFullName> {
val nameParts =
userProfile.name.trim().split("\\s+".toRegex(), limit = 2).map { it.trim() }
UpdateFullNameScreen(
currentFirstName = nameParts.getOrElse(0) { "" },
currentLastName = nameParts.getOrElse(1) { "" },
onBack = { navController.popBackStack() }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.unit.dp
import com.auth0.android.sample.ui.theme.isAuth0DarkTheme
import com.auth0.universalcomponents.theme.Auth0Theme
Expand All @@ -41,6 +42,7 @@ fun FactorCard(
description: String,
icon: Painter,
isSelected: Boolean = false,
enabled: Boolean = true,
onClick: () -> Unit = {}
) {
val colors = Auth0Theme.colors
Expand All @@ -59,7 +61,10 @@ fun FactorCard(

Card(
onClick = onClick,
modifier = Modifier.fillMaxWidth(),
enabled = enabled,
modifier = Modifier
.fillMaxWidth()
.alpha(if (enabled) 1f else 0.4f),
shape = shapes.large,
colors = CardDefaults.cardColors(containerColor = cardBackground),
border = BorderStroke(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
Expand All @@ -37,6 +38,7 @@ fun NavigationGridCard(
label: String,
icon: Int,
selected: Boolean = false,
enabled: Boolean = true,
onClick: () -> Unit
) {
val colors = Auth0Theme.colors
Expand All @@ -48,7 +50,8 @@ fun NavigationGridCard(
Card(
modifier = Modifier
.height(132.dp)
.clickable { onClick() },
.alpha(if (enabled) 1f else 0.4f)
.then(if (enabled) Modifier.clickable { onClick() } else Modifier),
shape = shapes.extraLarge,
colors = CardDefaults.cardColors(containerColor = colors.backgroundLayerTop),
border = BorderStroke(1.dp, colors.borderDefault),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fun AppearanceScreen(
onClick = { appearanceViewModel.selectTheme(index) },
colors = RadioButtonDefaults.colors(
selectedColor = if (isDark) colors.backgroundAccent else colors.backgroundPrimary,
unselectedColor = colors.borderDefault
unselectedColor = if (isDark) colors.backgroundAccent else colors.backgroundPrimary
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.auth0.android.sample.ui.screens

import android.widget.Toast
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
Expand All @@ -24,6 +25,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import com.auth0.android.sample.ui.components.Auth0LogoHeader
Expand All @@ -38,7 +40,8 @@ private enum class LoginOption { Embedded, Hosted }
* Pre-login screen for choosing the sign-in method.
*
* Cards are selectable — tapping a card sets the selection state. The Continue button
* navigates to the chosen flow and is disabled until a card is selected.
* navigates to the chosen flow. Hosted Login is selected by default so the button is
* enabled immediately on load.
*
* @param onEmbeddedLogin Navigate to embedded login
* @param onHostedLogin Navigate to hosted (redirect) Auth0 login
Expand All @@ -50,7 +53,8 @@ fun ChooseSignInScreen(
onHostedLogin: () -> Unit,
onSettings: () -> Unit = {}
) {
var selectedOption by remember { mutableStateOf<LoginOption?>(null) }
var selectedOption by remember { mutableStateOf<LoginOption?>(LoginOption.Hosted) }
val context = LocalContext.current
Comment on lines +56 to +57
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selectedOption now defaults to Hosted, which means the Continue button is enabled immediately. The KDoc above still states the button is disabled until a card is selected; either update the documentation to reflect the new default behavior or restore the previous null default so the UI matches the documented flow.

Copilot uses AI. Check for mistakes.
val typography = Auth0Theme.typography
val dimensions = Auth0Theme.dimensions
val shapes = Auth0Theme.shapes
Expand Down Expand Up @@ -90,7 +94,8 @@ fun ChooseSignInScreen(
description = "Total brand control and low user frictions",
icon = painterResource(com.auth0.android.sample.R.drawable.ic_embedded_login),
isSelected = selectedOption == LoginOption.Embedded,
onClick = { selectedOption = LoginOption.Embedded }
enabled = false,
onClick = { Toast.makeText(context, "Coming soon", Toast.LENGTH_SHORT).show() }
)

Spacer(modifier = Modifier.height(dimensions.spacingMd))
Expand Down Expand Up @@ -147,7 +152,7 @@ fun ChooseSignInScreen(
)
Text(
text = "Appearance",
style = typography.label,
style = typography.body,
color = colors.textBold
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ fun DashboardScreen(
verticalArrangement = Arrangement.spacedBy(dimensions.spacingMd)
) {
items(DashboardDestination.entries.toList()) { destination ->
val enabled = destination == DashboardDestination.Profile ||
destination == DashboardDestination.LoginSecurity
NavigationGridCard(
label = destination.label,
icon = destination.icon,
enabled = enabled,
onClick = { onNavigate(destination) }
)
}
Expand All @@ -100,7 +103,7 @@ fun DashboardScreen(
TextButton(onClick = onLogout) {
Text(
text = "Log out",
style = typography.label,
style = typography.body,
color = colors.textBold
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,12 @@ private fun ProfileInfoRow(
color = colors.textBold,
modifier = Modifier.weight(1f)
)
Icon(
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
contentDescription = null,
tint = colors.textDefault
)
if (onClick != null) {
Icon(
imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
contentDescription = null,
tint = colors.textDefault
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class AuthViewModel : ViewModel() {
try {
val user = credentials.user
_userProfile.value = UserProfile(
name = user.name ?: user.nickname ?: "User",
name = user.nickname ?: "User",
email = user.email ?: "",
pictureUrl = user.pictureURL ?: ""
)
Expand Down
Loading