-
Notifications
You must be signed in to change notification settings - Fork 0
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주차/필수/Compose] Android UI 구현 기초 : 회원가입 및 로그인 #4
Conversation
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.
컴포즈 첨인데도 수고하셨어요!!!! 컴포즈는 뷰가 그대로 코드에 들어가서 반복되는 코드가 조금만 많아져도 코드 길이가 뿅 길어져서 재사용 할 수 있는 건 하는 게 가독성에 도움이 많이 된답니당 파이팅
app/src/main/AndroidManifest.xml
Outdated
@@ -13,7 +13,7 @@ | |||
android:theme="@style/Theme.NOWSOPTAndroid" | |||
tools:targetApi="31"> | |||
<activity | |||
android:name=".MainActivity" | |||
android:name=".SignInActivity" |
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.
SignIn, SignUp으로 맞춘거 편-안하네요..저도 그래야겠ㅇ어요
|
||
// Title | ||
Text( | ||
text = "SOPT에 온걸 환영해!", |
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 = stringResource(id = ) 로 구현하면 짱짱
modifier = Modifier.padding(10.dp), | ||
fontSize = 20.sp, | ||
fontWeight = FontWeight.Bold, | ||
textAlign = TextAlign.Center |
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.
동일한 size, weight, align이 적용되는 텍스트는 한 컴포저블로 묶으면 재사용하기 편하다는 사아실
value = ID, | ||
onValueChange = { ID = it }, | ||
modifier = Modifier | ||
.fillMaxWidth() |
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.
텍스트 필드도 마찬가지로 공통되는 부분을 한 컴포저블로 묶으면 어떤 value인지만 전달해줘서 이후 대규모 작업할 때 가독성이 훨씬 좋아질 것 같아용!
.fillMaxWidth() | ||
.padding(10.dp), | ||
label = { Text("비밀번호를 입력하세요") }, | ||
leadingIcon = { Icon(Icons.Filled.Lock, contentDescription = "PW Icon") }, |
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.
아이콘 설정 깨알같구 좋네용 ㅎㅎ
}, | ||
modifier = Modifier.padding(10.dp), | ||
colors = ButtonDefaults.buttonColors(containerColor = Color.Green), | ||
shape = RoundedCornerShape(8.dp) |
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.
버튼도 동일한 스타일이 반복되는 것 같아요!
대신 OutlineButton 활용하면 자동으로 코너세이프가 적용되어있어서 둥글둥글해여 이외에도 IconButton 등 여러 버튼이 많아서 찾아보면 좋을 것 같읍니다
.padding(10.dp), | ||
label = { Text("비밀번호를 입력하세요") }, | ||
leadingIcon = { Icon(Icons.Filled.Lock, contentDescription = "PW Icon") }, | ||
singleLine = true, |
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.
진짜 처음이라 저도 너무 막막했는데 진짜 고생하셨어요..!! 앞으로 컴포즈 열심히 해봐용
) { | ||
Greeting("Android") | ||
} | ||
MainScreen() |
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.
컴포즈에서 유독 screen이라는 표현을 자주 보는 것 같아요!
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.
activity를 쓰는 xml 대신 screen으로 선언하는 것처럼 보이네요 🧐
var PW by remember { mutableStateOf("") } | ||
val context = LocalContext.current | ||
|
||
// Title |
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.
리펙할때 주석 지워주세용
// Sign Up | ||
Button( | ||
onClick = { | ||
val intent = Intent(context, SignInActivity::class.java) |
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.
기능까지 모두 구현해서 시연영상 올려보도록 하죠~~!!
도움이 필요하시다면 언제든지 부르세요 파이팅입니다 😄
app/src/main/AndroidManifest.xml
Outdated
<activity | ||
android:name=".MainActivity" | ||
android:exported="false" | ||
android:theme="@style/Theme.NOWSOPTAndroid" /> | ||
<activity | ||
android:name=".SignUpActivity" | ||
android:exported="false" | ||
android:theme="@style/Theme.NOWSOPTAndroid" /> |
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.
activity를 하나만 쓰는 방법도 있다던데 같이 알아봐요~~!!
) { | ||
Greeting("Android") | ||
} | ||
MainScreen() |
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.
activity를 쓰는 xml 대신 screen으로 선언하는 것처럼 보이네요 🧐
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(horizontal = 30.dp), |
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.
예쁘게 전체 modifier를 넎어주셧네요 굿굿~
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
NOWSOPTAndroidTheme { |
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.
컴포즈 천재인가료????? 수고해씁니다
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
NOWSOPTAndroidTheme { | ||
MainScreen() | ||
val navController = rememberNavController() | ||
|
||
NavHost(navController = navController, startDestination = "SignIn") { | ||
composable("SignIn?ID={ID}&PW={PW}&Name={Name}&Place={Place}") { backStackEntry -> | ||
SignInScreen( | ||
navController = navController, | ||
ID = backStackEntry.arguments?.getString("ID") ?: "", | ||
PW = backStackEntry.arguments?.getString("PW") ?: "", | ||
Name = backStackEntry.arguments?.getString("Name") ?: "", | ||
Place = backStackEntry.arguments?.getString("Place") ?: "" | ||
) | ||
} | ||
composable("SignUp") { | ||
SignUpScreen(navController = navController) | ||
} | ||
composable("MyPage?ID={InputID}&PW={InputPW}&Name={Name}&Place={Place}") {backStackEntry -> | ||
MyPageScreen( | ||
ID = backStackEntry.arguments?.getString("InputID") ?: "", | ||
PW = backStackEntry.arguments?.getString("InputPW") ?: "", | ||
Name = backStackEntry.arguments?.getString("Name") ?: "", | ||
Place = backStackEntry.arguments?.getString("Place") ?: "") |
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.
여러 액티비티 없이 NavHost로 구현 성공하셨네요!!!! 최곱니당
fun MyPageText( | ||
text: String | ||
) { | ||
Text( | ||
text = text, | ||
modifier = Modifier.padding(10.dp), | ||
fontSize = 20.sp, | ||
fontWeight = FontWeight.Bold, | ||
textAlign = TextAlign.Center) | ||
} |
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.
컴포넌트 따로 분리하니까 훨씬 깔끔하네용!
fun isSignUpValid( | ||
navController: NavController, | ||
context: Context, | ||
ID: String, | ||
IDValid: Boolean, | ||
PW: String, | ||
PWValid: Boolean, | ||
Name: String, | ||
NameValid: Boolean, | ||
Place: String | ||
) { | ||
if (IDValid && PWValid && NameValid) { | ||
showToast(context, R.string.toast_SignUp_ValidSignUp) | ||
navController.navigate("SignIn?ID=$ID&PW=$PW&Name=$Name&Place=$Place") | ||
} | ||
} |
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.
추후 뷰모델로도 구현해보고 싶은 부분이군욥!
MyPageText(text = stringResource(R.string.txt_MyPage_Title)) | ||
MyPageText(text = Name) | ||
MyPageText(text = stringResource(R.string.txt_MyPage_Id)) | ||
MyPageText(text = ID) | ||
MyPageText(text = stringResource(R.string.txt_MyPage_Pw)) | ||
MyPageText(text = PW) | ||
MyPageText(text = stringResource(R.string.txt_MyPage_Place)) | ||
MyPageText(text = Place) |
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.
하드코딩 문자열 처리까지 하시고 너무너무 깔끔하네ㅕ
SignUpTextField( | ||
PW, | ||
{ newPW -> | ||
PW = newPW | ||
isPWValid = newPW.trim().length in 8..12 | ||
}, | ||
stringResource(R.string.tf_SignUp_PW_Hint), | ||
Icons.Filled.Lock, | ||
isPassword = true | ||
) | ||
|
||
SignUpTextField( | ||
Name, | ||
{ newName -> | ||
Name = newName | ||
isNameValid = newName.trim().isNotEmpty() | ||
}, | ||
stringResource(R.string.tf_SignUp_Name_Hint), |
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.
SignUp, SignIn이 분리되어서 좋으네요
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.
와~~ 정말로 집념과 노력이 느껴지는 리팩토링 👏👏
고생 많이하셨습니다!!!!
@@ -50,15 +50,17 @@ dependencies { | |||
implementation 'androidx.core:core-ktx:1.12.0' | |||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0' | |||
implementation 'androidx.activity:activity-compose:1.8.2' | |||
implementation platform('androidx.compose:compose-bom:2024.03.00') | |||
implementation platform('androidx.compose:compose-bom:2024.04.00') |
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.
갑자기 업데이트된 이유가 있나요?!
// Navigation | ||
implementation 'androidx.navigation:navigation-compose:2.7.7' |
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.
이친구 주석 그대로 붙여두고 아래로 분리해주시면 읽기 좋을거같아요~~
NavHost(navController = navController, startDestination = "SignIn") { | ||
composable("SignIn?ID={ID}&PW={PW}&Name={Name}&Place={Place}") { backStackEntry -> | ||
SignInScreen( | ||
navController = navController, | ||
ID = backStackEntry.arguments?.getString("ID") ?: "", | ||
PW = backStackEntry.arguments?.getString("PW") ?: "", | ||
Name = backStackEntry.arguments?.getString("Name") ?: "", | ||
Place = backStackEntry.arguments?.getString("Place") ?: "" | ||
) | ||
} | ||
composable("SignUp") { | ||
SignUpScreen(navController = navController) | ||
} | ||
composable("MyPage?ID={InputID}&PW={InputPW}&Name={Name}&Place={Place}") { backStackEntry -> | ||
MyPageScreen( | ||
ID = backStackEntry.arguments?.getString("InputID") ?: "", | ||
PW = backStackEntry.arguments?.getString("InputPW") ?: "", | ||
Name = backStackEntry.arguments?.getString("Name") ?: "", | ||
Place = backStackEntry.arguments?.getString("Place") ?: "" | ||
) | ||
} | ||
} |
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.
크 NavHost를 배우셨군요~~ 저도 리팩할때 넣어야겠슴당
Related issue 🛠
Work Description ✏️
Screenshot 📸
1._Compose_.mp4
Uncompleted Tasks 😅
To Reviewers 📢
Navigation을 이용한 화면 이동 구현을 성공했습니다,,!
페이지 UI 는 천천히 꾸며가겠습니다!