mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
role filter mockup
This commit is contained in:
parent
fb2f182f70
commit
b19109b7c7
5 changed files with 41 additions and 8 deletions
|
|
@ -17386,6 +17386,9 @@
|
|||
},
|
||||
"Role: %@" : {
|
||||
|
||||
},
|
||||
"Roles" : {
|
||||
|
||||
},
|
||||
"Root Topic" : {
|
||||
|
||||
|
|
@ -22405,4 +22408,4 @@
|
|||
}
|
||||
},
|
||||
"version" : "1.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,8 @@ struct UserList: View {
|
|||
@State private var maxDistance: Double = 800000
|
||||
@State private var hopsAway: Int = -1
|
||||
@State private var deviceRole: Int = -1
|
||||
@State private var roleFilter = false
|
||||
@State private var deviceRoles: Set<Int> = []
|
||||
@State var isEditingFilters = false
|
||||
|
||||
@FetchRequest(
|
||||
|
|
@ -170,7 +172,7 @@ struct UserList: View {
|
|||
.listStyle(.plain)
|
||||
.navigationTitle(String.localizedStringWithFormat("contacts %@".localized, String(users.count == 0 ? 0 : users.count - 1)))
|
||||
.sheet(isPresented: $isEditingFilters) {
|
||||
NodeListFilter(filterTitle: "Contact Filters", viaLora: $viaLora, viaMqtt: $viaMqtt, isOnline: $isOnline, isFavorite: $isFavorite, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $deviceRole)
|
||||
NodeListFilter(filterTitle: "Contact Filters", viaLora: $viaLora, viaMqtt: $viaMqtt, isOnline: $isOnline, isFavorite: $isFavorite, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $deviceRole, roleFilter: $roleFilter, deviceRoles: $deviceRoles)
|
||||
}
|
||||
.onChange(of: searchText) { _ in
|
||||
searchUserList()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import SwiftUI
|
|||
|
||||
struct NodeListFilter: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State var editMode = EditMode.active
|
||||
/// Filters
|
||||
var filterTitle = "Node Filters"
|
||||
@Binding var viaLora: Bool
|
||||
|
|
@ -20,6 +21,7 @@ struct NodeListFilter: View {
|
|||
@Binding var maximumDistance: Double
|
||||
@Binding var hopsAway: Int
|
||||
@Binding var deviceRole: Int
|
||||
@Binding var roleFilter: Bool
|
||||
@Binding var deviceRoles: Set<Int>
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -127,6 +129,31 @@ struct NodeListFilter: View {
|
|||
}
|
||||
.pickerStyle(DefaultPickerStyle())
|
||||
}
|
||||
Toggle(isOn: $roleFilter) {
|
||||
|
||||
Label {
|
||||
Text("Roles")
|
||||
} icon: {
|
||||
Image(systemName: "apps.iphone")
|
||||
}
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
|
||||
.listRowSeparator(roleFilter ? .hidden : .visible)
|
||||
if roleFilter {
|
||||
VStack {
|
||||
List(DeviceRoles.allCases, selection: $deviceRoles) { dr in
|
||||
Label {
|
||||
Text(" \(dr.name)")
|
||||
} icon: {
|
||||
Image(systemName: dr.systemName)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.environment(\.editMode, $editMode) /// bind it here!
|
||||
.frame(minHeight: 210, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if targetEnvironment(macCatalyst)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ struct NodeList: View {
|
|||
@State private var distanceFilter = false
|
||||
@State private var maxDistance: Double = 800000
|
||||
@State private var hopsAway: Int = -1
|
||||
@State private var deviceRole: Int = -1
|
||||
@State private var nodeRole: Int = -1
|
||||
@State private var roleFilter = false
|
||||
@State private var deviceRoles: Set<Int> = []
|
||||
|
||||
@State var isEditingFilters = false
|
||||
|
|
@ -189,7 +190,7 @@ struct NodeList: View {
|
|||
}
|
||||
}
|
||||
.sheet(isPresented: $isEditingFilters) {
|
||||
NodeListFilter(viaLora: $viaLora, viaMqtt: $viaMqtt, isOnline: $isOnline, isFavorite: $isFavorite, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $deviceRole, deviceRoles: $deviceRoles)
|
||||
NodeListFilter(viaLora: $viaLora, viaMqtt: $viaMqtt, isOnline: $isOnline, isFavorite: $isFavorite, distanceFilter: $distanceFilter, maximumDistance: $maxDistance, hopsAway: $hopsAway, deviceRole: $nodeRole, roleFilter: $roleFilter, deviceRoles: $deviceRoles)
|
||||
}
|
||||
.safeAreaInset(edge: .bottom, alignment: .trailing) {
|
||||
HStack {
|
||||
|
|
@ -298,7 +299,7 @@ struct NodeList: View {
|
|||
}
|
||||
searchNodeList()
|
||||
}
|
||||
.onChange(of: deviceRole) { _ in
|
||||
.onChange(of: nodeRole) { _ in
|
||||
searchNodeList()
|
||||
}
|
||||
.onChange(of: hopsAway) { _ in
|
||||
|
|
@ -363,8 +364,8 @@ struct NodeList: View {
|
|||
}
|
||||
}
|
||||
/// Role
|
||||
if deviceRole > -1 {
|
||||
let rolePredicate = NSPredicate(format: "user.role == %i", Int32(deviceRole))
|
||||
if nodeRole > -1 {
|
||||
let rolePredicate = NSPredicate(format: "user.role == %i", Int32(nodeRole))
|
||||
predicates.append(rolePredicate)
|
||||
}
|
||||
/// Hops Away
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ struct AppLogFilter: View {
|
|||
var filterTitle = "App Log Filters"
|
||||
@Binding var categories: Set<Int>
|
||||
@Binding var levels: Set<Int>
|
||||
@State var editMode = EditMode.active /// the edit mode
|
||||
@State var editMode = EditMode.active
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue