the latest switch.

This commit is contained in:
Kevin G Christiano 2019-12-10 08:54:01 -05:00
parent 1668fb8c32
commit dd47707064

View File

@ -11,7 +11,12 @@ import UIKit
public typealias ValueChangeBlock = () -> () public typealias ValueChangeBlock = () -> ()
/**
A custom implementation of Apple's UISwitch.
Track: The background of the switch control.
Thumb: The circular indicator that slides on the track.
*/
@objcMembers open class Switch: Control, MVMCoreUIViewConstrainingProtocol, FormValidationFormFieldProtocol { @objcMembers open class Switch: Control, MVMCoreUIViewConstrainingProtocol, FormValidationFormFieldProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -21,10 +26,14 @@ public typealias ValueChangeBlock = () -> ()
public var thumbTintColor: (on: UIColor?, off: UIColor?)? = (on: .white, off: .white) public var thumbTintColor: (on: UIColor?, off: UIColor?)? = (on: .white, off: .white)
public var disabledTintColor: (track: UIColor?, thumb: UIColor?)? = (track: .mfSilver(), thumb: .white) public var disabledTintColor: (track: UIColor?, thumb: UIColor?)? = (track: .mfSilver(), thumb: .white)
var shouldTouchToSwitch = false private var valueShouldChange = false
var valueChangedBlock: ValueChangeBlock? private var canChangeValue = false
var actionBlock: ValueChangeBlock? private var shouldTouchToSwitch = false
private var valueChangedBlock: ValueChangeBlock?
private var actionBlock: ValueChangeBlock?
// Sizes are from InVision design specs.
static let trackSize = CGSize(width: 46, height: 24) static let trackSize = CGSize(width: 46, height: 24)
static let thumbSize = CGSize(width: 22, height: 22) static let thumbSize = CGSize(width: 22, height: 22)
@ -32,9 +41,6 @@ public typealias ValueChangeBlock = () -> ()
private var thumbView = View() private var thumbView = View()
private var valueShouldChange = false
private var canChangeValue = false
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Computed Properties // MARK: - Computed Properties
//-------------------------------------------------- //--------------------------------------------------