-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD/#19] TerningTextField #22
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
63e2097
[ADD/#19] TextField DecorationBox Add
arinming f3c312e
[FEAT/#19] TextField 속성 추가
arinming 3d47e7e
[FEAT/#19] SearchTextField 구현
arinming 54b355b
[FEAT/#19] NameTextField 구현
arinming 3e55a7e
[FEAT/#19] TextField helper 구현
arinming 8cd0618
[FEAT/#19] 완료 버튼으로 키보드 숨기기 구현
arinming 1064dd8
[REFACTOR/#19] 타이포 테마 적용 방식 변경
arinming 194e040
[REFACTOR/#19] 파라미터 정렬 변경
arinming 5ea9f2b
Merge branch 'refs/heads/develop' into add/#19-text-field
arinming 4af2441
[REFACTOR/#19] leftIconColor 기본값 설정
arinming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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, | ||
) | ||
} |
133 changes: 133 additions & 0 deletions
133
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,133 @@ | ||
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.graphics.SolidColor | ||
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 = TerningMain, | ||
cursorBrush: Brush = SolidColor(TerningMain), | ||
hint: String = "", | ||
hintColor: Color = TerningMain, | ||
strokeWidth: Float = 1f, | ||
drawLineColor: Color, | ||
leftIcon: Int? = null, | ||
leftIconColor: Color = TerningMain, | ||
maxTextLength: Int? = null, | ||
showTextLength: Boolean = false, | ||
helperMessage: String = "", | ||
helperIcon: Int? = null, | ||
helperColor: Color = TerningMain, | ||
) { | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요부분 줄바꿈해주면 더 보기 편할 것 같아요!! |
||
) | ||
} | ||
innerTextField() | ||
} | ||
if (showTextLength && maxTextLength != null) { | ||
Text( | ||
text = "${value.length}/$maxTextLength", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 진짜 짱이다 |
||
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, | ||
) | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분이 키보드 숨기는 부분인거 맞죠?!?? 진짜 최고다👍🏻👍🏻