mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #113 from meshtastic/feature/module_settings
Clean up log buttons, select default tab on settings delete color arr…
This commit is contained in:
commit
6e89779c1c
4 changed files with 36 additions and 69 deletions
|
|
@ -57,41 +57,3 @@ extension String {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
typealias NodeColor = Int
|
||||
|
||||
extension NodeColor {
|
||||
// a color to represent an individual meshtastic device
|
||||
var color: Color {
|
||||
switch self {
|
||||
case 0:
|
||||
return Color(.red)
|
||||
case 1:
|
||||
return Color(.blue)
|
||||
case 2:
|
||||
return Color(.yellow)
|
||||
case 3:
|
||||
return Color(.green)
|
||||
case 4:
|
||||
return Color(.purple)
|
||||
case 5:
|
||||
return Color(.systemPink)
|
||||
case 6:
|
||||
return Color(.systemTeal)
|
||||
case 7:
|
||||
return Color(.black)
|
||||
case 8:
|
||||
return Color(.gray)
|
||||
case 9:
|
||||
return Color(.brown)
|
||||
case 10:
|
||||
return Color(.magenta)
|
||||
case 11:
|
||||
return Color(.orange)
|
||||
case 12:
|
||||
return Color(.cyan)
|
||||
default:
|
||||
return Color(.blue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,12 +38,6 @@ class UserSettings: ObservableObject {
|
|||
UserDefaults.standard.set(keyboardType, forKey: "keyboardType")
|
||||
}
|
||||
}
|
||||
@Published var meshActivityLog: Bool {
|
||||
didSet {
|
||||
UserDefaults.standard.set(meshActivityLog, forKey: "meshActivityLog")
|
||||
}
|
||||
}
|
||||
|
||||
@Published var meshMapType: String {
|
||||
didSet {
|
||||
UserDefaults.standard.set(meshMapType, forKey: "meshMapType")
|
||||
|
|
@ -63,7 +57,6 @@ class UserSettings: ObservableObject {
|
|||
self.provideLocation = UserDefaults.standard.object(forKey: "provideLocation") as? Bool ?? false
|
||||
self.provideLocationInterval = UserDefaults.standard.object(forKey: "provideLocationInterval") as? Int ?? 900
|
||||
self.keyboardType = UserDefaults.standard.object(forKey: "keyboardType") as? Int ?? 0
|
||||
self.meshActivityLog = UserDefaults.standard.object(forKey: "meshActivityLog") as? Bool ?? true
|
||||
self.meshMapType = UserDefaults.standard.string(forKey: "meshMapType") ?? "hybrid"
|
||||
self.meshMapCustomTileServer = UserDefaults.standard.string(forKey: "meshMapCustomTileServer") ?? ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ struct MeshLog: View {
|
|||
|
||||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
Button(action: {
|
||||
|
||||
Button(role: .destructive) {
|
||||
|
||||
let text = ""
|
||||
do {
|
||||
try text.write(to: logFile!, atomically: false, encoding: .utf8)
|
||||
|
|
@ -54,35 +56,31 @@ struct MeshLog: View {
|
|||
} catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
}) {
|
||||
Image(systemName: "trash.circle.fill")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
.imageScale(.large).foregroundColor(.accentColor)
|
||||
Text("Clear Log").font(.caption)
|
||||
.font(.caption)
|
||||
.foregroundColor(.accentColor)
|
||||
|
||||
} label: {
|
||||
|
||||
Label("Clear Log", systemImage: "trash.fill")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.capsule)
|
||||
.controlSize(.large)
|
||||
.padding()
|
||||
.background(Color(.systemGray6))
|
||||
.clipShape(Capsule())
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
|
||||
Button {
|
||||
|
||||
isExporting = true
|
||||
}) {
|
||||
Image(systemName: "arrow.down.circle.fill")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
.imageScale(.large).foregroundColor(.accentColor)
|
||||
Text("Download Log")
|
||||
.font(.caption)
|
||||
.foregroundColor(.accentColor)
|
||||
|
||||
} label: {
|
||||
|
||||
Label("Download Log", systemImage: "arrow.down.circle.fill")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.buttonBorderShape(.capsule)
|
||||
.controlSize(.large)
|
||||
.padding()
|
||||
.background(Color(.systemGray6))
|
||||
.clipShape(Capsule())
|
||||
|
||||
|
||||
Spacer()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,15 @@ struct Settings: View {
|
|||
|
||||
private var nodes: FetchedResults<NodeInfoEntity>
|
||||
|
||||
@State private var selection: String? = ""
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
|
||||
let connectedNodeNum = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0
|
||||
|
||||
NavigationLink {
|
||||
NavigationLink(tag: String("0"), selection: $selection) {
|
||||
AppSettings()
|
||||
} label: {
|
||||
|
||||
|
|
@ -197,6 +199,18 @@ struct Settings: View {
|
|||
// WiFi Config - Would break connection to device
|
||||
// MQTT Config - Part of WiFi
|
||||
}
|
||||
.onAppear {
|
||||
|
||||
self.bleManager.context = context
|
||||
self.bleManager.userSettings = userSettings
|
||||
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
|
||||
if nodes.count > 0 {
|
||||
selection = "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(GroupedListStyle())
|
||||
.navigationTitle("Settings")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue