Added propably working navbar

This commit is contained in:
Fabio 2025-04-10 22:36:46 +02:00
parent 0b459e9f95
commit 4d25cd1329
7 changed files with 70 additions and 62 deletions

26
.idea/appInsightsSettings.xml generated Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AppInsightsSettings">
<option name="tabSettings">
<map>
<entry key="Firebase Crashlytics">
<value>
<InsightsFilterSettings>
<option name="connection">
<ConnectionSetting>
<option name="appId" value="PLACEHOLDER" />
<option name="mobileSdkAppId" value="" />
<option name="projectId" value="" />
<option name="projectNumber" value="" />
</ConnectionSetting>
</option>
<option name="signal" value="SIGNAL_UNSPECIFIED" />
<option name="timeIntervalDays" value="THIRTY_DAYS" />
<option name="visibilityType" value="ALL" />
</InsightsFilterSettings>
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@ -10,11 +10,14 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.f1rq.lifemap.navigationbar.NavigationBar
import com.f1rq.lifemap.screens.ListView
import com.f1rq.lifemap.screens.MapView
import com.f1rq.lifemap.ui.theme.LifeMapTheme
import com.f1rq.lifemap.ui.theme.ActiveNavColor
import com.f1rq.lifemap.ui.theme.InactiveNavColor
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@ -24,7 +27,17 @@ class MainActivity : ComponentActivity() {
val navController = rememberNavController()
Scaffold(
bottomBar = { NavigationBar(navController) }
bottomBar = {
val navBackStackEntry = navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry.value?.destination?.route
NavigationBar(
onWorldViewTapped = { navController.navigate("mapview") },
onListViewTapped = { navController.navigate("listview") },
worldViewBackgroundColor = if (currentRoute == "mapview") ActiveNavColor else InactiveNavColor,
listViewBackgroundColor = if (currentRoute == "listview") ActiveNavColor else InactiveNavColor
)
}
) { innerPadding ->
NavHost(
navController = navController,
@ -44,7 +57,9 @@ class MainActivity : ComponentActivity() {
@Composable
fun GreetingPreview() {
LifeMapTheme {
val previewNavController = rememberNavController()
NavigationBar(navController = previewNavController)
NavigationBar(
onWorldViewTapped = {},
onListViewTapped = {}
)
}
}

View File

@ -1,32 +0,0 @@
package com.f1rq.lifemap
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import com.f1rq.lifemap.navigationbar.NavigationBar
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.compose.runtime.getValue
@Composable
fun NavBarHandler(navController: NavHostController) {
val currentRoute = currentRoute(navController)
NavigationBar(
modifier = Modifier,
onWorldViewTapped = {
if (currentRoute != "mapview") navController.navigate("mapview")
},
onListViewTapped = {
if (currentRoute != "listview") navController.navigate("listview")
},
//homeState = if (currentRoute == "home") "active" else "inactive",
//settingsState = if (currentRoute == "settings") "active" else "inactive",
)
}
@Composable
private fun currentRoute(navController: NavHostController): String? {
val navBackStackEntry by navController.currentBackStackEntryAsState()
return navBackStackEntry?.destination?.route
}

View File

@ -13,6 +13,6 @@ fun ListView(modifier: Modifier = Modifier) {
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text("Settings Screen")
Text("List view")
}
}

View File

@ -13,6 +13,6 @@ fun MapView(modifier: Modifier = Modifier) {
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text("Home Screen")
Text("Map view")
}
}

View File

@ -9,3 +9,6 @@ val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val ActiveNavColor = Color(0xFFDDDDDD)
val InactiveNavColor = Color.Transparent

View File

@ -5,7 +5,7 @@
"type": "figma",
"file": "7RzB5mC9Qj82hGEbAM11GM",
"node": "38:3",
"version": "2204970891916878617",
"version": "2205486309991144776",
"component-id": "915162a5cdf4f7f91ace42d239b4d1faf0d5c6e7"
},
"default": "Navigation bar",
@ -110,7 +110,6 @@
"icon-container"
],
"item-spacing": 4.0,
"background-color": "$world view background color",
"clip-content": false
},
{
@ -133,7 +132,6 @@
"icon-container1"
],
"item-spacing": 4.0,
"background-color": "$list view background color",
"clip-content": false
},
{
@ -149,13 +147,7 @@
},
"children": [
"state-layer"
],
"background-color": {
"alpha": 1.0,
"hue": 0.0,
"saturation": 0.0,
"value": 1.0
}
]
},
{
"id": "state-layer",
@ -179,12 +171,7 @@
"children": [
"Frame"
],
"background-color": {
"alpha": 1.0,
"hue": 0.0,
"saturation": 0.0,
"value": 0.8666666666666667
},
"background-color": "$world view background color",
"clip-content": false
},
{
@ -256,6 +243,7 @@
"children": [
"Frame1"
],
"background-color": "$list view background color",
"clip-content": false
},
{
@ -300,23 +288,23 @@
}
},
"parameters": {
"world view background color": {
"data-type": "color",
"required": false,
"description": ""
},
"on world view tapped": {
"data-type": "void-callback",
"required": false,
"description": ""
},
"list view background color": {
"on list view tapped": {
"data-type": "void-callback",
"required": false,
"description": ""
},
"world view background color": {
"data-type": "color",
"required": false,
"description": ""
},
"on list view tapped": {
"data-type": "void-callback",
"list view background color": {
"data-type": "color",
"required": false,
"description": ""
}
@ -327,6 +315,14 @@
"size": {
"width": 375.0,
"height": 76.0
},
"parameters": {
"world view background color": {
"alpha": 1.0,
"hue": 0.0,
"saturation": 0.0,
"value": 0.8666666666666667
}
}
}
],