-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Make almost all button depend on 3 standard buttons - Replace surface and onSurface with our own custom theme color - Set button standard height to material design default - Support bigger font sizes for buttons
- Loading branch information
Showing
29 changed files
with
499 additions
and
547 deletions.
There are no files selected for viewing
51 changes: 0 additions & 51 deletions
51
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ActionButton.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...oid/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/DeviceRevokedLoginButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.mullvad.mullvadvpn.compose.button | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import net.mullvad.mullvadvpn.R | ||
import net.mullvad.mullvadvpn.compose.state.DeviceRevokedUiState | ||
|
||
@Composable | ||
fun DeviceRevokedLoginButton(onClick: () -> Unit, state: DeviceRevokedUiState) { | ||
if (state == DeviceRevokedUiState.SECURED) { | ||
NegativeButton(text = stringResource(id = R.string.go_to_login), onClick = onClick) | ||
} else { | ||
VariantButton(text = stringResource(id = R.string.go_to_login), onClick = onClick) | ||
} | ||
} |
71 changes: 26 additions & 45 deletions
71
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ExternalActionButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,51 @@ | ||
package net.mullvad.mullvadvpn.compose.button | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.ButtonColors | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import net.mullvad.mullvadvpn.R | ||
import net.mullvad.mullvadvpn.lib.theme.AppTheme | ||
import net.mullvad.mullvadvpn.lib.theme.Dimens | ||
import net.mullvad.mullvadvpn.lib.theme.color.AlphaDisabled | ||
import net.mullvad.mullvadvpn.lib.theme.color.AlphaVisible | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewExternalActionButton() { | ||
private fun PreviewExternalButtonEnabled() { | ||
AppTheme { ExternalButton(onClick = {}, text = "Button", isEnabled = true) } | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewExternalButtonDisabled() { | ||
AppTheme { ExternalButton(onClick = {}, text = "Button", isEnabled = false) } | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewExternalButtonLongText() { | ||
AppTheme { | ||
ExternalActionButton(onClick = {}, colors = ButtonDefaults.buttonColors(), text = "Button") | ||
ExternalButton( | ||
onClick = {}, | ||
text = "Button text is long and is trying to take up space that is large", | ||
isEnabled = true | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun ExternalActionButton( | ||
fun ExternalButton( | ||
onClick: () -> Unit, | ||
colors: ButtonColors, | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
isEnabled: Boolean = true, | ||
) { | ||
ActionButton( | ||
VariantButton( | ||
text = text, | ||
onClick = onClick, | ||
colors = colors, | ||
modifier = modifier, | ||
isEnabled = isEnabled, | ||
) { | ||
ConstraintLayout(modifier = Modifier.fillMaxSize()) { | ||
val (title, logo) = createRefs() | ||
Text( | ||
text = text, | ||
textAlign = TextAlign.Center, | ||
style = MaterialTheme.typography.bodyMedium, | ||
modifier = | ||
Modifier.constrainAs(title) { | ||
end.linkTo(logo.start) | ||
centerTo(parent) | ||
} | ||
) | ||
Image( | ||
painter = painterResource(id = R.drawable.icon_extlink), | ||
contentDescription = null, | ||
modifier = | ||
Modifier.constrainAs(logo) { | ||
centerVerticallyTo(parent) | ||
end.linkTo(parent.end) | ||
} | ||
.padding(horizontal = Dimens.smallPadding) | ||
.alpha(if (isEnabled) AlphaVisible else AlphaDisabled) | ||
) | ||
} | ||
} | ||
icon = { | ||
Icon(painter = painterResource(id = R.drawable.icon_extlink), contentDescription = null) | ||
}, | ||
) | ||
} |
Oops, something went wrong.