Skip to content

Commit

Permalink
Change SignInWithGoogleButton to visually support disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
wmontwe committed Nov 9, 2023
1 parent 86ed427 commit 9faaf96
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedButton
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
Expand All @@ -24,11 +23,12 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import app.k9mail.core.ui.compose.common.PreviewDevices
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import app.k9mail.feature.account.oauth.R
import androidx.compose.material.Button as MaterialButton

/**
* A sign in with Google button, following the Google Branding Guidelines.
Expand All @@ -43,10 +43,10 @@ fun SignInWithGoogleButton(
enabled: Boolean = true,
isLight: Boolean = MaterialTheme.colors.isLight,
) {
OutlinedButton(
MaterialButton(
onClick = onClick,
modifier = modifier,
colors = ButtonDefaults.outlinedButtonColors(
colors = ButtonDefaults.buttonColors(
contentColor = getTextColor(isLight),
backgroundColor = getSurfaceColor(isLight),
),
Expand Down Expand Up @@ -90,7 +90,6 @@ fun SignInWithGoogleButton(
id = R.string.account_oauth_sign_in_with_google_button,
),
style = TextStyle(
color = getTextColor(isLight),
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
letterSpacing = 1.25.sp,
Expand Down Expand Up @@ -127,7 +126,7 @@ private fun getTextColor(isLight: Boolean): Color {
}
}

@PreviewDevices
@Preview(showBackground = true)
@Composable
internal fun SignInWithGoogleButtonPreview() {
PreviewWithThemes {
Expand All @@ -136,3 +135,14 @@ internal fun SignInWithGoogleButtonPreview() {
)
}
}

@Preview(showBackground = true)
@Composable
internal fun SignInWithGoogleButtonDisabledPreview() {
PreviewWithThemes {
SignInWithGoogleButton(
onClick = {},
enabled = false,
)
}
}

0 comments on commit 9faaf96

Please sign in to comment.