-
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.
- Loading branch information
Showing
37 changed files
with
1,275 additions
and
44 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
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
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
37 changes: 37 additions & 0 deletions
37
core/src/main/java/com/terning/core/designsystem/textfield/NameTextField.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,37 @@ | ||
package com.terning.core.designsystem.textfield | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.SolidColor | ||
import com.terning.core.designsystem.theme.Black | ||
import com.terning.core.designsystem.theme.Grey300 | ||
import com.terning.core.designsystem.theme.Grey400 | ||
import com.terning.core.designsystem.theme.Grey500 | ||
import com.terning.core.designsystem.theme.TerningMain | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
|
||
@Composable | ||
fun NameTextField( | ||
text: String, | ||
onValueChange: (String) -> Unit, | ||
hint: String, | ||
helperMessage: String, | ||
helperIcon: Int? = null, | ||
helperColor: Color = TerningMain, | ||
) { | ||
TerningBasicTextField( | ||
value = text, | ||
onValueChange = onValueChange, | ||
textStyle = TerningTheme.typography.detail1, | ||
textColor = Black, | ||
drawLineColor = Grey500, | ||
cursorBrush = SolidColor(Grey400), | ||
hint = hint, | ||
hintColor = Grey300, | ||
showTextLength = true, | ||
maxTextLength = 12, | ||
helperMessage = helperMessage, | ||
helperIcon = helperIcon, | ||
helperColor = helperColor, | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
core/src/main/java/com/terning/core/designsystem/textfield/SearchTextField.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,29 @@ | ||
package com.terning.core.designsystem.textfield | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.SolidColor | ||
import com.terning.core.designsystem.theme.Grey300 | ||
import com.terning.core.designsystem.theme.Grey400 | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
|
||
@Composable | ||
fun SearchTextField( | ||
text: String, | ||
onValueChange: (String) -> Unit, | ||
hint: String, | ||
leftIcon: Int, | ||
) { | ||
// TerningBasicTextField( | ||
// value = text, | ||
// onValueChange = onValueChange, | ||
// textStyle = TerningTheme.typography.button3, | ||
// textColor = Grey400, | ||
// cursorBrush = SolidColor(Grey300), | ||
// drawLineColor = Grey300, | ||
// strokeWidth = 2f, | ||
// hint = hint, | ||
// hintColor = Grey300, | ||
// leftIcon = leftIcon, | ||
// leftIconColor = Grey400, | ||
// ) | ||
} |
134 changes: 134 additions & 0 deletions
134
core/src/main/java/com/terning/core/designsystem/textfield/TerningBasicTextField.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,134 @@ | ||
package com.terning.core.designsystem.textfield | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.foundation.text.KeyboardActions | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
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.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.LocalFocusManager | ||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.input.ImeAction | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.designsystem.theme.Grey300 | ||
import com.terning.core.designsystem.theme.TerningMain | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
import com.terning.core.designsystem.theme.White | ||
|
||
@Composable | ||
fun TerningBasicTextField( | ||
value: String, | ||
onValueChange: (String) -> Unit, | ||
textStyle: TextStyle, | ||
textColor: Color, | ||
hintColor: Color, | ||
drawLineColor: Color, | ||
helperColor: Color, | ||
cursorBrush: Brush, | ||
strokeWidth: Float = 1f, | ||
leftIcon: Int? = null, | ||
leftIconColor: Color = TerningMain, | ||
maxTextLength: Int? = null, | ||
showTextLength: Boolean = false, | ||
hint: String = "", | ||
helperMessage: String = "", | ||
helperIcon: Int? = null, | ||
) { | ||
val keyboardController = LocalSoftwareKeyboardController.current | ||
val focusManager = LocalFocusManager.current | ||
|
||
BasicTextField(value = value, | ||
onValueChange = onValueChange, | ||
singleLine = true, | ||
maxLines = 1, | ||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), | ||
keyboardActions = KeyboardActions(onDone = { | ||
keyboardController?.hide() | ||
focusManager.clearFocus() | ||
}), | ||
|
||
modifier = Modifier | ||
.fillMaxWidth() | ||
.background(White) | ||
.drawWithContent { | ||
val canvasWidth = size.width | ||
val canvasHeight = size.height | ||
|
||
drawContent() | ||
drawLine( | ||
color = drawLineColor, | ||
start = Offset(x = 0f, y = canvasHeight), | ||
end = Offset(x = canvasWidth, y = canvasHeight), | ||
strokeWidth = strokeWidth.dp.toPx(), | ||
) | ||
}, | ||
|
||
textStyle = textStyle.copy(color = textColor), | ||
cursorBrush = cursorBrush, | ||
|
||
decorationBox = { innerTextField -> | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
modifier = Modifier.padding(vertical = 8.dp) | ||
) { | ||
leftIcon?.let { | ||
Icon( | ||
painter = painterResource(id = it), | ||
contentDescription = null, | ||
tint = leftIconColor, | ||
) | ||
} | ||
Box(modifier = Modifier.weight(1f)) { | ||
if (value.isEmpty()) { | ||
Text( | ||
text = hint, | ||
style = textStyle, | ||
color = hintColor | ||
) | ||
} | ||
innerTextField() | ||
} | ||
if (showTextLength && maxTextLength != null) { | ||
Text( | ||
text = "${value.length}/$maxTextLength", | ||
style = TerningTheme.typography.button3, | ||
color = Grey300, | ||
) | ||
} | ||
} | ||
}) | ||
|
||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
modifier = Modifier.padding(vertical = 8.dp) | ||
) { | ||
helperIcon?.let { | ||
Icon( | ||
painter = painterResource(id = it), | ||
contentDescription = null, | ||
tint = helperColor, | ||
) | ||
} | ||
Text( | ||
text = helperMessage, | ||
style = TerningTheme.typography.detail3, | ||
color = helperColor, | ||
) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/com/terning/core/extension/LocalDateExt.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,6 @@ | ||
package com.terning.core.extension | ||
|
||
import java.time.LocalDate | ||
|
||
fun LocalDate.getStringAsTitle(): String = | ||
"${year}๋ ${monthValue.toString().padStart(2, '0')}์" |
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
Oops, something went wrong.