You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.9 KiB
118 lines
3.9 KiB
![]()
2 years ago
|
//
|
||
![]()
2 years ago
|
// FirmwareUpdateViewControllers.swift
|
||
![]()
1 year ago
|
// FireBoltt
|
||
![]()
2 years ago
|
//
|
||
|
// Created by lemo. on 2020/4/17.
|
||
|
// Copyright © 2020 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
import RxSwift
|
||
|
|
||
![]()
2 years ago
|
class FirmwareUpdateViewControllers: ViewController {
|
||
![]()
2 years ago
|
|
||
|
lazy var versionLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemRegularFont(16)
|
||
|
label.numberOfLines = 0
|
||
|
return label
|
||
|
}()
|
||
|
lazy var versionLogsLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.numberOfLines = 0
|
||
|
return label
|
||
|
}()
|
||
|
lazy var firmwareTipLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemRegularFont(16)
|
||
![]()
1 year ago
|
label.text = MultiLanguageKey_FB.firmwareTipFB.localized
|
||
![]()
2 years ago
|
label.numberOfLines = 0
|
||
|
return label
|
||
|
}()
|
||
|
|
||
|
lazy var bgImg: UIImageView = {
|
||
![]()
1 year ago
|
let img = UIImageView(image: R.image.fb_update_icon())
|
||
![]()
2 years ago
|
return img
|
||
|
}()
|
||
|
lazy var updateBtn: UIButton = {
|
||
|
let btn = UIButton()
|
||
![]()
2 years ago
|
btn.gradient(colors: [kHexColor(0x59AAFF), kHexColor(0x2B75FF)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5), locations: [0, 1], autoLaoutFrame: CGRect(x: 0, y: 0, width: kScaleWidth(190), height: kScaleWidth(45)))
|
||
![]()
2 years ago
|
btn.layer.cornerRadius = 22.5
|
||
|
btn.layer.masksToBounds = true
|
||
![]()
1 year ago
|
btn.setTitle(MultiLanguageKey_FB.updateFirmwareFB.localized, for: .normal)
|
||
![]()
2 years ago
|
btn.titleLabel?.font = SystemRegularFont(18)
|
||
|
btn.setTitleColor(kHexColor(0xffffff), for: .normal)
|
||
|
return btn
|
||
|
}()
|
||
|
|
||
|
override func viewDidLoad() {
|
||
|
super.viewDidLoad()
|
||
|
//Bluetooth.shareInstance()!.openDialFile()
|
||
|
UIApplication.shared.isIdleTimerDisabled = true
|
||
|
|
||
|
}
|
||
|
override func viewDidDisappear(_ animated: Bool) {
|
||
|
super.viewDidDisappear(true)
|
||
|
UIApplication.shared.isIdleTimerDisabled = false
|
||
|
}
|
||
|
|
||
|
override func makeUI() {
|
||
|
super.makeUI()
|
||
|
view.addSubview(versionLabel)
|
||
|
view.addSubview(versionLogsLabel)
|
||
|
view.addSubview(firmwareTipLabel)
|
||
|
view.addSubview(bgImg)
|
||
|
view.addSubview(updateBtn)
|
||
|
layoutUI()
|
||
|
}
|
||
|
|
||
|
func layoutUI() {
|
||
|
versionLabel.snp.makeConstraints { (make) in
|
||
|
make.left.equalTo(32)
|
||
|
make.right.equalTo(-32)
|
||
|
make.top.equalTo(25)
|
||
|
}
|
||
|
versionLogsLabel.snp.makeConstraints { (make) in
|
||
|
make.left.equalTo(32)
|
||
|
make.top.equalTo(versionLabel.snp.bottom).offset(10)
|
||
|
}
|
||
|
firmwareTipLabel.snp.makeConstraints { (make) in
|
||
|
make.left.equalTo(32)
|
||
|
make.right.equalTo(-32)
|
||
|
make.top.equalTo(versionLogsLabel.snp.bottom).offset(10)
|
||
|
}
|
||
|
bgImg.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(firmwareTipLabel.snp.bottom).offset(30)
|
||
|
make.centerX.equalToSuperview()
|
||
|
make.width.height.equalTo(200)
|
||
|
}
|
||
|
updateBtn.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(bgImg.snp.bottom).offset(27)
|
||
|
make.width.equalTo(kScaleWidth(190))
|
||
|
make.height.equalTo(kScaleWidth(45))
|
||
|
make.centerX.equalToSuperview()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override func bindViewModel() {
|
||
|
super.bindViewModel()
|
||
![]()
2 years ago
|
guard let viewModel = viewModel as? FirmwareUpdateViewModels else { return }
|
||
|
let output = viewModel.transform(input: FirmwareUpdateViewModels.Input(startUpdate: updateBtn.rx.tap.asObservable()))
|
||
![]()
2 years ago
|
output.versionTip
|
||
|
.bind(to: versionLabel.rx.text)
|
||
|
.disposed(by: rx.disposeBag)
|
||
|
output.versionLogTip
|
||
|
.bind(to: versionLogsLabel.rx.attributedText)
|
||
|
.disposed(by: rx.disposeBag)
|
||
|
viewModel.updateComplete
|
||
|
.subscribe(onNext: { [weak self] in
|
||
|
self?.navigator.pop(sender: self)
|
||
|
})
|
||
|
.disposed(by: rx.disposeBag)
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|