ArchiveSettingCell.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // ArchiveSettingCell.swift
  3. // Bark
  4. //
  5. // Created by huangfeng on 2020/5/29.
  6. // Copyright © 2020 Fin. All rights reserved.
  7. //
  8. import UIKit
  9. class ArchiveSettingCell: BaseTableViewCell<ArchiveSettingCellViewModel> {
  10. let switchButton: UISwitch = {
  11. let btn = UISwitch()
  12. return btn
  13. }()
  14. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  15. super.init(style: style, reuseIdentifier: reuseIdentifier)
  16. self.selectionStyle = .none
  17. self.backgroundColor = BKColor.background.secondary
  18. self.textLabel?.text = NSLocalizedString("defaultArchiveSettings")
  19. contentView.addSubview(switchButton)
  20. switchButton.snp.makeConstraints { make in
  21. make.right.equalToSuperview().offset(-16)
  22. make.centerY.equalToSuperview()
  23. }
  24. }
  25. @available(*, unavailable)
  26. required init?(coder aDecoder: NSCoder) {
  27. fatalError("init(coder:) has not been implemented")
  28. }
  29. override func bindViewModel(model: ArchiveSettingCellViewModel) {
  30. super.bindViewModel(model: model)
  31. (self.switchButton.rx.isOn <-> model.on)
  32. .disposed(by: rx.reuseBag)
  33. }
  34. }