mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Add functions to make lighter and darker UIColors for the map
This commit is contained in:
parent
163788bcc9
commit
976a609803
3 changed files with 46 additions and 1 deletions
|
|
@ -68,6 +68,7 @@
|
|||
DD6193792863875F00E59241 /* SerialConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6193782863875F00E59241 /* SerialConfig.swift */; };
|
||||
DD73FD1128750779000852D6 /* PositionLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD73FD1028750779000852D6 /* PositionLog.swift */; };
|
||||
DD769E0328D18BF1001A3F05 /* DeviceMetricsLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD769E0228D18BF0001A3F05 /* DeviceMetricsLog.swift */; };
|
||||
DD77093F2AA1B146007A8BF0 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD77093E2AA1B146007A8BF0 /* UIColor.swift */; };
|
||||
DD798B072915928D005217CD /* ChannelMessageList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD798B062915928D005217CD /* ChannelMessageList.swift */; };
|
||||
DD8169F9271F1A6100F4AB02 /* MeshLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */; };
|
||||
DD8169FB271F1F3A00F4AB02 /* MeshLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */; };
|
||||
|
|
@ -268,6 +269,7 @@
|
|||
DD6193782863875F00E59241 /* SerialConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SerialConfig.swift; sourceTree = "<group>"; };
|
||||
DD73FD1028750779000852D6 /* PositionLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PositionLog.swift; sourceTree = "<group>"; };
|
||||
DD769E0228D18BF0001A3F05 /* DeviceMetricsLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceMetricsLog.swift; sourceTree = "<group>"; };
|
||||
DD77093E2AA1B146007A8BF0 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = "<group>"; };
|
||||
DD798B062915928D005217CD /* ChannelMessageList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelMessageList.swift; sourceTree = "<group>"; };
|
||||
DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshLogger.swift; sourceTree = "<group>"; };
|
||||
DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshLog.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -790,6 +792,7 @@
|
|||
DDDB444329F8A8DD00EE2349 /* Float.swift */,
|
||||
DDDB444D29F8AB0E00EE2349 /* Int.swift */,
|
||||
DDDB444729F8A9C900EE2349 /* String.swift */,
|
||||
DD77093E2AA1B146007A8BF0 /* UIColor.swift */,
|
||||
DDDB444F29F8AC9C00EE2349 /* UIImage.swift */,
|
||||
DDDB443F29F79AB000EE2349 /* UserDefaults.swift */,
|
||||
DDB75A0E2A05920E006ED576 /* FileManager.swift */,
|
||||
|
|
@ -1145,6 +1148,7 @@
|
|||
DD3CC6BC28E366DF00FA9159 /* Meshtastic.xcdatamodeld in Sources */,
|
||||
DDC4C9FF2A8D982900CE201C /* DetectionSensorConfig.swift in Sources */,
|
||||
DD5E5210298EE33B00D21B61 /* telemetry.pb.swift in Sources */,
|
||||
DD77093F2AA1B146007A8BF0 /* UIColor.swift in Sources */,
|
||||
DD5E5205298EE33B00D21B61 /* mesh.pb.swift in Sources */,
|
||||
DDF6B2482A9AEBF500BA6931 /* StoreForward.swift in Sources */,
|
||||
DD8169F9271F1A6100F4AB02 /* MeshLogger.swift in Sources */,
|
||||
|
|
|
|||
41
Meshtastic/Extensions/UIColor.swift
Normal file
41
Meshtastic/Extensions/UIColor.swift
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// UIColor.swift
|
||||
// Meshtastic
|
||||
//
|
||||
// Copyright(c) Garth Vander Houwen 8/31/23.
|
||||
//
|
||||
import Foundation
|
||||
import Swift
|
||||
import UIKit
|
||||
|
||||
extension UIColor {
|
||||
|
||||
private func makeColor(componentDelta: CGFloat) -> UIColor {
|
||||
var red: CGFloat = 0
|
||||
var blue: CGFloat = 0
|
||||
var green: CGFloat = 0
|
||||
var alpha: CGFloat = 0
|
||||
|
||||
getRed(&red, green: &green, blue: &blue, alpha: &alpha)
|
||||
|
||||
return UIColor(
|
||||
red: add(componentDelta, toComponent: red),
|
||||
green: add(componentDelta, toComponent: green),
|
||||
blue: add(componentDelta, toComponent: blue),
|
||||
alpha: alpha
|
||||
)
|
||||
}
|
||||
|
||||
func lighter(componentDelta: CGFloat = 0.1) -> UIColor {
|
||||
return makeColor(componentDelta: componentDelta)
|
||||
}
|
||||
|
||||
func darker(componentDelta: CGFloat = 0.1) -> UIColor {
|
||||
return makeColor(componentDelta: -3*componentDelta)
|
||||
}
|
||||
|
||||
private func add(_ value: CGFloat, toComponent: CGFloat) -> CGFloat {
|
||||
return max(0, min(1, toComponent + value))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
annotationView.tag = -1
|
||||
annotationView.canShowCallout = true
|
||||
if positionAnnotation.latest {
|
||||
annotationView.markerTintColor = .systemRed
|
||||
annotationView.markerTintColor = UIColor(hex: UInt32(positionAnnotation.nodePosition?.num ?? 0)).darker()
|
||||
annotationView.displayPriority = .required
|
||||
annotationView.titleVisibility = .visible
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue