Skip to content

Commit

Permalink
Separate keyboard switcher button. Indicate disabled nav items
Browse files Browse the repository at this point in the history
  • Loading branch information
jherkenhoff committed Oct 14, 2024
1 parent e3ce49f commit bb7143f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
)

Expand All @@ -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)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ 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
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

Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
<string name="top_sheet_menu">Menu button</string>
<string name="textfield_hint">Enter expression</string>
<string name="about_qalculate_text">Powerful and versatile multi-purpose calculator based on the almighty Qalculate! desktop calculator.</string>
<string name="navigation_calculator">Calculator</string>
<string name="navigation_functions">Functions</string>
<string name="navigation_variables">Variables</string>
<string name="navigation_units">Units</string>
<string name="navigation_datasets">Datasets</string>
<string name="navigation_about">About</string>
<string name="navigation_settings">Settings</string>
</resources>

0 comments on commit bb7143f

Please sign in to comment.