Conversation
leeeyubin
left a comment
There was a problem hiding this comment.
굿굿! 성장하는 모습 보기 좋아요!!
폴더링에 있어서 조금 더 신경 써준다면 감사하겠습니당!!
마이페이지 구현도 완성되면 다시 불러주세요!
| data?.let { | ||
| continuation.resume( |
There was a problem hiding this comment.
resume은 어떤 역할을 하는 건가용..? 궁금해서 물어봅니당
|
|
||
| class LoginViewModel : ViewModel() { | ||
| private val _loginState = mutableStateOf(LoginState()) | ||
| fun login( | ||
| userId: String, |
There was a problem hiding this comment.
xml 코리에 달렸던 내용과 동일한데, 뷰모델은 따로 파일화 해주세요!
| @Composable | ||
| fun SignUpTextField( | ||
| value: String, | ||
| onValueChange: (String) -> Unit, | ||
| label: String, | ||
| hint: String, | ||
| isPassword: Boolean = false | ||
| ) { |
There was a problem hiding this comment.
TextField 따로 빼준 거 좋네요!! 저도 얼른 리팩 하도록 하겠습니닷
| class SignUpViewModel : ViewModel() { | ||
| private val _signUpState = mutableStateOf(SignUpState()) | ||
| fun signUp( |
There was a problem hiding this comment.
보통 _signUpState 와 signUpState로 나눠서 백킹 프로퍼티를 적용하곤 하는데,
이렇게 사용하면 그 의미가 사라지는 것 같습니다!
이에 대해 공부해보시면 좋을 것 같아요!
| private val viewModel by lazy { LoginViewModel() } | ||
|
|
There was a problem hiding this comment.
뷰모델을 by lazy로 선언하신 이유는 무엇인가용....?
| LaunchedEffect(userId) { | ||
| try { | ||
| userInfo = getUserInfo(userId) | ||
| } catch (e: Exception) { |
There was a problem hiding this comment.
단순 궁금증인데 userId를 매개변수로 받아서 LaunchedEffect에 넣어주는 것만으로도 getUserInfo() 함수가 실행이 되나요,,?!
| fun login( | ||
| userId: String, | ||
| userPassword: String, | ||
| context: Context |
There was a problem hiding this comment.
ViewModel에서 Context를 직접 사용하는 것은 권장하지 않습니다!
| context.startActivity(intent) | ||
| intent.putExtra("userId", userId) |
There was a problem hiding this comment.
putExtra를 화면전환 이전에 시키는게 좋지 않을까요?
| userPassword: String, | ||
| userNickname: String, | ||
| userPhone: String, | ||
| context: Context |
| Log.e("userId", "sign up success for $userId") | ||
|
|
||
| // 회원가입 성공 시 로그인 화면으로 이동 | ||
| val intent = Intent(context, LoginActivity::class.java) |
There was a problem hiding this comment.
실제 화면 전환은 ViewModel이 아니라 Composable에서 처리할 수 있도록 하는게 어떨까요?
| import kotlin.coroutines.resumeWithException | ||
| import kotlin.coroutines.suspendCoroutine | ||
| @Composable | ||
| fun MyPageFragment(context: Context, userId: String) { |
There was a problem hiding this comment.
컴포저블 함수에 직접 Context를 매개변수로 전달하는 것은 권장하지 않는 것으로 알고있는데 어떤 방법이 있을까요?
| } | ||
|
|
||
| suspend fun getUserInfo(userId: String): UserInfo { | ||
| return suspendCoroutine { continuation -> |
There was a problem hiding this comment.
suspendCoroutine을 사용하신 이유가 있나요? 그냥 궁금!!
| var userId by remember { mutableStateOf("") } | ||
| var userPassword by remember { mutableStateOf("") } |
There was a problem hiding this comment.
이런 변수들도 뷰모델에서 관리해봐요~
그렇게 하면 밑에 로그인 함수 호출할 때 인자를 넘길 필요도 없어지겠죠?
| var userId by remember { mutableStateOf("") } | ||
| var userPassword by remember { mutableStateOf("") } | ||
| var userNickname by remember { mutableStateOf("") } | ||
| var userPhone by remember { mutableStateOf("") } |
| val phone: String | ||
| ) : Parcelable { | ||
| constructor(parcel: Parcel) : this( | ||
| parcel.readString() ?: "", |
There was a problem hiding this comment.
?: ""와 같은 기능을 하는 orEmpty()라는 메서드가 있답니다~
저도 방금 배움ㅎ
📗 WORK DESCRIPTION
TODO
📗VIDEO (RUN)
4week-compose-essential.mp4
📗TO REVIEWER
userInfo 불러오는 마이페이지 구현이 미완성입니다 ,,,, 얼른 마치겠습니다 ㅠㅠ