Skip to content

Commit

Permalink
mod: #6 MainActivity 데이터 받아오는 부분 함수로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 2, 2024
1 parent 8f71fac commit 25df58c
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions app/src/main/java/com/sopt/now/compose/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -46,6 +52,7 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
initUserData()
MainScreen()
}
}
Expand Down Expand Up @@ -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) ?: ""
}
}


}

0 comments on commit 25df58c

Please sign in to comment.