Skip to content

Commit

Permalink
improve navigation bar items
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Aug 23, 2024
1 parent d34f7be commit 3f20529
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.hisp.dhis.common.screens.others

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Assignment
import androidx.compose.material.icons.automirrored.filled.List
import androidx.compose.material.icons.automirrored.filled.StickyNote2
import androidx.compose.material.icons.automirrored.outlined.Assignment
import androidx.compose.material.icons.automirrored.outlined.List
Expand All @@ -15,7 +14,6 @@ import androidx.compose.material.icons.outlined.BarChart
import androidx.compose.material.icons.outlined.Description
import androidx.compose.material.icons.outlined.Hub
import androidx.compose.material.icons.outlined.Map
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -27,56 +25,48 @@ import org.hisp.dhis.mobile.ui.designsystem.component.ColumnScreenContainer
import org.hisp.dhis.mobile.ui.designsystem.component.navigationBar.NavigationBar
import org.hisp.dhis.mobile.ui.designsystem.component.navigationBar.NavigationBarItem

enum class NavigationItem {
DESCRIPTION,
VISUALIZATION,
LIST,
MAPS,
RELATIONSHIPS,
NOTES,
ASSIGNMENT,
}

@Composable
fun NavigationBarScreen() {
val homeItems = listOf(
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.Description, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.Description, contentDescription = null)
},
id = NavigationItem.DESCRIPTION,
icon = Icons.Outlined.Description,
label = "Description",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.BarChart, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.BarChart, contentDescription = null)
},
id = NavigationItem.VISUALIZATION,
icon = Icons.Outlined.BarChart,
label = "Charts",
showBadge = true,
),
)

val programItems = listOf(
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.AutoMirrored.Outlined.List, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.List, contentDescription = null)
},
id = NavigationItem.LIST,
icon = Icons.AutoMirrored.Outlined.List,
label = "List",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.Map, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.Map, contentDescription = null)
},
id = NavigationItem.MAPS,
icon = Icons.Outlined.Map,
selectedIcon = Icons.Filled.Map,
label = "Maps",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.BarChart, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.BarChart, contentDescription = null)
},
id = NavigationItem.VISUALIZATION,
icon = Icons.Outlined.BarChart,
selectedIcon = Icons.Filled.BarChart,
label = "Charts",
showBadge = true,
badgeText = "32",
Expand All @@ -85,70 +75,49 @@ fun NavigationBarScreen() {

val enrollmentItems = listOf(
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.AutoMirrored.Outlined.Assignment, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.Assignment, contentDescription = null)
},
id = NavigationItem.ASSIGNMENT,
icon = Icons.AutoMirrored.Outlined.Assignment,
selectedIcon = Icons.AutoMirrored.Filled.Assignment,
label = "Details",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.BarChart, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.BarChart, contentDescription = null)
},
id = NavigationItem.VISUALIZATION,
icon = Icons.Outlined.BarChart,
selectedIcon = Icons.Filled.BarChart,
label = "Charts",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.Hub, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.Hub, contentDescription = null)
},
id = NavigationItem.RELATIONSHIPS,
icon = Icons.Outlined.Hub,
selectedIcon = Icons.Filled.Hub,
label = "Relationships",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.AutoMirrored.Outlined.StickyNote2, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.StickyNote2, contentDescription = null)
},
id = NavigationItem.NOTES,
icon = Icons.AutoMirrored.Outlined.StickyNote2,
selectedIcon = Icons.AutoMirrored.Filled.StickyNote2,
label = "Notes",
showBadge = true,
),
)

val formItems = listOf(
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.Description, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.Description, contentDescription = null)
},
id = NavigationItem.DESCRIPTION,
icon = Icons.Outlined.Description,
selectedIcon = Icons.Filled.Description,
label = "Description",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.Outlined.BarChart, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.Filled.BarChart, contentDescription = null)
},
id = NavigationItem.VISUALIZATION,
icon = Icons.Outlined.BarChart,
selectedIcon = Icons.Filled.BarChart,
label = "Charts",
),
NavigationBarItem(
defaultIcon = {
Icon(imageVector = Icons.AutoMirrored.Outlined.StickyNote2, contentDescription = null)
},
selectedIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.StickyNote2, contentDescription = null)
},
id = NavigationItem.NOTES,
icon = Icons.AutoMirrored.Outlined.StickyNote2,
selectedIcon = Icons.AutoMirrored.Filled.StickyNote2,
label = "Notes",
showBadge = true,
badgeText = "3",
Expand All @@ -163,17 +132,17 @@ fun NavigationBarScreen() {
NavigationBar(
items = homeItems,
selectedItemIndex = selectedHomeItemIndex,
) {
selectedHomeItemIndex = it
) { itemId ->
selectedHomeItemIndex = homeItems.indexOfFirst { it.id == itemId }
}
}
ColumnComponentContainer("Program dashboard") {
var selectedProgramItemIndex by remember { mutableStateOf<Int?>(null) }
NavigationBar(
items = programItems,
selectedItemIndex = selectedProgramItemIndex,
) {
selectedProgramItemIndex = it
) { itemId ->
selectedProgramItemIndex = programItems.indexOfFirst { it.id == itemId }
}
}

Expand All @@ -182,8 +151,8 @@ fun NavigationBarScreen() {
NavigationBar(
items = enrollmentItems,
selectedItemIndex = selectedEnrollmentItemIndex,
) {
selectedEnrollmentItemIndex = it
) { itemId ->
selectedEnrollmentItemIndex = enrollmentItems.indexOfFirst { it.id == itemId }
}
}

Expand All @@ -192,8 +161,8 @@ fun NavigationBarScreen() {
NavigationBar(
items = formItems,
selectedItemIndex = selectedFormItemIndex,
) {
selectedFormItemIndex = it
) { itemId ->
selectedFormItemIndex = formItems.indexOfFirst { it.id == itemId }
}
}
}
Expand Down
Loading

0 comments on commit 3f20529

Please sign in to comment.