|
|
|
//
|
|
|
|
// DeviceHeaderView.swift
|
|
|
|
// FireBoltt
|
|
|
|
//
|
|
|
|
// Created by lemo. on 2020/3/22.
|
|
|
|
// Copyright © 2020 Sheldon. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
// MARK:- 常量
|
|
|
|
fileprivate struct Metric {
|
|
|
|
static let otherColor = kHexColor(0x000000)
|
|
|
|
static let otherFont = SystemRegularFont(10)
|
|
|
|
static let backgroundColor = kHexColor(0xFBFBFB)
|
|
|
|
static let titleFont = SystemRegularFont(18)
|
|
|
|
}
|
|
|
|
|
|
|
|
class DeviceHeaderView: UIView {
|
|
|
|
|
|
|
|
lazy var commIcon: UIImageView = {
|
|
|
|
let imageView = UIImageView(image: UIImage(named: "picture_bg")).then {
|
|
|
|
addSubview($0)
|
|
|
|
}
|
|
|
|
return imageView
|
|
|
|
}()
|
|
|
|
|
|
|
|
lazy var fbdeviceNameLabel: UILabel = {
|
|
|
|
let label = UILabel().then {
|
|
|
|
$0.textColor = ThemeManagerFrieBoltt.commonTextColor
|
|
|
|
$0.font = Metric.titleFont
|
|
|
|
addSubview($0)
|
|
|
|
}
|
|
|
|
label.text = "设备名称"
|
|
|
|
return label;
|
|
|
|
}()
|
|
|
|
lazy var fbdeviceIcon: UIImageView = {
|
|
|
|
let imageView = UIImageView(image: R.image.fb_icon_device()).then {
|
|
|
|
addSubview($0)
|
|
|
|
}
|
|
|
|
return imageView
|
|
|
|
}()
|
|
|
|
lazy var fbstatusBtn: UIButton = {
|
|
|
|
let btn = UIButton(type: .custom).then {
|
|
|
|
$0.setTitleColor(Metric.otherColor, for: .normal)
|
|
|
|
$0.titleLabel?.font = Metric.otherFont
|
|
|
|
$0.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
|
|
|
|
addSubview($0)
|
|
|
|
}
|
|
|
|
btn.setImage(R.image.fb_icon_watch_notConnect(), for: .normal)
|
|
|
|
btn.setTitle(MultiLanguageKey_FB.disConnectedFB.localized, for: .normal)
|
|
|
|
btn.setImage(R.image.fb_icon_watch_connect(), for: .selected)
|
|
|
|
btn.setTitle(MultiLanguageKey_FB.coonectedFB.localized, for: .selected)
|
|
|
|
return btn
|
|
|
|
}()
|
|
|
|
lazy var fbpowerBtn: UIButton = {
|
|
|
|
let btn = UIButton(type: .custom).then {
|
|
|
|
$0.setTitleColor(Metric.otherColor, for: .normal)
|
|
|
|
$0.titleLabel?.font = Metric.otherFont;
|
|
|
|
$0.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -10)
|
|
|
|
addSubview($0)
|
|
|
|
}
|
|
|
|
btn.setImage(R.image.power_0(), for: .normal)
|
|
|
|
btn.setTitle(MultiLanguageKey_FB.powerFB.localized, for: .normal)
|
|
|
|
return btn
|
|
|
|
}()
|
|
|
|
lazy var fbsyncBtn: UIButton = {
|
|
|
|
let btn = UIButton(type: .custom).then {
|
|
|
|
$0.setTitle(MultiLanguageKey_FB.syncDataFB.localized, for: .normal)
|
|
|
|
$0.setTitleColor(kHexColor(0x33D700), for: .normal)
|
|
|
|
$0.titleLabel?.font = Metric.otherFont
|
|
|
|
addSubview($0)
|
|
|
|
}
|
|
|
|
btn.layer.cornerRadius = kScaleWidth(15)
|
|
|
|
btn.layer.borderWidth = 1
|
|
|
|
btn.borderColor = kHexColor(0x33D700)
|
|
|
|
return btn
|
|
|
|
}()
|
|
|
|
lazy var fbbottomSection: UIView = {
|
|
|
|
let view = UIView()
|
|
|
|
view.backgroundColor = kHexColor(0xFAFAFA)
|
|
|
|
addSubview(view)
|
|
|
|
return view
|
|
|
|
}()
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
setUpUI()
|
|
|
|
}
|
|
|
|
|
|
|
|
func setUpUI() {
|
|
|
|
commIcon.snp.makeConstraints { make in
|
|
|
|
make.left.equalTo(kNavBarItemMargin)
|
|
|
|
make.centerY.equalTo(self)
|
|
|
|
make.size.equalTo(CGSize(width: kScaleWidth(110), height: kScaleWidth(110)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fbstatusBtn.snp.makeConstraints { (make) in
|
|
|
|
make.left.equalTo(commIcon.snp_right).offset(50)
|
|
|
|
make.centerY.equalTo(self.snp_centerY)
|
|
|
|
}
|
|
|
|
fbpowerBtn.snp.makeConstraints { (make) in
|
|
|
|
make.left.equalTo(fbstatusBtn.snp.right).offset(kScaleWidth(13))
|
|
|
|
make.centerY.equalTo(fbstatusBtn.snp_centerY)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fbdeviceIcon.snp.makeConstraints { (make) in
|
|
|
|
make.left.equalTo(fbstatusBtn.snp_left)
|
|
|
|
make.bottom.equalTo(fbstatusBtn.snp_top).inset(-20)
|
|
|
|
make.width.height.equalTo(kScaleWidth(30))
|
|
|
|
}
|
|
|
|
fbdeviceNameLabel.snp.makeConstraints { (make) in
|
|
|
|
make.centerY.equalTo(fbdeviceIcon.snp.centerY)
|
|
|
|
make.left.equalTo(fbdeviceIcon.snp.right).offset(kScaleWidth(10))
|
|
|
|
}
|
|
|
|
|
|
|
|
fbsyncBtn.snp.makeConstraints { (make) in
|
|
|
|
make.top.equalTo(fbstatusBtn.snp.bottom).offset(20)
|
|
|
|
make.left.equalTo(fbdeviceIcon.snp_left)
|
|
|
|
make.width.equalTo(kScaleWidth(65))
|
|
|
|
make.height.equalTo(kScaleWidth(30))
|
|
|
|
}
|
|
|
|
fbbottomSection.snp.makeConstraints { (make) in
|
|
|
|
make.width.equalToSuperview()
|
|
|
|
make.bottom.equalToSuperview()
|
|
|
|
make.height.equalTo(10)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|