mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 22:23:44 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
@objc
|
||||
protocol SettingsTableViewSwitchCellDelegate {
|
||||
func switchCell(_ cell: SettingsTableViewSwitchCell, didChangeValue value: Bool)
|
||||
}
|
||||
|
||||
@objc
|
||||
class SettingsTableViewSwitchCell: MWMTableViewCell {
|
||||
|
||||
let switchButton = UISwitch()
|
||||
|
||||
@IBOutlet weak var delegate: SettingsTableViewSwitchCellDelegate?
|
||||
|
||||
@objc
|
||||
var isEnabled = true {
|
||||
didSet {
|
||||
styleTitle()
|
||||
switchButton.isUserInteractionEnabled = isEnabled
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
var isOn: Bool {
|
||||
get { return switchButton.isOn }
|
||||
set { switchButton.isOn = newValue }
|
||||
}
|
||||
|
||||
@objc
|
||||
func setOn(_ isOn: Bool, animated: Bool) {
|
||||
switchButton.setOn(isOn, animated: animated)
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
setupCell()
|
||||
}
|
||||
|
||||
@objc
|
||||
func config(delegate: SettingsTableViewSwitchCellDelegate, title: String, isOn: Bool) {
|
||||
backgroundColor = UIColor.white()
|
||||
|
||||
self.delegate = delegate
|
||||
|
||||
self.textLabel?.text = title
|
||||
styleTitle()
|
||||
|
||||
switchButton.isOn = isOn
|
||||
}
|
||||
|
||||
private func setupCell() {
|
||||
setStyle(.background)
|
||||
styleTitle()
|
||||
textLabel?.numberOfLines = 0
|
||||
textLabel?.lineBreakMode = .byWordWrapping
|
||||
|
||||
switchButton.onTintColor = UIColor.linkBlue()
|
||||
switchButton.addTarget(self, action: #selector(switchChanged), for: .valueChanged)
|
||||
accessoryView = switchButton
|
||||
}
|
||||
|
||||
@objc
|
||||
private func switchChanged() {
|
||||
delegate?.switchCell(self, didChangeValue: switchButton.isOn)
|
||||
}
|
||||
|
||||
private func styleTitle() {
|
||||
textLabel?.setFontStyleAndApply(.regular17, color: isEnabled ? .blackPrimary : .blackSecondary)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user