Skip to content

Commit

Permalink
created a compose theme to avoid using resource dimens. addressed com…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
lalwani committed Jun 27, 2024
1 parent 95e0a19 commit 90236f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,27 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.uber.sdk2.auth.ui.theme.UberBlack
import com.uber.sdk2.auth.ui.theme.UberBlack90
import com.uber.sdk2.auth.ui.theme.UberDimens
import com.uber.sdk2.auth.ui.theme.UberTypography
import com.uber.sdk2.auth.ui.theme.UberWhite
import com.uber.sdk2.auth.ui.theme.UberWhite40
import com.uber.sdk2.core.R

@Composable
fun UberAuthButton(
isWhite: Boolean = false,
shape: Shape = MaterialTheme.shapes.small,
shape: Shape = MaterialTheme.shapes.large,
onClick: () -> Unit,
) {
val text = stringResource(id = com.uber.sdk2.auth.R.string.ub__sign_in)
val interactionSource = remember { MutableInteractionSource() }
val isPressed = interactionSource.collectIsPressedAsState().value

val backgroundColor =
if (isPressed) {
if (isWhite) UberWhite40 else UberBlack90
MaterialTheme.colorScheme.onSecondary
} else {
if (isWhite) UberWhite else UberBlack
MaterialTheme.colorScheme.onPrimary
}

val textColor = MaterialTheme.colorScheme.onPrimary
val textColor = MaterialTheme.colorScheme.primary

val iconResId = if (isWhite) R.drawable.uber_logotype_black else R.drawable.uber_logotype_white

Expand All @@ -66,6 +61,7 @@ fun UberAuthButton(
colors =
ButtonDefaults.buttonColors(containerColor = backgroundColor, contentColor = textColor),
shape = shape,
interactionSource = interactionSource,
) {
Icon(
painter = painterResource(id = iconResId),
Expand All @@ -75,7 +71,7 @@ fun UberAuthButton(
Text(
text = text.uppercase(),
color = textColor,
style = UberTypography.bodySmall,
style = UberTypography.bodyMedium,
modifier = Modifier.padding(UberDimens.standardPadding).wrapContentWidth(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ val UberButtonShapes =
Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(8.dp),
large = RoundedCornerShape(4.dp),
large = RoundedCornerShape(16.dp),
)

object UberDimens {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,9 @@ import androidx.compose.runtime.Composable
fun UberTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val colors =
if (darkTheme) {
darkColorScheme(
primary = UberBlack,
onPrimary = UberWhite,
secondary = UberWhite,
onSecondary = UberBlack,
background = UberBlack90,
surface = UberBlack90,
onBackground = UberWhite,
onSurface = UberWhite,
)
darkColorScheme(primary = UberBlack, onPrimary = UberWhite, onSecondary = UberWhite40)
} else {
lightColorScheme(
primary = UberBlack,
onPrimary = UberWhite,
secondary = UberBlack90,
onSecondary = UberWhite,
background = UberWhite,
surface = UberWhite40,
onBackground = UberBlack,
onSurface = UberBlack,
)
lightColorScheme(primary = UberWhite, onPrimary = UberBlack, onSecondary = UberBlack90)
}

MaterialTheme(
Expand Down
20 changes: 0 additions & 20 deletions authentication/src/main/res/values/dimens.xml

This file was deleted.

0 comments on commit 90236f8

Please sign in to comment.