diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index eca12778..ef5471c7 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -9,8 +9,6 @@ /* Begin PBXBuildFile section */ C9697F9D279336B700250207 /* LocalMBTileOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9697F9C279336B700250207 /* LocalMBTileOverlay.swift */; }; C9697FA527933B8C00250207 /* SQLite in Frameworks */ = {isa = PBXBuildFile; productRef = C9697FA427933B8C00250207 /* SQLite */; }; - C9A7BC1027759A9600760B50 /* PositionAnnotationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9A7BC0F27759A9600760B50 /* PositionAnnotationView.swift */; }; - C9A88B55278B503C00BD810A /* MapViewModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9A88B54278B503C00BD810A /* MapViewModule.swift */; }; DD0F791B28713C8A00A6FDAD /* AdminMessageList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0F791A28713C8A00A6FDAD /* AdminMessageList.swift */; }; DD1925B728CDA5A400720036 /* CannedMessagesConfigEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1925B628CDA5A400720036 /* CannedMessagesConfigEnums.swift */; }; DD1925B928CDA93900720036 /* SerialConfigEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1925B828CDA93900720036 /* SerialConfigEnums.swift */; }; @@ -170,8 +168,6 @@ /* Begin PBXFileReference section */ A65FA974296876BF00A97686 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; C9697F9C279336B700250207 /* LocalMBTileOverlay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalMBTileOverlay.swift; sourceTree = ""; }; - C9A7BC0F27759A9600760B50 /* PositionAnnotationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PositionAnnotationView.swift; sourceTree = ""; }; - C9A88B54278B503C00BD810A /* MapViewModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapViewModule.swift; sourceTree = ""; }; DD0F791A28713C8A00A6FDAD /* AdminMessageList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminMessageList.swift; sourceTree = ""; }; DD1925B628CDA5A400720036 /* CannedMessagesConfigEnums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CannedMessagesConfigEnums.swift; sourceTree = ""; }; DD1925B828CDA93900720036 /* SerialConfigEnums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SerialConfigEnums.swift; sourceTree = ""; }; @@ -356,8 +352,6 @@ C9697F9C279336B700250207 /* LocalMBTileOverlay.swift */, DD964FC32974767D007C176F /* MapViewFitExtension.swift */, DD2AD8A7296D2DF9001FF0E7 /* MapViewSwiftUI.swift */, - C9A88B54278B503C00BD810A /* MapViewModule.swift */, - C9A7BC0F27759A9600760B50 /* PositionAnnotationView.swift */, ); path = Custom; sourceTree = ""; @@ -923,7 +917,6 @@ DD23A50F26FD1B4400D9B90C /* PeripheralModel.swift in Sources */, DDB6ABDB28B0AC6000384BA1 /* DistanceText.swift in Sources */, DD5E520D298EE33B00D21B61 /* storeforward.pb.swift in Sources */, - C9A7BC1027759A9600760B50 /* PositionAnnotationView.swift in Sources */, DD882F5D2772E4640005BF05 /* Contacts.swift in Sources */, DD964FC2297272AE007C176F /* WaypointEntityExtension.swift in Sources */, DD47E3CE26F103C600029299 /* NodeList.swift in Sources */, @@ -935,7 +928,6 @@ DD2553572855B02500E55709 /* LoRaConfig.swift in Sources */, DDB6ABD928B0A4BA00384BA1 /* BluetoothModes.swift in Sources */, DDD9E4E4284B208E003777C5 /* UserEntityExtension.swift in Sources */, - C9A88B55278B503C00BD810A /* MapViewModule.swift in Sources */, DD2553592855B52700E55709 /* PositionConfig.swift in Sources */, DD97E96828EFE9A00056DDA4 /* About.swift in Sources */, DDB6ABE028B13AC700384BA1 /* DeviceEnums.swift in Sources */, diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index b1f2391d..c9274bf0 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -18,19 +18,17 @@ enum KeyboardType: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .defaultKeyboard: - return NSLocalizedString("default", comment: "Default Keyboard") - case .asciiCapable: - return NSLocalizedString("ascii.capable", comment: "ASCII Capable Keyboard") - case .twitter: - return NSLocalizedString("twitter", comment: "Twitter Keyboard") - case .emailAddress: - return NSLocalizedString("email.address", comment: "Email Address Keyboard") - case .numbersAndPunctuation: - return NSLocalizedString("numbers.punctuation", comment: "Numbers and Punctuation Keyboard") - } + switch self { + case .defaultKeyboard: + return NSLocalizedString("default", comment: "Default Keyboard") + case .asciiCapable: + return NSLocalizedString("ascii.capable", comment: "ASCII Capable Keyboard") + case .twitter: + return NSLocalizedString("twitter", comment: "Twitter Keyboard") + case .emailAddress: + return NSLocalizedString("email.address", comment: "Email Address Keyboard") + case .numbersAndPunctuation: + return NSLocalizedString("numbers.punctuation", comment: "Numbers and Punctuation Keyboard") } } } @@ -42,44 +40,40 @@ enum CenteringMode: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .allAnnotations: - return "All Annotations"// NSLocalizedString("default", comment: "Default Keyboard") - case .allPositions: - return "All Node Postions"// NSLocalizedString("ascii.capable", comment: "ASCII Capable Keyboard") - } + switch self { + case .allAnnotations: + return "All Annotations"// NSLocalizedString("default", comment: "Default Keyboard") + case .allPositions: + return "All Node Postions"// NSLocalizedString("ascii.capable", comment: "ASCII Capable Keyboard") } } } enum MeshMapType: String, CaseIterable, Identifiable { - case standard = "standard" - case mutedStandard = "mutedStandard" - case hybrid = "hybrid" - case hybridFlyover = "hybridFlyover" - case satellite = "satellite" - case satelliteFlyover = "satelliteFlyover" + case standard + case mutedStandard + case hybrid + case hybridFlyover + case satellite + case satelliteFlyover var id: String { self.rawValue } var description: String { - get { - switch self { - case .standard: - return NSLocalizedString("standard", comment: "Standard") - case .mutedStandard: - return NSLocalizedString("standard.muted", comment: "Standard Muted") - case .hybrid: - return NSLocalizedString("hybrid", comment: "Hybrid") - case .hybridFlyover: - return NSLocalizedString("hybrid.flyover", comment: "Hybrid Flyover") - case .satellite: - return NSLocalizedString("satellite", comment: "Satellite") - case .satelliteFlyover: - return NSLocalizedString("satellite.flyover", comment: "Satellite Flyover") - } + switch self { + case .standard: + return NSLocalizedString("standard", comment: "Standard") + case .mutedStandard: + return NSLocalizedString("standard.muted", comment: "Standard Muted") + case .hybrid: + return NSLocalizedString("hybrid", comment: "Hybrid") + case .hybridFlyover: + return NSLocalizedString("hybrid.flyover", comment: "Hybrid Flyover") + case .satellite: + return NSLocalizedString("satellite", comment: "Satellite") + case .satelliteFlyover: + return NSLocalizedString("satellite.flyover", comment: "Satellite Flyover") } } func MKMapTypeValue() -> MKMapType { @@ -110,15 +104,13 @@ enum UserTrackingModes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .none: - return NSLocalizedString("map.usertrackingmode.none", comment: "None") - case .follow: - return NSLocalizedString("map.usertrackingmode.follow", comment: "Follow") - case .followWithHeading: - return NSLocalizedString("map.usertrackingmode.followwithheading", comment: "Follow with Heading") - } + switch self { + case .none: + return NSLocalizedString("map.usertrackingmode.none", comment: "None") + case .follow: + return NSLocalizedString("map.usertrackingmode.follow", comment: "Follow") + case .followWithHeading: + return NSLocalizedString("map.usertrackingmode.followwithheading", comment: "Follow with Heading") } } func MKUserTrackingModeValue() -> MKUserTrackingMode { @@ -147,25 +139,23 @@ enum LocationUpdateInterval: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .fiveSeconds: - return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") - case .tenSeconds: - return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - } + switch self { + case .fiveSeconds: + return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") } } } diff --git a/Meshtastic/Enums/BluetoothModes.swift b/Meshtastic/Enums/BluetoothModes.swift index bc29062c..8304a9e8 100644 --- a/Meshtastic/Enums/BluetoothModes.swift +++ b/Meshtastic/Enums/BluetoothModes.swift @@ -14,15 +14,13 @@ enum BluetoothModes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .randomPin: - return NSLocalizedString("bluetooth.mode.randompin", comment: "Random PIN") - case .fixedPin: - return NSLocalizedString("bluetooth.mode.fixedpin", comment: "Fixed PIN") - case .noPin: - return NSLocalizedString("bluetooth.mode.nopin", comment: "No PIN (Just Works)") - } + switch self { + case .randomPin: + return NSLocalizedString("bluetooth.mode.randompin", comment: "Random PIN") + case .fixedPin: + return NSLocalizedString("bluetooth.mode.fixedpin", comment: "Fixed PIN") + case .noPin: + return NSLocalizedString("bluetooth.mode.nopin", comment: "No PIN (Just Works)") } } func protoEnumValue() -> Config.BluetoothConfig.PairingMode { diff --git a/Meshtastic/Enums/CannedMessagesConfigEnums.swift b/Meshtastic/Enums/CannedMessagesConfigEnums.swift index 1d1e810d..7cdbe6ef 100644 --- a/Meshtastic/Enums/CannedMessagesConfigEnums.swift +++ b/Meshtastic/Enums/CannedMessagesConfigEnums.swift @@ -15,16 +15,14 @@ enum ConfigPresets: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { + switch self { - case .unset: - return NSLocalizedString("canned.messages.preset.manual", comment: "Manual Configuration") - case .rakRotaryEncoder: - return NSLocalizedString("canned.messages.preset.rakrotary", comment: "RAK Rotary Encoder Module") - case .cardKB: - return NSLocalizedString("canned.messages.preset.cardkb", comment: "M5 Stack Card KB / RAK Keypad") - } + case .unset: + return NSLocalizedString("canned.messages.preset.manual", comment: "Manual Configuration") + case .rakRotaryEncoder: + return NSLocalizedString("canned.messages.preset.rakrotary", comment: "RAK Rotary Encoder Module") + case .cardKB: + return NSLocalizedString("canned.messages.preset.cardkb", comment: "M5 Stack Card KB / RAK Keypad") } } } @@ -43,26 +41,24 @@ enum InputEventChars: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { + switch self { - case .none: - return NSLocalizedString("inputevent.none", comment: "None") - case .up: - return NSLocalizedString("inputevent.up", comment: "Up") - case .down: - return NSLocalizedString("inputevent.down", comment: "Down") - case .left: - return NSLocalizedString("inputevent.left", comment: "Left") - case .right: - return NSLocalizedString("inputevent.right", comment: "Right") - case .select: - return NSLocalizedString("inputevent.select", comment: "Select") - case .back: - return NSLocalizedString("inputevent.back", comment: "Back") - case .cancel: - return NSLocalizedString("inputevent.cancel", comment: "Cancel") - } + case .none: + return NSLocalizedString("inputevent.none", comment: "None") + case .up: + return NSLocalizedString("inputevent.up", comment: "Up") + case .down: + return NSLocalizedString("inputevent.down", comment: "Down") + case .left: + return NSLocalizedString("inputevent.left", comment: "Left") + case .right: + return NSLocalizedString("inputevent.right", comment: "Right") + case .select: + return NSLocalizedString("inputevent.select", comment: "Select") + case .back: + return NSLocalizedString("inputevent.back", comment: "Back") + case .cancel: + return NSLocalizedString("inputevent.cancel", comment: "Cancel") } } func protoEnumValue() -> ModuleConfig.CannedMessageConfig.InputEventChar { diff --git a/Meshtastic/Enums/ChannelRoles.swift b/Meshtastic/Enums/ChannelRoles.swift index 13814541..39f91dbc 100644 --- a/Meshtastic/Enums/ChannelRoles.swift +++ b/Meshtastic/Enums/ChannelRoles.swift @@ -15,16 +15,14 @@ enum ChannelRoles: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { + switch self { - case .disabled: - return NSLocalizedString("channel.role.disabled", comment: "Disabled") - case .primary: - return NSLocalizedString("channel.role.primary", comment: "Primary") - case .secondary: - return NSLocalizedString("channel.role.secondary", comment: "Secondary") - } + case .disabled: + return NSLocalizedString("channel.role.disabled", comment: "Disabled") + case .primary: + return NSLocalizedString("channel.role.primary", comment: "Primary") + case .secondary: + return NSLocalizedString("channel.role.secondary", comment: "Secondary") } } func protoEnumValue() -> Channel.Role { diff --git a/Meshtastic/Enums/DeviceEnums.swift b/Meshtastic/Enums/DeviceEnums.swift index 3e9a16ad..a53a9893 100644 --- a/Meshtastic/Enums/DeviceEnums.swift +++ b/Meshtastic/Enums/DeviceEnums.swift @@ -20,51 +20,44 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var name: String { - get { - switch self { - - case .client: - return "Client" - case .clientMute: - return "Muted Client" - case .router: - return "Router" - case .routerClient: - return "Router & Client" - case .repeater: - return "Repeater" - case .tracker: - return "Tracker" - case .sensor: - return "Sensor" - } + switch self { + case .client: + return "Client" + case .clientMute: + return "Muted Client" + case .router: + return "Router" + case .routerClient: + return "Router & Client" + case .repeater: + return "Repeater" + case .tracker: + return "Tracker" + case .sensor: + return "Sensor" } } var description: String { - get { - switch self { - - case .client: - return NSLocalizedString("device.role.client", comment: "Client (default) - App connected client.") - case .clientMute: - return NSLocalizedString("device.role.clientmute", comment: "Client Mute - Same as a client except packets will not hop over this node, does not contribute to routing packets for mesh.") - case .router: - return NSLocalizedString("device.role.router", comment: "Router - Mesh packets will prefer to be routed over this node. Assumes device will operate in a standalone manner while placed in a location with a coverage advantage. WARNING: The BLE/Wi-Fi radios and the OLED screen will be put to sleep.") - case .routerClient: - return NSLocalizedString("device.role.routerclient", comment: "Router Client - Hybrid of the Client and Router roles. Similar to Router, except the Router Client can be used as both a Router and an app connected Client. BLE/Wi-Fi and OLED screen will not be put to sleep.") - case .repeater: - return NSLocalizedString("device.role.repeater", comment: "Repeater - Mesh packets will prefer to be routed over this node. This role eliminates unnecessary overhead such as NodeInfo, DeviceTelemetry, and any other mesh packet, resulting in the device not appearing as part of the network. Please see Rebroadcast Mode for additional settings specific to this role.") - case .tracker: - return NSLocalizedString("device.role.tracker", comment: "Tracker - For use with devices intended as a GPS tracker. Position packets sent from this device will be higher priority, with position broadcasting every two minutes. Smart Position Broadcast will default to off.") - case .sensor: - return NSLocalizedString("device.role.sensor", comment: "Sensor - For use with remote telemetry sensors. Setting this role will turn on environment telemetry. Telemetry packets sent from this device will be higher priority, with telemetry broadcasting every 7 minutes") - } + switch self { + case .client: + return NSLocalizedString("device.role.client", comment: "Client (default) - App connected client.") + case .clientMute: + return NSLocalizedString("device.role.clientmute", comment: "Client Mute - Same as a client except packets will not hop over this node, does not contribute to routing packets for mesh.") + case .router: + return NSLocalizedString("device.role.router", comment: "Router - Mesh packets will prefer to be routed over this node. Assumes device will operate in a standalone manner while placed in a location with a coverage advantage. WARNING: The BLE/Wi-Fi radios and the OLED screen will be put to sleep.") + case .routerClient: + return NSLocalizedString("device.role.routerclient", comment: "Router Client - Hybrid of the Client and Router roles. Similar to Router, except the Router Client can be used as both a Router and an app connected Client. BLE/Wi-Fi and OLED screen will not be put to sleep.") + case .repeater: + return NSLocalizedString("device.role.repeater", comment: "Repeater - Mesh packets will prefer to be routed over this node. This role eliminates unnecessary overhead such as NodeInfo, DeviceTelemetry, and any other mesh packet, resulting in the device not appearing as part of the network. Please see Rebroadcast Mode for additional settings specific to this role.") + case .tracker: + return NSLocalizedString("device.role.tracker", comment: "Tracker - For use with devices intended as a GPS tracker. Position packets sent from this device will be higher priority, with position broadcasting every two minutes. Smart Position Broadcast will default to off.") + case .sensor: + return NSLocalizedString("device.role.sensor", comment: "Sensor - For use with remote telemetry sensors. Setting this role will turn on environment telemetry. Telemetry packets sent from this device will be higher priority, with telemetry broadcasting every 7 minutes") } } func protoEnumValue() -> Config.DeviceConfig.Role { switch self { - case .client: return Config.DeviceConfig.Role.client case .clientMute: @@ -92,28 +85,23 @@ enum RebroadcastModes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var name: String { - get { - switch self { - - case .all: - return "All" - case .allSkipDecoding: - return "All Skip Decoding" - case .localOnly: - return "Local Only" - } + switch self { + case .all: + return "All" + case .allSkipDecoding: + return "All Skip Decoding" + case .localOnly: + return "Local Only" } } var description: String { - get { - switch self { - case .all: - return "Rebroadcast any observed message, if it was on our private channel or from another mesh with the same lora params." - case .allSkipDecoding: - return "Same as behavior as ALL but skips packet decoding and simply rebroadcasts them. Only available in Repeater role. Setting this on any other roles will result in ALL behavior." - case .localOnly: - return "Inverted top bar for 2 Color display" - } + switch self { + case .all: + return "Rebroadcast any observed message, if it was on our private channel or from another mesh with the same lora params." + case .allSkipDecoding: + return "Same as behavior as ALL but skips packet decoding and simply rebroadcasts them. Only available in Repeater role. Setting this on any other roles will result in ALL behavior." + case .localOnly: + return "Inverted top bar for 2 Color display" } } func protoEnumValue() -> Config.DeviceConfig.RebroadcastMode { diff --git a/Meshtastic/Enums/DisplayEnums.swift b/Meshtastic/Enums/DisplayEnums.swift index 95d6a0a0..af2ed5a3 100644 --- a/Meshtastic/Enums/DisplayEnums.swift +++ b/Meshtastic/Enums/DisplayEnums.swift @@ -14,13 +14,11 @@ enum ScreenUnits: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .metric: - return "Metric" - case .imperial: - return "Imperial" - } + switch self { + case .metric: + return "Metric" + case .imperial: + return "Imperial" } } func protoEnumValue() -> Config.DisplayConfig.DisplayUnits { @@ -48,27 +46,25 @@ enum ScreenOnIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - case .thirtyMinutes: - return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") - case .oneHour: - return NSLocalizedString("interval.one.hour", comment: "One Hour") - case .max: - return NSLocalizedString("always.on", comment: "Always On") - } + switch self { + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") + case .thirtyMinutes: + return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") + case .oneHour: + return NSLocalizedString("interval.one.hour", comment: "One Hour") + case .max: + return NSLocalizedString("always.on", comment: "Always On") } } } @@ -85,24 +81,21 @@ enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .off: - return NSLocalizedString("off", comment: "Off") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - } + switch self { + case .off: + return NSLocalizedString("off", comment: "Off") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") } } - } // Default of 0 is auto enum OledTypes: Int, CaseIterable, Identifiable { @@ -114,17 +107,15 @@ enum OledTypes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .auto: - return NSLocalizedString("automatic.detection", comment: "Automatic Detection") - case .ssd1306: - return "SSD 1306" - case .sh1106: - return "SH 1106" - case .sh1107: - return "SH 1107" - } + switch self { + case .auto: + return NSLocalizedString("automatic.detection", comment: "Automatic Detection") + case .ssd1306: + return "SSD 1306" + case .sh1106: + return "SH 1106" + case .sh1107: + return "SH 1107" } } func protoEnumValue() -> Config.DisplayConfig.OledType { @@ -152,17 +143,15 @@ enum DisplayModes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .defaultMode: - return "Default 128x64 screen layout" - case .twoColor: - return "Optimized for 2 color displays" - case .inverted: - return "Inverted top bar for 2 Color display" - case .color: - return "TFT Full Color Displays" - } + switch self { + case .defaultMode: + return "Default 128x64 screen layout" + case .twoColor: + return "Optimized for 2 color displays" + case .inverted: + return "Inverted top bar for 2 Color display" + case .color: + return "TFT Full Color Displays" } } func protoEnumValue() -> Config.DisplayConfig.DisplayMode { diff --git a/Meshtastic/Enums/EthernetModes.swift b/Meshtastic/Enums/EthernetModes.swift index bd459939..beff9ea0 100644 --- a/Meshtastic/Enums/EthernetModes.swift +++ b/Meshtastic/Enums/EthernetModes.swift @@ -14,14 +14,12 @@ enum EthernetMode: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .dhcp: - return "DHCP" - case .staticip: - return "Static IP" - } + switch self { + case .dhcp: + return "DHCP" + case .staticip: + return "Static IP" } } func protoEnumValue() -> Config.NetworkConfig.AddressMode { diff --git a/Meshtastic/Enums/IntervalEnums.swift b/Meshtastic/Enums/IntervalEnums.swift index 7a941906..06087893 100644 --- a/Meshtastic/Enums/IntervalEnums.swift +++ b/Meshtastic/Enums/IntervalEnums.swift @@ -22,30 +22,28 @@ enum OutputIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .unset: - return NSLocalizedString("unset", comment: "Unset") - case .oneSecond: - return NSLocalizedString("interval.one.second", comment: "One Second") - case .twoSeconds: - return NSLocalizedString("interval.two.seconds", comment: "Two Seconds") - case .threeSeconds: - return NSLocalizedString("interval.three.seconds", comment: "Three Seconds") - case .fourSeconds: - return NSLocalizedString("interval.four.seconds", comment: "Four Seconds") - case .fiveSeconds: - return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") - case .tenSeconds: - return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - } + switch self { + case .unset: + return NSLocalizedString("unset", comment: "Unset") + case .oneSecond: + return NSLocalizedString("interval.one.second", comment: "One Second") + case .twoSeconds: + return NSLocalizedString("interval.two.seconds", comment: "Two Seconds") + case .threeSeconds: + return NSLocalizedString("interval.three.seconds", comment: "Three Seconds") + case .fourSeconds: + return NSLocalizedString("interval.four.seconds", comment: "Four Seconds") + case .fiveSeconds: + return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") } } } @@ -65,27 +63,25 @@ enum SenderIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .off: - return NSLocalizedString("off", comment: "Off") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - case .thirtyMinutes: - return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") - case .oneHour: - return NSLocalizedString("interval.one.hour", comment: "One Hour") - } + switch self { + case .off: + return NSLocalizedString("off", comment: "Off") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") + case .thirtyMinutes: + return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") + case .oneHour: + return NSLocalizedString("interval.one.hour", comment: "One Hour") } } } @@ -115,50 +111,48 @@ enum UpdateIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .tenSeconds: - return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - case .thirtyMinutes: - return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") - case .oneHour: - return NSLocalizedString("interval.one.hour", comment: "One Hour") - case .twoHours: - return NSLocalizedString("interval.two.hours", comment: "Two Hours") - case .threeHours: - return NSLocalizedString("interval.three.hours", comment: "Three Hours") - case .fourHours: - return NSLocalizedString("interval.four.hours", comment: "Four Hours") - case .fiveHours: - return NSLocalizedString("interval.five.hours", comment: "Five Hours") - case .sixHours: - return NSLocalizedString("interval.six.hours", comment: "Six Hours") - case .twelveHours: - return NSLocalizedString("interval.twelve.hours", comment: "Twelve Hours") - case .eighteenHours: - return NSLocalizedString("interval.eighteen.hours", comment: "Eighteen Hours") - case .twentyFourHours: - return NSLocalizedString("interval.twentyfour.hours", comment: "Twenty Four Hours") - case .thirtySixHours: - return NSLocalizedString("interval.thirtysix.hours", comment: "Thirty Six Hours") - case .fortyeightHours: - return NSLocalizedString("interval.fortyeight.hours", comment: "Forty Eight Hours") - case .seventyTwoHours: - return NSLocalizedString("interval.seventytwo.hours", comment: "Seventy Two Hours") - } + switch self { + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") + case .thirtyMinutes: + return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") + case .oneHour: + return NSLocalizedString("interval.one.hour", comment: "One Hour") + case .twoHours: + return NSLocalizedString("interval.two.hours", comment: "Two Hours") + case .threeHours: + return NSLocalizedString("interval.three.hours", comment: "Three Hours") + case .fourHours: + return NSLocalizedString("interval.four.hours", comment: "Four Hours") + case .fiveHours: + return NSLocalizedString("interval.five.hours", comment: "Five Hours") + case .sixHours: + return NSLocalizedString("interval.six.hours", comment: "Six Hours") + case .twelveHours: + return NSLocalizedString("interval.twelve.hours", comment: "Twelve Hours") + case .eighteenHours: + return NSLocalizedString("interval.eighteen.hours", comment: "Eighteen Hours") + case .twentyFourHours: + return NSLocalizedString("interval.twentyfour.hours", comment: "Twenty Four Hours") + case .thirtySixHours: + return NSLocalizedString("interval.thirtysix.hours", comment: "Thirty Six Hours") + case .fortyeightHours: + return NSLocalizedString("interval.fortyeight.hours", comment: "Forty Eight Hours") + case .seventyTwoHours: + return NSLocalizedString("interval.seventytwo.hours", comment: "Seventy Two Hours") } } } diff --git a/Meshtastic/Enums/LoraConfigEnums.swift b/Meshtastic/Enums/LoraConfigEnums.swift index 30299bb8..1e737a84 100644 --- a/Meshtastic/Enums/LoraConfigEnums.swift +++ b/Meshtastic/Enums/LoraConfigEnums.swift @@ -28,80 +28,77 @@ enum RegionCodes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .unset: - return "Please set a region" - case .us: - return "United States" - case .eu433: - return "European Union 433mhz" - case .eu868: - return "European Union 868mhz" - case .cn: - return "China" - case .jp: - return "Japan" - case .anz: - return "Australia / New Zealand" - case .kr: - return "Korea" - case .tw: - return "Taiwan" - case .ru: - return "Russia" - case .in: - return "India" - case .nz865: - return "New Zealand 865mhz" - case .th: - return "Thailand" - case .ua433: - return "Ukraine 433mhz" - case .ua868: - return "Ukraine 868mhz" - case .lora24: - return "2.4 GHZ" - } + switch self { + case .unset: + return "Please set a region" + case .us: + return "United States" + case .eu433: + return "European Union 433mhz" + case .eu868: + return "European Union 868mhz" + case .cn: + return "China" + case .jp: + return "Japan" + case .anz: + return "Australia / New Zealand" + case .kr: + return "Korea" + case .tw: + return "Taiwan" + case .ru: + return "Russia" + case .in: + return "India" + case .nz865: + return "New Zealand 865mhz" + case .th: + return "Thailand" + case .ua433: + return "Ukraine 433mhz" + case .ua868: + return "Ukraine 868mhz" + case .lora24: + return "2.4 GHZ" } } func protoEnumValue() -> Config.LoRaConfig.RegionCode { switch self { - - case .unset: - return Config.LoRaConfig.RegionCode.unset - case .us: - return Config.LoRaConfig.RegionCode.us - case .eu433: - return Config.LoRaConfig.RegionCode.eu433 - case .eu868: - return Config.LoRaConfig.RegionCode.eu868 - case .cn: - return Config.LoRaConfig.RegionCode.cn - case .jp: - return Config.LoRaConfig.RegionCode.jp - case .anz: - return Config.LoRaConfig.RegionCode.anz - case .kr: - return Config.LoRaConfig.RegionCode.kr - case .tw: - return Config.LoRaConfig.RegionCode.tw - case .ru: - return Config.LoRaConfig.RegionCode.ru - case .in: - return Config.LoRaConfig.RegionCode.in - case .nz865: - return Config.LoRaConfig.RegionCode.nz865 - case .th: - return Config.LoRaConfig.RegionCode.th - case .ua433: - return Config.LoRaConfig.RegionCode.ua433 - case .ua868: - return Config.LoRaConfig.RegionCode.ua868 - case .lora24: - return Config.LoRaConfig.RegionCode.lora24 + case .unset: + return Config.LoRaConfig.RegionCode.unset + case .us: + return Config.LoRaConfig.RegionCode.us + case .eu433: + return Config.LoRaConfig.RegionCode.eu433 + case .eu868: + return Config.LoRaConfig.RegionCode.eu868 + case .cn: + return Config.LoRaConfig.RegionCode.cn + case .jp: + return Config.LoRaConfig.RegionCode.jp + case .anz: + return Config.LoRaConfig.RegionCode.anz + case .kr: + return Config.LoRaConfig.RegionCode.kr + case .tw: + return Config.LoRaConfig.RegionCode.tw + case .ru: + return Config.LoRaConfig.RegionCode.ru + case .in: + return Config.LoRaConfig.RegionCode.in + case .nz865: + return Config.LoRaConfig.RegionCode.nz865 + case .th: + return Config.LoRaConfig.RegionCode.th + case .ua433: + return Config.LoRaConfig.RegionCode.ua433 + case .ua868: + return Config.LoRaConfig.RegionCode.ua868 + case .lora24: + return Config.LoRaConfig.RegionCode.lora24 } } } @@ -119,25 +116,23 @@ enum ModemPresets: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .longFast: - return "Long Range - Fast" - case .longSlow: - return "Long Range - Slow" - case .longModerate: - return "Long Range - Moderate" - case .vLongSlow: - return "Very Long Range - Slow" - case .medSlow: - return "Medium Range - Slow" - case .medFast: - return "Medium Range - Fast" - case .shortSlow: - return "Short Range - Slow" - case .shortFast: - return "Short Range - Fast" - } + switch self { + case .longFast: + return "Long Range - Fast" + case .longSlow: + return "Long Range - Slow" + case .longModerate: + return "Long Range - Moderate" + case .vLongSlow: + return "Very Long Range - Slow" + case .medSlow: + return "Medium Range - Slow" + case .medFast: + return "Medium Range - Fast" + case .shortSlow: + return "Short Range - Slow" + case .shortFast: + return "Short Range - Fast" } } func protoEnumValue() -> Config.LoRaConfig.ModemPreset { diff --git a/Meshtastic/Enums/MessagingEnums.swift b/Meshtastic/Enums/MessagingEnums.swift index 9b9f145d..cb01341a 100644 --- a/Meshtastic/Enums/MessagingEnums.swift +++ b/Meshtastic/Enums/MessagingEnums.swift @@ -23,43 +23,39 @@ enum Tapbacks: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var emojiString: String { - get { - switch self { - case .heart: - return "❤️" - case .thumbsUp: - return "👍" - case .thumbsDown: - return "👎" - case .haHa: - return "🤣" - case .exclamation: - return "‼️" - case .question: - return "❓" - case .poop: - return "💩" - } + switch self { + case .heart: + return "❤️" + case .thumbsUp: + return "👍" + case .thumbsDown: + return "👎" + case .haHa: + return "🤣" + case .exclamation: + return "‼️" + case .question: + return "❓" + case .poop: + return "💩" } } var description: String { - get { - switch self { - case .heart: - return NSLocalizedString("tapback.heart", comment: "Heart") - case .thumbsUp: - return NSLocalizedString("tapback.thumbsup", comment: "Thumbs Up") - case .thumbsDown: - return NSLocalizedString("tapback.thumbsdown", comment: "Thumbs Down") - case .haHa: - return NSLocalizedString("tapback.haha", comment: "HaHa") - case .exclamation: - return NSLocalizedString("tapback.exclamation", comment: "Exclamation Mark") - case .question: - return NSLocalizedString("tapback.question", comment: "Question Mark") - case .poop: - return NSLocalizedString("tapback.poop", comment: "Poop") - } + switch self { + case .heart: + return NSLocalizedString("tapback.heart", comment: "Heart") + case .thumbsUp: + return NSLocalizedString("tapback.thumbsup", comment: "Thumbs Up") + case .thumbsDown: + return NSLocalizedString("tapback.thumbsdown", comment: "Thumbs Down") + case .haHa: + return NSLocalizedString("tapback.haha", comment: "HaHa") + case .exclamation: + return NSLocalizedString("tapback.exclamation", comment: "Exclamation Mark") + case .question: + return NSLocalizedString("tapback.question", comment: "Question Mark") + case .poop: + return NSLocalizedString("tapback.poop", comment: "Poop") } } } diff --git a/Meshtastic/Enums/PositionConfigEnums.swift b/Meshtastic/Enums/PositionConfigEnums.swift index 106f5fb8..fbfb956a 100644 --- a/Meshtastic/Enums/PositionConfigEnums.swift +++ b/Meshtastic/Enums/PositionConfigEnums.swift @@ -18,21 +18,19 @@ enum GpsFormats: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .gpsFormatDec: - return NSLocalizedString("gpsformat.dec", comment: "Decimal Degrees Format") - case .gpsFormatDms: - return NSLocalizedString("gpsformat.dms", comment: "Degrees Minutes Seconds") - case .gpsFormatUtm: - return NSLocalizedString("gpsformat.utm", comment: "Universal Transverse Mercator") - case .gpsFormatMgrs: - return NSLocalizedString("gpsformat.mgrs", comment: "Military Grid Reference System") - case .gpsFormatOlc: - return NSLocalizedString("gpsformat.olc", comment: "Open Location Code (aka Plus Codes)") - case .gpsFormatOsgr: - return NSLocalizedString("gpsformat.osgr", comment: "Ordnance Survey Grid Reference") - } + switch self { + case .gpsFormatDec: + return NSLocalizedString("gpsformat.dec", comment: "Decimal Degrees Format") + case .gpsFormatDms: + return NSLocalizedString("gpsformat.dms", comment: "Degrees Minutes Seconds") + case .gpsFormatUtm: + return NSLocalizedString("gpsformat.utm", comment: "Universal Transverse Mercator") + case .gpsFormatMgrs: + return NSLocalizedString("gpsformat.mgrs", comment: "Military Grid Reference System") + case .gpsFormatOlc: + return NSLocalizedString("gpsformat.olc", comment: "Open Location Code (aka Plus Codes)") + case .gpsFormatOsgr: + return NSLocalizedString("gpsformat.osgr", comment: "Ordnance Survey Grid Reference") } } func protoEnumValue() -> Config.DisplayConfig.GpsCoordinateFormat { @@ -77,44 +75,41 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - - case .fiveSeconds: - return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") - case .tenSeconds: - return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .twentySeconds: - return NSLocalizedString("interval.twenty.seconds", comment: "Twenty Seconds") - case .twentyFiveSeconds: - return NSLocalizedString("interval.twentyfive.seconds", comment: "Twenty Five Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .twoMinutes: - return NSLocalizedString("interval.two.minutes", comment: "Two Minutes") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - case .thirtyMinutes: - return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") - case .oneHour: - return NSLocalizedString("interval.one.hour", comment: "One Hour") - case .sixHours: - return NSLocalizedString("interval.six.hours", comment: "Six Hours") - case .twelveHours: - return NSLocalizedString("interval.twelve.hours", comment: "Twelve Hours") - case .twentyFourHours: - return NSLocalizedString("interval.twentyfour.hours", comment: "Twenty Four Hours") - case .maxInt32: - return NSLocalizedString("on.boot", comment: "On Boot Only") - } + switch self { + case .fiveSeconds: + return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .twentySeconds: + return NSLocalizedString("interval.twenty.seconds", comment: "Twenty Seconds") + case .twentyFiveSeconds: + return NSLocalizedString("interval.twentyfive.seconds", comment: "Twenty Five Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .twoMinutes: + return NSLocalizedString("interval.two.minutes", comment: "Two Minutes") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") + case .thirtyMinutes: + return NSLocalizedString("interval.thirty.minutes", comment: "Thirty Minutes") + case .oneHour: + return NSLocalizedString("interval.one.hour", comment: "One Hour") + case .sixHours: + return NSLocalizedString("interval.six.hours", comment: "Six Hours") + case .twelveHours: + return NSLocalizedString("interval.twelve.hours", comment: "Twelve Hours") + case .twentyFourHours: + return NSLocalizedString("interval.twentyfour.hours", comment: "Twenty Four Hours") + case .maxInt32: + return NSLocalizedString("on.boot", comment: "On Boot Only") } } } @@ -136,34 +131,31 @@ enum GpsAttemptTimes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - - case .twoSeconds: - return NSLocalizedString("interval.two.seconds", comment: "Two Seconds") - case .fiveSeconds: - return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") - case .tenSeconds: - return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .twentySeconds: - return NSLocalizedString("interval.twenty.seconds", comment: "Twenty Seconds") - case .twentyFiveSeconds: - return NSLocalizedString("interval.twentyfive.seconds", comment: "Twenty Five Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .twoMinutes: - return NSLocalizedString("interval.two.minutes", comment: "Two Minutes") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - case .tenMinutes: - return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") - case .fifteenMinutes: - return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") - } + switch self { + case .twoSeconds: + return NSLocalizedString("interval.two.seconds", comment: "Two Seconds") + case .fiveSeconds: + return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .twentySeconds: + return NSLocalizedString("interval.twenty.seconds", comment: "Twenty Seconds") + case .twentyFiveSeconds: + return NSLocalizedString("interval.twentyfive.seconds", comment: "Twenty Five Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .twoMinutes: + return NSLocalizedString("interval.two.minutes", comment: "Two Minutes") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") + case .tenMinutes: + return NSLocalizedString("interval.ten.minutes", comment: "Ten Minutes") + case .fifteenMinutes: + return NSLocalizedString("interval.fifteen.minutes", comment: "Fifteen Minutes") } } } diff --git a/Meshtastic/Enums/RoutingError.swift b/Meshtastic/Enums/RoutingError.swift index 0090ac1a..d9724aa3 100644 --- a/Meshtastic/Enums/RoutingError.swift +++ b/Meshtastic/Enums/RoutingError.swift @@ -23,34 +23,32 @@ enum RoutingError: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var display: String { - get { - switch self { + switch self { - case .none: - return NSLocalizedString("routing.acknowledged", comment: "Acknowledged") - case .noRoute: - return NSLocalizedString("routing.noroute", comment: "No Route") - case .gotNak: - return NSLocalizedString("routing.gotnak", comment: "Received a negative acknowledgment") - case .timeout: - return NSLocalizedString("routing.timeout", comment: "Timeout") - case .noInterface: - return NSLocalizedString("routing.nointerface", comment: "No Interface") - case .maxRetransmit: - return NSLocalizedString("routing.maxretransmit", comment: "Max Retransmission Reached") - case .noChannel: - return NSLocalizedString("routing.nochannel", comment: "No Channel") - case .tooLarge: - return NSLocalizedString("routing.toolarge", comment: "The packet is too large") - case .noResponse: - return NSLocalizedString("routing.noresponse", comment: "No Response") - case .dutyCycleLimit: - return NSLocalizedString("routing.dutycyclelimit", comment: "Regional Duty Cycle Limit Reached") - case .badRequest: - return NSLocalizedString("routing.badRequest", comment: "Bad Request") - case .notAuthorized: - return NSLocalizedString("routing.notauthorized", comment: "Not Authorized") - } + case .none: + return NSLocalizedString("routing.acknowledged", comment: "Acknowledged") + case .noRoute: + return NSLocalizedString("routing.noroute", comment: "No Route") + case .gotNak: + return NSLocalizedString("routing.gotnak", comment: "Received a negative acknowledgment") + case .timeout: + return NSLocalizedString("routing.timeout", comment: "Timeout") + case .noInterface: + return NSLocalizedString("routing.nointerface", comment: "No Interface") + case .maxRetransmit: + return NSLocalizedString("routing.maxretransmit", comment: "Max Retransmission Reached") + case .noChannel: + return NSLocalizedString("routing.nochannel", comment: "No Channel") + case .tooLarge: + return NSLocalizedString("routing.toolarge", comment: "The packet is too large") + case .noResponse: + return NSLocalizedString("routing.noresponse", comment: "No Response") + case .dutyCycleLimit: + return NSLocalizedString("routing.dutycyclelimit", comment: "Regional Duty Cycle Limit Reached") + case .badRequest: + return NSLocalizedString("routing.badRequest", comment: "Bad Request") + case .notAuthorized: + return NSLocalizedString("routing.notauthorized", comment: "Not Authorized") } } func protoEnumValue() -> Routing.Error { diff --git a/Meshtastic/Enums/SerialConfigEnums.swift b/Meshtastic/Enums/SerialConfigEnums.swift index 0543700a..3948750f 100644 --- a/Meshtastic/Enums/SerialConfigEnums.swift +++ b/Meshtastic/Enums/SerialConfigEnums.swift @@ -27,42 +27,40 @@ enum SerialBaudRates: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { + switch self { - case .baudDefault: - return NSLocalizedString("default", comment: "Default") - case .baud110: - return "110 Baud" - case .baud300: - return "300 Baud" - case .baud600: - return "600 Baud" - case .baud1200: - return "1200 Baud" - case .baud2400: - return "2400 Baud" - case .baud4800: - return "4800 Baud" - case .baud9600: - return "9600 Baud" - case .baud19200: - return "19200 Baud" - case .baud38400: - return "38400 Baud" - case .baud57600: - return "57600 Baud" - case .baud115200: - return "115200 Baud" - case .baud230400: - return "230400 Baud" - case .baud460800: - return "460800 Baud" - case .baud576000: - return "576000 Baud" - case .baud921600: - return "921600 Baud" - } + case .baudDefault: + return NSLocalizedString("default", comment: "Default") + case .baud110: + return "110 Baud" + case .baud300: + return "300 Baud" + case .baud600: + return "600 Baud" + case .baud1200: + return "1200 Baud" + case .baud2400: + return "2400 Baud" + case .baud4800: + return "4800 Baud" + case .baud9600: + return "9600 Baud" + case .baud19200: + return "19200 Baud" + case .baud38400: + return "38400 Baud" + case .baud57600: + return "57600 Baud" + case .baud115200: + return "115200 Baud" + case .baud230400: + return "230400 Baud" + case .baud460800: + return "460800 Baud" + case .baud576000: + return "576000 Baud" + case .baud921600: + return "921600 Baud" } } @@ -116,19 +114,17 @@ enum SerialModeTypes: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .default: - return NSLocalizedString("serial.mode.default", comment: "Default") - case .simple: - return NSLocalizedString("serial.mode.simple", comment: "Simple") - case .proto: - return NSLocalizedString("serial.mode.proto", comment: "Protobufs") - case .txtmsg: - return NSLocalizedString("serial.mode.txtmsg", comment: "Text Message") - case .nmea: - return NSLocalizedString("serial.mode.nmea", comment: "NMEA Positions") - } + switch self { + case .default: + return NSLocalizedString("serial.mode.default", comment: "Default") + case .simple: + return NSLocalizedString("serial.mode.simple", comment: "Simple") + case .proto: + return NSLocalizedString("serial.mode.proto", comment: "Protobufs") + case .txtmsg: + return NSLocalizedString("serial.mode.txtmsg", comment: "Text Message") + case .nmea: + return NSLocalizedString("serial.mode.nmea", comment: "NMEA Positions") } } func protoEnumValue() -> ModuleConfig.SerialConfig.Serial_Mode { @@ -162,25 +158,23 @@ enum SerialTimeoutIntervals: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { - get { - switch self { - case .unset: - return NSLocalizedString("unset", comment: "Unset") - case .oneSecond: - return NSLocalizedString("interval.one.second", comment: "One Second") - case .fiveSeconds: - return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") - case .tenSeconds: - return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") - case .fifteenSeconds: - return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") - case .thirtySeconds: - return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") - case .oneMinute: - return NSLocalizedString("interval.one.minute", comment: "One Minute") - case .fiveMinutes: - return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") - } + switch self { + case .unset: + return NSLocalizedString("unset", comment: "Unset") + case .oneSecond: + return NSLocalizedString("interval.one.second", comment: "One Second") + case .fiveSeconds: + return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") + case .fifteenSeconds: + return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") + case .thirtySeconds: + return NSLocalizedString("interval.thirty.seconds", comment: "Thirty Seconds") + case .oneMinute: + return NSLocalizedString("interval.one.minute", comment: "One Minute") + case .fiveMinutes: + return NSLocalizedString("interval.five.minutes", comment: "Five Minutes") } } } diff --git a/Meshtastic/Enums/TelemetryWeather.swift b/Meshtastic/Enums/TelemetryWeather.swift index deb0b1be..4da4e79c 100644 --- a/Meshtastic/Enums/TelemetryWeather.swift +++ b/Meshtastic/Enums/TelemetryWeather.swift @@ -17,24 +17,22 @@ enum WeatherConditions: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var symbolName: String { - get { - switch self { + switch self { - case .clear: - return "sparkle" - case .cloudy: - return "cloud" - case .hot: - return "sun.max.trianglebadge.exclamationmark.fill" - case .rain: - return "cloud.rain" - case .frigid: - return "thermometer.snowflake" - case .smoky: - return "smoke" - case .snow: - return "cloud.snow" - } + case .clear: + return "sparkle" + case .cloudy: + return "cloud" + case .hot: + return "sun.max.trianglebadge.exclamationmark.fill" + case .rain: + return "cloud.rain" + case .frigid: + return "thermometer.snowflake" + case .smoky: + return "smoke" + case .snow: + return "cloud.snow" } } } diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index eba11eab..81e0ff81 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -411,8 +411,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { switch decodedInfo.packet.decoded.portnum { - // Handle Any local only packets we get over BLE - case .unknownApp: + // Handle Any local only packets we get over BLE + case .unknownApp: var nowKnown = false // MyInfo from initial connection @@ -449,7 +449,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { } // NodeInfo if decodedInfo.nodeInfo.num > 0 && !invalidVersion { - nowKnown = true let nodeInfo = nodeInfoPacket(nodeInfo: decodedInfo.nodeInfo, channel: decodedInfo.packet.channel, context: context!) @@ -467,7 +466,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { nowKnown = true channelPacket(channel: decodedInfo.channel, fromNum: connectedPeripheral.num, context: context!) } - // Config if decodedInfo.config.isInitialized && !invalidVersion { @@ -492,49 +490,48 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { nowKnown = true deviceMetadataPacket(metadata: decodedInfo.metadata, fromNum: connectedPeripheral.num, context: context!) } - // Log any other unknownApp calls - if !nowKnown { MeshLogger.log("🕸️ MESH PACKET received for Unknown App UNHANDLED \(try! decodedInfo.packet.jsonString())") } + if !nowKnown { MeshLogger.log("🕸️ MESH PACKET received for Unknown App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") } - case .textMessageApp: - textMessageAppPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) - case .remoteHardwareApp: - MeshLogger.log("🕸️ MESH PACKET received for Remote Hardware App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .positionApp: - upsertPositionPacket(packet: decodedInfo.packet, context: context!) - case .waypointApp: - waypointPacket(packet: decodedInfo.packet, context: context!) - case .nodeinfoApp: - if !invalidVersion { nodeInfoAppPacket(packet: decodedInfo.packet, context: context!) } - case .routingApp: - if !invalidVersion { routingPacket(packet: decodedInfo.packet, connectedNodeNum: self.connectedPeripheral.num, context: context!) } - case .adminApp: - adminAppPacket(packet: decodedInfo.packet, context: context!) - case .replyApp: - MeshLogger.log("🕸️ MESH PACKET received for Reply App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .ipTunnelApp: - MeshLogger.log("🕸️ MESH PACKET received for IP Tunnel App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .serialApp: - MeshLogger.log("🕸️ MESH PACKET received for Serial App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .storeForwardApp: - MeshLogger.log("🕸️ MESH PACKET received for Store Forward App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .rangeTestApp: - MeshLogger.log("🕸️ MESH PACKET received for Range Test App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .telemetryApp: - if !invalidVersion { telemetryPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) } - case .textMessageCompressedApp: - MeshLogger.log("🕸️ MESH PACKET received for Text Message Compressed App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .zpsApp: - MeshLogger.log("🕸️ MESH PACKET received for ZPS App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .privateApp: - MeshLogger.log("🕸️ MESH PACKET received for Private App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .atakForwarder: - MeshLogger.log("🕸️ MESH PACKET received for ATAK Forwarder App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .simulatorApp: - MeshLogger.log("🕸️ MESH PACKET received for Simulator App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .audioApp: - MeshLogger.log("🕸️ MESH PACKET received for Audio App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .tracerouteApp: + case .textMessageApp: + textMessageAppPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) + case .remoteHardwareApp: + MeshLogger.log("🕸️ MESH PACKET received for Remote Hardware App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .positionApp: + upsertPositionPacket(packet: decodedInfo.packet, context: context!) + case .waypointApp: + waypointPacket(packet: decodedInfo.packet, context: context!) + case .nodeinfoApp: + if !invalidVersion { nodeInfoAppPacket(packet: decodedInfo.packet, context: context!) } + case .routingApp: + if !invalidVersion { routingPacket(packet: decodedInfo.packet, connectedNodeNum: self.connectedPeripheral.num, context: context!) } + case .adminApp: + adminAppPacket(packet: decodedInfo.packet, context: context!) + case .replyApp: + MeshLogger.log("🕸️ MESH PACKET received for Reply App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .ipTunnelApp: + MeshLogger.log("🕸️ MESH PACKET received for IP Tunnel App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .serialApp: + MeshLogger.log("🕸️ MESH PACKET received for Serial App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .storeForwardApp: + MeshLogger.log("🕸️ MESH PACKET received for Store Forward App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .rangeTestApp: + MeshLogger.log("🕸️ MESH PACKET received for Range Test App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .telemetryApp: + if !invalidVersion { telemetryPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) } + case .textMessageCompressedApp: + MeshLogger.log("🕸️ MESH PACKET received for Text Message Compressed App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .zpsApp: + MeshLogger.log("🕸️ MESH PACKET received for ZPS App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .privateApp: + MeshLogger.log("🕸️ MESH PACKET received for Private App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .atakForwarder: + MeshLogger.log("🕸️ MESH PACKET received for ATAK Forwarder App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .simulatorApp: + MeshLogger.log("🕸️ MESH PACKET received for Simulator App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .audioApp: + MeshLogger.log("🕸️ MESH PACKET received for Audio App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") + case .tracerouteApp: if let routingMessage = try? RouteDiscovery(serializedData: decodedInfo.packet.decoded.payload) { if routingMessage.route.count == 0 { @@ -553,10 +550,10 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { MeshLogger.log("🪧 \(logString)") } } - case .UNRECOGNIZED: - MeshLogger.log("🕸️ MESH PACKET received for Other App UNHANDLED \(try! decodedInfo.packet.jsonString())") - case .max: - print("MAX PORT NUM OF 511") + case .UNRECOGNIZED: + MeshLogger.log("🕸️ MESH PACKET received for Other App UNHANDLED \(try! decodedInfo.packet.jsonString())") + case .max: + print("MAX PORT NUM OF 511") } // MARK: Check for an All / Broadcast User and delete it as a transition to multi channel @@ -1906,20 +1903,20 @@ extension BLEManager: CBCentralManagerDelegate { var status = "" switch central.state { - case .poweredOff: - status = "BLE is powered off" - case .poweredOn: - status = "BLE is poweredOn" - case .resetting: - status = "BLE is resetting" - case .unauthorized: - status = "BLE is unauthorized" - case .unknown: - status = "BLE is unknown" - case .unsupported: - status = "BLE is unsupported" - default: - status = "default" + case .poweredOff: + status = "BLE is powered off" + case .poweredOn: + status = "BLE is poweredOn" + case .resetting: + status = "BLE is resetting" + case .unauthorized: + status = "BLE is unauthorized" + case .unknown: + status = "BLE is unknown" + case .unsupported: + status = "BLE is unsupported" + default: + status = "default" } print("BLEManager status: \(status)") } diff --git a/Meshtastic/Views/Map/Custom/LocalMBTileOverlay.swift b/Meshtastic/Views/Map/Custom/LocalMBTileOverlay.swift index 17c46b14..6ab30afb 100644 --- a/Meshtastic/Views/Map/Custom/LocalMBTileOverlay.swift +++ b/Meshtastic/Views/Map/Custom/LocalMBTileOverlay.swift @@ -44,9 +44,7 @@ class LocalMBTileOverlay: MKTileOverlay { var mb: Connection! private var _boundingMapRect: MKMapRect! override var boundingMapRect: MKMapRect { - get { - return _boundingMapRect - } + return _boundingMapRect } init?(mbTilePath path: String) { diff --git a/Meshtastic/Views/Map/Custom/MapViewModule.swift b/Meshtastic/Views/Map/Custom/MapViewModule.swift deleted file mode 100644 index 232785bf..00000000 --- a/Meshtastic/Views/Map/Custom/MapViewModule.swift +++ /dev/null @@ -1,469 +0,0 @@ -//// -//// MapView.swift -//// MapViewTest -//// -//// Created by Cem Yilmaz on 05.07.21. -//// -// import SwiftUI -// import MapKit -// import CoreData -// -// #if canImport(MapKit) && canImport(UIKit) -// public struct MapView: UIViewRepresentable { -// -// @Environment(\.managedObjectContext) var context -// -// //var context: NSManagedObjectContext? -// -// //@Binding private var region: MKCoordinateRegion -// -// //make this view dependent on the UserDefault that is updated when importing a new map file -// @AppStorage("lastUpdatedLocalMapFile") private var lastUpdatedLocalMapFile = 0 -// @State private var loadedLastUpdatedLocalMapFile = 0 -// -// private var customMapOverlay: CustomMapOverlay? -// @State private var presentCustomMapOverlayHash: CustomMapOverlay? -// -// private var mapType: MKMapType -// -// private var showZoomScale: Bool -// private var zoomEnabled: Bool -// private var zoomRange: (minHeight: CLLocationDistance?, maxHeight: CLLocationDistance?) -// -// private var scrollEnabled: Bool -// private var scrollBoundaries: MKCoordinateRegion? -// -// private var rotationEnabled: Bool -// private var showCompassWhenRotated: Bool -// -// private var showUserLocation: Bool -// private var userTrackingMode: MKUserTrackingMode -// @Binding private var userLocation: CLLocationCoordinate2D? -// -// private var overlays: [Overlay] -// -// @FetchRequest(sortDescriptors: [NSSortDescriptor(key: "time", ascending: false)], animation: .default) -// private var positions: FetchedResults -// -// public init( -// customMapOverlay: CustomMapOverlay? = nil, -// mapType: String = "hybrid", -// zoomEnabled: Bool = true, -// showZoomScale: Bool = false, -// zoomRange: (minHeight: CLLocationDistance?, maxHeight: CLLocationDistance?) = (nil, nil), -// scrollEnabled: Bool = true, -// scrollBoundaries: MKCoordinateRegion? = nil, -// rotationEnabled: Bool = true, -// showCompassWhenRotated: Bool = true, -// showUserLocation: Bool = true, -// userTrackingMode: MKUserTrackingMode = MKUserTrackingMode.none, -// userLocation: Binding = .constant(nil), -// overlays: [Overlay] = [] -// ) { -// self.customMapOverlay = customMapOverlay -// -// switch mapType { -// case "satellite": -// self.mapType = .satellite -// break -// case "standard": -// self.mapType = .standard -// break -// case "hybrid": -// self.mapType = .hybrid -// break -// default: -// self.mapType = .hybrid -// } -// -// self.showZoomScale = showZoomScale -// self.zoomEnabled = zoomEnabled -// self.zoomRange = zoomRange -// -// self.scrollEnabled = scrollEnabled -// self.scrollBoundaries = scrollBoundaries -// -// self.rotationEnabled = rotationEnabled -// self.showCompassWhenRotated = showCompassWhenRotated -// -// self.showUserLocation = showUserLocation -// self.userTrackingMode = userTrackingMode -// self._userLocation = userLocation -// -// self.overlays = overlays -// -// } -// -// public func makeUIView(context: Context) -> MKMapView { -// let mapView = MKMapView() -// mapView.delegate = context.coordinator -// mapView.register(PositionAnnotationView.self, forAnnotationViewWithReuseIdentifier: NSStringFromClass(PositionAnnotationView.self)) -// -// return mapView -// } -// -// -// public func updateUIView(_ mapView: MKMapView, context: Context) { -// -// if self.customMapOverlay != self.presentCustomMapOverlayHash || self.loadedLastUpdatedLocalMapFile != self.lastUpdatedLocalMapFile { -// mapView.removeOverlays(mapView.overlays) -// if let customMapOverlay = self.customMapOverlay { -// -// let fileManager = FileManager.default -// let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first! -// let tilePath = documentsDirectory.appendingPathComponent("offline_map.mbtiles", isDirectory: false).path -// if fileManager.fileExists(atPath: tilePath) { -// //if let tilePath = Bundle.main.path(forResource: "offline_map", ofType: "mbtiles") { -// -// print("Loading local map file") -// -// if let overlay = LocalMBTileOverlay(mbTilePath: tilePath) { -// -// overlay.canReplaceMapContent = false//customMapOverlay.canReplaceMapContent -// -// mapView.addOverlay(overlay) -// } -// } else { -// print("Couldn't find a local map file to load") -// } -// } -// DispatchQueue.main.async { -// self.presentCustomMapOverlayHash = self.customMapOverlay -// self.loadedLastUpdatedLocalMapFile = self.lastUpdatedLocalMapFile -// } -// } -// -// if mapView.mapType != self.mapType { -// mapView.mapType = self.mapType -// } -// -// mapView.showsScale = self.zoomEnabled ? self.showZoomScale : false -// -// if mapView.isZoomEnabled != self.zoomEnabled { -// mapView.isZoomEnabled = self.zoomEnabled -// } -// -// if mapView.cameraZoomRange.minCenterCoordinateDistance != self.zoomRange.minHeight ?? 0 || -// mapView.cameraZoomRange.maxCenterCoordinateDistance != self.zoomRange.maxHeight ?? .infinity { -// mapView.cameraZoomRange = MKMapView.CameraZoomRange( -// minCenterCoordinateDistance: self.zoomRange.minHeight ?? 0, -// maxCenterCoordinateDistance: self.zoomRange.maxHeight ?? .infinity -// ) -// } -// -// mapView.isScrollEnabled = self.userTrackingMode == MKUserTrackingMode.none ? self.scrollEnabled : false -// -// if let scrollBoundary = self.scrollBoundaries, (mapView.cameraBoundary?.region.center.latitude != scrollBoundary.center.latitude || mapView.cameraBoundary?.region.center.longitude != scrollBoundary.center.longitude || mapView.camera Boundary?.region.span.latitudeDelta != scrollBoundary.span.latitudeDelta || mapView.cameraBoundary?.region.span.longitudeDelta != scrollBoundary.span.longitudeDelta) { -// mapView.cameraBoundary = MKMapView.CameraBoundary(coordinateRegion: scrollBoundary) -// } else if self.scrollBoundaries == nil && mapView.cameraBoundary != nil { -// mapView.cameraBoundary = nil -// } -// -// mapView.isRotateEnabled = self.userTrackingMode != .followWithHeading ? self.rotationEnabled : false -// mapView.showsCompass = self.userTrackingMode != .followWithHeading ? self.showCompassWhenRotated : false -// -// if mapView.showsUserLocation != self.showUserLocation { -// mapView.showsUserLocation = self.showUserLocation -// } -// -// if mapView.userTrackingMode != self.userTrackingMode { -// mapView.userTrackingMode = self.userTrackingMode -// } -// -// // clear any existing annotations -// var shouldMoveRegion = false -// if !mapView.annotations.isEmpty { -// mapView.removeAnnotations(mapView.annotations) -// } else { -// shouldMoveRegion = true -// } -// -// var displayedNodes: [Int64] = [] -// for position in self.positions { -// if position.nodePosition == nil || displayedNodes.contains(position.nodePosition!.num) || position.coordinate == nil { -// continue -// } -// -// let annotation = PositionAnnotation() -// annotation.coordinate = position.nodeCoordinate! -// annotation.title = position.nodePosition!.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown") -// annotation.shortName = position.nodePosition!.user?.shortName?.uppercased() ?? "???" -// -// mapView.addAnnotation(annotation) -// -// displayedNodes.append(position.nodePosition!.num) -// } -// -// if shouldMoveRegion { -// self.moveToMeshRegion(mapView) -// } -// -// -// } -// -// func moveToMeshRegion(_ mapView: MKMapView) { -// //go through the annotations and create a bounding box that encloses them -// -// var minLat: CLLocationDegrees = 90.0 -// var maxLat: CLLocationDegrees = -90.0 -// var minLon: CLLocationDegrees = 180.0 -// var maxLon: CLLocationDegrees = -180.0 -// -// for annotation in mapView.annotations { -// if annotation.isKind(of: PositionAnnotation.self) { -// minLat = min(minLat, annotation.coordinate.latitude) -// maxLat = max(maxLat, annotation.coordinate.latitude) -// minLon = min(minLon, annotation.coordinate.longitude) -// maxLon = max(maxLon, annotation.coordinate.longitude) -// } -// } -// -// //check if the mesh region looks sensible before we move to it. Otherwise we won't move the map (leave it at the current location) -// if maxLat < minLat || (maxLat-minLat) > 5 || maxLon < minLon || (maxLon-minLon) > 5 { -// return -// } else if minLat == maxLat && minLon == maxLon { -// //then we are focussed on a single point (probably because there is only one node with a position) -// //widen that out a little (don't zoom way in to that point) -// -// //0.001 degrees latitude is about 100m -// //the mapView.regionThatFits call below will expand this out to a rectangle -// minLat = minLat - 0.001 -// maxLat = maxLat + 0.001 -// } -// -// let centerCoord = CLLocationCoordinate2D(latitude: (minLat+maxLat)/2, longitude: (minLon+maxLon)/2) -// -// let span = MKCoordinateSpan(latitudeDelta: (maxLat-minLat)*1.5, longitudeDelta: (maxLon-minLon)*1.5) -// -// let region = mapView.regionThatFits(MKCoordinateRegion(center: centerCoord, span: span)) -// -// mapView.setRegion(region, animated: true) -// } -// -// public func makeCoordinator() -> Coordinator { -// Coordinator(parent: self) -// } -// -// public class Coordinator: NSObject, MKMapViewDelegate { -// -// private var parent: MapView -// public var overlays: [Overlay] = [] -// -// init(parent: MapView) { -// self.parent = parent -// } -// -// public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { -// -// guard !annotation.isKind(of: MKUserLocation.self) else { -// // Make a fast exit if the annotation is the `MKUserLocation`, as it's not an annotation view we wish to customize. -// return nil -// } -// -// if let annotation = annotation as? PositionAnnotation { -// -// let annotationView = PositionAnnotationView(annotation: annotation, reuseIdentifier: "PositionAnnotation") -// annotationView.name = annotation.shortName ?? "????" -// annotationView.canShowCallout = true -// -// return annotationView -// } -// -// return nil -// } -// -// public func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { -// -// if let index = self.overlays.firstIndex(where: { overlay_ in overlay_.shape.hash == overlay.hash }) { -// -// let unwrappedOverlay = self.overlays[index] -// -// if let circleOverlay = unwrappedOverlay.shape as? MKCircle { -// -// let renderer = MKCircleRenderer(circle: circleOverlay) -// renderer.fillColor = unwrappedOverlay.fillColor -// renderer.strokeColor = unwrappedOverlay.strokeColor -// renderer.lineWidth = unwrappedOverlay.lineWidth -// return renderer -// -// } else if let polygonOverlay = unwrappedOverlay.shape as? MKPolygon { -// -// let renderer = MKPolygonRenderer(polygon: polygonOverlay) -// renderer.fillColor = unwrappedOverlay.fillColor -// renderer.strokeColor = unwrappedOverlay.strokeColor -// renderer.lineWidth = unwrappedOverlay.lineWidth -// return renderer -// -// } else if let multiPolygonOverlay = unwrappedOverlay.shape as? MKMultiPolygon { -// -// let renderer = MKMultiPolygonRenderer(multiPolygon: multiPolygonOverlay) -// renderer.fillColor = unwrappedOverlay.fillColor -// renderer.strokeColor = unwrappedOverlay.strokeColor -// renderer.lineWidth = unwrappedOverlay.lineWidth -// return renderer -// -// } else if let polyLineOverlay = unwrappedOverlay.shape as? MKPolyline { -// -// let renderer = MKPolylineRenderer(polyline: polyLineOverlay) -// renderer.fillColor = unwrappedOverlay.fillColor -// renderer.strokeColor = unwrappedOverlay.strokeColor -// renderer.lineWidth = unwrappedOverlay.lineWidth -// return renderer -// -// } else if let multiPolylineOverlay = unwrappedOverlay.shape as? MKMultiPolyline { -// -// let renderer = MKMultiPolylineRenderer(multiPolyline: multiPolylineOverlay) -// renderer.fillColor = unwrappedOverlay.fillColor -// renderer.strokeColor = unwrappedOverlay.strokeColor -// renderer.lineWidth = unwrappedOverlay.lineWidth -// return renderer -// -// } else { -// -// return MKOverlayRenderer() -// -// } -// -// } else if let tileOverlay = overlay as? MKTileOverlay { -// -// return MKTileOverlayRenderer(tileOverlay: tileOverlay) -// -// } else { -// return MKOverlayRenderer() -// } -// } -// } -// -// /// is supposed to be located in the folder with the map name -// public struct DefaultTile: Hashable { -// let tileName: String -// let tileType: String -// -// public init(tileName: String, tileType: String) { -// self.tileName = tileName -// self.tileType = tileType -// } -// } -// -// public struct CustomMapOverlay: Equatable, Hashable { -// let mapName: String -// let tileType: String -// var canReplaceMapContent: Bool -// var minimumZoomLevel: Int? -// var maximumZoomLevel: Int? -// let defaultTile: DefaultTile? -// -// public init( -// mapName: String, -// tileType: String, -// canReplaceMapContent: Bool = true, // false for transparent tiles -// minimumZoomLevel: Int? = nil, -// maximumZoomLevel: Int? = nil, -// defaultTile: DefaultTile? = nil -// ) { -// -// self.mapName = mapName -// self.tileType = tileType -// self.canReplaceMapContent = canReplaceMapContent -// self.minimumZoomLevel = minimumZoomLevel -// self.maximumZoomLevel = maximumZoomLevel -// self.defaultTile = defaultTile -// } -// -// public init?( -// mapName: String?, -// tileType: String, -// canReplaceMapContent: Bool = true, // false for transparent tiles -// minimumZoomLevel: Int? = nil, -// maximumZoomLevel: Int? = nil, -// defaultTile: DefaultTile? = nil -// ) { -// if (mapName == nil || mapName! == "") { -// return nil -// } -// self.mapName = mapName! -// self.tileType = tileType -// self.canReplaceMapContent = canReplaceMapContent -// self.minimumZoomLevel = minimumZoomLevel -// self.maximumZoomLevel = maximumZoomLevel -// self.defaultTile = defaultTile -// } -// } -// -// public class CustomMapOverlaySource: MKTileOverlay { -// -// // requires folder: tiles/{mapName}/z/y/y,{tileType} -// private var parent: MapView -// private let mapName: String -// private let tileType: String -// private let defaultTile: DefaultTile? -// -// public init( -// parent: MapView, -// mapName: String, -// tileType: String, -// defaultTile: DefaultTile? -// ) { -// self.parent = parent -// self.mapName = mapName -// self.tileType = tileType -// self.defaultTile = defaultTile -// super.init(urlTemplate: "") -// } -// -// public override func url(forTilePath path: MKTileOverlayPath) -> URL { -// if let tileUrl = Bundle.main.url( -// forResource: "\(path.y)", -// withExtension: self.tileType, -// subdirectory: "tiles/\(self.mapName)/\(path.z)/\(path.x)", -// localization: nil -// ) { -// return tileUrl -// } else if let defaultTile = self.defaultTile, let defaultTileUrl = Bundle.main.url( -// forResource: defaultTile.tileName, -// withExtension: defaultTile.tileType, -// subdirectory: "tiles/\(self.mapName)", -// localization: nil -// ) { -// return defaultTileUrl -// } else { -// let urlstring = self.mapName+"\(path.z)/\(path.x)/\(path.y).png" -// return URL(string: urlstring)! -// // Bundle.main.url(forResource: "surrounding", withExtension: "png", subdirectory: "tiles")! -// } -// -// } -// -// } -// -// public struct Overlay { -// -// public static func == (lhs: MapView.Overlay, rhs: MapView.Overlay) -> Bool { -// // maybe to use in the future for comparison of full array -// lhs.shape.coordinate.latitude == rhs.shape.coordinate.latitude && -// lhs.shape.coordinate.longitude == rhs.shape.coordinate.longitude && -// lhs.fillColor == rhs.fillColor -// } -// -// var shape: MKOverlay -// var fillColor: UIColor? -// var strokeColor: UIColor? -// var lineWidth: CGFloat -// -// public init( -// shape: MKOverlay, -// fillColor: UIColor? = nil, -// strokeColor: UIColor? = nil, -// lineWidth: CGFloat = 0 -// ) { -// self.shape = shape -// self.fillColor = fillColor -// self.strokeColor = strokeColor -// self.lineWidth = lineWidth -// } -// } -// -// } -// -// MARK: End of implementation -// #endif diff --git a/Meshtastic/Views/Map/Custom/PositionAnnotationView.swift b/Meshtastic/Views/Map/Custom/PositionAnnotationView.swift deleted file mode 100644 index 444718dc..00000000 --- a/Meshtastic/Views/Map/Custom/PositionAnnotationView.swift +++ /dev/null @@ -1,60 +0,0 @@ -//// -//// PositionAnnotationView.swift -//// MeshtasticApple -//// -//// Created by Joshua Pirihi on 24/12/21. -//// -// -// import UIKit -// import MapKit -// import SwiftUI -// -//// a simple circle annotation, with a string in it -// class PositionAnnotation: NSObject, MKAnnotation { -// -// // This property must be key-value observable, which the `@objc dynamic` attributes provide. -// @objc dynamic var coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0) -// -// // Required if you set the annotation view's `canShowCallout` property to `true` -// // this string fills the callout label when you tap an annotation -// var title: String? -// -// // the text to appear inside the little circle -// var shortName: String? -// -// } -// -// class PositionAnnotationView: MKAnnotationView { -// -// private let annotationFrame = CGRect(x: 0, y: 0, width: 40, height: 40) -// private let label: UILabel -// -// override init(annotation: MKAnnotation?, reuseIdentifier: String?) { -// self.label = UILabel(frame: annotationFrame.offsetBy(dx: 0, dy: 0)) -// super.init(annotation: annotation, reuseIdentifier: reuseIdentifier) -// self.frame = annotationFrame -// self.label.font = UIFont.preferredFont(forTextStyle: .caption2) -// self.label.textColor = .white -// self.label.textAlignment = .center -// self.backgroundColor = .clear -// self.addSubview(label) -// } -// -// required init?(coder aDecoder: NSCoder) { -// fatalError("init(coder:) not implemented!") -// } -// -// public var name: String = "" { -// didSet { -// self.label.text = name -// } -// } -// -// override func draw(_ rect: CGRect) { -// guard let context = UIGraphicsGetCurrentContext() else { return } -// -// let circleRect = CGRect(x: 1, y: 1, width: 38, height: 38) -// context.setFillColor(Color.accentColor.cgColor ?? CGColor(red: 0, green: 0.5, blue: 1.0, alpha: 1.0)) -// context.fillEllipse(in: circleRect) -// } -// } diff --git a/Meshtastic/Views/Nodes/NodeDetail.swift b/Meshtastic/Views/Nodes/NodeDetail.swift index a09649a1..95603729 100644 --- a/Meshtastic/Views/Nodes/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/NodeDetail.swift @@ -471,26 +471,20 @@ struct NodeDetail: View { .onAppear { self.bleManager.context = context switch meshMapType { - case "standard": - mapType = .standard - break - case "mutedStandard": - mapType = .mutedStandard - break - case "hybrid": - mapType = .hybrid - break - case "hybridFlyover": - mapType = .hybridFlyover - break - case "satellite": - mapType = .satellite - break - case "satelliteFlyover": - mapType = .satelliteFlyover - break - default: - mapType = .hybridFlyover + case "standard": + mapType = .standard + case "mutedStandard": + mapType = .mutedStandard + case "hybrid": + mapType = .hybrid + case "hybridFlyover": + mapType = .hybridFlyover + case "satellite": + mapType = .satellite + case "satelliteFlyover": + mapType = .satelliteFlyover + default: + mapType = .hybridFlyover } } .task(id: node.num) { diff --git a/Meshtastic/Views/Nodes/NodeMap.swift b/Meshtastic/Views/Nodes/NodeMap.swift index aca70205..59e42419 100644 --- a/Meshtastic/Views/Nodes/NodeMap.swift +++ b/Meshtastic/Views/Nodes/NodeMap.swift @@ -123,22 +123,16 @@ struct NodeMap: View { switch meshMapType { case "standard": mapType = .standard - break case "mutedStandard": mapType = .mutedStandard - break case "hybrid": mapType = .hybrid - break case "hybridFlyover": mapType = .hybridFlyover - break case "satellite": mapType = .satellite - break case "satelliteFlyover": mapType = .satelliteFlyover - break default: mapType = .hybridFlyover } diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index 0aea143d..c2703fb0 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -252,7 +252,7 @@ struct Channels: View { self.isPresentingEditView = false channelName = "" hasChanges = false - bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) + _ = bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) } } label: { Label("save", systemImage: "square.and.arrow.down") diff --git a/Meshtastic/Views/Settings/ShareChannels.swift b/Meshtastic/Views/Settings/ShareChannels.swift index d1cd3afa..9a9eda8f 100644 --- a/Meshtastic/Views/Settings/ShareChannels.swift +++ b/Meshtastic/Views/Settings/ShareChannels.swift @@ -262,18 +262,18 @@ struct ShareChannels: View { }) .onAppear { bleManager.context = context - GenerateChannelSet() + generateChannelSet() } - .onChange(of: includeChannel1) { _ in GenerateChannelSet() } - .onChange(of: includeChannel2) { _ in GenerateChannelSet() } - .onChange(of: includeChannel3) { _ in GenerateChannelSet() } - .onChange(of: includeChannel4) { _ in GenerateChannelSet() } - .onChange(of: includeChannel5) { _ in GenerateChannelSet() } - .onChange(of: includeChannel6) { _ in GenerateChannelSet() } - .onChange(of: includeChannel7) { _ in GenerateChannelSet() } + .onChange(of: includeChannel1) { _ in generateChannelSet() } + .onChange(of: includeChannel2) { _ in generateChannelSet() } + .onChange(of: includeChannel3) { _ in generateChannelSet() } + .onChange(of: includeChannel4) { _ in generateChannelSet() } + .onChange(of: includeChannel5) { _ in generateChannelSet() } + .onChange(of: includeChannel6) { _ in generateChannelSet() } + .onChange(of: includeChannel7) { _ in generateChannelSet() } } } - func GenerateChannelSet() { + func generateChannelSet() { channelSet = ChannelSet() var loRaConfig = Config.LoRaConfig() loRaConfig.region = RegionCodes(rawValue: Int(node?.loRaConfig?.regionCode ?? 0))!.protoEnumValue()