From 577186a7d7d8d856fabc3d89d170080d1ce3e3c0 Mon Sep 17 00:00:00 2001 From: gitsuhyun Date: Wed, 4 Dec 2024 17:48:52 +0900 Subject: [PATCH] =?UTF-8?q?#10=20[feat]=20:=20HomeTabType=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/sopt/and/domain/type/HomeTabType.kt | 24 +++++++++++++++++++ .../core/component/CustomTabBar.kt | 5 ++-- .../sopt/and/presentation/home/HomeScreen.kt | 2 +- .../and/presentation/home/HomeViewModel.kt | 16 ++----------- 4 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/domain/type/HomeTabType.kt diff --git a/app/src/main/java/org/sopt/and/domain/type/HomeTabType.kt b/app/src/main/java/org/sopt/and/domain/type/HomeTabType.kt new file mode 100644 index 0000000..29a92c0 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/type/HomeTabType.kt @@ -0,0 +1,24 @@ +package org.sopt.and.domain.type + +enum class HomeTabType( + val text: String, +) { + NEW_CLASSIC( + text = "뉴클래식" + ), + DRAMA( + text = "드라마" + ), + VARIETY_SHOW( + text = "예능" + ), + MOVIE( + text = "영화" + ), + ANIMATION( + text = "애니" + ), + OVERSEAS_SERIES( + text = "해외시리즈" + ) +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/presentation/core/component/CustomTabBar.kt b/app/src/main/java/org/sopt/and/presentation/core/component/CustomTabBar.kt index 2bce3e3..c7700c6 100644 --- a/app/src/main/java/org/sopt/and/presentation/core/component/CustomTabBar.kt +++ b/app/src/main/java/org/sopt/and/presentation/core/component/CustomTabBar.kt @@ -12,12 +12,13 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import org.sopt.and.domain.type.HomeTabType import org.sopt.and.ui.theme.WavveTheme @Composable fun WavveTabBar( - tabTitles: List, modifier: Modifier = Modifier + tabTitles: Array, modifier: Modifier = Modifier ) { var selectedTabIndex by remember { mutableIntStateOf(0) } @@ -35,7 +36,7 @@ fun WavveTabBar( onClick = { selectedTabIndex = index }, text = { Text( - text = tab, + text = tab.text, fontSize = 18.sp, color = if (selectedTabIndex == index) Color.White else Color.Gray ) diff --git a/app/src/main/java/org/sopt/and/presentation/home/HomeScreen.kt b/app/src/main/java/org/sopt/and/presentation/home/HomeScreen.kt index 087fdca..9111b8d 100644 --- a/app/src/main/java/org/sopt/and/presentation/home/HomeScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/home/HomeScreen.kt @@ -93,7 +93,7 @@ fun HomeScreen(navController: NavController, viewModel: HomeViewModel = viewMode .fillMaxSize() .verticalScroll(scrollState) ) { - WavveTabBar(viewModel.homeTabText) + WavveTabBar(tabTitles = viewModel.homeTabText) HorizontalPager( modifier = Modifier diff --git a/app/src/main/java/org/sopt/and/presentation/home/HomeViewModel.kt b/app/src/main/java/org/sopt/and/presentation/home/HomeViewModel.kt index 95a446a..225ffd7 100644 --- a/app/src/main/java/org/sopt/and/presentation/home/HomeViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/home/HomeViewModel.kt @@ -1,24 +1,12 @@ package org.sopt.and.presentation.home -import androidx.compose.runtime.Composable -import androidx.compose.ui.res.stringResource import androidx.lifecycle.ViewModel import org.sopt.and.R import org.sopt.and.data.local.TodayTopData +import org.sopt.and.domain.type.HomeTabType class HomeViewModel : ViewModel() { - private val _homeTabText = listOf( - R.string.new_classic, - R.string.drama, - R.string.variety_show, - R.string.movie, - R.string.animation, - R.string.overseas_series - ) - - val homeTabText: List - @Composable - get() = _homeTabText.map { stringResource(it) } + val homeTabText = HomeTabType.entries.toTypedArray() val editorDummy = List(20) { TodayTopData(