Button size cleanup

This commit is contained in:
Garth Vander Houwen 2023-05-13 14:23:12 -07:00
parent 255e10bbe5
commit 0dcdd4f009
7 changed files with 87 additions and 98 deletions

View file

@ -103,7 +103,6 @@
DDB75A142A0593E2006ED576 /* OfflineTileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB75A132A0593E2006ED576 /* OfflineTileManager.swift */; };
DDB75A162A0594AD006ED576 /* TileOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB75A152A0594AD006ED576 /* TileOverlay.swift */; };
DDB75A1A2A05EB67006ED576 /* alpha.png in Resources */ = {isa = PBXBuildFile; fileRef = DDB75A192A05EB67006ED576 /* alpha.png */; };
DDB75A1C2A076DFA006ED576 /* TilesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB75A1B2A076DFA006ED576 /* TilesView.swift */; };
DDB75A1E2A0B0CD0006ED576 /* LoRaSignalStrengthIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB75A1D2A0B0CD0006ED576 /* LoRaSignalStrengthIndicator.swift */; };
DDC2E15826CE248E0042C5E4 /* MeshtasticApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E15726CE248E0042C5E4 /* MeshtasticApp.swift */; };
DDC2E15C26CE248F0042C5E4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DDC2E15B26CE248F0042C5E4 /* Assets.xcassets */; };
@ -293,7 +292,6 @@
DDB75A132A0593E2006ED576 /* OfflineTileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineTileManager.swift; sourceTree = "<group>"; };
DDB75A152A0594AD006ED576 /* TileOverlay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileOverlay.swift; sourceTree = "<group>"; };
DDB75A192A05EB67006ED576 /* alpha.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = alpha.png; sourceTree = "<group>"; };
DDB75A1B2A076DFA006ED576 /* TilesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TilesView.swift; sourceTree = "<group>"; };
DDB75A1D2A0B0CD0006ED576 /* LoRaSignalStrengthIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoRaSignalStrengthIndicator.swift; sourceTree = "<group>"; };
DDBA45EC299ED78100DEEDDC /* MeshtasticDataModelV8.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV8.xcdatamodel; sourceTree = "<group>"; };
DDC2E15426CE248E0042C5E4 /* Meshtastic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Meshtastic.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -403,7 +401,6 @@
DD964FC32974767D007C176F /* MapViewFitExtension.swift */,
DD2AD8A7296D2DF9001FF0E7 /* MapViewSwiftUI.swift */,
DDDB443529F6287000EE2349 /* MapButtons.swift */,
DDB75A1B2A076DFA006ED576 /* TilesView.swift */,
);
path = Custom;
sourceTree = "<group>";
@ -1010,7 +1007,6 @@
DD2160AF28C5552500C17253 /* MQTTConfig.swift in Sources */,
DDDB444229F8A88700EE2349 /* Double.swift in Sources */,
DD5E520F298EE33B00D21B61 /* cannedmessages.pb.swift in Sources */,
DDB75A1C2A076DFA006ED576 /* TilesView.swift in Sources */,
DDB75A162A0594AD006ED576 /* TileOverlay.swift in Sources */,
DDF924CA26FBB953009FE055 /* ConnectedDevice.swift in Sources */,
DD3CC6BE28E4CD9800FA9159 /* BatteryGauge.swift in Sources */,

View file

@ -135,6 +135,26 @@ enum ModemPresets: Int, CaseIterable, Identifiable {
return "Short Range - Fast"
}
}
func snrLimit() -> Float {
switch self {
case .longFast:
return -17.5
case .longSlow:
return -7.5
case .longModerate:
return -17.5
case .vLongSlow:
return -20
case .medSlow:
return -15
case .medFast:
return -12.5
case .shortSlow:
return -10
case .shortFast:
return -7.5
}
}
func protoEnumValue() -> Config.LoRaConfig.ModemPreset {
switch self {
case .longFast:

View file

@ -787,9 +787,10 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
if LocationHelper.currentSpeed >= 0 {
positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed * 3.6)
}
if LocationHelper.currentHeading >= 0 {
if (!LocationHelper.currentHeading.isNaN || !LocationHelper.currentHeading.isInfinite) {
positionPacket.groundTrack = UInt32(LocationHelper.currentHeading)
}
var meshPacket = MeshPacket()
meshPacket.to = UInt32(destNum)
meshPacket.from = UInt32(fromNodeNum)

View file

@ -1,49 +0,0 @@
//
// TilesView.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen on 5/6/23.
//
import SwiftUI
import MapKit
struct TilesView: View {
@ObservedObject var tileManager = OfflineTileManager.shared
@State var totalDownloadedTileSize = ""
var body: some View {
Button(action: {
tileManager.removeAll()
totalDownloadedTileSize = tileManager.getAllDownloadedSize()
print("delete all tiles")
}) {
HStack {
Image(systemName: "trash")
.font(.callout)
.foregroundColor(.red)
Text("\("map.tiles.delete".localized) (\(totalDownloadedTileSize))")
.font(.callout)
.foregroundColor(.red)
Spacer()
}
}
.onAppear(perform: {
totalDownloadedTileSize = tileManager.getAllDownloadedSize()
})
}
}
// MARK: Previews
struct TilesView_Previews: PreviewProvider {
static var previews: some View {
TilesView()
.previewLayout(.fixed(width: 300, height: 80))
.environment(\.colorScheme, .light)
}
}

View file

@ -167,7 +167,7 @@ struct WaypointFormView: View {
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.controlSize(.regular)
.disabled(bleManager.connectedPeripheral == nil)
.padding(.bottom)
@ -178,7 +178,7 @@ struct WaypointFormView: View {
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.controlSize(.regular)
.padding(.bottom)
if coordinate.waypointId > 0 {
@ -230,7 +230,7 @@ struct WaypointFormView: View {
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.controlSize(.regular)
.padding(.bottom)
}
}

View file

@ -8,11 +8,14 @@ struct AppSettings: View {
@Environment(\.managedObjectContext) var context
@EnvironmentObject var bleManager: BLEManager
@ObservedObject var tileManager = OfflineTileManager.shared
@State var totalDownloadedTileSize = ""
@StateObject var locationHelper = LocationHelper()
@State var meshtasticUsername: String = UserDefaults.meshtasticUsername
@State var provideLocation: Bool = UserDefaults.provideLocation
@State var provideLocationInterval: Int = UserDefaults.provideLocationInterval
@State private var isPresentingCoreDataResetConfirm = false
@State private var isPresentingDeleteMapTilesConfirm = false
var body: some View {
VStack {
@ -40,8 +43,8 @@ struct AppSettings: View {
.font(.footnote)
}
Label("Coordinate \(String(format: "%.5f", locationHelper.locationManager.location?.coordinate.latitude ?? 0)), \(String(format: "%.5f", locationHelper.locationManager.location?.coordinate.longitude ?? 0))", systemImage: "mappin")
.font(.footnote)
.textSelection(.enabled)
.font(.footnote)
.textSelection(.enabled)
if locationHelper.locationManager.location?.verticalAccuracy ?? 0 > 0 {
Label("Altitude \(altitiude.formatted())", systemImage: "mountain.2")
.font(.footnote)
@ -55,56 +58,74 @@ struct AppSettings: View {
.font(.footnote)
}
}
Section(header: Text("Location Settings")) {
Toggle(isOn: $provideLocation) {
Label("provide.location", systemImage: "location.circle.fill")
.font(.footnote)
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
if UserDefaults.provideLocation {
Picker("update.interval", selection: $provideLocationInterval) {
ForEach(LocationUpdateInterval.allCases) { lu in
Text(lu.description)
VStack {
Picker("update.interval", selection: $provideLocationInterval) {
ForEach(LocationUpdateInterval.allCases) { lu in
Text(lu.description)
}
}
.pickerStyle(DefaultPickerStyle())
.onChange(of: (provideLocationInterval)) { newProvideLocationInterval in
UserDefaults.provideLocationInterval = newProvideLocationInterval
}
Text("phone.gps.interval.description")
.font(.caption2)
.foregroundColor(.gray)
}
.pickerStyle(DefaultPickerStyle())
.onChange(of: (provideLocationInterval)) { newProvideLocationInterval in
UserDefaults.provideLocationInterval = newProvideLocationInterval
}
Text("phone.gps.interval.description")
.font(.caption2)
.foregroundColor(.gray)
}
}
TilesView()
}
HStack {
Button {
isPresentingCoreDataResetConfirm = true
} label: {
Label("clear.app.data", systemImage: "trash")
.foregroundColor(.red)
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
.confirmationDialog(
"are.you.sure",
isPresented: $isPresentingCoreDataResetConfirm,
titleVisibility: .visible
) {
Button("Erase all app data?", role: .destructive) {
bleManager.disconnectPeripheral()
clearCoreDataDatabase(context: context)
UserDefaults.standard.reset()
UserDefaults.standard.synchronize()
Section(header: Text("App Data")) {
Button {
isPresentingDeleteMapTilesConfirm = true
} label: {
Label("\("map.tiles.delete".localized) (\(totalDownloadedTileSize))", systemImage: "trash")
.foregroundColor(.red)
}
.confirmationDialog(
"are.you.sure",
isPresented: $isPresentingDeleteMapTilesConfirm,
titleVisibility: .visible
) {
Button("Delete all map tiles?", role: .destructive) {
tileManager.removeAll()
totalDownloadedTileSize = tileManager.getAllDownloadedSize()
print("delete all tiles")
}
}
Button {
isPresentingCoreDataResetConfirm = true
} label: {
Label("clear.app.data", systemImage: "trash")
.foregroundColor(.red)
}
.confirmationDialog(
"are.you.sure",
isPresented: $isPresentingCoreDataResetConfirm,
titleVisibility: .visible
) {
Button("Erase all app data?", role: .destructive) {
bleManager.disconnectPeripheral()
clearCoreDataDatabase(context: context)
UserDefaults.standard.reset()
UserDefaults.standard.synchronize()
}
}
}
}
.onAppear(perform: {
totalDownloadedTileSize = tileManager.getAllDownloadedSize()
})
}
.navigationTitle("app.settings")
.navigationBarItems(trailing:

View file

@ -139,7 +139,7 @@
"map"="Mesh Map";
"map.type"="Default Type";
"map.centering"="Centering Mode";
"map.tiles.delete"="Delete Cached Map Tiles";
"map.tiles.delete"="Delete Map Tiles";
"map.recentering"="Automatic Re-centering";
"map.usertrackingmode"="User tracking mode";
"map.usertrackingmode.follow"="Follow";
@ -207,7 +207,7 @@
"position"="Position";
"position.config"="Position Config";
"preferred.radio"="Preferred Radio";
"provide.location"="Provide location to mesh";
"provide.location"="Share location";
"radio.configuration"="Radio Configuration";
"range.test"="Range Test";
"range.test.config"="Range Test Config";