mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Move all app settings to the settings bundle and link from the app settings view
Add enter shortcut to alert ok buttons on the node list
This commit is contained in:
parent
fc1cdc4d88
commit
6144786cf9
4 changed files with 77 additions and 81 deletions
|
|
@ -146,7 +146,7 @@ struct NodeList: View {
|
|||
"Position Sent",
|
||||
isPresented: $isPresentingPositionSentAlert
|
||||
) {
|
||||
Button("OK", role: .cancel) { }
|
||||
Button("OK") { }.keyboardShortcut(.defaultAction)
|
||||
} message: {
|
||||
Text("Your position has been sent with a request for a response with their position.")
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ struct NodeList: View {
|
|||
"Trace Route Sent",
|
||||
isPresented: $isPresentingTraceRouteSentAlert
|
||||
) {
|
||||
Button("OK", role: .cancel) { }
|
||||
Button("OK") { }.keyboardShortcut(.defaultAction)
|
||||
} message: {
|
||||
Text("This could take a while, response will appear in the trace route log for the node it was sent to.")
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ struct NodeList: View {
|
|||
"Client History Request Sent",
|
||||
isPresented: $isPresentingClientHistorySentAlert
|
||||
) {
|
||||
Button("OK", role: .cancel) { }
|
||||
Button("OK") { }.keyboardShortcut(.defaultAction)
|
||||
} message: {
|
||||
Text("Any missed messages will be delivered again.")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,55 +10,19 @@ struct AppSettings: View {
|
|||
@ObservedObject var tileManager = OfflineTileManager.shared
|
||||
@State var totalDownloadedTileSize = ""
|
||||
@StateObject var locationHelper = LocationHelper()
|
||||
@State var provideLocation: Bool = UserDefaults.provideLocation
|
||||
@State var enableSmartPosition: Bool = UserDefaults.enableSmartPosition
|
||||
@State var newNodeNotifications: Bool = UserDefaults.newNodeNotifications
|
||||
@State var useLegacyMap: Bool = UserDefaults.mapUseLegacy
|
||||
@State var provideLocationInterval: Int = UserDefaults.provideLocationInterval
|
||||
@State private var isPresentingCoreDataResetConfirm = false
|
||||
@State private var isPresentingDeleteMapTilesConfirm = false
|
||||
var body: some View {
|
||||
VStack {
|
||||
Form {
|
||||
Section(header: Text("Location Settings")) {
|
||||
Toggle(isOn: $provideLocation) {
|
||||
Label("appsettings.provide.location", systemImage: "location.circle.fill")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
Text("Use your phone's gps to provide a location to your node. Must have location access and precise location enabled for Meshtastic in Settings.")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.gray)
|
||||
if provideLocation {
|
||||
Toggle(isOn: $enableSmartPosition) {
|
||||
Label("appsettings.smartposition", systemImage: "brain")
|
||||
Text("Will only send a position to the phone if it is recent and of high horizontal accuracy.")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
VStack {
|
||||
Picker("update.interval", selection: $provideLocationInterval) {
|
||||
ForEach(LocationUpdateInterval.allCases) { lu in
|
||||
Text(lu.description)
|
||||
}
|
||||
}
|
||||
.pickerStyle(DefaultPickerStyle())
|
||||
Text("phone.gps.interval.description")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.gray)
|
||||
Section(header: Text("App Settings")) {
|
||||
Button("Open Settings", systemImage: "gear") {
|
||||
// Get the settings URL and open it
|
||||
if let url = URL(string: UIApplication.openSettingsURLString) {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
}
|
||||
Toggle(isOn: $useLegacyMap) {
|
||||
Label("map.use.legacy", systemImage: "map")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
}
|
||||
|
||||
// Section(header: Text("Notifications")){
|
||||
// Toggle(isOn: $newNodeNotifications){
|
||||
// Label("appsettings.newNodeNotifications", systemImage: "bell.fill")
|
||||
// }
|
||||
// }
|
||||
Section(header: Text("phone.gps")) {
|
||||
if #available(iOS 17.0, macOS 14.0, *) {
|
||||
GPSStatus()
|
||||
|
|
@ -139,14 +103,6 @@ struct AppSettings: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onReceive(
|
||||
NotificationCenter.default
|
||||
.publisher(for: UserDefaults.didChangeNotification)
|
||||
.receive(on: RunLoop.main)
|
||||
) { _ in
|
||||
provideLocation = !UserDefaults.provideLocation
|
||||
enableSmartPosition = UserDefaults.enableSmartPosition
|
||||
}
|
||||
.onAppear(perform: {
|
||||
totalDownloadedTileSize = tileManager.getAllDownloadedSize()
|
||||
})
|
||||
|
|
@ -157,32 +113,9 @@ struct AppSettings: View {
|
|||
ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?")
|
||||
})
|
||||
.onAppear {
|
||||
if provideLocationInterval <= 0 {
|
||||
provideLocationInterval = 30
|
||||
UserDefaults.provideLocationInterval = provideLocationInterval
|
||||
}
|
||||
if self.bleManager.context == nil {
|
||||
self.bleManager.context = context
|
||||
}
|
||||
}
|
||||
.onChange(of: provideLocation) { newProvideLocation in
|
||||
UserDefaults.provideLocation = newProvideLocation
|
||||
if bleManager.connectedPeripheral != nil {
|
||||
self.bleManager.sendWantConfig()
|
||||
}
|
||||
}
|
||||
|
||||
.onChange(of: newNodeNotifications){ newNewNodeNotifications in
|
||||
UserDefaults.newNodeNotifications = newNewNodeNotifications
|
||||
}
|
||||
.onChange(of: enableSmartPosition) { newEnableSmartPosition in
|
||||
UserDefaults.enableSmartPosition = newEnableSmartPosition
|
||||
}
|
||||
.onChange(of: (provideLocationInterval)) { newProvideLocationInterval in
|
||||
UserDefaults.provideLocationInterval = newProvideLocationInterval
|
||||
}
|
||||
.onChange(of: useLegacyMap) { newMapUseLegacy in
|
||||
UserDefaults.mapUseLegacy = newMapUseLegacy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,8 +231,9 @@ struct Channels: View {
|
|||
Button {
|
||||
goBack()
|
||||
} label: {
|
||||
Label("close", systemImage: "xmark")
|
||||
Label("close me", systemImage: "xmark")
|
||||
}
|
||||
.keyboardShortcut("w")
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.capsule)
|
||||
.controlSize(.large)
|
||||
|
|
|
|||
|
|
@ -8,19 +8,71 @@
|
|||
<array>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Notifications</string>
|
||||
<string>Share Location</string>
|
||||
<key>Key</key>
|
||||
<string>provideLocation</string>
|
||||
<key>DefaultValue</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>New Nodes</string>
|
||||
<string>Smart Position</string>
|
||||
<key>Key</key>
|
||||
<string>newNodeNotifications</string>
|
||||
<string>enableSmartPosition</string>
|
||||
<key>DefaultValue</key>
|
||||
<true/>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSMultiValueSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Location Interval</string>
|
||||
<key>Key</key>
|
||||
<string>provideLocationInterval</string>
|
||||
<key>Values</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>15</integer>
|
||||
<integer>30</integer>
|
||||
<integer>45</integer>
|
||||
<integer>60</integer>
|
||||
<integer>300</integer>
|
||||
<integer>600</integer>
|
||||
<integer>900</integer>
|
||||
</array>
|
||||
<key>Titles</key>
|
||||
<array>
|
||||
<string>Ten Seconds</string>
|
||||
<string>Fifteen Seconds</string>
|
||||
<string>Thirty Seconds</string>
|
||||
<string>Forty Five Seconds</string>
|
||||
<string>One Minute</string>
|
||||
<string>Five Minutes</string>
|
||||
<string>Ten Minutes</string>
|
||||
<string>Fifteen Minutes</string>
|
||||
</array>
|
||||
<key>DefaultValue</key>
|
||||
<string>Thirty Seconds</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Use Legacy Mesh Map</string>
|
||||
<key>Key</key>
|
||||
<string>mapUseLegacy</string>
|
||||
<key>DefaultValue</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Notifications</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
|
|
@ -32,6 +84,16 @@
|
|||
<key>DefaultValue</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>New Nodes</string>
|
||||
<key>Key</key>
|
||||
<string>newNodeNotifications</string>
|
||||
<key>DefaultValue</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue