From c3c4cb6bb897e217512613cf41d14c25c0243072 Mon Sep 17 00:00:00 2001 From: Hyoeun <137873124+hyoeunjoo@users.noreply.github.com> Date: Fri, 24 May 2024 22:45:01 +0900 Subject: [PATCH 01/12] =?UTF-8?q?[Del]=20:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/SignUp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/SignUp diff --git a/app/src/main/java/com/sopt/now/compose/SignUp b/app/src/main/java/com/sopt/now/compose/SignUp new file mode 100644 index 0000000..e69de29 From da287258c2c38425b37f69ab87ee031410b55806 Mon Sep 17 00:00:00 2001 From: Hyoeun <137873124+hyoeunjoo@users.noreply.github.com> Date: Fri, 24 May 2024 22:52:39 +0900 Subject: [PATCH 02/12] =?UTF-8?q?[FEAT]=20:=20Login=20ViewModel=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/LoginActivity.kt | 63 +++--------------- .../com/sopt/now/compose/LoginViewModel.kt | 64 +++++++++++++++++++ 2 files changed, 74 insertions(+), 53 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/LoginViewModel.kt diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt index b2c8001..47ad6cf 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -1,5 +1,6 @@ package com.sopt.now.compose +import LoginViewModel import android.content.Intent import android.os.Bundle import android.util.Log @@ -21,6 +22,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme import androidx.compose.ui.res.stringResource +import androidx.lifecycle.viewmodel.compose.viewModel import com.sopt.now.compose.TextField.CustomTextField import com.sopt.now.compose.api.ServicePool.authService import com.sopt.now.compose.dto.RequestLogInDto @@ -39,7 +41,8 @@ class LoginActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - LoginScreen(intent) + val loginViewModel: LoginViewModel = viewModel() + LoginScreen(loginViewModel) } } } @@ -47,55 +50,9 @@ class LoginActivity : ComponentActivity() { } @Composable -fun LoginScreen(intent: Intent) { - var login_id by remember { mutableStateOf("") } - var login_pw by remember { mutableStateOf("") } +fun LoginScreen(loginViewModel: LoginViewModel) { val context = LocalContext.current - fun getLogInRequestDto(): RequestLogInDto { - val id = login_id - val password = login_pw - return RequestLogInDto( - authenticationId = id, - password = password - ) - } - - fun logIn() { - val loginRequest = getLogInRequestDto() - authService.logIn(loginRequest).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response, - ) { - if (response.isSuccessful) { - val userId = response.headers()["location"] - Toast.makeText( - context, - "로그인 성공", - Toast.LENGTH_SHORT, - ).show() - - val intent = Intent(context, MainActivity::class.java).apply { - putExtra("userId", userId) - } - context.startActivity(intent) - } else { - val error = response.message() - Toast.makeText( - context, - "로그인 실패 $error", - Toast.LENGTH_SHORT, - ).show() - } - } - - override fun onFailure(call: Call, t: Throwable) { - Toast.makeText(context, "서버 에러 발생 ", Toast.LENGTH_SHORT).show() - } - }) - } - Column( modifier = Modifier .fillMaxSize() @@ -113,16 +70,16 @@ fun LoginScreen(intent: Intent) { Text(text = "ID", fontSize = 30.sp, color = Color.Black) Spacer(modifier = Modifier.height(16.dp)) CustomTextField( - value = login_id, - onInputChange = { login_id = it }, + value = loginViewModel.loginId.value, + onInputChange = { loginViewModel.loginId.value = it }, label = stringResource(R.string.string_id_hint) ) Spacer(modifier = Modifier.height(46.dp)) Text(text = "PW", fontSize = 30.sp, color = Color.Black) CustomTextField( - value = login_pw, - onInputChange = { login_pw = it }, + value = loginViewModel.loginPw.value, + onInputChange = { loginViewModel.loginPw.value = it }, label = stringResource(R.string.string_pw_hint), isPwSecret = true ) @@ -146,7 +103,7 @@ fun LoginScreen(intent: Intent) { } Spacer(modifier = Modifier.width(10.dp)) Button(onClick = { - logIn() + loginViewModel.logIn(context) }, modifier = Modifier.width(180.dp)) { Text(text = stringResource(R.string.log_in_btn), fontSize = 20.sp) } diff --git a/app/src/main/java/com/sopt/now/compose/LoginViewModel.kt b/app/src/main/java/com/sopt/now/compose/LoginViewModel.kt new file mode 100644 index 0000000..8867799 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/LoginViewModel.kt @@ -0,0 +1,64 @@ +import android.content.Context +import android.content.Intent +import android.widget.Toast +import androidx.compose.runtime.mutableStateOf +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.sopt.now.compose.MainActivity +import com.sopt.now.compose.api.ServicePool +import com.sopt.now.compose.dto.RequestLogInDto +import com.sopt.now.compose.dto.ResponseLogInDto +import kotlinx.coroutines.launch +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class LoginViewModel : ViewModel() { + + var loginId = mutableStateOf("") + var loginPw = mutableStateOf("") + + private val authService = ServicePool.authService + + fun getLogInRequestDto(): RequestLogInDto { + return RequestLogInDto( + authenticationId = loginId.value, + password = loginPw.value + ) + } + + fun logIn(context: Context) { + val loginRequest = getLogInRequestDto() + authService.logIn(loginRequest).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response, + ) { + if (response.isSuccessful) { + val userId = response.headers()["location"] + Toast.makeText( + context, + "로그인 성공", + Toast.LENGTH_SHORT, + ).show() + + val intent = Intent(context, MainActivity::class.java).apply { + putExtra("userId", userId) + } + context.startActivity(intent) + } else { + val error = response.message() + Toast.makeText( + context, + "로그인 실패 $error", + Toast.LENGTH_SHORT, + ).show() + } + } + + override fun onFailure(call: Call, t: Throwable) { + Toast.makeText(context, "서버 에러 발생 ", Toast.LENGTH_SHORT).show() + } + }) + } +} From 0c1f44147ca9f81de5988bf84baaa4e5fe551019 Mon Sep 17 00:00:00 2001 From: Hyoeun <137873124+hyoeunjoo@users.noreply.github.com> Date: Fri, 24 May 2024 22:52:49 +0900 Subject: [PATCH 03/12] =?UTF-8?q?[FEAT]=20:=20SignUp=20ViewModel=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/SignUpActivity.kt | 70 ++++--------------- .../com/sopt/now/compose/SignUpViewModel.kt | 67 ++++++++++++++++++ 2 files changed, 80 insertions(+), 57 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt index 71ca40a..553180d 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -36,6 +36,7 @@ import android.util.Log import android.view.View import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.lifecycle.viewmodel.compose.viewModel import com.sopt.now.compose.Constants.Constant.Companion.MAX_ID_LENGTH import com.sopt.now.compose.Constants.Constant.Companion.MAX_MBTI_LENGTH import com.sopt.now.compose.Constants.Constant.Companion.MAX_PW_LENGTH @@ -61,7 +62,8 @@ class SignUpActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - SignUpScreen() + val signUpViewModel: SignUpViewModel = viewModel() + SignUpScreen(signUpViewModel) } } } @@ -69,55 +71,9 @@ class SignUpActivity : ComponentActivity() { } @Composable -fun SignUpScreen() { - var signup_id by remember { mutableStateOf("") } - var signup_pw by remember { mutableStateOf("") } - var signup_name by remember { mutableStateOf("") } - var signup_phone by remember { mutableStateOf("") } +fun SignUpScreen(signUpViewModel: SignUpViewModel) { val context = LocalContext.current - fun getSignUpRequestDto(): RequestSignUpDto { - return RequestSignUpDto( - authenticationId = signup_id, - password = signup_pw, - nickname = signup_name, - phone = signup_phone - ) - } - - fun signUp(context: Context) { - val signUpRequest = getSignUpRequestDto() - authService.signUp(signUpRequest).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response, - ) { - if (response.isSuccessful) { - val data: ResponseSignUpDto? = response.body() - val userId = response.headers()["location"] - Toast.makeText( - context, - "회원가입 성공 유저의 ID는 $userId 입니둥", - Toast.LENGTH_SHORT, - ).show() - Log.d("SignUp", "data: $data, userId: $userId") - val toLogIn = Intent(context, LoginActivity::class.java) - context.startActivity(toLogIn) - } else { - val error = response.message() - Toast.makeText( - context, - "로그인이 실패 $error", - Toast.LENGTH_SHORT, - ).show() - } - } - override fun onFailure(call: Call, t: Throwable) { - Log.e("SignUp", "서버 요청 실패", t) - Toast.makeText(context, "서버 에러 발생 ", Toast.LENGTH_SHORT).show() - } - }) - } Column( modifier = Modifier .fillMaxSize() @@ -134,31 +90,31 @@ fun SignUpScreen() { Spacer(modifier = Modifier.height(60.dp)) Text(text = "ID", fontSize = 30.sp, color = Color.Black) CustomTextField( - value = signup_id, - onInputChange = { signup_id = it }, + value = signUpViewModel.signupId.value, + onInputChange = { signUpViewModel.signupId.value = it }, label = stringResource(R.string.string_id_hint) ) Spacer(modifier = Modifier.height(46.dp)) Text(text = "PW", fontSize = 30.sp, color = Color.Black) CustomTextField( - value = signup_pw, - onInputChange = { signup_pw = it }, + value = signUpViewModel.signupPw.value, + onInputChange = { signUpViewModel.signupPw.value = it }, label = stringResource(R.string.string_pw_hint) ) Spacer(modifier = Modifier.height(46.dp)) Text(text = "Name", fontSize = 30.sp, color = Color.Black) CustomTextField( - value = signup_name, - onInputChange = { signup_name = it }, + value = signUpViewModel.signupName.value, + onInputChange = { signUpViewModel.signupName.value = it }, label = stringResource(R.string.tv_sign_up_nickname_hint) ) Spacer(modifier = Modifier.height(30.dp)) Text(text = "Phone", fontSize = 30.sp, color = Color.Black) CustomTextField( - value = signup_phone, - onInputChange = { signup_phone = it }, + value = signUpViewModel.signupPhone.value, + onInputChange = { signUpViewModel.signupPhone.value = it }, label = stringResource(R.string.tv_sign_up_phone_hint) ) Spacer(modifier = Modifier.height(46.dp)) @@ -168,7 +124,7 @@ fun SignUpScreen() { ) { Button( onClick = { - signUp(context) + signUpViewModel.signUp(context) }, modifier = Modifier.width(280.dp) ) { diff --git a/app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt b/app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt new file mode 100644 index 0000000..39a2f57 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt @@ -0,0 +1,67 @@ +package com.sopt.now.compose + +import android.content.Context +import android.content.Intent +import android.util.Log +import android.widget.Toast +import androidx.compose.runtime.mutableStateOf +import androidx.lifecycle.ViewModel +import com.sopt.now.compose.api.ServicePool +import com.sopt.now.compose.dto.RequestSignUpDto +import com.sopt.now.compose.dto.ResponseSignUpDto +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class SignUpViewModel : ViewModel() { + + var signupId = mutableStateOf("") + var signupPw = mutableStateOf("") + var signupName = mutableStateOf("") + var signupPhone = mutableStateOf("") + + private val authService = ServicePool.authService + + fun getSignUpRequestDto(): RequestSignUpDto { + return RequestSignUpDto( + authenticationId = signupId.value, + password = signupPw.value, + nickname = signupName.value, + phone = signupPhone.value + ) + } + + fun signUp(context: Context) { + val signUpRequest = getSignUpRequestDto() + authService.signUp(signUpRequest).enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response, + ) { + if (response.isSuccessful) { + val data: ResponseSignUpDto? = response.body() + val userId = response.headers()["location"] + Toast.makeText( + context, + "회원가입 성공, 유저의 ID는 $userId 입니다.", + Toast.LENGTH_SHORT, + ).show() + val toLogIn = Intent(context, LoginActivity::class.java) + context.startActivity(toLogIn) + } else { + val error = response.message() + Toast.makeText( + context, + "회원가입 실패: $error", + Toast.LENGTH_SHORT, + ).show() + } + } + + override fun onFailure(call: Call, t: Throwable) { + Log.e("SignUp", "서버 요청 실패", t) + Toast.makeText(context, "서버 에러 발생", Toast.LENGTH_SHORT).show() + } + }) + } +} From 47c90b2d299ff339d4e290375b26d4d2e7c30d79 Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:52:37 +0900 Subject: [PATCH 04/12] =?UTF-8?q?[CHORE]=20:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 136674c..cdeb91d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,22 +12,25 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.NOWSOPTAndroid" - tools:targetApi="31" android:usesCleartextTraffic="true" - > + tools:targetApi="31"> + + From 364e18976ca87ac2fb3cc10c207a82935784a988 Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:52:47 +0900 Subject: [PATCH 05/12] =?UTF-8?q?[DEL]=20:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/Constants/Constant.kt | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 app/src/main/java/com/sopt/now/compose/Constants/Constant.kt diff --git a/app/src/main/java/com/sopt/now/compose/Constants/Constant.kt b/app/src/main/java/com/sopt/now/compose/Constants/Constant.kt deleted file mode 100644 index 7ff10b2..0000000 --- a/app/src/main/java/com/sopt/now/compose/Constants/Constant.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.sopt.now.compose.Constants - -class Constant { - companion object { - const val MIN_ID_LENGTH = 6 - const val MAX_ID_LENGTH = 10 - const val MIN_PW_LENGTH = 8 - const val MAX_PW_LENGTH = 12 - const val MAX_MBTI_LENGTH = 4 - - } - -} \ No newline at end of file From 152657fbe10e9556fc8137bdadc8fcfd7b2da2bd Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:53:43 +0900 Subject: [PATCH 06/12] =?UTF-8?q?[MOD]=20:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/{ => data}/api/ApiFactory.kt | 3 +-- .../com/sopt/now/compose/{ui => presentation}/theme/Theme.kt | 2 +- .../com/sopt/now/compose/{ui => presentation}/theme/Type.kt | 2 +- .../now/compose/{ui => presentation}/theme/ui/theme/Theme.kt | 2 +- .../now/compose/{ui => presentation}/theme/ui/theme/Type.kt | 2 +- app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 7 insertions(+), 6 deletions(-) rename app/src/main/java/com/sopt/now/compose/{ => data}/api/ApiFactory.kt (94%) rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/Theme.kt (97%) rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/Type.kt (95%) rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/ui/theme/Theme.kt (97%) rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/ui/theme/Type.kt (94%) diff --git a/app/src/main/java/com/sopt/now/compose/api/ApiFactory.kt b/app/src/main/java/com/sopt/now/compose/data/api/ApiFactory.kt similarity index 94% rename from app/src/main/java/com/sopt/now/compose/api/ApiFactory.kt rename to app/src/main/java/com/sopt/now/compose/data/api/ApiFactory.kt index b5214b4..8b43063 100644 --- a/app/src/main/java/com/sopt/now/compose/api/ApiFactory.kt +++ b/app/src/main/java/com/sopt/now/compose/data/api/ApiFactory.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.api +package com.sopt.now.compose.data.api import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import com.sopt.now.compose.BuildConfig @@ -15,7 +15,6 @@ object ApiFactory { .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) .build() } - inline fun create(): T = retrofit.create(T::class.java) } diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/Theme.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/Theme.kt similarity index 97% rename from app/src/main/java/com/sopt/now/compose/ui/theme/Theme.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/Theme.kt index da5ac84..fd4793a 100644 --- a/app/src/main/java/com/sopt/now/compose/ui/theme/Theme.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/theme/Theme.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.ui.theme +package com.sopt.now.compose.presentation.theme import android.app.Activity import android.os.Build diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/Type.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/Type.kt similarity index 95% rename from app/src/main/java/com/sopt/now/compose/ui/theme/Type.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/Type.kt index a5c1079..89efa05 100644 --- a/app/src/main/java/com/sopt/now/compose/ui/theme/Type.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/theme/Type.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.ui.theme +package com.sopt.now.compose.presentation.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Theme.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Theme.kt similarity index 97% rename from app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Theme.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Theme.kt index 93825a4..3912e2e 100644 --- a/app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Theme.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Theme.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.ui.theme.ui.theme +package com.sopt.now.compose.presentation.theme.ui.theme import android.app.Activity import android.os.Build diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Type.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Type.kt similarity index 94% rename from app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Type.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Type.kt index 504e5e9..7488e36 100644 --- a/app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Type.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Type.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.ui.theme.ui.theme +package com.sopt.now.compose.presentation.theme.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 48a4e5b..f63ae5e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,6 +2,8 @@ NOW SOPT Android LoginActivity SignUpActivity + MainActivity + ID ID를 입력해주세요 From 26a1a0d9d4c93c1add55ddfebcc61a7c087c46ca Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:54:07 +0900 Subject: [PATCH 07/12] =?UTF-8?q?[FEAT]=20:=20Repository=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/api/AuthService.kt | 29 ---------------- .../com/sopt/now/compose/data/AuthRepoImpl.kt | 33 +++++++++++++++++++ .../sopt/now/compose/data/api/AuthService.kt | 30 +++++++++++++++++ .../sopt/now/compose/domain/AuthRepository.kt | 9 +++++ .../now/compose/domain/model/AuthEntity.kt | 8 +++++ 5 files changed, 80 insertions(+), 29 deletions(-) delete mode 100644 app/src/main/java/com/sopt/now/compose/api/AuthService.kt create mode 100644 app/src/main/java/com/sopt/now/compose/data/AuthRepoImpl.kt create mode 100644 app/src/main/java/com/sopt/now/compose/data/api/AuthService.kt create mode 100644 app/src/main/java/com/sopt/now/compose/domain/AuthRepository.kt create mode 100644 app/src/main/java/com/sopt/now/compose/domain/model/AuthEntity.kt diff --git a/app/src/main/java/com/sopt/now/compose/api/AuthService.kt b/app/src/main/java/com/sopt/now/compose/api/AuthService.kt deleted file mode 100644 index c3aa6bb..0000000 --- a/app/src/main/java/com/sopt/now/compose/api/AuthService.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.sopt.now.compose.api - -import com.sopt.now.compose.dto.RequestLogInDto -import com.sopt.now.compose.dto.RequestSignUpDto -import com.sopt.now.compose.dto.ResponseLogInDto -import com.sopt.now.compose.dto.ResponseSignUpDto -import com.sopt.now.compose.dto.ResponseUserProfile -import retrofit2.Call -import retrofit2.http.Body -import retrofit2.http.GET -import retrofit2.http.Header -import retrofit2.http.POST - -interface AuthService { - @POST("member/join") - fun signUp( - @Body request: RequestSignUpDto, - ): Call - - @POST("member/login") - fun logIn( - @Body request: RequestLogInDto, - ): Call - - @GET("member/info") - fun getUserInfo( - @Header("memberId") memberId : Int - ): Call -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/data/AuthRepoImpl.kt b/app/src/main/java/com/sopt/now/compose/data/AuthRepoImpl.kt new file mode 100644 index 0000000..dda29e9 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/data/AuthRepoImpl.kt @@ -0,0 +1,33 @@ +package com.sopt.now.compose.data + +import com.sopt.now.compose.data.api.AuthService +import com.sopt.now.compose.data.dto.LoginDto.RequestLogInDto +import com.sopt.now.compose.data.dto.SignUpDto.RequestSignUpDto +import com.sopt.now.compose.domain.AuthRepository +import com.sopt.now.compose.domain.model.AuthEntity +import retrofit2.Response + +class AuthRepoImpl( + private val authService: AuthService, +) : AuthRepository { + override suspend fun logIn(authEntity: AuthEntity): Result> = runCatching { + authService.logIn( + request = RequestLogInDto( + authenticationId = authEntity.id, + password = authEntity.pw + ) + ) + } + + override suspend fun signUp(authEntity: AuthEntity): Result> = runCatching { + authService.signUp( + request = RequestSignUpDto( + authenticationId = authEntity.id, + password = authEntity.pw, + nickname = authEntity.name ?: "", + phone = authEntity.phone ?: "" + + ) + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/data/api/AuthService.kt b/app/src/main/java/com/sopt/now/compose/data/api/AuthService.kt new file mode 100644 index 0000000..f89aa80 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/data/api/AuthService.kt @@ -0,0 +1,30 @@ +package com.sopt.now.compose.data.api + +import com.sopt.now.compose.data.dto.LoginDto.RequestLogInDto +import com.sopt.now.compose.data.dto.SignUpDto.RequestSignUpDto +import com.sopt.now.compose.data.dto.LoginDto.ResponseLogInDto +import com.sopt.now.compose.data.dto.SignUpDto.ResponseSignUpDto +import com.sopt.now.compose.data.dto.ResponseUserProfile +import retrofit2.Call +import retrofit2.Response +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.POST + +interface AuthService { + @POST("member/join") + suspend fun signUp( + @Body request: RequestSignUpDto, + ): Response + + @POST("member/login") + suspend fun logIn( + @Body request: RequestLogInDto, + ): Response + + @GET("member/info") + fun getUserInfo( + @Header("memberId") memberId : Int + ): Call +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/domain/AuthRepository.kt b/app/src/main/java/com/sopt/now/compose/domain/AuthRepository.kt new file mode 100644 index 0000000..14ee4d1 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/domain/AuthRepository.kt @@ -0,0 +1,9 @@ +package com.sopt.now.compose.domain + +import com.sopt.now.compose.domain.model.AuthEntity +import retrofit2.Response + +interface AuthRepository { + suspend fun logIn(authData: AuthEntity): Result> + suspend fun signUp(authData: AuthEntity): Result> +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/domain/model/AuthEntity.kt b/app/src/main/java/com/sopt/now/compose/domain/model/AuthEntity.kt new file mode 100644 index 0000000..68488ce --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/domain/model/AuthEntity.kt @@ -0,0 +1,8 @@ +package com.sopt.now.compose.domain.model + +data class AuthEntity( + val id: String, + val pw: String, + val name: String? = null, + val phone: String? = null +) From cdeddb7ebfb2b4a4193f8c9a7b2d9946e686a727 Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:54:23 +0900 Subject: [PATCH 08/12] =?UTF-8?q?[MOD]=20:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/{ui => presentation}/theme/Color.kt | 2 +- .../now/compose/{ui => presentation}/theme/ui/theme/Color.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/Color.kt (83%) rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/ui/theme/Color.kt (81%) diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/Color.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/Color.kt similarity index 83% rename from app/src/main/java/com/sopt/now/compose/ui/theme/Color.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/Color.kt index 58ffdfc..f61d94f 100644 --- a/app/src/main/java/com/sopt/now/compose/ui/theme/Color.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/theme/Color.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.ui.theme +package com.sopt.now.compose.presentation.theme import androidx.compose.ui.graphics.Color diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Color.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Color.kt similarity index 81% rename from app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Color.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Color.kt index 8ba5de5..e5b5986 100644 --- a/app/src/main/java/com/sopt/now/compose/ui/theme/ui/theme/Color.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/theme/ui/theme/Color.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.ui.theme.ui.theme +package com.sopt.now.compose.presentation.theme.ui.theme import androidx.compose.ui.graphics.Color From ffa7661d60f410ce65cdb9f96ad8b2c081cd9c6a Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:54:56 +0900 Subject: [PATCH 09/12] =?UTF-8?q?[MOD]=20:=20LoginActivity=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/LoginViewModel.kt | 64 ---------------- .../{ => presentation/Login}/LoginActivity.kt | 74 ++++++++++++------- .../presentation/Login/LoginViewModel.kt | 62 ++++++++++++++++ .../Login/LoginViewModelFactory.kt | 18 +++++ 4 files changed, 129 insertions(+), 89 deletions(-) delete mode 100644 app/src/main/java/com/sopt/now/compose/LoginViewModel.kt rename app/src/main/java/com/sopt/now/compose/{ => presentation/Login}/LoginActivity.kt (60%) create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModel.kt create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModelFactory.kt diff --git a/app/src/main/java/com/sopt/now/compose/LoginViewModel.kt b/app/src/main/java/com/sopt/now/compose/LoginViewModel.kt deleted file mode 100644 index 8867799..0000000 --- a/app/src/main/java/com/sopt/now/compose/LoginViewModel.kt +++ /dev/null @@ -1,64 +0,0 @@ -import android.content.Context -import android.content.Intent -import android.widget.Toast -import androidx.compose.runtime.mutableStateOf -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.sopt.now.compose.MainActivity -import com.sopt.now.compose.api.ServicePool -import com.sopt.now.compose.dto.RequestLogInDto -import com.sopt.now.compose.dto.ResponseLogInDto -import kotlinx.coroutines.launch -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response - -class LoginViewModel : ViewModel() { - - var loginId = mutableStateOf("") - var loginPw = mutableStateOf("") - - private val authService = ServicePool.authService - - fun getLogInRequestDto(): RequestLogInDto { - return RequestLogInDto( - authenticationId = loginId.value, - password = loginPw.value - ) - } - - fun logIn(context: Context) { - val loginRequest = getLogInRequestDto() - authService.logIn(loginRequest).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response, - ) { - if (response.isSuccessful) { - val userId = response.headers()["location"] - Toast.makeText( - context, - "로그인 성공", - Toast.LENGTH_SHORT, - ).show() - - val intent = Intent(context, MainActivity::class.java).apply { - putExtra("userId", userId) - } - context.startActivity(intent) - } else { - val error = response.message() - Toast.makeText( - context, - "로그인 실패 $error", - Toast.LENGTH_SHORT, - ).show() - } - } - - override fun onFailure(call: Call, t: Throwable) { - Toast.makeText(context, "서버 에러 발생 ", Toast.LENGTH_SHORT).show() - } - }) - } -} diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginActivity.kt similarity index 60% rename from app/src/main/java/com/sopt/now/compose/LoginActivity.kt rename to app/src/main/java/com/sopt/now/compose/presentation/Login/LoginActivity.kt index 47ad6cf..9a5d0b2 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginActivity.kt @@ -1,17 +1,17 @@ -package com.sopt.now.compose +package com.sopt.now.compose.presentation.Login -import LoginViewModel import android.content.Intent import android.os.Bundle -import android.util.Log import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.activity.viewModels import androidx.compose.foundation.layout.* import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -20,19 +20,19 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme +import com.sopt.now.compose.presentation.theme.NOWSOPTAndroidTheme import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.lifecycle.viewmodel.compose.viewModel +import com.sopt.now.compose.R import com.sopt.now.compose.TextField.CustomTextField -import com.sopt.now.compose.api.ServicePool.authService -import com.sopt.now.compose.dto.RequestLogInDto -import com.sopt.now.compose.dto.ResponseLogInDto -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response - +import com.sopt.now.compose.domain.model.AuthEntity +import com.sopt.now.compose.presentation.MainActivity +import com.sopt.now.compose.presentation.SignUp.SignUpActivity class LoginActivity : ComponentActivity() { + private val viewModel: LoginViewModel by viewModels { LoginViewModelFactory() } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { @@ -41,16 +41,33 @@ class LoginActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - val loginViewModel: LoginViewModel = viewModel() - LoginScreen(loginViewModel) + LoginScreen(viewModel) } } } + observeViewModel() + } + + private fun observeViewModel() { + viewModel.loginResult.observe(this) { success -> + if (success) { + val toMain = Intent(this, MainActivity::class.java) + toMain.putExtra("userId", viewModel.userId.value) + startActivity(toMain) + finish() + } + } + + viewModel.errorMessage.observe(this) { errorMessage -> + errorMessage?.let { + Toast.makeText(this, it, Toast.LENGTH_LONG).show() + } + } } } @Composable -fun LoginScreen(loginViewModel: LoginViewModel) { +fun LoginScreen(viewModel: LoginViewModel) { val context = LocalContext.current Column( @@ -69,19 +86,20 @@ fun LoginScreen(loginViewModel: LoginViewModel) { Spacer(modifier = Modifier.height(86.dp)) Text(text = "ID", fontSize = 30.sp, color = Color.Black) Spacer(modifier = Modifier.height(16.dp)) - CustomTextField( - value = loginViewModel.loginId.value, - onInputChange = { loginViewModel.loginId.value = it }, - label = stringResource(R.string.string_id_hint) + TextField( + value = viewModel.loginId.value, + onValueChange = { viewModel.loginId.value = it }, + label = { Text(stringResource(R.string.string_id_hint)) }, + modifier = Modifier.fillMaxWidth() ) - Spacer(modifier = Modifier.height(46.dp)) Text(text = "PW", fontSize = 30.sp, color = Color.Black) - CustomTextField( - value = loginViewModel.loginPw.value, - onInputChange = { loginViewModel.loginPw.value = it }, - label = stringResource(R.string.string_pw_hint), - isPwSecret = true + TextField( + value = viewModel.loginPw.value, + onValueChange = { viewModel.loginPw.value = it }, + label = { Text(stringResource(R.string.string_pw_hint)) }, + visualTransformation = PasswordVisualTransformation(), + modifier = Modifier.fillMaxWidth() ) Box( @@ -103,7 +121,11 @@ fun LoginScreen(loginViewModel: LoginViewModel) { } Spacer(modifier = Modifier.width(10.dp)) Button(onClick = { - loginViewModel.logIn(context) + val authData = AuthEntity( + id = viewModel.loginId.value, + pw = viewModel.loginPw.value, + ) + viewModel.login(authData) }, modifier = Modifier.width(180.dp)) { Text(text = stringResource(R.string.log_in_btn), fontSize = 20.sp) } @@ -111,3 +133,5 @@ fun LoginScreen(loginViewModel: LoginViewModel) { } } } + + diff --git a/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModel.kt b/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModel.kt new file mode 100644 index 0000000..1471791 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModel.kt @@ -0,0 +1,62 @@ +package com.sopt.now.compose.presentation.Login + +import android.content.ContentValues.TAG +import android.content.Context +import android.content.Intent +import android.util.Log +import android.view.View +import android.widget.Toast +import androidx.compose.runtime.mutableStateOf +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.sopt.now.compose.presentation.MainActivity +import com.sopt.now.compose.data.api.ServicePool +import com.sopt.now.compose.data.dto.LoginDto.RequestLogInDto +import com.sopt.now.compose.data.dto.LoginDto.ResponseLogInDto +import com.sopt.now.compose.domain.AuthRepository +import com.sopt.now.compose.domain.model.AuthEntity +import kotlinx.coroutines.launch +import retrofit2.Call +import retrofit2.Callback +import retrofit2.HttpException +import retrofit2.Response + +class LoginViewModel( + private val authRepository: AuthRepository +) : ViewModel() { + + val loginResult: MutableLiveData = MutableLiveData() + + val errorMessage = MutableLiveData() + val userId = MutableLiveData() + var loginId = mutableStateOf("") + var loginPw = mutableStateOf("") + + fun login(authEntity: AuthEntity) { + viewModelScope.launch { + authRepository.logIn(authEntity) + .onSuccess { response -> + val userId = response.headers()["Location"] + userId?.let { + this@LoginViewModel.userId.postValue(it) + loginResult.postValue(true) + } + Log.d(TAG, "login successful. User ID: $userId") + } + .onFailure { t -> + if (t is HttpException) { + val error = t.message() + errorMessage.postValue("$error") + Log.e(TAG,"fail ${t.message}") + } else { + errorMessage.postValue("서버 에러 발생") + Log.e(TAG,"server fail ${t.message}") + + } + } + } + } +} + diff --git a/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModelFactory.kt b/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModelFactory.kt new file mode 100644 index 0000000..66a4d42 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/Login/LoginViewModelFactory.kt @@ -0,0 +1,18 @@ +package com.sopt.now.compose.presentation.Login + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.sopt.now.compose.data.AuthRepoImpl +import com.sopt.now.compose.data.api.ServicePool + +class LoginViewModelFactory : ViewModelProvider.Factory { + override fun create(modelClass: Class): T { + if (modelClass.isAssignableFrom(LoginViewModel::class.java)) { + val repository = + AuthRepoImpl(ServicePool.authService) + return LoginViewModel(repository) as T + } else { + throw IllegalArgumentException("Failed to create ViewModel: ${modelClass.name}") + } + } +} \ No newline at end of file From 5876bb50dccd64e4cef5a2d5be87785634eed567 Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:55:20 +0900 Subject: [PATCH 10/12] =?UTF-8?q?[MOD]=20:=20SignUpActivity=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/SignUpViewModel.kt | 67 --------- .../SignUp}/SignUpActivity.kt | 107 ++++++++------- .../presentation/SignUp/SignUpViewModel.kt | 128 ++++++++++++++++++ .../SignUp/SignUpViewModelFactory.kt | 19 +++ .../{ui => presentation}/theme/SignUpData.kt | 0 5 files changed, 205 insertions(+), 116 deletions(-) delete mode 100644 app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt rename app/src/main/java/com/sopt/now/compose/{ => presentation/SignUp}/SignUpActivity.kt (56%) create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModel.kt create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModelFactory.kt rename app/src/main/java/com/sopt/now/compose/{ui => presentation}/theme/SignUpData.kt (100%) diff --git a/app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt b/app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt deleted file mode 100644 index 39a2f57..0000000 --- a/app/src/main/java/com/sopt/now/compose/SignUpViewModel.kt +++ /dev/null @@ -1,67 +0,0 @@ -package com.sopt.now.compose - -import android.content.Context -import android.content.Intent -import android.util.Log -import android.widget.Toast -import androidx.compose.runtime.mutableStateOf -import androidx.lifecycle.ViewModel -import com.sopt.now.compose.api.ServicePool -import com.sopt.now.compose.dto.RequestSignUpDto -import com.sopt.now.compose.dto.ResponseSignUpDto -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response - -class SignUpViewModel : ViewModel() { - - var signupId = mutableStateOf("") - var signupPw = mutableStateOf("") - var signupName = mutableStateOf("") - var signupPhone = mutableStateOf("") - - private val authService = ServicePool.authService - - fun getSignUpRequestDto(): RequestSignUpDto { - return RequestSignUpDto( - authenticationId = signupId.value, - password = signupPw.value, - nickname = signupName.value, - phone = signupPhone.value - ) - } - - fun signUp(context: Context) { - val signUpRequest = getSignUpRequestDto() - authService.signUp(signUpRequest).enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response, - ) { - if (response.isSuccessful) { - val data: ResponseSignUpDto? = response.body() - val userId = response.headers()["location"] - Toast.makeText( - context, - "회원가입 성공, 유저의 ID는 $userId 입니다.", - Toast.LENGTH_SHORT, - ).show() - val toLogIn = Intent(context, LoginActivity::class.java) - context.startActivity(toLogIn) - } else { - val error = response.message() - Toast.makeText( - context, - "회원가입 실패: $error", - Toast.LENGTH_SHORT, - ).show() - } - } - - override fun onFailure(call: Call, t: Throwable) { - Log.e("SignUp", "서버 요청 실패", t) - Toast.makeText(context, "서버 에러 발생", Toast.LENGTH_SHORT).show() - } - }) - } -} diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpActivity.kt similarity index 56% rename from app/src/main/java/com/sopt/now/compose/SignUpActivity.kt rename to app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpActivity.kt index 553180d..a627c79 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpActivity.kt @@ -1,9 +1,11 @@ -package com.sopt.now.compose +package com.sopt.now.compose.presentation.SignUp +import android.content.Intent import android.os.Bundle import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.activity.viewModels import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -17,43 +19,27 @@ import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TextField 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.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme -import android.content.Context -import android.content.Intent -import android.os.Message -import android.util.Log -import android.view.View +import com.sopt.now.compose.presentation.theme.NOWSOPTAndroidTheme import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.lifecycle.viewmodel.compose.viewModel -import com.sopt.now.compose.Constants.Constant.Companion.MAX_ID_LENGTH -import com.sopt.now.compose.Constants.Constant.Companion.MAX_MBTI_LENGTH -import com.sopt.now.compose.Constants.Constant.Companion.MAX_PW_LENGTH -import com.sopt.now.compose.Constants.Constant.Companion.MIN_ID_LENGTH -import com.sopt.now.compose.Constants.Constant.Companion.MIN_PW_LENGTH +import com.sopt.now.compose.R import com.sopt.now.compose.TextField.CustomTextField -import com.sopt.now.compose.api.AuthService -import com.sopt.now.compose.api.ServicePool -import com.sopt.now.compose.api.ServicePool.authService -import com.sopt.now.compose.dto.RequestSignUpDto -import com.sopt.now.compose.dto.ResponseSignUpDto -import com.sopt.now.compose.feature.model.UserDataInput -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response - +import com.sopt.now.compose.domain.model.AuthEntity +import com.sopt.now.compose.presentation.Login.LoginActivity +import kotlin.math.sign class SignUpActivity : ComponentActivity() { + private val viewModel: SignUpViewModel by viewModels { SignUpViewModelFactory() } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { @@ -62,18 +48,32 @@ class SignUpActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - val signUpViewModel: SignUpViewModel = viewModel() - SignUpScreen(signUpViewModel) + SignUpScreen(viewModel) } } } + observeViewModel() + } + + private fun observeViewModel() { + viewModel.signUpResult.observe(this) { success -> + if (success) { + val toLogIn = Intent(this, LoginActivity::class.java) + startActivity(toLogIn) + finish() + } + } + viewModel.errorMessage.observe(this) { errorMessage -> + errorMessage?.let { + Toast.makeText(this, it, Toast.LENGTH_SHORT).show() + } + } } } + @Composable fun SignUpScreen(signUpViewModel: SignUpViewModel) { - val context = LocalContext.current - Column( modifier = Modifier .fillMaxSize() @@ -89,33 +89,36 @@ fun SignUpScreen(signUpViewModel: SignUpViewModel) { ) Spacer(modifier = Modifier.height(60.dp)) Text(text = "ID", fontSize = 30.sp, color = Color.Black) - CustomTextField( - value = signUpViewModel.signupId.value, - onInputChange = { signUpViewModel.signupId.value = it }, - label = stringResource(R.string.string_id_hint) + TextField( + value = signUpViewModel.signUpId.value, + onValueChange = { signUpViewModel.signUpId.value = it }, + label = { Text(stringResource(R.string.string_id_hint)) }, + modifier = Modifier.fillMaxWidth() ) - Spacer(modifier = Modifier.height(46.dp)) Text(text = "PW", fontSize = 30.sp, color = Color.Black) - CustomTextField( - value = signUpViewModel.signupPw.value, - onInputChange = { signUpViewModel.signupPw.value = it }, - label = stringResource(R.string.string_pw_hint) + TextField( + value = signUpViewModel.signUpPw.value, + onValueChange = { signUpViewModel.signUpPw.value = it }, + label = { Text(stringResource(R.string.string_pw_hint)) }, + visualTransformation = PasswordVisualTransformation(), + modifier = Modifier.fillMaxWidth() ) Spacer(modifier = Modifier.height(46.dp)) Text(text = "Name", fontSize = 30.sp, color = Color.Black) - CustomTextField( - value = signUpViewModel.signupName.value, - onInputChange = { signUpViewModel.signupName.value = it }, - label = stringResource(R.string.tv_sign_up_nickname_hint) + TextField( + value = signUpViewModel.signUpName.value, + onValueChange = { signUpViewModel.signUpName.value = it }, + label = { Text(stringResource(R.string.tv_sign_up_nickname_hint)) }, + modifier = Modifier.fillMaxWidth() ) - Spacer(modifier = Modifier.height(30.dp)) Text(text = "Phone", fontSize = 30.sp, color = Color.Black) - CustomTextField( - value = signUpViewModel.signupPhone.value, - onInputChange = { signUpViewModel.signupPhone.value = it }, - label = stringResource(R.string.tv_sign_up_phone_hint) + TextField( + value = signUpViewModel.signUpPhone.value, + onValueChange = { signUpViewModel.signUpPhone.value = it }, + label = { Text(stringResource(R.string.tv_sign_up_phone_hint)) }, + modifier = Modifier.fillMaxWidth() ) Spacer(modifier = Modifier.height(46.dp)) Row( @@ -124,7 +127,13 @@ fun SignUpScreen(signUpViewModel: SignUpViewModel) { ) { Button( onClick = { - signUpViewModel.signUp(context) + val authData = AuthEntity( + id = signUpViewModel.signUpId.value, + pw = signUpViewModel.signUpPw.value, + name = signUpViewModel.signUpName.value, + phone = signUpViewModel.signUpPhone.value, + ) + signUpViewModel.signUp(authData) }, modifier = Modifier.width(280.dp) ) { diff --git a/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModel.kt b/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModel.kt new file mode 100644 index 0000000..1fb2960 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModel.kt @@ -0,0 +1,128 @@ +package com.sopt.now.compose.presentation.SignUp + + +import android.content.ContentValues.TAG +import android.util.Log +import androidx.compose.runtime.mutableStateOf +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.sopt.now.compose.domain.AuthRepository +import com.sopt.now.compose.domain.model.AuthEntity +import kotlinx.coroutines.launch +import retrofit2.HttpException +class SignUpViewModel( + private val authRepository: AuthRepository +) : ViewModel() { + val signUpResult: MutableLiveData = MutableLiveData() + val errorMessage: MutableLiveData = MutableLiveData() + val userId: MutableLiveData = MutableLiveData() + + var signUpId = mutableStateOf("") + var signUpPw = mutableStateOf("") + var signUpName = mutableStateOf("") + var signUpPhone = mutableStateOf("") + fun signUp(authEntity: AuthEntity) { + viewModelScope.launch { + runCatching { + authRepository.signUp(authEntity) + .onSuccess { response -> + val userId = response.headers()["Location"] + userId?.let { + this@SignUpViewModel.userId.postValue(it) + signUpResult.postValue(true) + } + Log.d(TAG, "Sign up successful. User ID: $userId") + } + .onFailure { t -> + if (t is HttpException) { + val error = t.message() + errorMessage.postValue("$error") + Log.e(TAG, "Sign up failed: ${t.message}") + } else { + errorMessage.postValue("서버 에러 발생") + Log.e(TAG, "Server error: ${t.message}") + } + } + } + } + } + + +// fun signUp(authEntity: AuthEntity) { +// viewModelScope.launch { +// runCatching { +// authRepository.signUp(authEntity) +// .onSuccess { response -> +// val userId = response.headers()["Location"] +// userId?.let { +// this@SignUpViewModel.userId.postValue(it) +// signUpResult.postValue(true) +// } +// } +// .onFailure { t -> +// Log.e("SignUpViewModel", "Error: ${t.message}", t) +// if (t is HttpException) { +// val error = t.message() +// errorMessage.postValue("$error") +// } else { +// errorMessage.postValue("서버 에러 발생") +// } +// } +// } +// } +// } + +} +//class SignUpViewModel : ViewModel() { +// +// var signupId = mutableStateOf("") +// var signupPw = mutableStateOf("") +// var signupName = mutableStateOf("") +// var signupPhone = mutableStateOf("") +// +// private val authService = ServicePool.authService +// +// fun getSignUpRequestDto(): RequestSignUpDto { +// return RequestSignUpDto( +// authenticationId = signupId.value, +// password = signupPw.value, +// nickname = signupName.value, +// phone = signupPhone.value +// ) +// } +// +// fun signUp(context: Context) { +// val signUpRequest = getSignUpRequestDto() +// authService.signUp(signUpRequest).enqueue(object : Callback { +// override fun onResponse( +// call: Call, +// response: Response, +// ) { +// if (response.isSuccessful) { +// val data: ResponseSignUpDto? = response.body() +// val userId = response.headers()["location"] +// Toast.makeText( +// context, +// "회원가입 성공, 유저의 ID는 $userId 입니다.", +// Toast.LENGTH_SHORT, +// ).show() +// val toLogIn = Intent(context, LoginActivity::class.java) +// context.startActivity(toLogIn) +// } else { +// val error = response.message() +// Toast.makeText( +// context, +// "회원가입 실패: $error", +// Toast.LENGTH_SHORT, +// ).show() +// } +// } +// +// override fun onFailure(call: Call, t: Throwable) { +// Log.e("SignUp", "서버 요청 실패", t) +// Toast.makeText(context, "서버 에러 발생", Toast.LENGTH_SHORT).show() +// } +// }) +// } +//} diff --git a/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModelFactory.kt b/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModelFactory.kt new file mode 100644 index 0000000..e6791c4 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/SignUp/SignUpViewModelFactory.kt @@ -0,0 +1,19 @@ +package com.sopt.now.compose.presentation.SignUp + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.sopt.now.compose.data.AuthRepoImpl +import com.sopt.now.compose.data.api.ServicePool +import com.sopt.now.compose.presentation.Login.LoginViewModel + +class SignUpViewModelFactory : ViewModelProvider.Factory { + override fun create(modelClass: Class): T { + if(modelClass.isAssignableFrom(SignUpViewModel::class.java)) { + val repository = + AuthRepoImpl(ServicePool.authService) + return SignUpViewModel(repository) as T + } else{ + throw IllegalArgumentException("Failed to create ViewModel: ${modelClass.name}") + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/ui/theme/SignUpData.kt b/app/src/main/java/com/sopt/now/compose/presentation/theme/SignUpData.kt similarity index 100% rename from app/src/main/java/com/sopt/now/compose/ui/theme/SignUpData.kt rename to app/src/main/java/com/sopt/now/compose/presentation/theme/SignUpData.kt From 797320bb7c544ea7a3bdc3496991bb9bd284f7c4 Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:55:40 +0900 Subject: [PATCH 11/12] =?UTF-8?q?[MOD]=20:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 3 +++ .../java/com/sopt/now/compose/Profile/ProfileFriendItem.kt | 2 +- .../main/java/com/sopt/now/compose/Profile/ProfileUserItem.kt | 3 +-- .../now/compose/{dto => data/dto/LoginDto}/RequestLogInDto.kt | 2 +- .../now/compose/{dto => data/dto/LoginDto}/ResponseLogInDto.kt | 2 +- .../com/sopt/now/compose/{ => data}/dto/ResponseUserProfile.kt | 2 +- .../compose/{dto => data/dto/SignUpDto}/RequestSignUpDto.kt | 2 +- .../compose/{dto => data/dto/SignUpDto}/ResponseSignUpDto.kt | 2 +- .../com/sopt/now/compose/{ => presentation/Home}/Friend.kt | 2 +- .../sopt/now/compose/{ => presentation/Home}/HomeViewModel.kt | 3 ++- 10 files changed, 13 insertions(+), 10 deletions(-) rename app/src/main/java/com/sopt/now/compose/{dto => data/dto/LoginDto}/RequestLogInDto.kt (84%) rename app/src/main/java/com/sopt/now/compose/{dto => data/dto/LoginDto}/ResponseLogInDto.kt (82%) rename app/src/main/java/com/sopt/now/compose/{ => data}/dto/ResponseUserProfile.kt (93%) rename app/src/main/java/com/sopt/now/compose/{dto => data/dto/SignUpDto}/RequestSignUpDto.kt (88%) rename app/src/main/java/com/sopt/now/compose/{dto => data/dto/SignUpDto}/ResponseSignUpDto.kt (82%) rename app/src/main/java/com/sopt/now/compose/{ => presentation/Home}/Friend.kt (76%) rename app/src/main/java/com/sopt/now/compose/{ => presentation/Home}/HomeViewModel.kt (96%) diff --git a/app/build.gradle b/app/build.gradle index a600460..05aea5e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -94,4 +94,7 @@ dependencies { // define any required OkHttp artifacts without version implementation("com.squareup.okhttp3:okhttp") implementation("com.squareup.okhttp3:logging-interceptor") + + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9") + implementation 'com.google.android.gms:play-services-location:21.2.0' } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/Profile/ProfileFriendItem.kt b/app/src/main/java/com/sopt/now/compose/Profile/ProfileFriendItem.kt index 6dddec7..d181d6e 100644 --- a/app/src/main/java/com/sopt/now/compose/Profile/ProfileFriendItem.kt +++ b/app/src/main/java/com/sopt/now/compose/Profile/ProfileFriendItem.kt @@ -17,7 +17,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.sopt.now.compose.Friend +import com.sopt.now.compose.presentation.Home.Friend import com.sopt.now.compose.R diff --git a/app/src/main/java/com/sopt/now/compose/Profile/ProfileUserItem.kt b/app/src/main/java/com/sopt/now/compose/Profile/ProfileUserItem.kt index 59b7330..a5fef8e 100644 --- a/app/src/main/java/com/sopt/now/compose/Profile/ProfileUserItem.kt +++ b/app/src/main/java/com/sopt/now/compose/Profile/ProfileUserItem.kt @@ -17,10 +17,9 @@ import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.sopt.now.compose.Friend +import com.sopt.now.compose.presentation.Home.Friend import com.sopt.now.compose.R diff --git a/app/src/main/java/com/sopt/now/compose/dto/RequestLogInDto.kt b/app/src/main/java/com/sopt/now/compose/data/dto/LoginDto/RequestLogInDto.kt similarity index 84% rename from app/src/main/java/com/sopt/now/compose/dto/RequestLogInDto.kt rename to app/src/main/java/com/sopt/now/compose/data/dto/LoginDto/RequestLogInDto.kt index f23ed05..2dd9950 100644 --- a/app/src/main/java/com/sopt/now/compose/dto/RequestLogInDto.kt +++ b/app/src/main/java/com/sopt/now/compose/data/dto/LoginDto/RequestLogInDto.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.dto +package com.sopt.now.compose.data.dto.LoginDto import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/app/src/main/java/com/sopt/now/compose/dto/ResponseLogInDto.kt b/app/src/main/java/com/sopt/now/compose/data/dto/LoginDto/ResponseLogInDto.kt similarity index 82% rename from app/src/main/java/com/sopt/now/compose/dto/ResponseLogInDto.kt rename to app/src/main/java/com/sopt/now/compose/data/dto/LoginDto/ResponseLogInDto.kt index 2a84c82..2112d94 100644 --- a/app/src/main/java/com/sopt/now/compose/dto/ResponseLogInDto.kt +++ b/app/src/main/java/com/sopt/now/compose/data/dto/LoginDto/ResponseLogInDto.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.dto +package com.sopt.now.compose.data.dto.LoginDto import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/app/src/main/java/com/sopt/now/compose/dto/ResponseUserProfile.kt b/app/src/main/java/com/sopt/now/compose/data/dto/ResponseUserProfile.kt similarity index 93% rename from app/src/main/java/com/sopt/now/compose/dto/ResponseUserProfile.kt rename to app/src/main/java/com/sopt/now/compose/data/dto/ResponseUserProfile.kt index 5183f04..a717c3d 100644 --- a/app/src/main/java/com/sopt/now/compose/dto/ResponseUserProfile.kt +++ b/app/src/main/java/com/sopt/now/compose/data/dto/ResponseUserProfile.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.dto +package com.sopt.now.compose.data.dto import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/app/src/main/java/com/sopt/now/compose/dto/RequestSignUpDto.kt b/app/src/main/java/com/sopt/now/compose/data/dto/SignUpDto/RequestSignUpDto.kt similarity index 88% rename from app/src/main/java/com/sopt/now/compose/dto/RequestSignUpDto.kt rename to app/src/main/java/com/sopt/now/compose/data/dto/SignUpDto/RequestSignUpDto.kt index a65a4aa..058cb9a 100644 --- a/app/src/main/java/com/sopt/now/compose/dto/RequestSignUpDto.kt +++ b/app/src/main/java/com/sopt/now/compose/data/dto/SignUpDto/RequestSignUpDto.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.dto +package com.sopt.now.compose.data.dto.SignUpDto import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/app/src/main/java/com/sopt/now/compose/dto/ResponseSignUpDto.kt b/app/src/main/java/com/sopt/now/compose/data/dto/SignUpDto/ResponseSignUpDto.kt similarity index 82% rename from app/src/main/java/com/sopt/now/compose/dto/ResponseSignUpDto.kt rename to app/src/main/java/com/sopt/now/compose/data/dto/SignUpDto/ResponseSignUpDto.kt index 5e9158b..1576593 100644 --- a/app/src/main/java/com/sopt/now/compose/dto/ResponseSignUpDto.kt +++ b/app/src/main/java/com/sopt/now/compose/data/dto/SignUpDto/ResponseSignUpDto.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose.dto +package com.sopt.now.compose.data.dto.SignUpDto import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/app/src/main/java/com/sopt/now/compose/Friend.kt b/app/src/main/java/com/sopt/now/compose/presentation/Home/Friend.kt similarity index 76% rename from app/src/main/java/com/sopt/now/compose/Friend.kt rename to app/src/main/java/com/sopt/now/compose/presentation/Home/Friend.kt index c02d3e3..fb362bc 100644 --- a/app/src/main/java/com/sopt/now/compose/Friend.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/Home/Friend.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose +package com.sopt.now.compose.presentation.Home import androidx.annotation.DrawableRes diff --git a/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt b/app/src/main/java/com/sopt/now/compose/presentation/Home/HomeViewModel.kt similarity index 96% rename from app/src/main/java/com/sopt/now/compose/HomeViewModel.kt rename to app/src/main/java/com/sopt/now/compose/presentation/Home/HomeViewModel.kt index 793b63d..2f121eb 100644 --- a/app/src/main/java/com/sopt/now/compose/HomeViewModel.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/Home/HomeViewModel.kt @@ -1,6 +1,7 @@ -package com.sopt.now.compose +package com.sopt.now.compose.presentation.Home import androidx.lifecycle.ViewModel +import com.sopt.now.compose.R class HomeViewModel : ViewModel() { From a856518280925b920cdaa7314ea2824309ba56c9 Mon Sep 17 00:00:00 2001 From: Hyoeun Date: Fri, 31 May 2024 20:55:58 +0900 Subject: [PATCH 12/12] =?UTF-8?q?[MOD]=20:=20MainActivity=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compose/{ => presentation}/MainActivity.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) rename app/src/main/java/com/sopt/now/compose/{ => presentation}/MainActivity.kt (95%) diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/presentation/MainActivity.kt similarity index 95% rename from app/src/main/java/com/sopt/now/compose/MainActivity.kt rename to app/src/main/java/com/sopt/now/compose/presentation/MainActivity.kt index a905b06..b1b03b2 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/MainActivity.kt @@ -1,4 +1,4 @@ -package com.sopt.now.compose +package com.sopt.now.compose.presentation import android.os.Bundle import androidx.activity.ComponentActivity @@ -33,12 +33,15 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.sopt.now.compose.BottomNavItem +import com.sopt.now.compose.presentation.Home.HomeViewModel import com.sopt.now.compose.Profile.ProfileFriendItem import com.sopt.now.compose.Profile.ProfileUserItem +import com.sopt.now.compose.R import com.sopt.now.compose.TextField.mainInfoText -import com.sopt.now.compose.api.ServicePool -import com.sopt.now.compose.dto.ResponseUserProfile -import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme +import com.sopt.now.compose.data.api.ServicePool +import com.sopt.now.compose.data.dto.ResponseUserProfile +import com.sopt.now.compose.presentation.theme.NOWSOPTAndroidTheme import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -60,11 +63,9 @@ class MainActivity : ComponentActivity() { } } } - } } } - @Composable fun ScaffoldExample(userId: String) { var selectedItem by remember { mutableIntStateOf(0) } @@ -91,7 +92,6 @@ fun ScaffoldExample(userId: String) { } } }, - ) { innerPadding -> Column( modifier = Modifier @@ -107,12 +107,10 @@ fun ScaffoldExample(userId: String) { } } } - } } } - @Composable fun MyPageScreen(userId: String) { var userProfile by remember { mutableStateOf(null) } @@ -138,7 +136,6 @@ fun MyPageScreen(userId: String) { } }) } - getUserInfo(userId)