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.
94 lines
0 B
94 lines
0 B
1 year ago
|
//
|
||
1 year ago
|
// DialPushViewControllers.swift
|
||
1 year ago
|
// FireBoltt
|
||
1 year ago
|
//
|
||
|
// Created by lemo. on 2020/4/29.
|
||
|
// Copyright © 2020 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
// MARK:- 复用
|
||
|
fileprivate enum Resuable {
|
||
|
static let dialCell = ReusableCell<DialPushCell>(nibName: "DialPushCell")
|
||
|
}
|
||
|
|
||
|
// MARK:- 常量
|
||
|
fileprivate struct Metric {
|
||
|
static let itemW = (kScreenW - (kNavBarItemMargin * 4)) / 3.0
|
||
|
static let itemSize: CGSize = CGSize(width: itemW, height: itemW)
|
||
|
}
|
||
|
|
||
1 year ago
|
class DialPushViewControllers: ViewController {
|
||
1 year ago
|
|
||
|
|
||
|
|
||
|
private lazy var rxDataSource: RxCollectionViewSectionedReloadDataSource = {
|
||
|
return RxCollectionViewSectionedReloadDataSource
|
||
|
<SectionModel<String, DialModel>>(
|
||
|
configureCell: { (dataSource, collectionView, indexPath, element) in
|
||
|
let cell = collectionView.dequeue(Resuable.dialCell, for: indexPath)
|
||
|
|
||
|
let path = element.icon.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)
|
||
|
let url = URL.init(string: path!)
|
||
|
print(url as Any);
|
||
|
cell.dilaImageView.kf.setImage(with: url)
|
||
|
return cell
|
||
|
})
|
||
|
}()
|
||
|
private lazy var collectionView: UICollectionView = {
|
||
|
let flowLayout = UICollectionViewFlowLayout()
|
||
|
flowLayout.headerReferenceSize = CGSize(width: kScreenW, height: 34)
|
||
|
flowLayout.minimumInteritemSpacing = kNavBarItemMargin
|
||
|
flowLayout.itemSize = Metric.itemSize
|
||
|
flowLayout.sectionInset = UIEdgeInsets(top: 0, left: kNavBarItemMargin, bottom: kNavBarItemMargin, right: kNavBarItemMargin)
|
||
|
let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: flowLayout).then {
|
||
|
$0.backgroundColor = .white
|
||
|
$0.showsVerticalScrollIndicator = false
|
||
|
$0.register(Resuable.dialCell)
|
||
|
view.addSubview($0)
|
||
|
}
|
||
|
return collectionView
|
||
|
}()
|
||
|
|
||
|
override func viewDidLoad() {
|
||
|
super.viewDidLoad()
|
||
|
|
||
|
// Do any additional setup after loading the view.
|
||
|
|
||
1 year ago
|
if let deviceInfo = UserDefaultsManagerFrieBoltt.getDeviceInfo() {
|
||
1 year ago
|
switch deviceInfo.otaPlan {
|
||
|
case .jerry:
|
||
1 year ago
|
BluetoothFireBoltt.shareInstance()?.openDialFile()
|
||
1 year ago
|
default:
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
// override func viewDidDisappear(_ animated: Bool) {
|
||
|
// super.viewDidDisappear(animated)
|
||
|
// if Bluetooth.shareInstance()!.isConnected == false {
|
||
|
// Bluetooth.shareInstance()?.startAndStopReconnect(true)
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
override func makeUI() {
|
||
|
super.makeUI()
|
||
|
collectionView.snp.makeConstraints { (make) in
|
||
|
make.edges.equalToSuperview()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override func bindViewModel() {
|
||
|
super.bindViewModel()
|
||
1 year ago
|
guard let viewModel = viewModel as? DialPushViewModels else { return }
|
||
1 year ago
|
viewModel.relay
|
||
|
.bind(to: collectionView.rx.items(dataSource: rxDataSource))
|
||
|
.disposed(by: rx.disposeBag)
|
||
1 year ago
|
let _ = viewModel.transform(input: DialPushViewModels.Input(selection: collectionView.rx.modelSelected(DialModel.self).asObservable()))
|
||
1 year ago
|
}
|
||
|
|
||
|
}
|