Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
Expand Down Expand Up @@ -576,7 +576,7 @@ fun HomeScreen(
ExtendedFloatingActionButton(
onClick = {
if (homeUiState.nfcStatus == NfcStatus.DISABLED) {
onOpenNfcSettings()
onOpenNfcSettings?.invoke()
} else {
onScanCard()
}
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class IosPlatformActions : PlatformActions {
UIApplication.sharedApplication.openURL(nsUrl, emptyMap<Any?, Any>(), null)
}

override fun openNfcSettings() {
override val openNfcSettings: (() -> Unit) = {
val settingsUrl = NSURL(string = "App-prefs:root")
UIApplication.sharedApplication.openURL(settingsUrl, emptyMap<Any?, Any>(), null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down