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.
 
 
 

108 lines
3.8 KiB

//
// WeChatSportViewControllerss.swift
// Lookfit
//
// Created by lemo. on 2020/10/27.
// Copyright © 2020 Sheldon. All rights reserved.
//
import UIKit
class WeChatSportViewControllerss: ViewController {
lazy var titleLabel: UILabel = {
let view = UILabel()
view.text = MultiLanguageKey.wechatSportStep.localized
view.font = SystemMediumFont(20)
view.textColor = kHexColor(0x444444)
view.numberOfLines = 0
view.textAlignment = .center
return view
}()
lazy var qrCodeImage: UIImageView = {
let view = UIImageView()
view.layer.cornerRadius = 10
view.layer.masksToBounds = true
return view
}()
lazy var saveBtn: UIButton = {
let view = UIButton()
view.setTitle(MultiLanguageKey.saveQrCode.localized, for: .normal)
view.setTitleColor(kHexColor(0x414141), for: .normal)
view.titleLabel?.font = SystemMediumFont(14)
view.titleLabel?.adjustsFontSizeToFitWidth = true
view.layer.cornerRadius = 20
view.layer.borderColor = kHexColor(0x000000).cgColor
view.layer.borderWidth = 1
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
}
override func makeUI() {
super.makeUI()
view.addSubview(titleLabel)
titleLabel.snp.makeConstraints { (make) in
make.centerX.equalToSuperview()
make.top.equalTo(20)
make.left.equalTo(20)
make.right.equalTo(-20)
}
//
let titles = [MultiLanguageKey.wechatSportStep1.localized, MultiLanguageKey.wechatSportStep2.localized, MultiLanguageKey.wechatSportStep3.localized, MultiLanguageKey.wechatSportStep4.localized]
let images = [R.image.wechatSportStep1(), R.image.wechatSportStep2(), R.image.wechatSportStep3(), R.image.wechatSportStep4()]
for (index, title) in titles.enumerated() {
let btn = stepBtn(image: images[index], title: title)
view.addSubview(btn)
btn.snp.makeConstraints { (make) in
make.top.equalTo(titleLabel.snp.bottom).offset(30 + (index * (60 + 10)))
make.centerX.equalToSuperview()
make.left.equalTo(30)
make.right.equalTo(-30)
}
}
//
view.addSubview(saveBtn)
saveBtn.snp.makeConstraints { (make) in
make.centerX.equalToSuperview()
make.bottom.equalTo(-20)
make.height.equalTo(40)
make.width.equalTo(120)
}
//
view.addSubview(qrCodeImage)
qrCodeImage.snp.makeConstraints { (make) in
make.centerX.equalToSuperview()
make.bottom.equalTo(saveBtn.snp.top).offset(-30)
make.width.height.equalTo(kScaleWidth(120))
}
}
private func stepBtn(image: UIImage?, title: String) -> UIView {
let bgImageView = UIImageView(image: image)
let titleLabel = UILabel()
titleLabel.textColor = kHexColor(0x414141)
titleLabel.font = SystemMediumFont(12)
titleLabel.text = title
titleLabel.numberOfLines = 0
titleLabel.adjustsFontSizeToFitWidth = true
bgImageView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { (make) in
make.centerY.equalToSuperview().offset(-5)
make.left.equalTo(45)
make.right.equalToSuperview()
}
return bgImageView
}
override func bindViewModel() {
guard let viewModel = viewModel as? WeChatSportViewModelss else { return }
let output = viewModel.transform(input: WeChatSportViewModelss.Input(saveQrCode: saveBtn.rx.tap.asObservable()))
output.qrCodeImage.asDriver()
.drive(qrCodeImage.rx.image)
.disposed(by: rx.disposeBag)
}
}