50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
//
|
|
// ResourcesControllerPopupStatistics.swift
|
|
// Wallet
|
|
//
|
|
// Created by Igor on 11.02.2021.
|
|
// Copyright © 2021 AM. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
protocol ResourcesControllerPopupStatisticsDelegate: AnyObject {
|
|
func sendSubmit()
|
|
}
|
|
|
|
class ResourcesControllerPopupStatistics: UIViewController {
|
|
|
|
weak var delegate: ResourcesControllerPopupStatisticsDelegate?
|
|
@IBOutlet private weak var stackView: UIStackView!
|
|
|
|
var service: Resources.Service.Popup.Statistics! {
|
|
didSet {
|
|
service.didUpdate = { [weak self] in self?.reload() }
|
|
reload()
|
|
}
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
}
|
|
|
|
private func reload() {
|
|
stackView.arrangedSubviews.forEach({ $0.removeFromSuperview() })
|
|
let kinds: [Resources.Model.Performance.Kind] = [.cpu, .net, .ram]
|
|
kinds.forEach({
|
|
let performance = service.performance[$0]
|
|
let view = ResourcesViewChart()
|
|
view.title = $0.title
|
|
view.text = performance.usedTitle
|
|
view.progress = CGFloat(performance.usedProgress)
|
|
view.progressText = performance.usedPercentageProgress
|
|
stackView.addArrangedSubview(view)
|
|
})
|
|
}
|
|
|
|
@IBAction func onSubmit(_: AnyObject?) {
|
|
self.delegate?.sendSubmit()
|
|
}
|
|
|
|
}
|