// // ConnectionButton.swift // PrivadoVPN // // Created by Murad Shabanov on 27.05.2022. // Copyright © 2022 Privado LLC. All rights reserved. // import Foundation class ConnectionButton: StrokeButton { enum Constants { enum Localized { static let connect = "connection.button.title.connect" static let disconnect = "connection.button.title.disconnect" } } enum ConnectionButtonState { case connect case disconnect } var state: ConnectionButtonState = .connect { didSet { self.updateUI(with: self.state) } } private func updateUI(with state: ConnectionButtonState) { switch state { case .connect: self.backgroundColor = NSColor(red: 255, green: 143, blue: 0) self.hoverBackgroundColor = NSColor(red: 255, green: 184, blue: 91) self.strokePressedColor = .white self.titleColor = .white self.titlePressedColor = .white self.strokeNormalColor = NSColor.clear self.title = NSLocalizedString(Constants.Localized.connect, comment: "") case .disconnect: self.backgroundColor = .clear self.strokeNormalColor = .white self.backgroundPressedColor = .white self.titlePressedColor = NSColor(red: 80, green: 88, blue: 200) self.strokePressedColor = NSColor(red: 155, green: 160, blue: 224) self.hoverBackgroundColor = .clear self.title = NSLocalizedString(Constants.Localized.disconnect, comment: "") } } }