-
Notifications
You must be signed in to change notification settings - Fork 2
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
[YDS-#218] Atom - SuffixTextField 구현 #268
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a1b05e5
feat : SuffixTextField 구현
leeeyubin d059950
chore : SuffixTextField 수정
leeeyubin 1fdb703
chore : Preview 추가
leeeyubin b270a38
chore : versionName 2.5.10 -> 2.5.11
leeeyubin 86aea11
fix : text, suffixLabel 기본값 제거
leeeyubin 06177d1
fix : versionName 2.6.0으로 수정
leeeyubin f01dbc1
fix : isDisabled 네이밍 수정
leeeyubin 396a063
fix : 코드리뷰 반영
leeeyubin a162d4a
fix : hintText 8dp로 수정
leeeyubin 640432e
fix : TextField의 hintText 8dp로 수정
leeeyubin 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
141 changes: 141 additions & 0 deletions
141
compose/src/main/java/com/yourssu/design/system/compose/atom/SuffixTextField.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,141 @@ | ||
package com.yourssu.design.system.compose.atom | ||
|
||
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.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.OutlinedTextField | ||
import androidx.compose.material.TextFieldDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.yourssu.design.system.compose.YdsTheme | ||
import com.yourssu.design.system.compose.base.YdsText | ||
|
||
@Composable | ||
fun SuffixTextField( | ||
text: String, | ||
suffixLabel: String, | ||
modifier: Modifier = Modifier, | ||
isError: Boolean = false, | ||
isDisabled: Boolean = false, | ||
placeHolder: String = "", | ||
hintText: String = "", | ||
onValueChange: (value: String) -> Unit, | ||
keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), | ||
) { | ||
Column(modifier = modifier) { | ||
OutlinedTextField( | ||
value = text, | ||
onValueChange = onValueChange, | ||
modifier = Modifier.fillMaxWidth(), | ||
shape = RoundedCornerShape(8.dp), | ||
colors = TextFieldDefaults.outlinedTextFieldColors( | ||
backgroundColor = YdsTheme.colors.inputFieldElevated, | ||
cursorColor = YdsTheme.colors.textPointed, | ||
errorBorderColor = YdsTheme.colors.textWarned, | ||
unfocusedBorderColor = Color.Transparent, | ||
focusedBorderColor = YdsTheme.colors.textPointed, | ||
disabledTextColor = YdsTheme.colors.textDisabled, | ||
disabledBorderColor = Color.Transparent, | ||
textColor = YdsTheme.colors.textSecondary, | ||
), | ||
isError = isError, | ||
enabled = !isDisabled, | ||
placeholder = { | ||
YdsText( | ||
text = placeHolder, | ||
style = YdsTheme.typography.body1, | ||
color = YdsTheme.colors.textTertiary, | ||
) | ||
}, | ||
trailingIcon = { | ||
YdsText( | ||
modifier = Modifier.padding(16.dp), | ||
text = suffixLabel, | ||
style = YdsTheme.typography.body1, | ||
color = YdsTheme.colors.textTertiary, | ||
) | ||
}, | ||
textStyle = YdsTheme.typography.body1.toTextStyle(), | ||
keyboardOptions = keyboardOptions, | ||
singleLine = true, | ||
) | ||
if (hintText.isNotEmpty()) { | ||
Row(modifier = Modifier.padding(top = 8.dp)) { | ||
Spacer( | ||
modifier = Modifier | ||
.width(16.dp), | ||
) | ||
YdsText( | ||
text = hintText, | ||
style = YdsTheme.typography.caption1, | ||
color = if (isError) { | ||
YdsTheme.colors.textWarned | ||
} else if (!isDisabled) { | ||
YdsTheme.colors.textDisabled | ||
} else { | ||
YdsTheme.colors.textTertiary | ||
}, | ||
) | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreviewSuffixTextField() { | ||
var isError by remember { mutableStateOf(false) } | ||
var text1 by rememberSaveable { mutableStateOf("") } | ||
var text2 by rememberSaveable { mutableStateOf("") } | ||
var text3 by rememberSaveable { mutableStateOf("") } | ||
|
||
Column { | ||
SuffixTextField( | ||
text = text1, | ||
isError = isError, isDisabled = false, | ||
placeHolder = "플레이스 홀더", | ||
onValueChange = { value -> | ||
text1 = value | ||
}, | ||
hintText = "힌트 텍스트", | ||
modifier = Modifier.padding(10.dp), | ||
suffixLabel = "@soongsil.ac.kr", | ||
) | ||
|
||
SuffixTextField( | ||
text = text2, | ||
isDisabled = true, | ||
onValueChange = { value -> | ||
text2 = value | ||
}, | ||
hintText = "힌트 텍스트", | ||
modifier = Modifier.padding(bottom = 10.dp), | ||
suffixLabel = "@soongsil.ac.kr", | ||
) | ||
|
||
SuffixTextField( | ||
text = text3, | ||
isError = true, | ||
hintText = "힌트 텍스트", | ||
suffixLabel = "@soongsil.ac.kr", | ||
onValueChange = { value -> | ||
text3 = value | ||
}, | ||
) | ||
} | ||
} |
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,2 +1,2 @@ | ||
versionName=2.5.10 | ||
versionName=2.6.0 | ||
#자동 배포를 위해서 버전은 여기 한 군데에서 관리하면 된다 |
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.
엇 제가 피그마 확인해봤을 땐 8dp던데 16dp였을까요..?
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.
확인해보니 8dp가 맞네요!! 다음엔 더 꼼꼼히 보겠습니닷
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.
현재 다른
TextField
들도hintText
는 8dp인데 16dp로 되어있는 것 같습니다..! 같이 수정해놓을까요??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.
그럼 확인하고 그렇게 해주시면 감사하겠습니다!
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.
넵 수정 완료했습니다!