From bb7143f9028a80cf46239deeb3503b784a0643db Mon Sep 17 00:00:00 2001 From: jherkenhoff Date: Mon, 14 Oct 2024 15:28:26 +0200 Subject: [PATCH] Separate keyboard switcher button. Indicate disabled nav items --- .../ui/{calculator => }/NavigationDrawer.kt | 34 ++++++++++--------- .../jherkenhoff/qalculate/ui/QalculateApp.kt | 5 --- app/src/main/res/values/strings.xml | 7 ++++ 3 files changed, 25 insertions(+), 21 deletions(-) rename app/src/main/java/com/jherkenhoff/qalculate/ui/{calculator => }/NavigationDrawer.kt (81%) diff --git a/app/src/main/java/com/jherkenhoff/qalculate/ui/calculator/NavigationDrawer.kt b/app/src/main/java/com/jherkenhoff/qalculate/ui/NavigationDrawer.kt similarity index 81% rename from app/src/main/java/com/jherkenhoff/qalculate/ui/calculator/NavigationDrawer.kt rename to app/src/main/java/com/jherkenhoff/qalculate/ui/NavigationDrawer.kt index 5eff206..01ecae3 100644 --- a/app/src/main/java/com/jherkenhoff/qalculate/ui/calculator/NavigationDrawer.kt +++ b/app/src/main/java/com/jherkenhoff/qalculate/ui/NavigationDrawer.kt @@ -1,4 +1,4 @@ -package com.jherkenhoff.qalculate.ui.calculator +package com.jherkenhoff.qalculate.ui import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box @@ -26,6 +26,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.jherkenhoff.qalculate.R @@ -56,48 +58,48 @@ fun NavigationDrawer( ) { Image( painter = painterResource(id = R.drawable.logo), - contentDescription = "Qalculate logo", + contentDescription = null, modifier = Modifier .size(80.dp) .shadow(6.dp, shape = CircleShape) ) } NavigationDrawerItem( - label = { Text(text = "Calculator") }, + label = { Text(text = stringResource(R.string.navigation_calculator)) }, selected = calculatorActive, onClick = onCalculatorClick, - icon = { Icon(Icons.Filled.Calculate, contentDescription = "Calculator icon") }, + icon = { Icon(Icons.Filled.Calculate, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) HorizontalDivider( Modifier .padding(horizontal = 25.dp, vertical = 15.dp)) NavigationDrawerItem( - label = { Text(text = "Functions") }, + label = { Text(text = stringResource(R.string.navigation_functions), textDecoration = TextDecoration.LineThrough) }, selected = functionsActive, onClick = onFunctionsClick, - icon = { Icon(Icons.Outlined.Functions, contentDescription = "Functions icon") }, + icon = { Icon(Icons.Outlined.Functions, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) NavigationDrawerItem( - label = { Text(text = "Variables") }, + label = { Text(text = stringResource(R.string.navigation_variables), textDecoration = TextDecoration.LineThrough) }, selected = variablesActive, onClick = onVariablesClick, - icon = { Icon(Icons.Outlined.Pin, contentDescription = "Variables icon") }, + icon = { Icon(Icons.Outlined.Pin, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) NavigationDrawerItem( - label = { Text(text = "Units") }, + label = { Text(text = stringResource(R.string.navigation_units)) }, selected = unitsActive, onClick = onUnitsClick, - icon = { Icon(Icons.Outlined.Straighten, contentDescription = "Units icon") }, + icon = { Icon(Icons.Outlined.Straighten, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) NavigationDrawerItem( - label = { Text(text = "Datasets") }, + label = { Text(text = stringResource(R.string.navigation_datasets), textDecoration = TextDecoration.LineThrough) }, selected = datasetsActive, onClick = onDatasetsClick, - icon = { Icon(Icons.Outlined.Dataset, contentDescription = "Datasets icon") }, + icon = { Icon(Icons.Outlined.Dataset, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) @@ -107,17 +109,17 @@ fun NavigationDrawer( .padding(horizontal = 25.dp) .padding(top = 15.dp)) NavigationDrawerItem( - label = { Text(text = "About") }, + label = { Text(text = stringResource(R.string.navigation_about)) }, selected = false, onClick = onAboutClick, - icon = { Icon(Icons.Filled.Info, contentDescription = "About icon") }, + icon = { Icon(Icons.Filled.Info, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) NavigationDrawerItem( - label = { Text(text = "Settings") }, + label = { Text(text = stringResource(R.string.navigation_settings), textDecoration = TextDecoration.LineThrough) }, selected = false, onClick = onSettingsClick, - icon = { Icon(Icons.Filled.Settings, contentDescription = "Settings icon") }, + icon = { Icon(Icons.Filled.Settings, contentDescription = null) }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding) ) } diff --git a/app/src/main/java/com/jherkenhoff/qalculate/ui/QalculateApp.kt b/app/src/main/java/com/jherkenhoff/qalculate/ui/QalculateApp.kt index 7bfc06b..4c42149 100644 --- a/app/src/main/java/com/jherkenhoff/qalculate/ui/QalculateApp.kt +++ b/app/src/main/java/com/jherkenhoff/qalculate/ui/QalculateApp.kt @@ -5,7 +5,6 @@ import androidx.compose.material3.ModalNavigationDrawer import androidx.compose.material3.rememberDrawerState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.tooling.preview.Preview @@ -13,7 +12,6 @@ import androidx.navigation.NavDestination.Companion.hasRoute import androidx.navigation.NavDestination.Companion.hierarchy import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController -import com.jherkenhoff.qalculate.ui.calculator.NavigationDrawer import com.jherkenhoff.qalculate.ui.theme.QalculateTheme import kotlinx.coroutines.launch @@ -22,9 +20,6 @@ import kotlinx.coroutines.launch fun QalculateApp() { QalculateTheme(dynamicColor = true) { val navController = rememberNavController() - val navigationActions = remember(navController) { - QalculateNavigationActions(navController) - } val coroutineScope = rememberCoroutineScope() val keyboardController = LocalSoftwareKeyboardController.current diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2aad6cc..9e4bf0c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,4 +4,11 @@ Menu button Enter expression Powerful and versatile multi-purpose calculator based on the almighty Qalculate! desktop calculator. + Calculator + Functions + Variables + Units + Datasets + About + Settings \ No newline at end of file