refactored reset methods
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
e82a94304c
commit
bd902434ef
@ -66,16 +66,18 @@ open class Badge: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
label.reset()
|
label.reset()
|
||||||
label.lineBreakMode = .byTruncatingTail
|
label.lineBreakMode = .byTruncatingTail
|
||||||
label.textPosition = .left
|
label.textPosition = .left
|
||||||
label.textStyle = .boldBodySmall
|
label.textStyle = .boldBodySmall
|
||||||
|
|
||||||
fillColor = .red
|
fillColor = .red
|
||||||
text = ""
|
text = ""
|
||||||
maxWidth = nil
|
maxWidth = nil
|
||||||
numberOfLines = 1
|
numberOfLines = 1
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -132,9 +132,12 @@ open class Button: ButtonBase, Useable {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
use = .primary
|
use = .primary
|
||||||
width = nil
|
width = nil
|
||||||
size = .large
|
size = .large
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -45,7 +45,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var shouldUpdateView: Bool = true
|
open var shouldUpdateView: Bool = true
|
||||||
|
|
||||||
open var availableSizes: [ButtonSize] { [] }
|
open var availableSizes: [ButtonSize] { [] }
|
||||||
|
|
||||||
@ -136,10 +136,13 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func reset() {
|
open func reset() {
|
||||||
|
shouldUpdateView = false
|
||||||
surface = .light
|
surface = .light
|
||||||
disabled = false
|
disabled = false
|
||||||
text = nil
|
text = nil
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -88,10 +88,14 @@ open class TextLink: ButtonBase {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
|
text = nil
|
||||||
size = .large
|
size = .large
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
isAccessibilityElement = true
|
isAccessibilityElement = true
|
||||||
accessibilityTraits = .link
|
accessibilityTraits = .link
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -100,6 +100,7 @@ open class TextLinkCaret: ButtonBase {
|
|||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
iconPosition = .right
|
iconPosition = .right
|
||||||
|
text = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -252,6 +252,7 @@ open class Checkbox: Control, Errorable, Changeable {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
label.reset()
|
label.reset()
|
||||||
childLabel.reset()
|
childLabel.reset()
|
||||||
errorLabel.reset()
|
errorLabel.reset()
|
||||||
@ -272,7 +273,8 @@ open class Checkbox: Control, Errorable, Changeable {
|
|||||||
value = nil
|
value = nil
|
||||||
isSelected = false
|
isSelected = false
|
||||||
|
|
||||||
updateSelector()
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
|
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
|
|
||||||
open var shouldUpdateView: Bool = true
|
open var shouldUpdateView: Bool = true
|
||||||
|
|
||||||
open var useAttributedText: Bool = false
|
open var useAttributedText: Bool = false
|
||||||
|
|
||||||
@ -102,6 +102,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
open func setup() {}
|
open func setup() {}
|
||||||
|
|
||||||
open func reset() {
|
open func reset() {
|
||||||
|
shouldUpdateView = false
|
||||||
surface = .light
|
surface = .light
|
||||||
disabled = false
|
disabled = false
|
||||||
attributes = nil
|
attributes = nil
|
||||||
@ -111,6 +112,8 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
attributedText = nil
|
attributedText = nil
|
||||||
numberOfLines = 0
|
numberOfLines = 0
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -231,6 +231,8 @@ open class Notification: View {
|
|||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
|
shouldUpdateView = false
|
||||||
|
|
||||||
titleLabel.reset()
|
titleLabel.reset()
|
||||||
titleLabel.text = ""
|
titleLabel.text = ""
|
||||||
titleLabel.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall
|
titleLabel.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall
|
||||||
@ -255,6 +257,9 @@ open class Notification: View {
|
|||||||
layout = .vertical
|
layout = .vertical
|
||||||
hideCloseButton = false
|
hideCloseButton = false
|
||||||
fullBleed = false
|
fullBleed = false
|
||||||
|
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -204,6 +204,7 @@ open class RadioBox: Control, Changeable {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
textLabel.reset()
|
textLabel.reset()
|
||||||
subTextLabel.reset()
|
subTextLabel.reset()
|
||||||
subTextRightLabel.reset()
|
subTextRightLabel.reset()
|
||||||
@ -227,7 +228,8 @@ open class RadioBox: Control, Changeable {
|
|||||||
|
|
||||||
isSelected = false
|
isSelected = false
|
||||||
|
|
||||||
updateSelector()
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This will radioBox the state of the Selector and execute the actionBlock if provided.
|
/// This will radioBox the state of the Selector and execute the actionBlock if provided.
|
||||||
|
|||||||
@ -240,6 +240,7 @@ open class RadioButton: Control, Errorable, Changeable {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
label.reset()
|
label.reset()
|
||||||
childLabel.reset()
|
childLabel.reset()
|
||||||
errorLabel.reset()
|
errorLabel.reset()
|
||||||
@ -261,7 +262,9 @@ open class RadioButton: Control, Errorable, Changeable {
|
|||||||
|
|
||||||
isSelected = false
|
isSelected = false
|
||||||
|
|
||||||
updateSelector()
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
|
/// This will checkbox the state of the Selector and execute the actionBlock if provided.
|
||||||
|
|||||||
@ -91,7 +91,7 @@ open class RadioSwatch: Control {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
fillImage = nil
|
fillImage = nil
|
||||||
text = ""
|
text = ""
|
||||||
primaryColor = nil
|
primaryColor = nil
|
||||||
@ -99,7 +99,8 @@ open class RadioSwatch: Control {
|
|||||||
strikethrough = false
|
strikethrough = false
|
||||||
inputId = nil
|
inputId = nil
|
||||||
value = nil
|
value = nil
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -191,7 +191,17 @@ open class TileContainer: Control {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
|
color = .white
|
||||||
|
padding = .padding4X
|
||||||
|
aspectRatio = .ratio1x1
|
||||||
|
imageFallbackColor = .light
|
||||||
|
width = nil
|
||||||
|
height = nil
|
||||||
|
showBorder = false
|
||||||
|
showDropShadows = false
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -256,15 +256,17 @@ open class Tilelet: TileContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
|
shouldUpdateView = false
|
||||||
aspectRatio = .none
|
aspectRatio = .none
|
||||||
color = .black
|
color = .black
|
||||||
|
|
||||||
//models
|
//models
|
||||||
badgeModel = nil
|
badgeModel = nil
|
||||||
titleModel = nil
|
titleModel = nil
|
||||||
subTitleModel = nil
|
subTitleModel = nil
|
||||||
descriptiveIconModel = nil
|
descriptiveIconModel = nil
|
||||||
directionalIconModel = nil
|
directionalIconModel = nil
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -176,7 +176,11 @@ open class TitleLockup: View {
|
|||||||
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
|
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
//style
|
//style
|
||||||
open var otherTextStyle: OtherTextStyle = UIDevice.isIPad ? .bodyLarge : .bodyMedium { didSet { setNeedsUpdate() }}
|
open var otherTextStyle: OtherTextStyle = UIDevice.isIPad ? .bodyLarge : .bodyMedium {
|
||||||
|
didSet {
|
||||||
|
setNeedsUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//first row
|
//first row
|
||||||
open var eyebrowLabel = Label().with {
|
open var eyebrowLabel = Label().with {
|
||||||
@ -218,17 +222,14 @@ open class TitleLockup: View {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
titleLabel.reset()
|
shouldUpdateView = false
|
||||||
eyebrowLabel.reset()
|
|
||||||
subTitleLabel.reset()
|
|
||||||
|
|
||||||
textPosition = .left
|
textPosition = .left
|
||||||
|
|
||||||
eyebrowModel = nil
|
eyebrowModel = nil
|
||||||
titleModel = nil
|
titleModel = nil
|
||||||
subTitleModel = nil
|
subTitleModel = nil
|
||||||
otherTextStyle = .bodyLarge
|
otherTextStyle = UIDevice.isIPad ? .bodyLarge : .bodyMedium
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -241,7 +242,7 @@ open class TitleLockup: View {
|
|||||||
var eyebrowTextIsEmpty = true
|
var eyebrowTextIsEmpty = true
|
||||||
var titleTextIsEmpty = true
|
var titleTextIsEmpty = true
|
||||||
var subTitleTextIsEmpty = true
|
var subTitleTextIsEmpty = true
|
||||||
|
|
||||||
if let eyebrowModel, !eyebrowModel.text.isEmpty {
|
if let eyebrowModel, !eyebrowModel.text.isEmpty {
|
||||||
eyebrowTextIsEmpty = false
|
eyebrowTextIsEmpty = false
|
||||||
eyebrowLabel.textPosition = allLabelsTextPosition
|
eyebrowLabel.textPosition = allLabelsTextPosition
|
||||||
|
|||||||
@ -272,9 +272,9 @@ open class Toggle: Control, Changeable {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
label.reset()
|
label.reset()
|
||||||
isOn = false
|
isOn = false
|
||||||
|
|
||||||
isAnimated = true
|
isAnimated = true
|
||||||
showText = false
|
showText = false
|
||||||
onText = "On"
|
onText = "On"
|
||||||
@ -284,9 +284,10 @@ open class Toggle: Control, Changeable {
|
|||||||
textPosition = .left
|
textPosition = .left
|
||||||
inputId = nil
|
inputId = nil
|
||||||
value = nil
|
value = nil
|
||||||
|
|
||||||
toggleView.backgroundColor = toggleColorConfiguration.getColor(self)
|
toggleView.backgroundColor = toggleColorConfiguration.getColor(self)
|
||||||
knobView.backgroundColor = knobColorConfiguration.getColor(self)
|
knobView.backgroundColor = knobColorConfiguration.getColor(self)
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This will toggle the state of the Toggle and execute the actionBlock if provided.
|
/// This will toggle the state of the Toggle and execute the actionBlock if provided.
|
||||||
|
|||||||
@ -138,12 +138,15 @@ open class Tooltip: Control, TooltipLaunchable {
|
|||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
size = .medium
|
size = .medium
|
||||||
title = ""
|
title = ""
|
||||||
content = ""
|
content = ""
|
||||||
fillColor = .primary
|
fillColor = .primary
|
||||||
closeButtonText = "Close"
|
closeButtonText = "Close"
|
||||||
imageView.image = nil
|
imageView.image = nil
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
|
|||||||
@ -40,7 +40,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
|
|
||||||
open var tooltipContent: String = "" { didSet { setNeedsUpdate() } }
|
open var tooltipContent: String = "" { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var tooltipYOffset: CGFloat = 0 { didSet { setNeedsUpdate() } }
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -75,6 +74,20 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
label.addTooltip(model: .init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, content: tooltipContent))
|
label.addTooltip(model: .init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, content: tooltipContent))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func reset() {
|
||||||
|
super.reset()
|
||||||
|
shouldUpdateView = false
|
||||||
|
labelText = nil
|
||||||
|
labelAttributes = nil
|
||||||
|
labelTextStyle = .defaultStyle
|
||||||
|
labelTextPosition = .left
|
||||||
|
tooltipCloseButtonText = "Close"
|
||||||
|
tooltipTitle = ""
|
||||||
|
tooltipContent = ""
|
||||||
|
shouldUpdateView = true
|
||||||
|
setNeedsUpdate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user