diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9d2cd40..5dd98b0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -14,6 +14,13 @@
tools:targetApi="31">
+
+
+
+
@@ -24,5 +31,4 @@
-
\ No newline at end of file
diff --git a/app/src/main/java/com/sopt/now/compose/LoginActivity.kt b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt
new file mode 100644
index 0000000..5eacdf5
--- /dev/null
+++ b/app/src/main/java/com/sopt/now/compose/LoginActivity.kt
@@ -0,0 +1,161 @@
+package com.sopt.now.compose
+
+import android.content.Context
+import android.content.Intent
+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.shape.RoundedCornerShape
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+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.platform.LocalContext
+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.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
+
+class LoginActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ NOWSOPTAndroidTheme {
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ val userId = intent.getStringExtra("userId").toString()
+ val userPw = intent.getStringExtra("userPw").toString()
+ val userName = intent.getStringExtra("userName").toString()
+ val userMbti = intent.getStringExtra("userMbti").toString()
+
+ LoginCompose(userId, userPw, userName ,userMbti)
+ }
+ }
+ }
+ }
+}
+
+@Composable
+fun LoginCompose(userId: String, userPw: String, userName: String, userMbti: String) {
+ val context = LocalContext.current
+ var inputId by remember { mutableStateOf("") }
+ var inputPw by remember { mutableStateOf("") }
+
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(horizontal = 30.dp),
+ ) {
+ Spacer(modifier = Modifier.height(60.dp))
+ Text(
+ text = "Welcom To SOPT",
+ 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)
+ )
+ 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)
+ }
+ 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)
+ }
+ Spacer(modifier = Modifier.padding(bottom = 60.dp))
+ }
+}
+
+// 메인 페이지로 이동
+private fun moveToMain(context: Context, userId: String, userPw: String, userName: String, userMbti: String) {
+ val intent = Intent(context, MainActivity::class.java).apply {
+ putExtra("userId", userId)
+ putExtra("userPw", userPw)
+ putExtra("userName", userName)
+ putExtra("userMbti", userMbti)
+ }
+ context.startActivity(intent)
+ Toast.makeText(context, "로그인 성공!", Toast.LENGTH_SHORT).show()
+}
+
+@Preview(showBackground = true)
+@Composable
+fun LoginPreview() {
+ NOWSOPTAndroidTheme {
+ LoginCompose("","","","")
+ }
+}
\ 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 73fb148..29f448d 100644
--- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt
+++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt
@@ -3,13 +3,26 @@ 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.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.material3.MaterialTheme
import androidx.compose.material3.Surface
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.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() {
@@ -17,12 +30,16 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
NOWSOPTAndroidTheme {
- // A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
- Greeting("Android")
+ 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)
}
}
}
@@ -30,17 +47,67 @@ class MainActivity : ComponentActivity() {
}
@Composable
-fun Greeting(name: String, modifier: Modifier = Modifier) {
- Text(
- text = "Hello $name!",
- modifier = modifier
- )
+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 (
+ 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
+ )
+ }
+ 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,
+ )
+ }
}
@Preview(showBackground = true)
@Composable
-fun GreetingPreview() {
+fun MainPreview() {
NOWSOPTAndroidTheme {
- Greeting("Android")
+ MainCompose("nowSopt", "password123", "UserName", "ISTP")
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt
new file mode 100644
index 0000000..fde8d08
--- /dev/null
+++ b/app/src/main/java/com/sopt/now/compose/SignUpActivity.kt
@@ -0,0 +1,183 @@
+package com.sopt.now.compose
+
+import android.content.Context
+import android.content.Intent
+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.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+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.platform.LocalContext
+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.ui.theme.NOWSOPTAndroidTheme
+
+class SignUpActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ NOWSOPTAndroidTheme {
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ SignUpCompose()
+ }
+ }
+ }
+ }
+}
+
+@Composable
+fun SignUpCompose(){
+ val context = LocalContext.current
+ var userId by remember { mutableStateOf("") }
+ var userPw by remember { mutableStateOf("") }
+ var userName by remember { mutableStateOf("") }
+ var userMbti by remember { mutableStateOf("") }
+
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(horizontal = 30.dp),
+ ) {
+ Spacer(modifier = Modifier.height(60.dp))
+ Text(
+ text = "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 //단일 줄로 제한
+ )
+ 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))
+ 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
+ )
+ 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
+ )
+ Spacer(modifier = Modifier.weight(2f))
+ Button(
+ onClick = {
+ checkSignUp(context, userId, userPw, userName, userMbti)
+ },
+ colors = ButtonDefaults.buttonColors(containerColor = Color.Black),
+ shape = RoundedCornerShape(50.dp),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Text("회원가입", color = Color.White)
+ }
+ Spacer(modifier = Modifier.padding(bottom = 60.dp))
+ }
+}
+
+// 회원 가입 가능 여부 체크
+fun checkSignUp(context: Context, userId: String, userPw: String, userName: String, userMbti: 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 -> "모든 정보를 입력해주세요."
+ else -> {
+ moveToLogin(context, userId, userPw, userName, userMbti)
+ "회원가입 성공!"
+ }
+ }
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
+}
+
+// 로그인 페이지로 이동
+private fun moveToLogin(context: Context, userId: String, userPw: String, userName: String, userMbti: String) {
+ val intent = Intent(context, LoginActivity::class.java).apply {
+ putExtra("userId", userId)
+ putExtra("userPw", userPw)
+ putExtra("userName", userName)
+ putExtra("userMbti", userMbti)
+ }
+ context.startActivity(intent)
+}
+
+@Preview(showBackground = true)
+@Composable
+fun SignUpPreview() {
+ NOWSOPTAndroidTheme {
+ SignUpCompose()
+ }
+}
\ 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
new file mode 100644
index 0000000..f824185
Binary files /dev/null and b/app/src/main/res/drawable/img_profile.jpg differ