From 25df58cbc69a06e1abdab9ab747e0505cbcac88d Mon Sep 17 00:00:00 2001 From: Hyobeen-Park Date: Thu, 2 May 2024 22:17:31 +0900 Subject: [PATCH] =?UTF-8?q?mod:=20#6=20MainActivity=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=B0=9B=EC=95=84=EC=98=A4=EB=8A=94=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=ED=95=A8=EC=88=98=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/compose/MainActivity.kt | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 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 11553d8..07c7789 100644 --- a/app/src/main/java/com/sopt/now/compose/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/MainActivity.kt @@ -24,6 +24,7 @@ import androidx.compose.material3.TopAppBarDefaults.topAppBarColors import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier @@ -38,6 +39,11 @@ import com.sopt.now.compose.data.Key.PW import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme class MainActivity : ComponentActivity() { + private lateinit var id: String + private lateinit var pw: String + private lateinit var nickname: String + private lateinit var mbti: String + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { @@ -46,6 +52,7 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { + initUserData() MainScreen() } } @@ -109,22 +116,24 @@ class MainActivity : ComponentActivity() { verticalArrangement = Arrangement.spacedBy(16.dp) ) { when (selectedItem) { - 0 -> HomeScreen( - intent.getStringExtra(NICKNAME), - intent.getStringExtra(MBTI) - ) - + 0 -> HomeScreen(nickname, mbti) 1 -> SearchScreen() - 2 -> MypageScreen( - intent.getStringExtra(ID), - intent.getStringExtra(PW), - intent.getStringExtra(NICKNAME), - intent.getStringExtra(MBTI) - ) + 2 -> MypageScreen(id, pw, nickname, mbti) } } } } + @Composable + fun initUserData() { + intent.apply { + id = getStringExtra(ID) ?: "" + pw = getStringExtra(PW) ?: "" + nickname = getStringExtra(NICKNAME) ?: "" + mbti = getStringExtra(MBTI) ?: "" + } + } + + } \ No newline at end of file