diff --git a/app/desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop/DesktopPlatformActions.kt b/app/desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop/DesktopPlatformActions.kt index 88d4fb559..8decf83a6 100644 --- a/app/desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop/DesktopPlatformActions.kt +++ b/app/desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop/DesktopPlatformActions.kt @@ -17,9 +17,7 @@ class DesktopPlatformActions : PlatformActions { } } - override fun openNfcSettings() { - // No NFC settings on desktop - } + // openNfcSettings not overridden — no NFC settings on desktop override fun copyToClipboard(text: String) { val clipboard = Toolkit.getDefaultToolkit().systemClipboard diff --git a/app/src/androidMain/kotlin/com/codebutler/farebot/app/core/platform/AndroidPlatformActions.kt b/app/src/androidMain/kotlin/com/codebutler/farebot/app/core/platform/AndroidPlatformActions.kt index 232881bd8..228f8ce71 100644 --- a/app/src/androidMain/kotlin/com/codebutler/farebot/app/core/platform/AndroidPlatformActions.kt +++ b/app/src/androidMain/kotlin/com/codebutler/farebot/app/core/platform/AndroidPlatformActions.kt @@ -73,7 +73,7 @@ class AndroidPlatformActions( context.startActivity(intent) } - override fun openNfcSettings() { + override val openNfcSettings: (() -> Unit) = { val intent = Intent(Settings.ACTION_WIRELESS_SETTINGS) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(intent) diff --git a/app/src/commonMain/kotlin/com/codebutler/farebot/shared/App.kt b/app/src/commonMain/kotlin/com/codebutler/farebot/shared/App.kt index d6e500eea..f009f49c1 100644 --- a/app/src/commonMain/kotlin/com/codebutler/farebot/shared/App.kt +++ b/app/src/commonMain/kotlin/com/codebutler/farebot/shared/App.kt @@ -218,7 +218,7 @@ fun FareBotApp( null }, onOpenAbout = { platformActions.openUrl("https://codebutler.github.io/farebot") }, - onOpenNfcSettings = { platformActions.openNfcSettings() }, + onOpenNfcSettings = platformActions.openNfcSettings, onToggleShowAllScans = { historyViewModel.toggleShowAllScans() }, onAddAllSamples = if (isDebug) { diff --git a/app/src/commonMain/kotlin/com/codebutler/farebot/shared/platform/PlatformActions.kt b/app/src/commonMain/kotlin/com/codebutler/farebot/shared/platform/PlatformActions.kt index 738921868..454638f3d 100644 --- a/app/src/commonMain/kotlin/com/codebutler/farebot/shared/platform/PlatformActions.kt +++ b/app/src/commonMain/kotlin/com/codebutler/farebot/shared/platform/PlatformActions.kt @@ -7,7 +7,7 @@ package com.codebutler.farebot.shared.platform interface PlatformActions { fun openUrl(url: String) - fun openNfcSettings() + val openNfcSettings: (() -> Unit)? get() = null fun copyToClipboard(text: String) diff --git a/app/src/commonMain/kotlin/com/codebutler/farebot/shared/ui/screen/HomeScreen.kt b/app/src/commonMain/kotlin/com/codebutler/farebot/shared/ui/screen/HomeScreen.kt index d4b925291..f809c5fc7 100644 --- a/app/src/commonMain/kotlin/com/codebutler/farebot/shared/ui/screen/HomeScreen.kt +++ b/app/src/commonMain/kotlin/com/codebutler/farebot/shared/ui/screen/HomeScreen.kt @@ -140,7 +140,7 @@ fun HomeScreen( onStatusChipTap: (String) -> Unit = {}, onNavigateToKeys: (() -> Unit)?, onOpenAbout: () -> Unit, - onOpenNfcSettings: () -> Unit, + onOpenNfcSettings: (() -> Unit)? = null, onAddAllSamples: (() -> Unit)? = null, onSampleCardTap: ((CardInfo) -> Unit)? = null, onToggleShowAllScans: () -> Unit = {}, @@ -576,7 +576,7 @@ fun HomeScreen( ExtendedFloatingActionButton( onClick = { if (homeUiState.nfcStatus == NfcStatus.DISABLED) { - onOpenNfcSettings() + onOpenNfcSettings?.invoke() } else { onScanCard() } @@ -616,7 +616,7 @@ fun HomeScreen( ), ) { // NFC disabled banner (scan tab only) - if (selectedTab == 0 && homeUiState.nfcStatus == NfcStatus.DISABLED) { + if (selectedTab == 0 && homeUiState.nfcStatus == NfcStatus.DISABLED && onOpenNfcSettings != null) { Surface( color = MaterialTheme.colorScheme.errorContainer, modifier = Modifier.fillMaxWidth(), diff --git a/app/src/iosMain/kotlin/com/codebutler/farebot/shared/platform/IosPlatformActions.kt b/app/src/iosMain/kotlin/com/codebutler/farebot/shared/platform/IosPlatformActions.kt index 9e706810c..490042b43 100644 --- a/app/src/iosMain/kotlin/com/codebutler/farebot/shared/platform/IosPlatformActions.kt +++ b/app/src/iosMain/kotlin/com/codebutler/farebot/shared/platform/IosPlatformActions.kt @@ -51,7 +51,7 @@ class IosPlatformActions : PlatformActions { UIApplication.sharedApplication.openURL(nsUrl, emptyMap(), null) } - override fun openNfcSettings() { + override val openNfcSettings: (() -> Unit) = { val settingsUrl = NSURL(string = "App-prefs:root") UIApplication.sharedApplication.openURL(settingsUrl, emptyMap(), null) } diff --git a/app/web/src/wasmJsMain/kotlin/com/codebutler/farebot/web/WebPlatformActions.kt b/app/web/src/wasmJsMain/kotlin/com/codebutler/farebot/web/WebPlatformActions.kt index fb62acfe8..6e453ea91 100644 --- a/app/web/src/wasmJsMain/kotlin/com/codebutler/farebot/web/WebPlatformActions.kt +++ b/app/web/src/wasmJsMain/kotlin/com/codebutler/farebot/web/WebPlatformActions.kt @@ -117,9 +117,7 @@ class WebPlatformActions : PlatformActions { jsOpenUrl(url.toJsString()) } - override fun openNfcSettings() { - // No NFC settings on web - } + // openNfcSettings not overridden — no NFC settings on web override fun copyToClipboard(text: String) { jsCopyToClipboard(text.toJsString())