mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix lint errors
This commit is contained in:
parent
59d05a533b
commit
373aa9c511
5 changed files with 20 additions and 23 deletions
|
|
@ -23,7 +23,7 @@ struct DeviceMetricsLog: View {
|
|||
let data = node.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0 && time !=nil && time >= %@", oneDayAgo! as CVarArg)) ?? []
|
||||
if data.count > 0 {
|
||||
GroupBox(label: Label("battery.level.trend", systemImage: "battery.100")) {
|
||||
Chart(data.array as! [TelemetryEntity], id: \.self) {
|
||||
Chart(data.array as? [TelemetryEntity] ?? [], id: \.self) {
|
||||
LineMark(
|
||||
x: .value("Hour", $0.time!.formattedDate(format: "ha")),
|
||||
y: .value("Value", $0.batteryLevel)
|
||||
|
|
@ -40,7 +40,7 @@ struct DeviceMetricsLog: View {
|
|||
let dateFormatString = (localeDateFormat ?? "MM/dd/YY j:mma").replacingOccurrences(of: ",", with: "")
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
// Add a table for mac and ipad
|
||||
Table(node.telemetries!.reversed() as! [TelemetryEntity]) {
|
||||
Table(node.telemetries?.reversed() as? [TelemetryEntity] ?? []) {
|
||||
|
||||
TableColumn("battery.level") { dm in
|
||||
if dm.metricsType == 0 {
|
||||
|
|
@ -102,7 +102,7 @@ struct DeviceMetricsLog: View {
|
|||
.font(.caption)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
ForEach(node.telemetries!.reversed() as! [TelemetryEntity], id: \.self) { (dm: TelemetryEntity) in
|
||||
ForEach(node.telemetries?.reversed() as? [TelemetryEntity] ?? [], id: \.self) { (dm: TelemetryEntity) in
|
||||
if dm.metricsType == 0 {
|
||||
GridRow {
|
||||
if dm.batteryLevel == 0 {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ struct EnvironmentMetricsLog: View {
|
|||
.font(.caption)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
ForEach(node.telemetries!.reversed() as! [TelemetryEntity], id: \.self) { (em: TelemetryEntity) in
|
||||
ForEach(node.telemetries?.reversed() as? [TelemetryEntity] ?? [], id: \.self) { (em: TelemetryEntity) in
|
||||
|
||||
if em.metricsType == 1 {
|
||||
|
||||
|
|
|
|||
|
|
@ -104,9 +104,8 @@ struct NodeDetail: View {
|
|||
Text("Today's Weather Forecast")
|
||||
.font(.title)
|
||||
.padding()
|
||||
let nodeLocation = node.positions?.lastObject as! PositionEntity
|
||||
|
||||
NodeWeatherForecastView(location: CLLocation(latitude: nodeLocation.nodeCoordinate!.latitude, longitude: nodeLocation.nodeCoordinate!.longitude) )
|
||||
let nodeLocation = node.positions?.lastObject as? PositionEntity
|
||||
NodeWeatherForecastView(location: CLLocation(latitude: nodeLocation?.nodeCoordinate!.latitude ?? LocationHelper.currentLocation.latitude, longitude: nodeLocation?.nodeCoordinate!.longitude ?? LocationHelper.currentLocation.longitude) )
|
||||
.frame(height: 250)
|
||||
}
|
||||
#else
|
||||
|
|
@ -114,10 +113,8 @@ struct NodeDetail: View {
|
|||
Text("Today's Weather Forecast")
|
||||
.font(.title)
|
||||
.padding()
|
||||
|
||||
let nodeLocation = node.positions?.lastObject as! PositionEntity
|
||||
NodeWeatherForecastView(location: CLLocation(latitude: nodeLocation.nodeCoordinate!.latitude, longitude: nodeLocation.nodeCoordinate!.longitude) )
|
||||
.frame(height: 250)
|
||||
let nodeLocation = node.positions?.lastObject as? PositionEntity
|
||||
NodeWeatherForecastView(location: CLLocation(latitude: nodeLocation?.nodeCoordinate!.latitude ?? LocationHelper.currentLocation.latitude, longitude: nodeLocation?.nodeCoordinate!.longitude ?? LocationHelper.currentLocation.longitude) ).frame(height: 250)
|
||||
.presentationDetents([.medium])
|
||||
.presentationDragIndicator(.automatic)
|
||||
}
|
||||
|
|
@ -181,13 +178,13 @@ struct NodeDetail: View {
|
|||
|
||||
if node.telemetries?.count ?? 0 >= 1 {
|
||||
|
||||
let mostRecent = node.telemetries?.lastObject as! TelemetryEntity
|
||||
let mostRecent = node.telemetries?.lastObject as? TelemetryEntity
|
||||
Divider()
|
||||
VStack(alignment: .center) {
|
||||
BatteryGauge(batteryLevel: Double(mostRecent.batteryLevel))
|
||||
if mostRecent.voltage > 0 {
|
||||
BatteryGauge(batteryLevel: Double(mostRecent?.batteryLevel ?? 0))
|
||||
if mostRecent?.voltage ?? 0 > 0 {
|
||||
|
||||
Text(String(format: "%.2f", mostRecent.voltage) + " V")
|
||||
Text(String(format: "%.2f", mostRecent?.voltage ?? 0.0) + " V")
|
||||
.font(.title)
|
||||
.foregroundColor(.gray)
|
||||
.fixedSize()
|
||||
|
|
@ -290,13 +287,13 @@ struct NodeDetail: View {
|
|||
}
|
||||
|
||||
if node.telemetries?.count ?? 0 >= 1 {
|
||||
let mostRecent = node.telemetries?.lastObject as! TelemetryEntity
|
||||
let mostRecent = node.telemetries?.lastObject as? TelemetryEntity
|
||||
Divider()
|
||||
VStack(alignment: .center) {
|
||||
BatteryGauge(batteryLevel: Double(mostRecent.batteryLevel))
|
||||
if mostRecent.voltage > 0 {
|
||||
BatteryGauge(batteryLevel: Double(mostRecent?.batteryLevel ?? 0))
|
||||
if mostRecent?.voltage ?? 0 > 0 {
|
||||
|
||||
Text(String(format: "%.2f", mostRecent.voltage) + " V")
|
||||
Text(String(format: "%.2f", mostRecent?.voltage ?? 0) + " V")
|
||||
.font(.callout)
|
||||
.foregroundColor(.gray)
|
||||
.fixedSize()
|
||||
|
|
@ -494,9 +491,9 @@ struct NodeDetail: View {
|
|||
|
||||
if node.positions?.count ?? 0 > 0 {
|
||||
|
||||
let mostRecent = node.positions?.lastObject as! PositionEntity
|
||||
let mostRecent = node.positions?.lastObject as? PositionEntity
|
||||
|
||||
let weather = try await WeatherService.shared.weather(for: mostRecent.nodeLocation!)
|
||||
let weather = try await WeatherService.shared.weather(for: mostRecent?.nodeLocation ?? CLLocation(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude))
|
||||
condition = weather.currentWeather.condition
|
||||
temperature = weather.currentWeather.temperature
|
||||
humidity = Int(weather.currentWeather.humidity * 100)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ struct PositionLog: View {
|
|||
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
// Add a table for mac and ipad
|
||||
Table(node.positions!.reversed() as! [PositionEntity]) {
|
||||
Table(node.positions?.reversed() as? [PositionEntity] ?? []) {
|
||||
TableColumn("SeqNo") { position in
|
||||
Text(String(position.seqNo))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ struct ShareChannels: View {
|
|||
loRaConfig.sx126XRxBoostedGain = node?.loRaConfig?.sx126xRxBoostedGain ?? false
|
||||
channelSet.loraConfig = loRaConfig
|
||||
if node?.myInfo?.channels != nil && node?.myInfo?.channels?.count ?? 0 > 0 {
|
||||
for ch in node!.myInfo!.channels!.array as! [ChannelEntity] {
|
||||
for ch in node?.myInfo?.channels?.array as? [ChannelEntity] ?? [] {
|
||||
if ch.role > 0 {
|
||||
|
||||
if ch.index == 0 && includeChannel0 || ch.index == 1 && includeChannel1 || ch.index == 2 && includeChannel2 || ch.index == 3 && includeChannel3 ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue