84 lines
2.7 KiB
Swift
84 lines
2.7 KiB
Swift
//
|
|
// EmptyViewController.swift
|
|
// PrivadoVPN
|
|
//
|
|
// Created by Juraldinio on 7/30/20.
|
|
// Copyright © 2020 Privado LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import AppKit
|
|
|
|
final class EmptyViewController: NSViewController {
|
|
|
|
private enum Constants {
|
|
static let imageBackground = "bg-graphic"
|
|
static let imageDiff: CGFloat = 300
|
|
static let loaderSize: CGFloat = 120.0
|
|
}
|
|
|
|
private lazy var loader = PrivadoLoader(frame: .zero, isButton: false)
|
|
|
|
// MARK: - Lyfecycle
|
|
|
|
override func loadView() {
|
|
|
|
let view = NSView(frame: .zero)
|
|
view.autoresizesSubviews = true
|
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
view.wantsLayer = true
|
|
view.layer?.backgroundColor = NSColor(red: 21, green: 25, blue: 53).cgColor
|
|
|
|
self.view = view
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
self.configureUI()
|
|
}
|
|
|
|
override func viewDidAppear() {
|
|
super.viewDidAppear()
|
|
self.loader.startAnimation(clockwise: false)
|
|
}
|
|
|
|
// MARK: - UI
|
|
|
|
private func configureUI() {
|
|
|
|
self.view.viewBackgroundColor = NSColor(red: 80, green: 88, blue: 200)
|
|
|
|
NSLayoutConstraint.activate([
|
|
self.view.widthAnchor.constraint(equalToConstant: PrivadoConstants.Window.sizeWidth),
|
|
self.view.heightAnchor.constraint(equalToConstant: PrivadoConstants.Window.sizeHeight)
|
|
])
|
|
|
|
// Background image
|
|
let image = NSImage(imageLiteralResourceName: Constants.imageBackground)
|
|
let imageView = ImageView(image: image)
|
|
imageView.imageScaling = .scaleNone
|
|
self.view.addSubview(imageView)
|
|
NSLayoutConstraint.activate([
|
|
imageView.topAnchor.constraint(equalTo: self.view.topAnchor),
|
|
imageView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
|
|
imageView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
|
|
imageView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
|
|
])
|
|
|
|
self.loader.translatesAutoresizingMaskIntoConstraints = false
|
|
self.loader.arcColor = NSColor(red: 132, green: 138, blue: 217)
|
|
self.loader.keyholeColor = .white
|
|
self.loader.arcWidth = 5
|
|
self.view.addSubview(self.loader)
|
|
|
|
NSLayoutConstraint.activate([
|
|
self.loader.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
|
|
self.loader.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
|
|
self.loader.heightAnchor.constraint(equalToConstant: Constants.loaderSize),
|
|
self.loader.widthAnchor.constraint(equalToConstant: Constants.loaderSize)
|
|
])
|
|
}
|
|
}
|