Skip to content

Commit

Permalink
Allow scanning NFC tags from anywhere in app
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenperera committed Oct 28, 2024
1 parent 9378269 commit 6aadec7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ios/Cove/CoveApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,17 @@ struct CoveApp: App {
id = UUID()
}
.onChange(of: scannedCode) { _, scannedCode in
// QR code scanning
guard let scannedCode else { return }
if scannedCode.value.isEmpty { return }
handleScannedCode(StringOrData(scannedCode.value))
}
.onChange(of: model.nfcReader.scannedMessage) { _, scannedMessage in
// NFC scanning
guard let scannedMessage else { return }
if scannedMessage.value.isEmpty { return }
handleScannedCode(StringOrData(scannedMessage))
}
.alert(
alert?.item.title() ?? "Alert",
isPresented: showingAlert,
Expand Down
2 changes: 1 addition & 1 deletion ios/Cove/HomeScreens/SelectedWalletScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct SelectedWalletScreenInner: View {
.toolbar {
ToolbarItemGroup {
Button(action: {
sheetState = PresentableItem(.settings)
app.nfcReader.scan()
}) {
HStack {
Image(systemName: "wave.3.right")
Expand Down
1 change: 1 addition & 0 deletions ios/Cove/MainViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SwiftUI
var selectedNode = Database().globalConfig().selectedNode()

var sheetState: PresentableItem<AppSheetState>? = .none
var nfcReader = NFCReader()

// changed when route is reset, to clear lifecycle view state
var routeId = UUID()
Expand Down

0 comments on commit 6aadec7

Please sign in to comment.