Skip to content

Commit

Permalink
mod: #6 상수 -> Key에 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 2, 2024
1 parent d5e382f commit 8f71fac
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
20 changes: 12 additions & 8 deletions app/src/main/java/com/sopt/now/compose/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ 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.data.Key.ID
import com.sopt.now.compose.data.Key.MBTI
import com.sopt.now.compose.data.Key.NICKNAME
import com.sopt.now.compose.data.Key.PW
import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme

class LoginActivity : ComponentActivity() {
Expand All @@ -49,10 +53,10 @@ class LoginActivity : ComponentActivity() {
color = MaterialTheme.colorScheme.background
) {
Login(
signupId = intent.getStringExtra("id"),
signupPw = intent.getStringExtra("pw"),
nickname = intent.getStringExtra("nickname"),
mbti = intent.getStringExtra("mbti")
signupId = intent.getStringExtra(ID),
signupPw = intent.getStringExtra(PW),
nickname = intent.getStringExtra(NICKNAME),
mbti = intent.getStringExtra(MBTI)
)
}
}
Expand Down Expand Up @@ -149,10 +153,10 @@ fun Login(signupId: String?, signupPw: String?, nickname: String?, mbti: String?
if (id == signupId && pw == signupPw) {
Toast.makeText(context, R.string.login_success, Toast.LENGTH_SHORT).show()
Intent(context, MainActivity::class.java).apply {
putExtra("id", id)
putExtra("pw", pw)
putExtra("nickname", nickname)
putExtra("mbti", mbti)
putExtra(ID, id)
putExtra(PW, pw)
putExtra(NICKNAME, nickname)
putExtra(MBTI, mbti)
context.startActivity(this)
}

Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/sopt/now/compose/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.sopt.now.compose.data.Key.ID
import com.sopt.now.compose.data.Key.MBTI
import com.sopt.now.compose.data.Key.NICKNAME
import com.sopt.now.compose.data.Key.PW
import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme

class MainActivity : ComponentActivity() {
Expand Down Expand Up @@ -106,16 +110,16 @@ class MainActivity : ComponentActivity() {
) {
when (selectedItem) {
0 -> HomeScreen(
intent.getStringExtra("nickname"),
intent.getStringExtra("mbti")
intent.getStringExtra(NICKNAME),
intent.getStringExtra(MBTI)
)

1 -> SearchScreen()
2 -> MypageScreen(
intent.getStringExtra("id"),
intent.getStringExtra("pw"),
intent.getStringExtra("nickname"),
intent.getStringExtra("mbti")
intent.getStringExtra(ID),
intent.getStringExtra(PW),
intent.getStringExtra(NICKNAME),
intent.getStringExtra(MBTI)
)
}
}
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/com/sopt/now/compose/SignupActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ 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.data.Key.ID
import com.sopt.now.compose.data.Key.MBTI
import com.sopt.now.compose.data.Key.NICKNAME
import com.sopt.now.compose.data.Key.PW
import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme

class SignupActivity : ComponentActivity() {
Expand Down Expand Up @@ -199,10 +203,10 @@ fun Signup() {
else -> {
Toast.makeText(context, R.string.signup_success, Toast.LENGTH_SHORT).show()
Intent(context, LoginActivity::class.java).apply {
putExtra("id", id)
putExtra("pw", pw)
putExtra("nickname", nickname)
putExtra("mbti", mbti)
putExtra(ID, id)
putExtra(PW, pw)
putExtra(NICKNAME, nickname)
putExtra(MBTI, mbti)
context.startActivity(this)
}
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/sopt/now/compose/data/Key.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.sopt.now.compose.data

object Key {
const val ID = "id"
const val PW = "pw"
const val NICKNAME = "nickname"
const val MBTI = "mbti"
}

0 comments on commit 8f71fac

Please sign in to comment.