// // ModalController+UI.swift // PrivadoVPN // // Created by Juraldinio on 4/17/21. // Copyright © 2021 Privado LLC. All rights reserved. // import Foundation extension ModalController { static func createCloseButton(image name: String) -> ImageView { let closeButton = ImageView(frame: .zero) closeButton.isHidden = true if let image = NSImage(named: name) { closeButton.image = image closeButton.useHandCursor = true } return closeButton } static func createTextField(color: NSColor, font: NSFont?, numberLines: Int = 1) -> NSTextField { let textField = NSTextField(frame: .zero) textField.isHidden = true textField.translatesAutoresizingMaskIntoConstraints = false textField.isBezeled = false textField.drawsBackground = false textField.isEditable = false textField.isSelectable = false textField.focusRingType = .none textField.textColor = color textField.font = font textField.alignment = .center textField.maximumNumberOfLines = numberLines return textField } static func createDynamicTextField(color: NSColor, font: NSFont?, fontName: String) -> DynamicTextField { let textField = DynamicTextField(frame: .zero) textField.fontName = fontName textField.isHidden = true textField.translatesAutoresizingMaskIntoConstraints = false textField.isBezeled = false textField.drawsBackground = false textField.isEditable = false textField.isSelectable = false textField.focusRingType = .none textField.textColor = color textField.font = font textField.alignment = .center return textField } // swiftlint:disable function_parameter_count static func createActionButton(corner: CGFloat, normalColor: NSColor, highlightColor: NSColor, titleColor: NSColor, font: NSFont?) -> FlatButton { let flatButton = FlatButton(frame: .zero) flatButton.momentary = true flatButton.cornerRadius = corner flatButton.backgroundNormalColor = normalColor flatButton.backgroundHighlightColor = highlightColor flatButton.titleNormalColor = titleColor flatButton.font = font return flatButton } // swiftlint:enable function_parameter_count static func createImageView(image name: String?) -> ImageView { let imageView = ImageView(frame: .zero) imageView.isHidden = true imageView.useHandCursor = false if let name = name , let image = NSImage(named: name) { imageView.image = image } return imageView } }