-
Notifications
You must be signed in to change notification settings - Fork 20
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
[올리브] 회원가입 미션 1, 2단계 제출합니다. #2
base: kimhm0728
Are you sure you want to change the base?
Changes from all commits
8735210
466ead5
69d1270
83f8a29
a53bf72
405eac7
1884f7c
a18c357
6b78e76
f55c3ae
031ae71
917ce0e
135f602
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
# android-signup# android-signup | ||
# android-signup | ||
## 1단계 - 컴포즈 기초 | ||
### 기능 요구사항 | ||
- [x] text() 테스트를 성공하도록 수정한다. | ||
- [x] column() 테스트를 성공하도록 수정한다. | ||
- [x] button() 테스트를 성공하도록 수정한다. | ||
|
||
## 2단계 - 회원가입(뷰) | ||
### 기능 요구사항 | ||
- [x] 디자인 시안을 참고하여 회원가입 뷰를 구현한다. | ||
|
||
### 프로그래밍 요구사항 | ||
- [x] ViewModel, Hilt 등은 활용하지 않는다. | ||
- [x] 컴포저블 함수가 너무 많은 일을 하지 않도록 분리한다. | ||
- [x] Material3 Button, TextField를 활용한다. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package woowacourse.signup | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.test.assert | ||
import androidx.compose.ui.test.assertCountEquals | ||
import androidx.compose.ui.test.assertIsNotEnabled | ||
import androidx.compose.ui.test.hasText | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onChildren | ||
import androidx.compose.ui.test.onFirst | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.sp | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class LayoutBasicsTest { | ||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
Comment on lines
+28
to
+31
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.
단순 질문입니다,,하핳 |
||
@Test | ||
fun text() { | ||
// given | ||
val text = "안녕 난 컴포즈야~" | ||
composeTestRule.setContent { | ||
Text( | ||
text = text, | ||
color = Color.Blue, | ||
style = TextStyle( | ||
fontSize = 26.sp, | ||
fontWeight = FontWeight.Bold, | ||
fontFamily = FontFamily.SansSerif | ||
), | ||
) | ||
} | ||
|
||
// then | ||
composeTestRule | ||
.onNodeWithText(text) | ||
.assertExists() | ||
} | ||
|
||
@Test | ||
fun column() { | ||
// given | ||
composeTestRule.setContent { | ||
Column( | ||
modifier = Modifier.testTag("이름") | ||
) { | ||
Text(text = "깜포즈", color = Color.Red) | ||
Text(text = "킴포즈", color = Color.Cyan) | ||
Text(text = "끔포즈", color = Color.Yellow) | ||
} | ||
} | ||
|
||
// then | ||
composeTestRule.onNodeWithTag("이름") | ||
.onChildren() | ||
.assertCountEquals(3) | ||
.onFirst() | ||
.assert(hasText("깜포즈")) | ||
} | ||
|
||
@Test | ||
fun button() { | ||
// given | ||
composeTestRule.setContent { | ||
val enabled = remember { mutableStateOf(true) } | ||
Button( | ||
onClick = { enabled.value = !enabled.value }, | ||
enabled = enabled.value, | ||
modifier = Modifier.testTag("버튼") | ||
) { | ||
Text(text = "클릭해주세요") | ||
} | ||
} | ||
|
||
// when | ||
val button = composeTestRule | ||
.onNodeWithTag("버튼") | ||
.performClick() | ||
|
||
// then | ||
button.assertIsNotEnabled() | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package woowacourse.signup | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
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.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.input.PasswordVisualTransformation | ||
import androidx.compose.ui.text.input.VisualTransformation | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import woowacourse.signup.ui.theme.Blue50 | ||
import woowacourse.signup.ui.util.FillMaxTheme | ||
import woowacourse.signup.ui.util.Space | ||
|
||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
FillMaxTheme { | ||
SignUpLayout() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SignUpLayout() { | ||
Column { | ||
SignUpTitle() | ||
Space(dp = 18) | ||
SignUpInput(titleId = R.string.username_input) | ||
SignUpInput(titleId = R.string.email_input) | ||
SignUpInput(titleId = R.string.password_input, isPassword = true) | ||
SignUpInput(titleId = R.string.password_confirm_input, isPassword = true) | ||
Comment on lines
+52
to
+55
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. 만약에 SignUpInput(titleId = R.string.username_input)
SignUpInput(titleId = R.string.username_input)
SignUpInput(titleId = R.string.username_input)
SignUpInput(titleId = R.string.username_input)
SignUpInput(titleId = R.string.username_input)
SignUpInput(titleId = R.string.username_input)
SignUpInput(titleId = R.string.username_input)
|
||
Space(dp = 24) | ||
SignUpButton() | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SignUpTitle() { | ||
Text( | ||
text = stringResource(id = R.string.sign_up_title), | ||
fontSize = 26.sp, | ||
color = Color.Black, | ||
fontWeight = FontWeight.W700, | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(top = 60.dp) | ||
) | ||
} | ||
|
||
@Composable | ||
private fun SignUpInput( | ||
@StringRes titleId: Int, | ||
isPassword: Boolean = false, | ||
) { | ||
var input by remember { mutableStateOf("") } | ||
|
||
TextField( | ||
label = { SignUpInputLabel(titleId) }, | ||
value = input, | ||
onValueChange = { input = it }, | ||
textStyle = TextStyle( | ||
fontSize = 16.sp, | ||
fontWeight = FontWeight.W400, | ||
), | ||
singleLine = true, | ||
colors = TextFieldDefaults.colors( | ||
focusedIndicatorColor = Blue50, | ||
focusedLabelColor = Blue50, | ||
cursorColor = Blue50, | ||
), | ||
visualTransformation = if (isPassword) PasswordVisualTransformation() else VisualTransformation.None, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp, vertical = 18.dp), | ||
) | ||
} | ||
|
||
@Composable | ||
private fun SignUpInputLabel(@StringRes labelId: Int) { | ||
Text( | ||
text = stringResource(id = labelId), | ||
fontWeight = FontWeight.W400, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun SignUpButton() { | ||
Button( | ||
onClick = { | ||
// TODO | ||
}, | ||
contentPadding = PaddingValues(0.dp), | ||
colors = ButtonDefaults.buttonColors( | ||
containerColor = Blue50, | ||
), | ||
modifier = | ||
Modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 32.dp), | ||
) { | ||
Text( | ||
text = stringResource(id = R.string.sign_up_button), | ||
fontSize = 14.sp, | ||
fontWeight = FontWeight.W500, | ||
modifier = Modifier.padding(vertical = 15.dp) | ||
) | ||
} | ||
} | ||
Comment on lines
+111
to
+133
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. 여러 곳에서 다양한 크기의 |
||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun MainActivityPreview() { | ||
FillMaxTheme { | ||
SignUpLayout() | ||
} | ||
} |
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.
굿굿