Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SzobatárSCH
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fodor Patrik
SzobatárSCH
Commits
b68d0e22
Commit
b68d0e22
authored
May 15, 2022
by
Fodor Patrik
Browse files
Options
Downloads
Patches
Plain Diff
Create bottom navigation bar
parent
b6c97372
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/hu/bme/kszk/szobatarsch/composable/BottomNavBar.kt
+81
-0
81 additions, 0 deletions
...n/java/hu/bme/kszk/szobatarsch/composable/BottomNavBar.kt
with
81 additions
and
0 deletions
app/src/main/java/hu/bme/kszk/szobatarsch/composable/BottomNavBar.kt
0 → 100644
+
81
−
0
View file @
b68d0e22
package
hu.bme.kszk.szobatarsch.composable
import
androidx.compose.material.icons.Icons
import
androidx.compose.material.icons.filled.*
import
androidx.compose.material3.*
import
androidx.compose.runtime.Composable
import
androidx.compose.runtime.getValue
import
androidx.compose.ui.graphics.vector.ImageVector
import
androidx.navigation.NavGraph.Companion.findStartDestination
import
androidx.navigation.NavHostController
import
androidx.navigation.compose.currentBackStackEntryAsState
sealed
class
NavRoutes
(
val
route
:
String
)
{
object
Find
:
NavRoutes
(
"find"
)
object
Matches
:
NavRoutes
(
"matches"
)
object
Profile
:
NavRoutes
(
"profile"
)
object
Settings
:
NavRoutes
(
"settings"
)
}
data class
BarItem
(
val
title
:
String
,
val
image
:
ImageVector
,
val
route
:
String
)
object
NavBarItems
{
val
BarItems
=
listOf
(
BarItem
(
title
=
"Find"
,
image
=
Icons
.
Filled
.
Search
,
route
=
"find"
),
BarItem
(
title
=
"Matches"
,
image
=
Icons
.
Filled
.
ThumbUp
,
route
=
"matches"
),
BarItem
(
title
=
"Profile"
,
image
=
Icons
.
Filled
.
Face
,
route
=
"profile"
),
BarItem
(
title
=
"Settings"
,
image
=
Icons
.
Filled
.
Settings
,
route
=
"settings"
)
)
}
@Composable
fun
BottomNavigationBar
(
navController
:
NavHostController
)
{
NavigationBar
{
val
backStackEntry
by
navController
.
currentBackStackEntryAsState
()
val
currentRoute
=
backStackEntry
?.
destination
?.
route
NavBarItems
.
BarItems
.
forEach
{
navItem
->
NavigationBarItem
(
selected
=
currentRoute
==
navItem
.
route
,
onClick
=
{
navController
.
navigate
(
navItem
.
route
)
{
popUpTo
(
navController
.
graph
.
findStartDestination
().
id
)
{
saveState
=
true
}
launchSingleTop
=
true
restoreState
=
true
}
},
icon
=
{
Icon
(
imageVector
=
navItem
.
image
,
contentDescription
=
navItem
.
title
)
},
label
=
{
Text
(
text
=
navItem
.
title
)
},
)
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment