diff options
Diffstat (limited to 'Map/Core Extensions')
| -rw-r--r-- | Map/Core Extensions/Color+Theme.swift | 27 | ||||
| -rw-r--r-- | Map/Core Extensions/Date+format.swift | 17 | ||||
| -rw-r--r-- | Map/Core Extensions/Font+Theme.swift | 8 | ||||
| -rw-r--r-- | Map/Core Extensions/NSColor+Theme.swift | 10 | ||||
| -rw-r--r-- | Map/Core Extensions/NSImage+writePNG.swift | 25 |
5 files changed, 87 insertions, 0 deletions
diff --git a/Map/Core Extensions/Color+Theme.swift b/Map/Core Extensions/Color+Theme.swift new file mode 100644 index 0000000..ffbd224 --- /dev/null +++ b/Map/Core Extensions/Color+Theme.swift @@ -0,0 +1,27 @@ +import SwiftUI + +extension Color { + struct theme { + static let darkSlate = Color("Dark Slate") + static let jasperRed = Color("Jasper Red") + static let olympicBlue = Color("Olympic Blue") + static let neutralGray = Color("Neutral Gray") + static let lightNeutralGray = Color("Light Neutral Gray") + static let darkNeutralGray = Color("Dark Neutral Gray") + } + + struct map { + static let labelColor = Color.theme.darkSlate + static let axisColor = Color.theme.darkSlate + static let vertexColor = Color.theme.darkSlate + static let blockerColor = Color.theme.jasperRed + static let opportunityColor = Color.theme.olympicBlue + static let stageForeground = Color.theme.lightNeutralGray + static let stageBackground = Color.white + } + + struct ui { + static let foreground = Color("Foreground") + static let background = Color("Background") + } +} diff --git a/Map/Core Extensions/Date+format.swift b/Map/Core Extensions/Date+format.swift new file mode 100644 index 0000000..d29ed0f --- /dev/null +++ b/Map/Core Extensions/Date+format.swift @@ -0,0 +1,17 @@ +// +// Date+format.swift +// Map +// +// Created by Ruben Beltran del Rio on 2/1/21. +// + +import Foundation + +extension Date { + func format() -> String { + let formatter = DateFormatter() + formatter.dateStyle = .short + formatter.timeStyle = .medium + return formatter.string(from: self) + } +} diff --git a/Map/Core Extensions/Font+Theme.swift b/Map/Core Extensions/Font+Theme.swift new file mode 100644 index 0000000..30bc6f9 --- /dev/null +++ b/Map/Core Extensions/Font+Theme.swift @@ -0,0 +1,8 @@ +import SwiftUI + +public extension Font { + struct theme { + static let axisLabel = Font.custom("Hiragino Mincho ProN", size: 14) + static let vertexLabel = Font.custom("Hiragino Mincho ProN", size: 12) + } +} diff --git a/Map/Core Extensions/NSColor+Theme.swift b/Map/Core Extensions/NSColor+Theme.swift new file mode 100644 index 0000000..0ef1094 --- /dev/null +++ b/Map/Core Extensions/NSColor+Theme.swift @@ -0,0 +1,10 @@ +import AppKit + +extension NSColor { + struct syntax { + static let vertex = NSColor(named: "Vertex") ?? .textColor + static let number = NSColor(named: "Number") ?? .textColor + static let option = NSColor(named: "Option") ?? .textColor + static let symbol = NSColor(named: "Symbol") ?? .textColor + } +} diff --git a/Map/Core Extensions/NSImage+writePNG.swift b/Map/Core Extensions/NSImage+writePNG.swift new file mode 100644 index 0000000..c24c0cf --- /dev/null +++ b/Map/Core Extensions/NSImage+writePNG.swift @@ -0,0 +1,25 @@ +import Cocoa + +extension NSImage { + public func writePNG(toURL url: URL) { + + guard let data = tiffRepresentation, + let rep = NSBitmapImageRep(data: data), + let imgData = rep.representation( + using: .png, properties: [.compressionFactor: NSNumber(floatLiteral: 1.0)]) + else { + + print( + "\(self.self) Error Function '\(#function)' Line: \(#line) No tiff rep found for image writing to \(url)" + ) + return + } + + do { + try imgData.write(to: url) + } catch let error { + print( + "\(self.self) Error Function '\(#function)' Line: \(#line) \(error.localizedDescription)") + } + } +} |