Skip to content

Commit

Permalink
#10 [feat] : HomeTabType 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gitsuhyun committed Dec 4, 2024
1 parent 6753a6f commit 577186a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
24 changes: 24 additions & 0 deletions app/src/main/java/org/sopt/and/domain/type/HomeTabType.kt
Original file line number Diff line number Diff line change
@@ -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 = "해외시리즈"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, modifier: Modifier = Modifier
tabTitles: Array<HomeTabType>, modifier: Modifier = Modifier
) {
var selectedTabIndex by remember { mutableIntStateOf(0) }

Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun HomeScreen(navController: NavController, viewModel: HomeViewModel = viewMode
.fillMaxSize()
.verticalScroll(scrollState)
) {
WavveTabBar(viewModel.homeTabText)
WavveTabBar(tabTitles = viewModel.homeTabText)

HorizontalPager(
modifier = Modifier
Expand Down
16 changes: 2 additions & 14 deletions app/src/main/java/org/sopt/and/presentation/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
@@ -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<String>
@Composable
get() = _homeTabText.map { stringResource(it) }
val homeTabText = HomeTabType.entries.toTypedArray()

val editorDummy = List(20) {
TodayTopData(
Expand Down

0 comments on commit 577186a

Please sign in to comment.