From a27d2f133df218c63aa550624e688c202452706a Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:29:56 +0900 Subject: [PATCH 01/12] =?UTF-8?q?add/#6:=20viewBinding=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index f534bf6..36b9bd1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,6 +35,7 @@ android { } buildFeatures { compose true + viewBinding true } composeOptions { kotlinCompilerExtensionVersion '1.5.1' @@ -55,6 +56,12 @@ dependencies { implementation 'androidx.compose.ui:ui-graphics' implementation 'androidx.compose.ui:ui-tooling-preview' implementation 'androidx.compose.material3:material3' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.11.0' + implementation 'androidx.activity:activity:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7' + implementation 'androidx.navigation:navigation-ui-ktx:2.7.7' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' From 2e8b194b107de19512ab5b14e8db40b7ef7fc542 Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:32:38 +0900 Subject: [PATCH 02/12] =?UTF-8?q?mod/#6:=20=EC=A4=91=EB=B3=B5=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20Composable=EB=A1=9C=20=EC=9E=AC=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/LoginActivity.kt | 126 ++++++++-------- .../com/sopt/now/compose/SignUpActivity.kt | 134 +++++++----------- 2 files changed, 108 insertions(+), 152 deletions(-) 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 5eacdf5..8c02e07 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -6,12 +6,7 @@ import android.os.Bundle import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Button @@ -28,9 +23,11 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.KeyboardType 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 @@ -49,9 +46,9 @@ class LoginActivity : ComponentActivity() { val userId = intent.getStringExtra("userId").toString() val userPw = intent.getStringExtra("userPw").toString() val userName = intent.getStringExtra("userName").toString() - val userMbti = intent.getStringExtra("userMbti").toString() + val userDescription = intent.getStringExtra("userDescription").toString() - LoginCompose(userId, userPw, userName ,userMbti) + LoginCompose(userId, userPw, userName ,userDescription) } } } @@ -59,7 +56,43 @@ class LoginActivity : ComponentActivity() { } @Composable -fun LoginCompose(userId: String, userPw: String, userName: String, userMbti: String) { +fun LoginInputField(label: String, value: String, onValueChange: (String) -> Unit) { + Column( + modifier = Modifier.fillMaxWidth() + ) { + Text( + text = label, + fontSize = 20.sp, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Start + ) + Spacer(modifier = Modifier.height(10.dp)) + TextField( + value = value, + onValueChange = onValueChange, + modifier = Modifier.fillMaxWidth(), + label = { Text(label) }, + singleLine = true, + visualTransformation = if (label == "비밀번호") PasswordVisualTransformation() else VisualTransformation.None, + keyboardOptions = if (label == "비밀번호") KeyboardOptions(keyboardType = KeyboardType.Password) else KeyboardOptions.Default + ) + } +} + +@Composable +fun LoginButton(text: String, onClick: () -> Unit) { + Button( + onClick = onClick, + colors = ButtonDefaults.buttonColors(containerColor = Color.Black), + shape = RoundedCornerShape(50.dp), + modifier = Modifier.fillMaxWidth() + ) { + Text(text, color = Color.White) + } +} + +@Composable +fun LoginCompose(userId: String, userPw: String, userName: String, userDescription: String) { val context = LocalContext.current var inputId by remember { mutableStateOf("") } var inputPw by remember { mutableStateOf("") } @@ -67,86 +100,39 @@ fun LoginCompose(userId: String, userPw: String, userName: String, userMbti: Str Column( modifier = Modifier .fillMaxSize() - .padding(horizontal = 30.dp), + .padding(horizontal = 30.dp, vertical = 60.dp), ) { - Spacer(modifier = Modifier.height(60.dp)) Text( - text = "Welcom To SOPT", + text = stringResource(id = R.string.title_login), fontSize = 30.sp, fontWeight = FontWeight.Bold, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth() ) Spacer(modifier = Modifier.height(60.dp)) - Text( - text = "ID", - fontSize = 20.sp, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Start - ) - Spacer(modifier = Modifier.height(10.dp)) - TextField( - value = inputId, - onValueChange = { inputId = it }, - modifier = Modifier.fillMaxWidth(), - label = { Text("아이디를 입력하세요.") }, - singleLine = true, //단일 줄로 제한 - ) - Spacer(modifier = Modifier.height(30.dp)) - Text( - text = "비밀번호", - fontSize = 20.sp, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Start - ) - Spacer(modifier = Modifier.height(10.dp)) - TextField( - value = inputPw, - onValueChange = { inputPw = it }, - modifier = Modifier.fillMaxWidth(), - label = { Text("비밀번호를 입력하세요.") }, - singleLine = true, //단일 줄로 제한 - visualTransformation = PasswordVisualTransformation(), // 비밀번호 마스킹 처리 - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password) - ) + LoginInputField(label = stringResource(id = R.string.tv_id), value = inputId) { inputId = it } + Spacer(modifier = Modifier.height(60.dp)) + LoginInputField(label = stringResource(id = R.string.tv_pw), value = inputPw) { inputPw = it } Spacer(modifier = Modifier.weight(2f)) - Button( - onClick = { - // 로그인 - if(userId == inputId && userPw == inputPw){ - moveToMain(context, userId, userPw, userName ,userMbti) - } - }, - colors = ButtonDefaults.buttonColors(containerColor = Color.Black), - shape = RoundedCornerShape(50.dp), - modifier = Modifier.fillMaxWidth() - ) { - Text("로그인", color = Color.White) + LoginButton(stringResource(id = R.string.btn_login)) { + if (userId == inputId && userPw == inputPw) { + moveToMain(context, userId, userPw, userName, userDescription) + } } Spacer(modifier = Modifier.height(10.dp)) - Button( - onClick = { - // 회원가입 페이지로 이동 - val intent = Intent(context, SignUpActivity::class.java) - context.startActivity(intent) - }, - colors = ButtonDefaults.buttonColors(containerColor = Color.Black), - shape = RoundedCornerShape(50.dp), - modifier = Modifier.fillMaxWidth() - ) { - Text("회원가입", color = Color.White) + LoginButton(stringResource(id = R.string.btn_sign_up)) { + val intent = Intent(context, SignUpActivity::class.java) + context.startActivity(intent) } - Spacer(modifier = Modifier.padding(bottom = 60.dp)) } } -// 메인 페이지로 이동 -private fun moveToMain(context: Context, userId: String, userPw: String, userName: String, userMbti: String) { +private fun moveToMain(context: Context, userId: String, userPw: String, userName: String, userDescription: String) { val intent = Intent(context, MainActivity::class.java).apply { putExtra("userId", userId) putExtra("userPw", userPw) putExtra("userName", userName) - putExtra("userMbti", userMbti) + putExtra("userDescription", userDescription) } context.startActivity(intent) 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/SignUpActivity.kt index fde8d08..50259db 100644 --- a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt @@ -6,12 +6,7 @@ import android.os.Bundle import android.widget.Toast import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults @@ -19,14 +14,11 @@ 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.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -56,120 +48,98 @@ fun SignUpCompose(){ var userId by remember { mutableStateOf("") } var userPw by remember { mutableStateOf("") } var userName by remember { mutableStateOf("") } - var userMbti by remember { mutableStateOf("") } + var userDescription by remember { mutableStateOf("") } Column( modifier = Modifier .fillMaxSize() - .padding(horizontal = 30.dp), + .padding(horizontal = 30.dp, vertical = 60.dp), ) { - Spacer(modifier = Modifier.height(60.dp)) Text( - text = "Sign Up", + text = stringResource(id = R.string.title_sign_up), fontSize = 30.sp, fontWeight = FontWeight.Bold, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth() ) Spacer(modifier = Modifier.height(60.dp)) - Text( - text = "ID", - fontSize = 20.sp, - textAlign = TextAlign.Start - ) - Spacer(modifier = Modifier.height(10.dp)) - TextField( - value = userId, - onValueChange = { userId = it }, - modifier = Modifier.fillMaxWidth(), - label = { Text("아이디를 입력하세요.") }, - singleLine = true //단일 줄로 제한 - ) + TextFieldWithLabel( + stringResource(id = R.string.tv_id), userId, + stringResource(id = R.string.hint_id) + ) { userId = it } Spacer(modifier = Modifier.height(30.dp)) - Text( - text = "비밀번호", - fontSize = 20.sp, - textAlign = TextAlign.Start - ) - Spacer(modifier = Modifier.height(10.dp)) - TextField( - value = userPw, - onValueChange = { userPw = it }, - modifier = Modifier.fillMaxWidth(), - label = { Text("비밀번호를 입력하세요.") }, - singleLine = true - ) - Spacer(modifier = Modifier.height(10.dp)) + TextFieldWithLabel( + stringResource(id = R.string.tv_pw), userPw, + stringResource(id = R.string.hint_pw) + ) { userPw = it } Spacer(modifier = Modifier.height(30.dp)) - Text( - text = "닉네임", - fontSize = 20.sp, - textAlign = TextAlign.Start - ) - Spacer(modifier = Modifier.height(10.dp)) - TextField( - value = userName, - onValueChange = { userName = it }, - modifier = Modifier.fillMaxWidth(), - label = { Text("닉네임을 입력하세요.") }, - singleLine = true - ) + TextFieldWithLabel( + stringResource(id = R.string.tv_user_name), userName, + stringResource(id = R.string.hint_user_name) + ) { userName = it } Spacer(modifier = Modifier.height(30.dp)) - Text( - text = "MBTI", - fontSize = 20.sp, - textAlign = TextAlign.Start - ) - Spacer(modifier = Modifier.height(10.dp)) - TextField( - value = userMbti, - onValueChange = { userMbti = it }, - modifier = Modifier.fillMaxWidth(), - label = { Text("MBTI를 입력하세요.") }, - singleLine = true - ) + TextFieldWithLabel( + stringResource(id = R.string.tv_user_description), userDescription, + stringResource(id = R.string.hint_user_description) + ) { userDescription = it } Spacer(modifier = Modifier.weight(2f)) Button( onClick = { - checkSignUp(context, userId, userPw, userName, userMbti) + checkSignUp(context, userId, userPw, userName, userDescription) }, colors = ButtonDefaults.buttonColors(containerColor = Color.Black), shape = RoundedCornerShape(50.dp), modifier = Modifier.fillMaxWidth() ) { - Text("회원가입", color = Color.White) + Text(stringResource(id = R.string.btn_sign_up), color = Color.White) } - Spacer(modifier = Modifier.padding(bottom = 60.dp)) + } +} + +@Composable +fun TextFieldWithLabel(label: String, value: String, hint: String, onValueChange: (String) -> Unit) { + Column { + Text( + text = label, + fontSize = 20.sp, + textAlign = TextAlign.Start + ) + Spacer(modifier = Modifier.height(10.dp)) + TextField( + value = value, + onValueChange = onValueChange, + modifier = Modifier.fillMaxWidth(), + label = { Text(hint) }, + singleLine = true + ) } } // 회원 가입 가능 여부 체크 -fun checkSignUp(context: Context, userId: String, userPw: String, userName: String, userMbti: String) { +fun checkSignUp(context: Context, userId: String, userPw: String, userName: String, userDescription: String) { val isValidId = userId.length in 6..10 val isValidPw = userPw.length in 8..12 val isValidName = userName.trim().isEmpty() // 공백으로만 이루어진 경우 판단 - val isEmpty = userId.isEmpty() || userPw.isEmpty() || userName.isEmpty() || userMbti.isEmpty() val message = when { - !isValidId -> "ID는 6~10 글자여야 합니다." - !isValidPw -> "Password는 8~12 글자여야 합니다." - isValidName -> "공백으로만 이루어진 닉네임은 불가합니다." - isEmpty -> "모든 정보를 입력해주세요." + !isValidId -> context.getString(R.string.error_invalid_id) + !isValidPw -> context.getString(R.string.error_invalid_pw) + isValidName -> context.getString(R.string.error_empty_name) else -> { - moveToLogin(context, userId, userPw, userName, userMbti) - "회원가입 성공!" + moveToLogin(context, userId, userPw, userName, userDescription) + context.getString(R.string.signup_success) } } Toast.makeText(context, message, Toast.LENGTH_SHORT).show() } -// 로그인 페이지로 이동 -private fun moveToLogin(context: Context, userId: String, userPw: String, userName: String, userMbti: String) { +// Move to login page +private fun moveToLogin(context: Context, userId: String, userPw: String, userName: String, userDescription: String) { val intent = Intent(context, LoginActivity::class.java).apply { putExtra("userId", userId) putExtra("userPw", userPw) putExtra("userName", userName) - putExtra("userMbti", userMbti) + putExtra("userDescription", userDescription) } context.startActivity(intent) } From 4188b5e4a473a6cbc9d585b2ab5dff41887973b1 Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:33:02 +0900 Subject: [PATCH 03/12] =?UTF-8?q?add/#6:=20string=20=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/strings.xml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index be0d381..6790dcb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,26 @@ NOW SOPT Android + Welcome to SOPT + 회원가입 + 로그인 + ID + 아이디를 입력해주세요. + 비밀번호 + 비밀번호를 입력해주세요. + + SIGN UP + 닉네임 + 닉네임을 입력해주세요. + 한 줄 소개 + 한 줄 소개를 입력해주세요. + + ID는 6~10 글자여야 합니다. + Password는 8~12 글자여야 합니다. + 공백으로만 이루어진 닉네임은 불가합니다. + 회원가입 성공! + + First Fragment + Second Fragment + Next + Previous \ No newline at end of file From 9a19af3006f1087e5bda51f9b2e16cbeabcfc46e Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:33:41 +0900 Subject: [PATCH 04/12] =?UTF-8?q?mod/#6:=20Main=20UI=EB=A5=BC=20MyPage?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/MyPageView.kt | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/compose/MyPageView.kt diff --git a/app/src/main/java/com/sopt/now/compose/MyPageView.kt b/app/src/main/java/com/sopt/now/compose/MyPageView.kt new file mode 100644 index 0000000..d0589b6 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/MyPageView.kt @@ -0,0 +1,82 @@ +package com.sopt.now.compose + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +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.ui.theme.NOWSOPTAndroidTheme + +@Composable +fun MyPageView(userId: String, userPw: String, userName: String, userDescription: String) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(horizontal = 30.dp, vertical = 60.dp), + ) { + Row( + modifier = Modifier.fillMaxWidth() + ) { + Image( + painter = painterResource(id = R.drawable.iv_user_profile), + contentDescription = stringResource(id = R.string.app_name), + Modifier + .size(100.dp) + .aspectRatio(1f) + ) + Spacer(modifier = Modifier.width(20.dp)) + Text( + text = userName, + fontSize = 20.sp + ) + } + Spacer(modifier = Modifier.height(60.dp)) + UserInfoItem( + label = stringResource(id = R.string.tv_id), + value = userId + ) + Spacer(modifier = Modifier.height(30.dp)) + UserInfoItem( + label = stringResource(id = R.string.tv_pw), + value = userPw + ) + Spacer(modifier = Modifier.height(30.dp)) + UserInfoItem( + label = stringResource(id = R.string.tv_user_description), + value = userDescription + ) + } +} + +@Composable +fun UserInfoItem(label: String, value: String) { + Column { + Text( + text = label, + fontSize = 20.sp, + fontWeight = FontWeight.Bold + ) + Spacer(modifier = Modifier.height(10.dp)) + Text( + text = value, + fontSize = 20.sp + ) + } +} + +@Preview(showBackground = true) +@Composable +fun MyPagePreview() { + NOWSOPTAndroidTheme { + MyPageView("myPageSopt", "mypagePassword123", "MyPageUserName", "INFJ 입니다!") + } +} From 025f95748cb0b8bb674332c15d3f535261c9b548 Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:34:21 +0900 Subject: [PATCH 05/12] =?UTF-8?q?add/#6:=20Profile=20Data=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/item/Profile.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/compose/item/Profile.kt diff --git a/app/src/main/java/com/sopt/now/compose/item/Profile.kt b/app/src/main/java/com/sopt/now/compose/item/Profile.kt new file mode 100644 index 0000000..0cb2a55 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/item/Profile.kt @@ -0,0 +1,7 @@ +package com.sopt.now.compose.item + +data class Profile( + val userProfile: Int, + val userName: String, + val userDescription: String +) \ No newline at end of file From efc87e8b7bdd9c0602a3adb15119d91bb83db843 Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:35:15 +0900 Subject: [PATCH 06/12] =?UTF-8?q?ui/#6:=20UserItem=20UI=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/item/UserItem.kt | 54 ++++++++++++++++++ app/src/main/res/drawable/iv_user_profile.jpg | Bin 0 -> 7022 bytes 2 files changed, 54 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/compose/item/UserItem.kt create mode 100644 app/src/main/res/drawable/iv_user_profile.jpg diff --git a/app/src/main/java/com/sopt/now/compose/item/UserItem.kt b/app/src/main/java/com/sopt/now/compose/item/UserItem.kt new file mode 100644 index 0000000..823c5cd --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/item/UserItem.kt @@ -0,0 +1,54 @@ +package com.sopt.now.compose.item + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +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.R +import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme + +@Composable +fun UserItem(profileData:Profile) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 10.dp, vertical = 20.dp), + ) { + Image( + painter = painterResource(profileData.userProfile), + contentDescription = stringResource(id = R.string.app_name), + Modifier + .size(80.dp) + .aspectRatio(1f) + ) + Spacer(modifier = Modifier.width(10.dp)) + Text( + text = profileData.userName, + fontSize = 20.sp, + fontWeight = FontWeight.Bold, + ) + Spacer(modifier = Modifier.weight(1f)) + Text( + text = profileData.userDescription, + fontSize = 20.sp, + textAlign = TextAlign.End, + maxLines = 1 + ) + } +} + +@Preview(showBackground = true) +@Composable +fun UserPreview() { + NOWSOPTAndroidTheme { + UserItem(Profile(R.drawable.iv_user_profile, "youjin", "welcome")) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/iv_user_profile.jpg b/app/src/main/res/drawable/iv_user_profile.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f82418514ce9f38dc0eb5e1304d11827659041d2 GIT binary patch literal 7022 zcmb7o%4!!xo56tu50d@`Kx|BwHRbd2zO9E{8e7CJgkQBDM(fRK<71G~74_EV-|$7!v+8UAT2HZw;Mo33|Ir~f`MEB5ET$i1^n9&UwxARR8iIAi=*E{Qr0$h>8>ZKf*K+ zS}w7_%K&ol|NV{%pbW6^h@~;~*Vg9^t__LxxqD)LB^u88CN|LTzEBZL{;i8NK}0mT z+~K79iK!%?nh28TK=lVxoM?uCND-0r(uIHn)=EvC*EF+`~}<>et9c};{D*{%i6mzJ$iUBQ);2H z!81EWA<={_w}{CzJJKH(yT=hW;oG^?=ev=bquZqI|r&UK2TPUEL$S1NE*mZ~fO_c`Nqt z#=?9gPX;^m=@~cEZ{^Y-aaH-#K%EbiQ#Y>`^IvTTWL~@|KOf}}JpJACX|x<$(jSau z-uQ#snBI&yv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z0( Date: Fri, 19 Apr 2024 23:35:33 +0900 Subject: [PATCH 07/12] =?UTF-8?q?ui/#6:=20FriendItem=20UI=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sopt/now/compose/item/FriendItem.kt | 54 ++++++++++++++++++ app/src/main/res/drawable/img_profile.jpg | Bin 7022 -> 0 bytes .../main/res/drawable/iv_friend_profile.jpg | Bin 0 -> 5115 bytes 3 files changed, 54 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/compose/item/FriendItem.kt delete mode 100644 app/src/main/res/drawable/img_profile.jpg create mode 100644 app/src/main/res/drawable/iv_friend_profile.jpg diff --git a/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt b/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt new file mode 100644 index 0000000..a7224d1 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt @@ -0,0 +1,54 @@ +package com.sopt.now.compose.item + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +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.R +import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme + +@Composable +fun FriendItem(profile: Profile) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 10.dp, vertical = 20.dp), + ) { + Image( + painter = painterResource(profile.userProfile), + contentDescription = stringResource(id = R.string.app_name), + Modifier + .size(50.dp) + .aspectRatio(1f) + ) + Spacer(modifier = Modifier.width(10.dp)) + Text( + text = profile.userName, + fontSize = 20.sp, + fontWeight = FontWeight.Bold, + ) + Spacer(modifier = Modifier.weight(1f)) + Text( + text = profile.userDescription, + fontSize = 20.sp, + textAlign = TextAlign.End, + maxLines = 1 + ) + } +} + +@Preview(showBackground = true) +@Composable +fun FriendPreview() { + NOWSOPTAndroidTheme { + FriendItem(Profile(R.drawable.iv_user_profile, "youjin", "welcome")) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/img_profile.jpg b/app/src/main/res/drawable/img_profile.jpg deleted file mode 100644 index f82418514ce9f38dc0eb5e1304d11827659041d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7022 zcmb7o%4!!xo56tu50d@`Kx|BwHRbd2zO9E{8e7CJgkQBDM(fRK<71G~74_EV-|$7!v+8UAT2HZw;Mo33|Ir~f`MEB5ET$i1^n9&UwxARR8iIAi=*E{Qr0$h>8>ZKf*K+ zS}w7_%K&ol|NV{%pbW6^h@~;~*Vg9^t__LxxqD)LB^u88CN|LTzEBZL{;i8NK}0mT z+~K79iK!%?nh28TK=lVxoM?uCND-0r(uIHn)=EvC*EF+`~}<>et9c};{D*{%i6mzJ$iUBQ);2H z!81EWA<={_w}{CzJJKH(yT=hW;oG^?=ev=bquZqI|r&UK2TPUEL$S1NE*mZ~fO_c`Nqt z#=?9gPX;^m=@~cEZ{^Y-aaH-#K%EbiQ#Y>`^IvTTWL~@|KOf}}JpJACX|x<$(jSau z-uQ#snBI&yv<-hnyOc*K*oBK2@fgrO>l}USLY-XovSK446~6oc{*}AM13SxT6kG@51 z@)L{|70Er=6&l@A3Fh-OM40`q5M`ca#d{p$Bg@g8KC-Ae(7Q|6v*HwystO1{Q^F<& zbH);-*h^^>JK%Vc-?FP+)>c9(v$#s7@UhYq2Om192qI61Q8tW@zEh>|b5w6@GBT$` zo$AR6odA@brMUU;&kPnXQC1(O;-)z{@xhu$NZJH4XY{mg3Py#PFh6tQo<=lcs- zd;DB_kBYrYL07i#Mb@j)XLDY3c>pMM-%sAR>sqJzp?2<9#n``q$;M!_V0gftPC|-; z*YmCXf;Z0*yMKJI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k8U#GDPCQrL=EmVIac-o`8n~sqy;mSfpIv; zrqm8ZtS%kvM~c8`3G z+@Ep@dWAVeu3n>U!smE_adl8(LN%{a9BWmJ#9-5qQ@PckQqV5Upz~nykW)CfR{Pi- zORVA~aVYi5RZ;#G zw@<|vy$Ha+sTFgGU^ed@l_7u~GaquTcJ9+jNpgNp2JwX`!38xb`WSl~p^UBqn2CQh z7r|kbJ1pevnX@o5U=gqQxF-yfETjc3JuuHFp{?p?xJw4FU#2-l zqEu*IL!6X`7K3y2%4Tw&O-g!Y5S3Ym6Eu&oHf4L24jHq24*tE*g-QC;C0}ucUt7=FMl*;j=_e8`pi@#;n%e0X_Jp#g=PktS$%uL3^fPA9{;jn-Md;3Q|)f=jG zbSxB*jxQ_`o#QS}+7L}UvZ8tvzAB>O+Q8lmA_?Z|5-j~A=`1}RUvP~?8&snAe2s)= z?ae^wrTkM^rqVxfjk{RpvfzypD68+hIU$fi96Wr<+gAX09YVSVg9$W)?T+M=mg#WQ;T_~;jMLLtSJYA zKPM+}k0(@b5AKzjd}*RWROs5^4QIJIkF!rc1>!&7P6AoyIg5nL>5|bLtTMKcvQnii z7Ju Date: Fri, 19 Apr 2024 23:36:11 +0900 Subject: [PATCH 08/12] =?UTF-8?q?feat/#6:=20HomeView=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/HomeView.kt | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/compose/HomeView.kt diff --git a/app/src/main/java/com/sopt/now/compose/HomeView.kt b/app/src/main/java/com/sopt/now/compose/HomeView.kt new file mode 100644 index 0000000..7534e1b --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/HomeView.kt @@ -0,0 +1,106 @@ +package com.sopt.now.compose + +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import com.sopt.now.compose.item.FriendItem +import com.sopt.now.compose.item.Profile +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.sopt.now.compose.item.UserItem +import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme + +@Composable +fun HomeView() { + LazyColumn( + modifier = Modifier.fillMaxSize() + ) { + item { + UserItem(friendList.first()) + } + + // 첫 번째 요소는 건너뛰고 적용 + itemsIndexed(friendList) { index, profile -> + if (index > 0) { + FriendItem(profile) + } + } + } +} + +val friendList = listOf( + Profile( + userProfile = R.drawable.iv_user_profile, + userName = "박유진", + userDescription = "안녕하세요~!!" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "AAA", + userDescription = "AAA님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "BBB", + userDescription = "BBB님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "CCC", + userDescription = "CCC님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "DDD", + userDescription = "DDD님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "EEE", + userDescription = "EEE님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "FFF", + userDescription = "FFF님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "GGG", + userDescription = "GGG님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "HHH", + userDescription = "HHH님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "III", + userDescription = "III님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "JJJ", + userDescription = "JJJ님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "KKK", + userDescription = "KKK님의 한 줄 소개" + ), + Profile( + userProfile = R.drawable.iv_friend_profile, + userName = "LLL", + userDescription = "LLL님의 한 줄 소개" + ) +) + +@Preview(showBackground = true) +@Composable +fun HomePreview() { + NOWSOPTAndroidTheme { + HomeView() + } +} \ No newline at end of file From 1cc3632865a82668c7b3aa3dd538afd41e232a5e Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Fri, 19 Apr 2024 23:38:53 +0900 Subject: [PATCH 09/12] =?UTF-8?q?feat/#6:=20BottomNavigation=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/now/compose/BottomNavigationItem.kt | 8 + .../java/com/sopt/now/compose/MainActivity.kt | 140 +++++++++--------- 2 files changed, 80 insertions(+), 68 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/BottomNavigationItem.kt diff --git a/app/src/main/java/com/sopt/now/compose/BottomNavigationItem.kt b/app/src/main/java/com/sopt/now/compose/BottomNavigationItem.kt new file mode 100644 index 0000000..efc4679 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/BottomNavigationItem.kt @@ -0,0 +1,8 @@ +package com.sopt.now.compose + +import androidx.compose.ui.graphics.vector.ImageVector + +data class BottomNavigationItem( + val icon: ImageVector, + val label: String +) \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index 29f448d..30a05a3 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -3,26 +3,29 @@ package com.sopt.now.compose import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Home +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource 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 class MainActivity : ComponentActivity() { @@ -34,12 +37,18 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - val userId = intent.getStringExtra("userId")?: "" - val userPw = intent.getStringExtra("userPw")?: "" - val userName = intent.getStringExtra("userName")?: "" - val userMbti = intent.getStringExtra("userMbti")?: "" - MainCompose(userId, userPw, userName, userMbti) + val userId = intent.getStringExtra("userId").toString() + val userPw = intent.getStringExtra("userPw").toString() + val userName = intent.getStringExtra("userName").toString() + val userDescription = intent.getStringExtra("userDescription").toString() + + ScaffoldExample( + userId = userId, + userPw = userPw, + userName = userName, + userDescription = userDescription + ) } } } @@ -47,60 +56,55 @@ class MainActivity : ComponentActivity() { } @Composable -fun MainCompose(userId: String, userPw: String, userName: String, userMbti: String){ - Column( - modifier = Modifier - .fillMaxSize() - .padding(horizontal = 30.dp), - ) { - Spacer(modifier = Modifier.height(60.dp)) - Row ( +fun ScaffoldExample(userId: String, userPw: String, userName: String, userDescription: String) { + var selectedItem by remember { mutableIntStateOf(0) } + val items = listOf( + BottomNavigationItem( + icon = Icons.Filled.Home, + label = "Home" + ), + BottomNavigationItem( + icon = Icons.Filled.Search, + label = "Search" + ), + BottomNavigationItem( + icon = Icons.Filled.Person, + label = "Profile" + ) + ) + + Scaffold( + bottomBar = { + NavigationBar { + items.forEachIndexed { index, item -> + NavigationBarItem( + icon = { Icon(item.icon, contentDescription = item.label) }, + label = { Text(item.label) }, + selected = selectedItem == index, + onClick = { selectedItem = index } + ) + } + } + }, + ) { innerPadding -> + Column( modifier = Modifier - .fillMaxWidth() - ){ - Image( - painter = painterResource(id = R.drawable.img_profile), - contentDescription = "Profile", - Modifier - .size(100.dp) - .aspectRatio(1f/1f) - ) - Spacer(modifier = Modifier.width(20.dp)) - Text( - text = userName, - fontSize = 20.sp - ) + .padding(innerPadding), + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + when(selectedItem) { + 0 -> { + HomeView() + } + 1 -> { + Text(text ="Search") + } + 2 -> { + MyPageView(userId, userPw, userName, userDescription) + } + } + } - Spacer(modifier = Modifier.height(60.dp)) - Text( - text = "ID", - fontSize = 20.sp - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = userId, - fontSize = 20.sp - ) - Spacer(modifier = Modifier.height(30.dp)) - Text( - text = "PW", - fontSize = 20.sp, - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = userPw, - fontSize = 20.sp, - ) - Spacer(modifier = Modifier.height(30.dp)) - Text( - text = "MBTI", - fontSize = 20.sp, - ) - Spacer(modifier = Modifier.height(10.dp)) - Text( - text = userMbti, - fontSize = 20.sp, - ) } } @@ -108,6 +112,6 @@ fun MainCompose(userId: String, userPw: String, userName: String, userMbti: Stri @Composable fun MainPreview() { NOWSOPTAndroidTheme { - MainCompose("nowSopt", "password123", "UserName", "ISTP") + ScaffoldExample("Id1234", "Password123", "UserName", "INFJ 입니다!") } } \ No newline at end of file From eb9441a0b23eff8d496a4546155973fdf61952df Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Thu, 2 May 2024 19:09:24 +0900 Subject: [PATCH 10/12] =?UTF-8?q?mod/#6:=20=EB=A7=90=20=EC=A4=84=EC=9E=84?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/item/FriendItem.kt | 7 ++++++- app/src/main/java/com/sopt/now/compose/item/UserItem.kt | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt b/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt index a7224d1..de33f4f 100644 --- a/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt +++ b/app/src/main/java/com/sopt/now/compose/item/FriendItem.kt @@ -9,12 +9,14 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.sopt.now.compose.R import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme + @Composable fun FriendItem(profile: Profile) { Row( @@ -34,13 +36,16 @@ fun FriendItem(profile: Profile) { text = profile.userName, fontSize = 20.sp, fontWeight = FontWeight.Bold, + maxLines = 1, + overflow = TextOverflow.Ellipsis ) Spacer(modifier = Modifier.weight(1f)) Text( text = profile.userDescription, fontSize = 20.sp, textAlign = TextAlign.End, - maxLines = 1 + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } } diff --git a/app/src/main/java/com/sopt/now/compose/item/UserItem.kt b/app/src/main/java/com/sopt/now/compose/item/UserItem.kt index 823c5cd..8f75cfa 100644 --- a/app/src/main/java/com/sopt/now/compose/item/UserItem.kt +++ b/app/src/main/java/com/sopt/now/compose/item/UserItem.kt @@ -9,6 +9,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -34,13 +35,15 @@ fun UserItem(profileData:Profile) { text = profileData.userName, fontSize = 20.sp, fontWeight = FontWeight.Bold, + overflow = TextOverflow.Ellipsis ) Spacer(modifier = Modifier.weight(1f)) Text( text = profileData.userDescription, fontSize = 20.sp, textAlign = TextAlign.End, - maxLines = 1 + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } } From a9e7d2d9a316c479a9beff5c44b456c0df0c5285 Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Thu, 2 May 2024 19:09:51 +0900 Subject: [PATCH 11/12] =?UTF-8?q?mod/#6:=20MainView=EB=A1=9C=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/compose/MainActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/MainActivity.kt index 30a05a3..d6075a3 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -43,7 +43,7 @@ class MainActivity : ComponentActivity() { val userName = intent.getStringExtra("userName").toString() val userDescription = intent.getStringExtra("userDescription").toString() - ScaffoldExample( + MainView( userId = userId, userPw = userPw, userName = userName, @@ -56,7 +56,7 @@ class MainActivity : ComponentActivity() { } @Composable -fun ScaffoldExample(userId: String, userPw: String, userName: String, userDescription: String) { +fun MainView(userId: String, userPw: String, userName: String, userDescription: String) { var selectedItem by remember { mutableIntStateOf(0) } val items = listOf( BottomNavigationItem( @@ -112,6 +112,6 @@ fun ScaffoldExample(userId: String, userPw: String, userName: String, userDescri @Composable fun MainPreview() { NOWSOPTAndroidTheme { - ScaffoldExample("Id1234", "Password123", "UserName", "INFJ 입니다!") + MainView("Id1234", "Password123", "UserName", "ISTP 입니다!") } } \ No newline at end of file From 2e0c262240d301a67d4401f0f34f4c7dc26433af Mon Sep 17 00:00:00 2001 From: youjin09222 Date: Thu, 2 May 2024 19:56:47 +0900 Subject: [PATCH 12/12] =?UTF-8?q?refactor/#6:=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=ED=98=B8=EC=9D=B4=EC=8A=A4=ED=8C=85=20=EB=B0=8F=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=EB=AC=B8=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/LoginActivity.kt | 131 ++++++++++++------ 1 file changed, 88 insertions(+), 43 deletions(-) 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 8c02e07..d4f42de 100644 --- a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt @@ -48,7 +48,7 @@ class LoginActivity : ComponentActivity() { val userName = intent.getStringExtra("userName").toString() val userDescription = intent.getStringExtra("userDescription").toString() - LoginCompose(userId, userPw, userName ,userDescription) + LoginView(userId, userPw, userName ,userDescription) } } } @@ -56,7 +56,64 @@ class LoginActivity : ComponentActivity() { } @Composable -fun LoginInputField(label: String, value: String, onValueChange: (String) -> Unit) { +fun LoginView( + userId: String, + userPw: String, + userName: String, + userDescription: String +) { + val context = LocalContext.current + var inputId by remember { mutableStateOf("") } + var inputPw by remember { mutableStateOf("") } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(horizontal = 30.dp, vertical = 60.dp), + ) { + Text( + text = stringResource(id = R.string.title_login), + fontSize = 30.sp, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() + ) + Spacer(modifier = Modifier.height(60.dp)) + LoginInputField( + label = stringResource(id = R.string.tv_id), + inputData = inputId, + isPassword = false + ) { inputId = it } + Spacer(modifier = Modifier.height(60.dp)) + LoginInputField( + label = stringResource(id = R.string.tv_pw), + inputData = inputPw, + isPassword = true + ) { inputPw = it } + Spacer(modifier = Modifier.weight(2f)) + LoginButton( + text = stringResource(id = R.string.btn_login), + onClick = { + checkLogin(context, userId, userPw, userName, userDescription, inputId, inputPw) + } + ) + Spacer(modifier = Modifier.height(10.dp)) + LoginButton( + stringResource(id = R.string.btn_sign_up)) { + Intent(context, SignUpActivity::class.java).apply { + context.startActivity(this) + } + } + } +} + +@Composable +fun LoginInputField( + label: String, + inputData: String, + isPassword: Boolean, + onValueChange: (String) -> Unit +) { Column( modifier = Modifier.fillMaxWidth() ) { @@ -68,17 +125,22 @@ fun LoginInputField(label: String, value: String, onValueChange: (String) -> Uni ) Spacer(modifier = Modifier.height(10.dp)) TextField( - value = value, + value = inputData, onValueChange = onValueChange, modifier = Modifier.fillMaxWidth(), label = { Text(label) }, singleLine = true, - visualTransformation = if (label == "비밀번호") PasswordVisualTransformation() else VisualTransformation.None, - keyboardOptions = if (label == "비밀번호") KeyboardOptions(keyboardType = KeyboardType.Password) else KeyboardOptions.Default + visualTransformation = + if (isPassword) + PasswordVisualTransformation() + else VisualTransformation.None, + keyboardOptions = + if (isPassword) + KeyboardOptions(keyboardType = KeyboardType.Password) + else KeyboardOptions.Default ) } } - @Composable fun LoginButton(text: String, onClick: () -> Unit) { Button( @@ -91,50 +153,33 @@ fun LoginButton(text: String, onClick: () -> Unit) { } } -@Composable -fun LoginCompose(userId: String, userPw: String, userName: String, userDescription: String) { - val context = LocalContext.current - var inputId by remember { mutableStateOf("") } - var inputPw by remember { mutableStateOf("") } - - Column( - modifier = Modifier - .fillMaxSize() - .padding(horizontal = 30.dp, vertical = 60.dp), - ) { - Text( - text = stringResource(id = R.string.title_login), - fontSize = 30.sp, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - Spacer(modifier = Modifier.height(60.dp)) - LoginInputField(label = stringResource(id = R.string.tv_id), value = inputId) { inputId = it } - Spacer(modifier = Modifier.height(60.dp)) - LoginInputField(label = stringResource(id = R.string.tv_pw), value = inputPw) { inputPw = it } - Spacer(modifier = Modifier.weight(2f)) - LoginButton(stringResource(id = R.string.btn_login)) { - if (userId == inputId && userPw == inputPw) { - moveToMain(context, userId, userPw, userName, userDescription) - } - } - Spacer(modifier = Modifier.height(10.dp)) - LoginButton(stringResource(id = R.string.btn_sign_up)) { - val intent = Intent(context, SignUpActivity::class.java) - context.startActivity(intent) - } +private fun checkLogin( + context: Context, + userId: String, + userPw: String, + userName: String, + userDescription: String, + inputId: String, + inputPw: String +) { + if (userId == inputId && userPw == inputPw) { + moveToMain(context, userId, userPw, userName, userDescription) } } -private fun moveToMain(context: Context, userId: String, userPw: String, userName: String, userDescription: String) { - val intent = Intent(context, MainActivity::class.java).apply { +private fun moveToMain( + context: Context, + userId: String, + userPw: String, + userName: String, + userDescription: String +) { + Intent(context, MainActivity::class.java).apply { putExtra("userId", userId) putExtra("userPw", userPw) putExtra("userName", userName) putExtra("userDescription", userDescription) } - context.startActivity(intent) Toast.makeText(context, "로그인 성공!", Toast.LENGTH_SHORT).show() } @@ -142,6 +187,6 @@ private fun moveToMain(context: Context, userId: String, userPw: String, userNam @Composable fun LoginPreview() { NOWSOPTAndroidTheme { - LoginCompose("","","","") + LoginView("","","","") } } \ No newline at end of file