-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e624323
commit ffa2b0f
Showing
4 changed files
with
100 additions
and
78 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
...sign-system/src/main/kotlin/xyz/ksharma/krail/design/system/components/TextFieldButton.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,72 @@ | ||
package xyz.ksharma.krail.design.system.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import xyz.ksharma.krail.design.system.LocalContentAlpha | ||
import xyz.ksharma.krail.design.system.LocalTextColor | ||
import xyz.ksharma.krail.design.system.LocalTextStyle | ||
import xyz.ksharma.krail.design.system.preview.ComponentPreviews | ||
import xyz.ksharma.krail.design.system.theme.KrailTheme | ||
import xyz.ksharma.krail.design.system.tokens.TextFieldTokens | ||
import xyz.ksharma.krail.design.system.tokens.TextFieldTokens.TextFieldHeight | ||
|
||
/** | ||
* A button that looks like a text field. | ||
* | ||
* @param modifier The modifier to apply to this component. | ||
* @param enabled Whether the button is enabled. | ||
* @param content The content of the button. | ||
* | ||
* TODO - how to ensure modifiers for TextField and TextFieldButton are consistent? | ||
*/ | ||
@Composable | ||
fun TextFieldButton( | ||
modifier: Modifier = Modifier, | ||
enabled: Boolean = true, | ||
content: @Composable () -> Unit, | ||
) { | ||
val contentAlpha = if (enabled) 1f else TextFieldTokens.DisabledLabelOpacity | ||
|
||
CompositionLocalProvider( | ||
LocalTextColor provides KrailTheme.colors.onSecondaryContainer, | ||
LocalTextStyle provides KrailTheme.typography.titleLarge, | ||
LocalContentAlpha provides contentAlpha, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.height(TextFieldHeight) | ||
.background( | ||
shape = RoundedCornerShape(TextFieldHeight.div(2)), | ||
color = KrailTheme.colors.secondaryContainer | ||
) | ||
.padding(horizontal = 16.dp, vertical = 4.dp), | ||
contentAlignment = Alignment.CenterStart, | ||
) { | ||
content() | ||
} | ||
} | ||
} | ||
|
||
// region Previews | ||
|
||
@ComponentPreviews | ||
@Composable | ||
private fun TextFieldButtonPreview() { | ||
KrailTheme { | ||
TextFieldButton { | ||
Text(text = "Search") | ||
} | ||
} | ||
} | ||
|
||
// endregion |
54 changes: 12 additions & 42 deletions
54
...-planner/ui/src/main/kotlin/xyz/ksharma/krail/trip_planner/ui/components/SearchStopRow.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
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