|
| 1 | +package com.flint.presentation.onboarding.component |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.clickable |
| 5 | +import androidx.compose.foundation.layout.Arrangement |
| 6 | +import androidx.compose.foundation.layout.Box |
| 7 | +import androidx.compose.foundation.layout.Column |
| 8 | +import androidx.compose.foundation.layout.Spacer |
| 9 | +import androidx.compose.foundation.layout.fillMaxSize |
| 10 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 11 | +import androidx.compose.foundation.layout.height |
| 12 | +import androidx.compose.foundation.layout.padding |
| 13 | +import androidx.compose.foundation.layout.size |
| 14 | +import androidx.compose.foundation.layout.width |
| 15 | +import androidx.compose.material3.Icon |
| 16 | +import androidx.compose.material3.Text |
| 17 | +import androidx.compose.runtime.Composable |
| 18 | +import androidx.compose.ui.Alignment |
| 19 | +import androidx.compose.ui.Modifier |
| 20 | +import androidx.compose.ui.graphics.vector.ImageVector |
| 21 | +import androidx.compose.ui.layout.ContentScale |
| 22 | +import androidx.compose.ui.res.vectorResource |
| 23 | +import androidx.compose.ui.text.style.TextAlign |
| 24 | +import androidx.compose.ui.tooling.preview.Preview |
| 25 | +import androidx.compose.ui.unit.dp |
| 26 | +import com.flint.R |
| 27 | +import com.flint.core.designsystem.component.image.NetworkImage |
| 28 | +import com.flint.core.designsystem.theme.FlintTheme |
| 29 | + |
| 30 | +@Composable |
| 31 | +fun OnboardingOttItem( |
| 32 | + imageUrl: String, |
| 33 | + platformName: String, |
| 34 | + isSelected: Boolean, |
| 35 | + onClick: () -> Unit, |
| 36 | + modifier: Modifier = Modifier |
| 37 | +) { |
| 38 | + Column( |
| 39 | + modifier = modifier.width(100.dp), |
| 40 | + horizontalAlignment = Alignment.CenterHorizontally |
| 41 | + ) { |
| 42 | + // OTT 로고 영역 |
| 43 | + Box( |
| 44 | + modifier = |
| 45 | + Modifier |
| 46 | + .size(100.dp) |
| 47 | + .clickable { onClick() }, |
| 48 | + contentAlignment = Alignment.Center |
| 49 | + ) { |
| 50 | + // OTT 로고 이미지 |
| 51 | + NetworkImage( |
| 52 | + imageUrl = imageUrl, |
| 53 | + contentDescription = platformName, |
| 54 | + contentScale = ContentScale.Crop, |
| 55 | + modifier = Modifier.fillMaxSize() |
| 56 | + ) |
| 57 | + |
| 58 | + // 선택 시 어두운 오버레이 |
| 59 | + if (isSelected) { |
| 60 | + Box( |
| 61 | + modifier = |
| 62 | + Modifier |
| 63 | + .fillMaxSize() |
| 64 | + .background(FlintTheme.colors.overlay) |
| 65 | + ) |
| 66 | + Icon( |
| 67 | + imageVector = ImageVector.vectorResource(id = R.drawable.ic_onboarding_film_check), |
| 68 | + contentDescription = "선택됨", |
| 69 | + tint = FlintTheme.colors.white, |
| 70 | + modifier = |
| 71 | + Modifier |
| 72 | + .align(Alignment.Center) |
| 73 | + .size(40.dp) |
| 74 | + ) |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + Spacer(modifier = Modifier.height(8.dp)) |
| 79 | + |
| 80 | + // 플랫폼 이름 |
| 81 | + Text( |
| 82 | + text = platformName, |
| 83 | + style = FlintTheme.typography.body1M16, |
| 84 | + color = if (isSelected) FlintTheme.colors.gray300 else FlintTheme.colors.white, |
| 85 | + textAlign = TextAlign.Center, |
| 86 | + modifier = Modifier.fillMaxWidth() |
| 87 | + ) |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +@Preview(showBackground = true) |
| 92 | +@Composable |
| 93 | +private fun OnboardingOttItemPreview() { |
| 94 | + FlintTheme { |
| 95 | + Column( |
| 96 | + modifier = |
| 97 | + Modifier |
| 98 | + .background(FlintTheme.colors.background) |
| 99 | + .padding(20.dp), |
| 100 | + verticalArrangement = Arrangement.spacedBy(20.dp) |
| 101 | + ) { |
| 102 | + // 선택된 상태 |
| 103 | + OnboardingOttItem( |
| 104 | + imageUrl = "", |
| 105 | + platformName = "넷플릭스", |
| 106 | + isSelected = true, |
| 107 | + onClick = {} |
| 108 | + ) |
| 109 | + |
| 110 | + // 선택되지 않은 상태 |
| 111 | + OnboardingOttItem( |
| 112 | + imageUrl = "", |
| 113 | + platformName = "넷플릭스", |
| 114 | + isSelected = false, |
| 115 | + onClick = {} |
| 116 | + ) |
| 117 | + |
| 118 | + OnboardingOttItem( |
| 119 | + imageUrl = "", |
| 120 | + platformName = "왓챠", |
| 121 | + isSelected = false, |
| 122 | + onClick = {} |
| 123 | + ) |
| 124 | + } |
| 125 | + } |
| 126 | +} |
0 commit comments