From 763a8f8b07d57518f29db7e960ac14bc7ee22088 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Thu, 26 Mar 2026 22:17:16 -0500 Subject: [PATCH] style: apply spotless formatting --- .../kotlin/org/meshtastic/app/MainActivity.kt | 3 +- .../main/kotlin/org/meshtastic/app/ui/Main.kt | 2 +- .../core/navigation/MultiBackstack.kt | 30 +++++------------ .../core/ui/component/MeshtasticAppShell.kt | 6 ++-- .../core/ui/component/MeshtasticNavDisplay.kt | 33 ++++++++----------- .../ui/component/MeshtasticNavigationSuite.kt | 11 +++---- .../kotlin/org/meshtastic/desktop/Main.kt | 11 ++----- .../desktop/ui/DesktopMainScreen.kt | 9 ++--- 8 files changed, 37 insertions(+), 68 deletions(-) diff --git a/app/src/main/kotlin/org/meshtastic/app/MainActivity.kt b/app/src/main/kotlin/org/meshtastic/app/MainActivity.kt index ad1e382ce..8b3e85b9c 100644 --- a/app/src/main/kotlin/org/meshtastic/app/MainActivity.kt +++ b/app/src/main/kotlin/org/meshtastic/app/MainActivity.kt @@ -173,7 +173,8 @@ class MainActivity : ComponentActivity() { }, org.meshtastic.core.ui.util.LocalTracerouteMapScreenProvider provides { destNum, requestId, logUuid, onNavigateUp -> - val metricsViewModel = koinViewModel { + val metricsViewModel = + koinViewModel { org.koin.core.parameter.parametersOf(destNum) } metricsViewModel.setNodeId(destNum) diff --git a/app/src/main/kotlin/org/meshtastic/app/ui/Main.kt b/app/src/main/kotlin/org/meshtastic/app/ui/Main.kt index 1002d01fd..4cad8493c 100644 --- a/app/src/main/kotlin/org/meshtastic/app/ui/Main.kt +++ b/app/src/main/kotlin/org/meshtastic/app/ui/Main.kt @@ -61,7 +61,7 @@ fun MainScreen() { MeshtasticNavigationSuite( multiBackstack = multiBackstack, uiViewModel = viewModel, - modifier = Modifier.fillMaxSize() + modifier = Modifier.fillMaxSize(), ) { val provider = entryProvider { diff --git a/core/navigation/src/commonMain/kotlin/org/meshtastic/core/navigation/MultiBackstack.kt b/core/navigation/src/commonMain/kotlin/org/meshtastic/core/navigation/MultiBackstack.kt index 51faeff50..067ee2ae7 100644 --- a/core/navigation/src/commonMain/kotlin/org/meshtastic/core/navigation/MultiBackstack.kt +++ b/core/navigation/src/commonMain/kotlin/org/meshtastic/core/navigation/MultiBackstack.kt @@ -26,9 +26,7 @@ import androidx.navigation3.runtime.NavBackStack import androidx.navigation3.runtime.NavKey import androidx.navigation3.runtime.rememberNavBackStack -/** - * Manages independent backstacks for multiple tabs. - */ +/** Manages independent backstacks for multiple tabs. */ class MultiBackstack(val startTab: NavKey) { var backStacks: Map> = emptyMap() @@ -38,9 +36,7 @@ class MultiBackstack(val startTab: NavKey) { val activeBackStack: NavBackStack get() = backStacks[currentTabRoute] ?: error("Stack for $currentTabRoute not found") - /** - * Switches to a new top-level tab route. - */ + /** Switches to a new top-level tab route. */ fun navigateTopLevel(route: NavKey) { val rootKey = TopLevelDestination.fromNavKey(route)?.route ?: route @@ -53,25 +49,21 @@ class MultiBackstack(val startTab: NavKey) { } } - /** - * Handles back navigation according to the "exit through home" pattern. - */ + /** Handles back navigation according to the "exit through home" pattern. */ fun goBack() { val currentStack = activeBackStack if (currentStack.size > 1) { currentStack.removeLastOrNull() return } - + // If we're at the root of a non-start tab, switch back to the start tab if (currentTabRoute != startTab) { currentTabRoute = startTab } } - /** - * Sets the active tab and replaces its stack with the provided route path. - */ + /** Sets the active tab and replaces its stack with the provided route path. */ fun handleDeepLink(navKeys: List) { val rootKey = navKeys.firstOrNull() ?: return val topLevel = TopLevelDestination.fromNavKey(rootKey)?.route ?: rootKey @@ -81,21 +73,17 @@ class MultiBackstack(val startTab: NavKey) { } } -/** - * Remembers a [MultiBackstack] for managing independent tab navigation histories with Navigation 3. - */ +/** Remembers a [MultiBackstack] for managing independent tab navigation histories with Navigation 3. */ @Composable fun rememberMultiBackstack(initialTab: NavKey = TopLevelDestination.Connections.route): MultiBackstack { val stacks = mutableMapOf>() - + TopLevelDestination.entries.forEach { dest -> - key(dest.route) { - stacks[dest.route] = rememberNavBackStack(MeshtasticNavSavedStateConfig, dest.route) - } + key(dest.route) { stacks[dest.route] = rememberNavBackStack(MeshtasticNavSavedStateConfig, dest.route) } } val multiBackstack = remember { MultiBackstack(initialTab) } multiBackstack.backStacks = stacks - + return multiBackstack } diff --git a/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticAppShell.kt b/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticAppShell.kt index 42aa57686..6ade7e3b2 100644 --- a/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticAppShell.kt +++ b/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticAppShell.kt @@ -37,16 +37,14 @@ fun MeshtasticAppShell( content: @Composable () -> Unit, ) { LaunchedEffect(uiViewModel) { - uiViewModel.navigationDeepLink.collect { navKeys -> - multiBackstack.handleDeepLink(navKeys) - } + uiViewModel.navigationDeepLink.collect { navKeys -> multiBackstack.handleDeepLink(navKeys) } } MeshtasticCommonAppSetup( uiViewModel = uiViewModel, onNavigateToTracerouteMap = { destNum, requestId, logUuid -> multiBackstack.activeBackStack.add( - NodeDetailRoutes.TracerouteMap(destNum = destNum, requestId = requestId, logUuid = logUuid) + NodeDetailRoutes.TracerouteMap(destNum = destNum, requestId = requestId, logUuid = logUuid), ) }, ) diff --git a/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavDisplay.kt b/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavDisplay.kt index 21f680901..18462b7c5 100644 --- a/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavDisplay.kt +++ b/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavDisplay.kt @@ -42,9 +42,7 @@ import androidx.navigation3.scene.SinglePaneSceneStrategy import androidx.navigation3.ui.NavDisplay import org.meshtastic.core.navigation.MultiBackstack -/** - * Duration in milliseconds for the shared crossfade transition between navigation scenes. - */ +/** Duration in milliseconds for the shared crossfade transition between navigation scenes. */ private const val TRANSITION_DURATION_MS = 350 /** @@ -64,13 +62,11 @@ fun MeshtasticNavDisplay( backStack = backStack, onBack = { multiBackstack.goBack() }, entryProvider = entryProvider, - modifier = modifier + modifier = modifier, ) } -/** - * Shared [NavDisplay] wrapper for a single backstack. - */ +/** Shared [NavDisplay] wrapper for a single backstack. */ @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable fun MeshtasticNavDisplay( @@ -114,20 +110,21 @@ fun MeshtasticNavDisplay( val saveableDecorator = rememberSaveableStateHolderNavEntryDecorator() val vmStoreDecorator = rememberViewModelStoreNavEntryDecorator() - - val activeDecorators = remember(backStack, saveableDecorator, vmStoreDecorator) { - listOf(saveableDecorator, vmStoreDecorator) - } + + val activeDecorators = + remember(backStack, saveableDecorator, vmStoreDecorator) { listOf(saveableDecorator, vmStoreDecorator) } NavDisplay( backStack = backStack, entryProvider = entryProvider, entryDecorators = activeDecorators, - onBack = onBack ?: { - if (backStack.size > 1) { - backStack.removeLastOrNull() - } - }, + onBack = + onBack + ?: { + if (backStack.size > 1) { + backStack.removeLastOrNull() + } + }, sceneStrategies = listOf( DialogSceneStrategy(), @@ -141,9 +138,7 @@ fun MeshtasticNavDisplay( ) } -/** - * Shared crossfade [ContentTransform] used for both forward and pop navigation. - */ +/** Shared crossfade [ContentTransform] used for both forward and pop navigation. */ private fun meshtasticTransitionSpec(): AnimatedContentTransitionScope>.() -> ContentTransform = { ContentTransform( fadeIn(animationSpec = tween(TRANSITION_DURATION_MS)), diff --git a/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavigationSuite.kt b/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavigationSuite.kt index c998b6e8a..39f8fc6b1 100644 --- a/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavigationSuite.kt +++ b/core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/MeshtasticNavigationSuite.kt @@ -46,7 +46,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.navigation3.runtime.NavKey import org.jetbrains.compose.resources.stringResource import org.meshtastic.core.model.ConnectionState import org.meshtastic.core.model.DeviceType @@ -65,8 +64,8 @@ import org.meshtastic.core.ui.viewmodel.UIViewModel /** * Shared adaptive navigation shell using [NavigationSuiteScaffold]. * - * This implementation uses the [MultiBackstack] state holder to manage independent histories for each tab, - * aligning with Navigation 3 best practices for state preservation during tab switching. + * This implementation uses the [MultiBackstack] state holder to manage independent histories for each tab, aligning + * with Navigation 3 best practices for state preservation during tab switching. */ @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -81,7 +80,7 @@ fun MeshtasticNavigationSuite( val selectedDevice by uiViewModel.currentDeviceAddressFlow.collectAsStateWithLifecycle() val adaptiveInfo = currentWindowAdaptiveInfo(supportLargeAndXLargeWidth = true) - + val currentTabRoute = multiBackstack.currentTabRoute val topLevelDestination = TopLevelDestination.fromNavKey(currentTabRoute) @@ -96,9 +95,7 @@ fun MeshtasticNavigationSuite( val isSelected = destination == topLevelDestination item( selected = isSelected, - onClick = { - handleNavigation(destination, topLevelDestination, multiBackstack, uiViewModel) - }, + onClick = { handleNavigation(destination, topLevelDestination, multiBackstack, uiViewModel) }, icon = { NavigationIconContent( destination = destination, diff --git a/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt b/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt index ad53c06cc..f48380dbc 100644 --- a/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt +++ b/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt @@ -36,19 +36,16 @@ import androidx.compose.ui.graphics.toComposeImageBitmap import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.KeyEventType import androidx.compose.ui.input.key.isMetaPressed -import androidx.compose.ui.input.key.isShiftPressed import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.type import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Notification import androidx.compose.ui.window.Tray import androidx.compose.ui.window.Window import androidx.compose.ui.window.WindowPosition import androidx.compose.ui.window.application import androidx.compose.ui.window.rememberTrayState import androidx.compose.ui.window.rememberWindowState -import androidx.navigation3.runtime.NavKey import co.touchlab.kermit.Logger import coil3.ImageLoader import coil3.compose.setSingletonImageLoaderFactory @@ -76,9 +73,7 @@ import org.meshtastic.desktop.ui.DesktopMainScreen import java.awt.Desktop import java.util.Locale -/** - * Meshtastic Desktop — the first non-Android target for the shared KMP module graph. - */ +/** Meshtastic Desktop — the first non-Android target for the shared KMP module graph. */ private val LocalAppLocale = staticCompositionLocalOf { "" } private const val MEMORY_CACHE_MAX_BYTES = 64L * 1024L * 1024L // 64 MiB @@ -160,9 +155,7 @@ fun main(args: Array) = application(exitProcessOnExit = false) { val windowState = rememberWindowState() LaunchedEffect(Unit) { - notificationManager.notifications.collect { notification -> - trayState.sendNotification(notification) - } + notificationManager.notifications.collect { notification -> trayState.sendNotification(notification) } } LaunchedEffect(Unit) { diff --git a/desktop/src/main/kotlin/org/meshtastic/desktop/ui/DesktopMainScreen.kt b/desktop/src/main/kotlin/org/meshtastic/desktop/ui/DesktopMainScreen.kt index 39b8c42c5..00b2e82c7 100644 --- a/desktop/src/main/kotlin/org/meshtastic/desktop/ui/DesktopMainScreen.kt +++ b/desktop/src/main/kotlin/org/meshtastic/desktop/ui/DesktopMainScreen.kt @@ -33,12 +33,9 @@ import org.meshtastic.desktop.navigation.desktopNavGraph /** Desktop main screen — uses shared navigation components. */ @Composable -fun DesktopMainScreen( - uiViewModel: UIViewModel, - multiBackstack: MultiBackstack, -) { +fun DesktopMainScreen(uiViewModel: UIViewModel, multiBackstack: MultiBackstack) { val backStack = multiBackstack.activeBackStack - + Surface(modifier = Modifier.fillMaxSize()) { MeshtasticAppShell( multiBackstack = multiBackstack, @@ -54,7 +51,7 @@ fun DesktopMainScreen( MeshtasticNavDisplay( multiBackstack = multiBackstack, entryProvider = provider, - modifier = Modifier.fillMaxSize() + modifier = Modifier.fillMaxSize(), ) } }