diff --git a/core/src/main/java/com/terning/core/designsystem/topappbar/BackButtonTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/topappbar/BackButtonTopAppBar.kt new file mode 100644 index 000000000..aeb7f1b00 --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/topappbar/BackButtonTopAppBar.kt @@ -0,0 +1,14 @@ +package com.terning.core.designsystem.topappbar + +import androidx.compose.runtime.Composable + +@Composable +fun BackButtonTopAppBar( + title: String, onBackButtonClick: (() -> Unit), +) { + TerningTopAppBar( + title = title, + showBackButton = true, + onBackButtonClick = { onBackButtonClick.invoke() }, + ) +} \ No newline at end of file diff --git a/core/src/main/java/com/terning/core/designsystem/topappbar/LogoTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/topappbar/LogoTopAppBar.kt new file mode 100644 index 000000000..a5b6e68e5 --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/topappbar/LogoTopAppBar.kt @@ -0,0 +1,20 @@ +package com.terning.core.designsystem.topappbar + +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import com.terning.core.R + +@Composable +fun LogoTopAppBar() { + TerningTopAppBar( + showBackButton = false, + actions = listOf { + Icon( + painter = painterResource(id = R.drawable.ic_logo), + contentDescription = stringResource(id = R.string.ic_logo), + ) + } + ) +} diff --git a/core/src/main/java/com/terning/core/designsystem/topappbar/MyPageTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/topappbar/MyPageTopAppBar.kt new file mode 100644 index 000000000..295c5aabd --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/topappbar/MyPageTopAppBar.kt @@ -0,0 +1,41 @@ +package com.terning.core.designsystem.topappbar + +import androidx.compose.foundation.layout.Row +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import com.terning.core.R +import com.terning.core.designsystem.theme.TerningTypography + +@Composable +fun MyPageTopAppBar() { + TerningTopAppBar( + showBackButton = false, + actions = listOf( + {}, + { + Row( + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = stringResource(id = R.string.my_page_top_app_bar), + style = TerningTypography().button3, + textAlign = TextAlign.Center + ) + IconButton(onClick = { + }) { + Icon( + painter = painterResource(id = R.drawable.ic_right), + contentDescription = stringResource(id = R.string.ic_20_right) + ) + } + } + } + ) + ) +} diff --git a/core/src/main/java/com/terning/core/designsystem/topappbar/TerningTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/topappbar/TerningTopAppBar.kt new file mode 100644 index 000000000..0e164edc5 --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/topappbar/TerningTopAppBar.kt @@ -0,0 +1,57 @@ +package com.terning.core.designsystem.topappbar + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import com.terning.core.R +import com.terning.core.designsystem.theme.TerningTypography + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun TerningTopAppBar( + title: String = "", + showBackButton: Boolean = false, + actions: List<@Composable () -> Unit> = emptyList(), + onBackButtonClick: () -> Unit = {}, +) { + CenterAlignedTopAppBar( + title = { + + Text( + text = title, + textAlign = TextAlign.Center, + style = TerningTypography().title2 + ) + + }, + navigationIcon = { + if (showBackButton) { + IconButton(onClick = { + onBackButtonClick.invoke() + }) { + Icon( + painter = painterResource(id = R.drawable.ic_back), + contentDescription = stringResource(id = R.string.ic_back) + ) + } + } else { + actions.getOrNull(0)?.invoke() + } + }, + actions = { + actions.drop(1).forEach { action -> + action() + } + }, + ) +} diff --git a/core/src/main/res/drawable/ic_back.xml b/core/src/main/res/drawable/ic_back.xml new file mode 100644 index 000000000..fac96f803 --- /dev/null +++ b/core/src/main/res/drawable/ic_back.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/core/src/main/res/drawable/ic_logo.xml b/core/src/main/res/drawable/ic_logo.xml new file mode 100644 index 000000000..7931bbb86 --- /dev/null +++ b/core/src/main/res/drawable/ic_logo.xml @@ -0,0 +1,13 @@ + + + + diff --git a/core/src/main/res/drawable/ic_right.xml b/core/src/main/res/drawable/ic_right.xml new file mode 100644 index 000000000..e022a144b --- /dev/null +++ b/core/src/main/res/drawable/ic_right.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml new file mode 100644 index 000000000..78c239c7f --- /dev/null +++ b/core/src/main/res/values/strings.xml @@ -0,0 +1,10 @@ + + + + 뒤로가기 버튼 + 탑 바 로고 + 오른쪽 버튼 + + + 프로필 수정 + \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 472557036..beb7b7920 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -46,7 +46,7 @@ class MainNavigator( } } - private fun navigateUp() { + fun navigateUp() { navController.navigateUp() } diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 4e3e13d6f..9d51ef625 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -21,6 +21,10 @@ import androidx.navigation.compose.NavHost import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White +import com.terning.core.designsystem.topappbar.BackButtonTopAppBar +import com.terning.core.designsystem.topappbar.LogoTopAppBar +import com.terning.core.designsystem.topappbar.MyPageTopAppBar +import com.terning.core.designsystem.topappbar.TerningTopAppBar import com.terning.feature.calendar.navigation.calendarNavGraph import com.terning.feature.home.navigation.homeNavGraph import com.terning.feature.mypage.navigation.myPageNavGraph @@ -35,6 +39,18 @@ fun MainScreen( navigator: MainNavigator = rememberMainNavigator(), ) { Scaffold( + topBar = { + when (navigator.currentTab) { + MainTab.HOME -> LogoTopAppBar() + MainTab.CALENDAR -> BackButtonTopAppBar( + title = "dkssud", + onBackButtonClick = { navigator.navigateUp() }) + + MainTab.SEARCH -> LogoTopAppBar() + MainTab.MY_PAGE -> MyPageTopAppBar() + null -> TerningTopAppBar() + } + }, bottomBar = { MainBottomBar( isVisible = navigator.showBottomBar(), diff --git a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt index 2302237e4..f22dd2d0e 100644 --- a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt +++ b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle +import com.terning.core.designsystem.topappbar.MyPageTopAppBar import com.terning.core.extension.toast import com.terning.core.state.UiState import com.terning.domain.entity.response.MockResponseModel @@ -46,13 +47,13 @@ fun MyPageRoute( is UiState.Loading -> {} is UiState.Failure -> {} is UiState.Success -> { - MockScreen(mockList = (state.followers as UiState.Success>).data) + MyPageScreen(mockList = (state.followers as UiState.Success>).data) } } } @Composable -fun MockScreen( +fun MyPageScreen( mockList: List, ) { LazyColumn( diff --git a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt new file mode 100644 index 000000000..3ba7af3d4 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt @@ -0,0 +1,25 @@ +package com.terning.feature.search + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.terning.core.designsystem.topappbar.LogoTopAppBar + +@Composable +fun SearchRoute() { + SearchScreen() +} + +@Composable +fun SearchScreen(modifier: Modifier = Modifier) { + Column( + modifier = Modifier + .fillMaxWidth() + ) { + Text(text = "탐색 스크린") + } +} diff --git a/feature/src/main/java/com/terning/feature/search/SearchRouth.kt b/feature/src/main/java/com/terning/feature/search/SearchRouth.kt deleted file mode 100644 index 18c655555..000000000 --- a/feature/src/main/java/com/terning/feature/search/SearchRouth.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.terning.feature.search - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier - -@Composable -fun SearchRoute() { - SearchScreen() -} - -@Composable -fun SearchScreen() { - Column(modifier = Modifier.fillMaxSize()) { - Text(text = "탐색 스크린") - } -} \ No newline at end of file