-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD/#19] TextField DecorationBox Add
- Loading branch information
Showing
4 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
core/src/main/java/com/terning/core/designsystem/textfield/TerningTextField.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,68 @@ | ||
package com.terning.core.designsystem.textfield | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.drawWithContent | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.theme.TerningMain | ||
import com.terning.core.designsystem.theme.TerningTypography | ||
import com.terning.core.designsystem.theme.White | ||
|
||
@Composable | ||
fun TerningTextField( | ||
value: String, | ||
onValueChange: (String) -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
BasicTextField( | ||
value = value, | ||
onValueChange = onValueChange, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.background(White), | ||
textStyle = TerningTypography().button3, | ||
decorationBox = { innerTextField -> | ||
Column(modifier = Modifier.drawWithContent { | ||
drawContent() | ||
drawLine( | ||
color = TerningMain, | ||
start = Offset( | ||
x = 0f, | ||
y = size.height - 1.dp.toPx(), | ||
), | ||
end = Offset( | ||
x = size.width, | ||
y = size.height - 1.dp.toPx(), | ||
), | ||
strokeWidth = 2.dp.toPx(), | ||
) | ||
}) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_back), | ||
contentDescription = null, | ||
tint = TerningMain, | ||
) | ||
innerTextField() | ||
} | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
} | ||
} | ||
) | ||
} |
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
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