mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Update admin drop down
This commit is contained in:
parent
8b2bc246dd
commit
dee96175bf
5 changed files with 24 additions and 16 deletions
|
|
@ -60,7 +60,7 @@ extension NodeInfoEntity {
|
|||
}
|
||||
|
||||
var canRemoteAdmin: Bool {
|
||||
if !(securityConfig?.adminKey?.isEmpty ?? true) {
|
||||
if UserDefaults.enableAdministration {
|
||||
return true
|
||||
} else {
|
||||
let adminChannel = myInfo?.channels?.filter { ($0 as AnyObject).name?.lowercased() == "admin" }
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ extension UserDefaults {
|
|||
case modemPreset
|
||||
case firmwareVersion
|
||||
case environmentEnableWeatherKit
|
||||
case enableAdministration
|
||||
case testIntEnum
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +163,9 @@ extension UserDefaults {
|
|||
@UserDefault(.environmentEnableWeatherKit, defaultValue: true)
|
||||
static var environmentEnableWeatherKit: Bool
|
||||
|
||||
@UserDefault(.enableAdministration, defaultValue: false)
|
||||
static var enableAdministration: Bool
|
||||
|
||||
@UserDefault(.testIntEnum, defaultValue: .one)
|
||||
static var testIntEnum: TestIntEnum
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ struct AppSettings: View {
|
|||
@State private var isPresentingCoreDataResetConfirm = false
|
||||
@State private var isPresentingDeleteMapTilesConfirm = false
|
||||
@AppStorage("environmentEnableWeatherKit") private var environmentEnableWeatherKit: Bool = true
|
||||
@AppStorage("enableAdministration") private var enableAdministration: Bool = false
|
||||
var body: some View {
|
||||
VStack {
|
||||
Form {
|
||||
|
|
@ -23,6 +24,10 @@ struct AppSettings: View {
|
|||
UIApplication.shared.open(url)
|
||||
}
|
||||
}
|
||||
Toggle(isOn: $enableAdministration) {
|
||||
Label("Administration", systemImage: "gearshape.2")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
}
|
||||
Section(header: Text("environment")) {
|
||||
VStack(alignment: .leading) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,18 @@ struct SaveChannelQRCode: View {
|
|||
.controlSize(.large)
|
||||
.padding()
|
||||
.disabled(!connectedToDevice)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Label("cancel", systemImage: "xmark")
|
||||
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.capsule)
|
||||
.controlSize(.large)
|
||||
.padding()
|
||||
#endif
|
||||
} else {
|
||||
Button {
|
||||
dismiss()
|
||||
|
|
@ -62,19 +74,6 @@ struct SaveChannelQRCode: View {
|
|||
.controlSize(.large)
|
||||
.padding()
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Label("cancel", systemImage: "xmark")
|
||||
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.capsule)
|
||||
.controlSize(.large)
|
||||
.padding()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ struct Settings: View {
|
|||
Image(systemName: "antenna.radiowaves.left.and.right")
|
||||
}
|
||||
.tag(Int(node.num))
|
||||
} else if node.canRemoteAdmin { /// Nodes using the new PKI system
|
||||
} else if node.canRemoteAdmin && UserDefaults.enableAdministration && node.sessionPasskey != nil { /// Nodes using the new PKI system
|
||||
Label {
|
||||
Text("Remote: \(node.user?.longName ?? "unknown".localized)")
|
||||
} icon: {
|
||||
|
|
@ -376,7 +376,7 @@ struct Settings: View {
|
|||
Image(systemName: "av.remote")
|
||||
}
|
||||
.tag(Int(node.num))
|
||||
} else if hasAdmin {
|
||||
} else if hasAdmin || node.user?.pkiEncrypted ?? false {
|
||||
Label {
|
||||
Text("Request Admin: \(node.user?.longName ?? "unknown".localized)")
|
||||
} icon: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue