Skip to content

Commit 3b17249

Browse files
committed
Add support for image vector
1 parent 9e38332 commit 3b17249

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
package com.PratikFagadiya.smoothanimationbottombar.model
22

3+
import androidx.compose.ui.graphics.vector.ImageVector
4+
35
data class SmoothAnimationBottomBarScreens(
46
val route: String,
57
val name: String,
6-
val icon: Int
7-
)
8+
val icon: Int,
9+
val imageVector: ImageVector? = null
10+
) {
11+
constructor(route: String, name: String, icon: Int) : this(route, name, icon, null)
12+
constructor(route: String, name: String, imageVector: ImageVector) : this(route, name, 0,imageVector)
13+
}

SmoothAnimationBottomBar/src/main/java/com/PratikFagadiya/smoothanimationbottombar/ui/SmoothAnimationBottomBar.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,20 @@ fun SmoothAnimationBottomBar(
135135
verticalAlignment = Alignment.CenterVertically,
136136
horizontalArrangement = Arrangement.Center) {
137137

138-
Icon(
139-
painter = painterResource(id = smoothAnimationBottomBarScreens.icon),
140-
contentDescription = "",
141-
tint = if (initialIndex.value == index) bottomBarProperties.iconTintActiveColor else bottomBarProperties.iconTintColor
142-
)
138+
val tint = if (index == initialIndex.value) bottomBarProperties.iconTintActiveColor else bottomBarProperties.iconTintColor
139+
if (smoothAnimationBottomBarScreens.imageVector != null) {
140+
Icon(
141+
imageVector = smoothAnimationBottomBarScreens.imageVector,
142+
contentDescription = smoothAnimationBottomBarScreens.name,
143+
tint = tint
144+
)
145+
} else {
146+
Icon(
147+
painter = painterResource(id = smoothAnimationBottomBarScreens.icon),
148+
contentDescription = smoothAnimationBottomBarScreens.name,
149+
tint = tint
150+
)
151+
}
143152

144153
AnimatedVisibility(visible = index == initialIndex.value) {
145154

0 commit comments

Comments
 (0)