-
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
Feature/#11 메뉴 정보 입력 페이지 기능을 구현한다. #28
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ccd7a36
feat: 메뉴 제거 기능 구현
JJongmen 6a90222
feat: InputTextBox 컴포저블 사용자가 입력한 값 받을 수 있도록 콜백 추가
JJongmen f827191
feat: 메뉴 추가 기능 구현
JJongmen 6ca559e
feat: 가격 입력할 시에 숫자 배열 키보드 사용
JJongmen 7fa807e
feat: 입력값 검증 추가
JJongmen 3572708
feat: 메뉴 등록 버튼 클릭 시 메인 화면 이동
JJongmen 31613bf
refactor: InputTextBox 컴포저블 OutlinedTextField 사용하도록 수정
JJongmen 10b4319
feat: 잘못된 값 입력시 빨간색으로 잘못된 위치 표시
JJongmen 3b2632a
feat: 입력된 메뉴가 하나도 없을 시 메뉴 입력 완료 실패
JJongmen 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,24 +10,27 @@ import androidx.compose.foundation.layout.fillMaxWidth | |
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.ArrowDropDown | ||
import androidx.compose.material3.DropdownMenu | ||
import androidx.compose.material3.DropdownMenuItem | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.OutlinedTextField | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.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.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.focus.onFocusChanged | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.SpanStyle | ||
import androidx.compose.ui.text.buildAnnotatedString | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.text.input.TextFieldValue | ||
import androidx.compose.ui.text.withStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
|
@@ -44,11 +47,11 @@ fun GsTextBox( | |
modifier: Modifier, | ||
innerTextModifier: Modifier, | ||
) { | ||
val text by remember { mutableStateOf(TextFieldValue(hintText)) } | ||
var text by remember { mutableStateOf(TextFieldValue(hintText)) } | ||
var expanded by remember { mutableStateOf(false) } | ||
var selectedOption by remember { mutableStateOf("") } | ||
Column { | ||
TextTitle(title, isRequired, description) | ||
TextTitle(title, isRequired, description, Modifier) | ||
if (options != null) { | ||
DropdownTextBox( | ||
text, | ||
|
@@ -66,9 +69,11 @@ fun GsTextBox( | |
) | ||
} else { | ||
InputTextBox( | ||
text, | ||
innerTextModifier, | ||
modifier, | ||
modifier = innerTextModifier, | ||
hintText = text.text, | ||
onValueChange = { text = TextFieldValue(it) }, | ||
keyboardType = KeyboardType.Text, | ||
isError = false, | ||
) | ||
} | ||
} | ||
|
@@ -79,6 +84,7 @@ fun TextTitle( | |
title: String, | ||
isRequired: Boolean, | ||
description: String?, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Text( | ||
text = | ||
|
@@ -108,6 +114,8 @@ fun TextTitle( | |
description?.let { append(description) } | ||
} | ||
}, | ||
style = MaterialTheme.typography.titleSmall, | ||
modifier = modifier, | ||
) | ||
} | ||
|
||
|
@@ -168,51 +176,41 @@ private fun DropdownTextBox( | |
|
||
@Composable | ||
fun InputTextBox( | ||
hintText: TextFieldValue, | ||
modifier: Modifier, | ||
innerTextModifier: Modifier, | ||
modifier: Modifier = Modifier, | ||
hintText: String, | ||
onValueChange: (String) -> Unit, | ||
keyboardType: KeyboardType = KeyboardType.Text, | ||
isError: Boolean = false, | ||
Comment on lines
+182
to
+183
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.
|
||
) { | ||
var text by remember { | ||
mutableStateOf(hintText) | ||
} | ||
var isFocused by remember { | ||
mutableStateOf(false) | ||
var textState by remember { | ||
mutableStateOf("") | ||
} | ||
BasicTextField( | ||
value = text, | ||
onValueChange = { updatedText -> | ||
text = updatedText | ||
OutlinedTextField( | ||
value = textState, | ||
onValueChange = { | ||
textState = it | ||
onValueChange(it) | ||
}, | ||
singleLine = true, | ||
modifier = | ||
modifier | ||
.background(Color.Transparent) | ||
.border( | ||
1.dp, | ||
Color.LightGray, | ||
RoundedCornerShape(percent = 15), | ||
).onFocusChanged { focusState -> | ||
isFocused = focusState.isFocused | ||
if (isFocused && text == hintText) { | ||
text = TextFieldValue("") | ||
} else if (!isFocused && text.text.isEmpty()) { | ||
text = hintText | ||
} | ||
}, | ||
decorationBox = { innerTextField -> | ||
Row( | ||
modifier = innerTextModifier, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
if (!isFocused && text == hintText) { | ||
Text(hintText.text, color = Color.Gray) | ||
Spacer(modifier = Modifier.weight(1f)) | ||
} else { | ||
innerTextField() | ||
Spacer(modifier = Modifier.weight(1f)) | ||
} | ||
} | ||
placeholder = { | ||
Text( | ||
text = hintText, | ||
color = Color.Gray, | ||
style = MaterialTheme.typography.bodyLarge, | ||
) | ||
}, | ||
singleLine = true, | ||
colors = | ||
TextFieldDefaults.colors( | ||
unfocusedContainerColor = Color.Transparent, | ||
unfocusedIndicatorColor = Color.LightGray, | ||
focusedContainerColor = Color.Transparent, | ||
errorContainerColor = Color.Transparent, | ||
), | ||
shape = RoundedCornerShape(percent = 15), | ||
keyboardOptions = KeyboardOptions(keyboardType = keyboardType), | ||
textStyle = MaterialTheme.typography.bodyLarge, | ||
modifier = modifier, | ||
isError = isError, | ||
) | ||
} | ||
|
||
|
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.
Text 컴포저블 사용할 때 서체를 사용할 수 있더라구
서체 사용하면 fontWeight, fontSize, lineHeight, letterSpacing 이 이미 정의되어있는거라 일일히 지정하는 귀찮음을 없앨 수 있어서 적극활용해보면 좋을듯
https://developer.android.com/jetpack/compose/designsystems/material3?hl=ko&_gl=1*844823*_up*MQ..*_ga*MTc3NTg1NDM1NS4xNzA4MDEzMDkw*_ga_34B604LFFQ*MTcwODAxMzA4OS4xLjAuMTcwODAxMzA4OS4wLjAuMA..#typography