Skip to content

Commit

Permalink
chore: #6 HomeActivity -> MainActivity 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 2, 2024
1 parent 9ce373e commit e8557ea
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 147 deletions.
6 changes: 0 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid">
</activity>
<activity
android:name=".HomeActivity"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid">
</activity>
</application>

</manifest>
126 changes: 0 additions & 126 deletions app/src/main/java/com/sopt/now/compose/HomeActivity.kt

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/java/com/sopt/now/compose/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fun Login(signupId: String?, signupPw: String?, nickname: String?, mbti: String?
onClick = {
if (id == signupId && pw == signupPw) {
Toast.makeText(context, R.string.login_success, Toast.LENGTH_SHORT).show()
Intent(context, HomeActivity::class.java).apply {
Intent(context, MainActivity::class.java).apply {
putExtra("id", id)
putExtra("pw", pw)
putExtra("nickname", nickname)
Expand Down
111 changes: 97 additions & 14 deletions app/src/main/java/com/sopt/now/compose/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,124 @@ package com.sopt.now.compose
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
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.ExperimentalMaterial3Api
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.material3.TopAppBar
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.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
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.ui.theme.NOWSOPTAndroidTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
NOWSOPTAndroidTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Main()
HomeScreen()
}
}
}
}
}

@Composable
fun Main() {
Text(text = "MAIN")
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
NOWSOPTAndroidTheme {
Main()

data class BottomNavigationItem(
val Icon: ImageVector,
val label: String
)

@OptIn(ExperimentalMaterial3Api::class)
@Preview(showBackground = true)
@Composable
private fun HomeScreen() {
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 = "Mypage"
)
)

Scaffold(
topBar = {
TopAppBar(
colors = topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.primary
),
title = {
Text(stringResource(id = R.string.app_name))
}
)
},
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
.padding(innerPadding)
.padding(horizontal = 30.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
when (selectedItem) {
0 -> HomeFragment(
intent.getStringExtra("nickname"),
intent.getStringExtra("mbti")
)

1 -> SearchFragment()
2 -> MypageFragment(
intent.getStringExtra("id"),
intent.getStringExtra("pw"),
intent.getStringExtra("nickname"),
intent.getStringExtra("mbti")
)
}
}
}
}


}

0 comments on commit e8557ea

Please sign in to comment.