From fce645c576f2742d89098c9a035ec271ec169dae Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 21 Aug 2023 22:46:34 -0700 Subject: [PATCH] Add search to nodes list --- Meshtastic/Views/Nodes/NodeList.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index d9a497ef..aa77c2f0 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -12,6 +12,16 @@ import SwiftUI import CoreLocation struct NodeList: View { + + @State private var searchText = "" + var nodesQuery: Binding { + Binding { + searchText + } set: { newValue in + searchText = newValue + nodes.nsPredicate = newValue.isEmpty ? nil : NSPredicate(format: "user.longName CONTAINS %@", newValue) + } + } @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager @@ -116,5 +126,7 @@ struct NodeList: View { Text("select.node") } } + .searchable(text: nodesQuery, prompt: "Find a node") } } +