Skip to content

Commit

Permalink
chore : 선택,비선택 아이콘을 없애고 단일 아이콘에 색상 변경만으로 선택여부 지정
Browse files Browse the repository at this point in the history
  • Loading branch information
Gael-Android committed Jan 14, 2025
1 parent 2730e0e commit e1036b2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 43 deletions.
34 changes: 16 additions & 18 deletions app/src/main/kotlin/com/yourssu/handy/demo/NavigationPreview.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@ import com.yourssu.handy.compose.R
fun NavigationPreview() {
val items = listOf(
BottomNavItem(
selectedIcon = R.drawable.home_selected,
unselectedIcon = R.drawable.home,
label = ""
),BottomNavItem(
selectedIcon = R.drawable.home_selected,
unselectedIcon = R.drawable.home,
label = ""
),BottomNavItem(
selectedIcon = R.drawable.home_selected,
unselectedIcon = R.drawable.home,
label = ""
),BottomNavItem(
selectedIcon = R.drawable.home_selected,
unselectedIcon = R.drawable.home,
label = ""
icon = R.drawable.home,
label = "Label"
),
BottomNavItem(
selectedIcon = R.drawable.home_selected,
unselectedIcon = R.drawable.home,
label = ""
icon = R.drawable.home,
label = "Label"
),
BottomNavItem(
icon = R.drawable.home,
label = "Label"
),
BottomNavItem(
icon = R.drawable.home,
label = "Label"
),
BottomNavItem(
icon = R.drawable.home,
label = "Label"
),
)

Expand Down
37 changes: 22 additions & 15 deletions compose/src/main/kotlin/com/yourssu/handy/compose/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ 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.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

/**
* BottomNavItem : 하단 네비게이션 바의 아이템을 정의하는 데이터 클래스 입니다.
*
* @param selectedIcon 선택되었을 때의 아이콘
* @param unselectedIcon 선택되지 않았을 때의 아이콘
* @param icon 아이템의 아이콘
* @param label 아이템의 라벨
*/
data class BottomNavItem(
val selectedIcon: Int,
val unselectedIcon: Int,
val label: String? = null
val icon: Int,
val label: String
)

/**
Expand All @@ -43,26 +47,29 @@ private fun BottomNavItem(
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
val color = if (isSelected) HandyTheme.colors.textBasicPrimary else HandyTheme.colors.textBasicDisabled

Column(
modifier = modifier
.clickable(onClick = onClick),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Image(
painter = painterResource(
id = if (isSelected) item.selectedIcon else item.unselectedIcon
),
Icon(
painter = painterResource(id = item.icon),
contentDescription = item.label,
tint = color,
modifier = Modifier.size(24.dp)
)

if (item.label != null) {
Text(
text = item.label,
fontSize = 12.dp
)
}
Text(
text = item.label,
fontSize = 11.dp,
lineHeight = 16.dp,
fontWeight = FontWeight(400),
color = color,
textAlign = TextAlign.Center
)
}
}

Expand Down
10 changes: 0 additions & 10 deletions compose/src/main/res/drawable/home_selected.xml

This file was deleted.

0 comments on commit e1036b2

Please sign in to comment.