diff --git a/Meshtastic/Extensions/UIColor.swift b/Meshtastic/Extensions/UIColor.swift
index 6a8909b9..d9160015 100644
--- a/Meshtastic/Extensions/UIColor.swift
+++ b/Meshtastic/Extensions/UIColor.swift
@@ -37,5 +37,13 @@ extension UIColor {
private func add(_ value: CGFloat, toComponent: CGFloat) -> CGFloat {
return max(0, min(1, toComponent + value))
}
-
+
+ static var random: UIColor {
+ return UIColor(
+ red: .random(in: 0...1),
+ green: .random(in: 0...1),
+ blue: .random(in: 0...1),
+ alpha: 1.0
+ )
+ }
}
diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV20.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV20.xcdatamodel/contents
index ec6e67db..b042f51f 100644
--- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV20.xcdatamodel/contents
+++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV20.xcdatamodel/contents
@@ -285,8 +285,9 @@
-
+
+
diff --git a/Meshtastic/Views/Settings/Routes.swift b/Meshtastic/Views/Settings/Routes.swift
index 2d64f42f..648d90e7 100644
--- a/Meshtastic/Views/Settings/Routes.swift
+++ b/Meshtastic/Views/Settings/Routes.swift
@@ -26,6 +26,10 @@ struct Routes: View {
Button("Import Route") {
importing = true
}
+ .buttonStyle(.bordered)
+ .buttonBorderShape(.capsule)
+ .controlSize(.large)
+ .padding()
.fileImporter(
isPresented: $importing,
allowedContentTypes: [.commaSeparatedText],
@@ -54,9 +58,9 @@ struct Routes: View {
}
if latIndex >= 0 && longIndex >= 0 {
let newRoute = RouteEntity(context: context)
- newRoute.name = ("\(String(routeName)) - \(Date().formatted())")
+ newRoute.name = String(routeName)
newRoute.id = Int32.random(in: Int32(Int8.max) ... Int32.max)
- newRoute.color = 12
+ newRoute.color = Int64(UIColor.random.hex)
newRoute.date = Date()
var newLocations = [LocationEntity]()
lines.dropFirst().forEach { line in
@@ -90,8 +94,22 @@ struct Routes: View {
VStack {
List(routes, id: \.self, selection: $selectedRoute) { route in
- Text(route.name ?? "No Name Route")
- .font(.title)
+ Label {
+ VStack (alignment: .leading) {
+ Text("\(route.name ?? "No Name Route")")
+ .padding(.top)
+ .foregroundStyle(.primary)
+
+ Text("\(route.date?.formatted() ?? "Unknown Time")")
+ .padding(.bottom)
+ .font(.callout)
+ .foregroundColor(.gray)
+ }
+ } icon: {
+ RoundedRectangle(cornerRadius: 10)
+ .fill(Color(UIColor(hex: route.color >= 0 ? UInt32(route.color) : 0)))
+ .frame(width: 20, height: 20)
+ }
}
.listStyle(.plain)
}
@@ -128,11 +146,11 @@ struct Routes: View {
lineCap: .round, lineJoin: .round, dash: [7, 10]
)
MapPolyline(coordinates: lineCoords)
- .stroke(.green, style: dashed)
+ .stroke(Color(UIColor(hex: UInt32(selectedRoute?.color ?? 0))), style: dashed)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
- }.navigationTitle(" \(selectedRoute?.name ?? "Unknown Route") Map")
+ }.navigationTitle(" \(selectedRoute?.name ?? "Unknown Route") \(selectedRoute?.locations?.count ?? 0) points")
}
}
}