-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHomeBottomNavigationBar.kt
More file actions
109 lines (102 loc) · 3.49 KB
/
HomeBottomNavigationBar.kt
File metadata and controls
109 lines (102 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.threegap.bitnagil.navigation.home
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.threegap.bitnagil.designsystem.BitnagilTheme
import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon
@Composable
fun HomeBottomNavigationBar(
selectedTab: HomeRoute,
onTabSelected: (HomeRoute) -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier = modifier) {
HorizontalDivider(
modifier = Modifier.fillMaxWidth(),
thickness = 1.dp,
color = BitnagilTheme.colors.coolGray98,
)
Row(
modifier = Modifier
.fillMaxWidth()
.background(color = BitnagilTheme.colors.white)
.height(62.dp)
.padding(horizontal = 16.dp, vertical = 7.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp),
verticalAlignment = Alignment.CenterVertically,
) {
homeTabList.forEach { homeTab ->
HomeBottomNavigationItem(
modifier = Modifier.weight(1f),
icon = homeTab.icon,
title = homeTab.title,
selected = selectedTab == homeTab.route,
onClick = { onTabSelected(homeTab.route) },
)
}
}
}
}
@Composable
private fun HomeBottomNavigationItem(
modifier: Modifier = Modifier,
icon: Int,
title: String,
selected: Boolean,
onClick: () -> Unit,
) {
val interactionSource = remember { MutableInteractionSource() }
val isPressed by interactionSource.collectIsPressedAsState()
val contentTintColor = when {
isPressed -> BitnagilTheme.colors.coolGray10
selected -> BitnagilTheme.colors.coolGray10
else -> BitnagilTheme.colors.coolGray90
}
Column(
modifier = modifier
.clickable(
onClick = onClick,
interactionSource = interactionSource,
indication = null,
)
.padding(4.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
BitnagilIcon(
id = icon,
modifier = Modifier.size(24.dp),
tint = contentTintColor,
)
Text(
text = title,
style = BitnagilTheme.typography.caption2Medium,
color = contentTintColor,
)
}
}
@Composable
@Preview
private fun HomeBottomNavigationBarPreview() {
HomeBottomNavigationBar(
selectedTab = HomeRoute.Home,
onTabSelected = {},
)
}