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
|
//
|
||
|
// FirmwareUpdateViewController.swift
|
||
|
// Lookfit
|
||
|
//
|
||
|
// Created by lemo. on 2020/4/17.
|
||
|
// Copyright © 2020 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
import RxSwift
|
||
|
|
||
|
class FirmwareUpdateViewController: ViewController {
|
||
|
|
||
|
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)
|
||
|
label.text = MultiLanguageKey.firmwareTip.localized
|
||
|
label.numberOfLines = 0
|
||
|
return label
|
||
|
}()
|
||
|
|
||
|
lazy var bgImg: UIImageView = {
|
||
|
let img = UIImageView(image: R.image.firmware_bg())
|
||
|
return img
|
||
|
}()
|
||
|
lazy var updateBtn: UIButton = {
|
||
|
let btn = UIButton()
|
||
|
btn.gradient(colors: [kHexColor(0xFFCD4D), kHexColor(0xFD9F26)], 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)))
|
||
|
btn.layer.cornerRadius = 22.5
|
||
|
btn.layer.masksToBounds = true
|
||
|
btn.setTitle(MultiLanguageKey.updateFirmware.localized, for: .normal)
|
||
|
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()
|
||
|
guard let viewModel = viewModel as? FirmwareUpdateViewModel else { return }
|
||
|
let output = viewModel.transform(input: FirmwareUpdateViewModel.Input(startUpdate: updateBtn.rx.tap.asObservable()))
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|