From f83f331a99f4a66b19666a55a9564b2525652de0 Mon Sep 17 00:00:00 2001 From: ad Date: Tue, 15 May 2018 15:11:34 +0300 Subject: [PATCH] + custom title --- MTMR/ItemsParsing.swift | 5 +++++ MTMR/TouchBarController.swift | 3 +++ 2 files changed, 8 insertions(+) diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift index 1a6a8b9..6980fa3 100644 --- a/MTMR/ItemsParsing.swift +++ b/MTMR/ItemsParsing.swift @@ -355,6 +355,7 @@ enum GeneralParameter { case align(_: Align) case bordered(_: Bool) case background(_:NSColor) + case title(_:String) } struct GeneralParameters: Decodable { @@ -366,6 +367,7 @@ struct GeneralParameters: Decodable { case align case bordered case background + case title } init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -384,6 +386,9 @@ struct GeneralParameters: Decodable { if let backgroundColor = try container.decodeIfPresent(String.self, forKey: .background)?.hexColor { result[.background] = .background(backgroundColor) } + if let title = try container.decodeIfPresent(String.self, forKey: .title) { + result[.title] = .title(title) + } parameters = result } } diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift index fe13822..290ee8a 100644 --- a/MTMR/TouchBarController.swift +++ b/MTMR/TouchBarController.swift @@ -275,6 +275,9 @@ class TouchBarController: NSObject, NSTouchBarDelegate { if case .image(let source)? = item.additionalParameters[.image], let item = barItem as? CustomButtonTouchBarItem { item.image = source.image } + if case .title(let value)? = item.additionalParameters[.title], let item = barItem as? CustomButtonTouchBarItem { + item.title = value + } return barItem }