refactored reset methods

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-05-08 14:40:11 -05:00
parent e82a94304c
commit bd902434ef
17 changed files with 83 additions and 24 deletions

View File

@ -66,16 +66,18 @@ open class Badge: View {
}
open override func reset() {
super.reset()
super.reset()
shouldUpdateView = false
label.reset()
label.lineBreakMode = .byTruncatingTail
label.textPosition = .left
label.textStyle = .boldBodySmall
fillColor = .red
text = ""
maxWidth = nil
numberOfLines = 1
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -132,9 +132,12 @@ open class Button: ButtonBase, Useable {
open override func reset() {
super.reset()
shouldUpdateView = false
use = .primary
width = nil
size = .large
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -45,7 +45,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open var shouldUpdateView: Bool = true
open var shouldUpdateView: Bool = true
open var availableSizes: [ButtonSize] { [] }
@ -136,10 +136,13 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
}
open func reset() {
shouldUpdateView = false
surface = .light
disabled = false
text = nil
accessibilityCustomActions = []
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -88,10 +88,14 @@ open class TextLink: ButtonBase {
open override func reset() {
super.reset()
shouldUpdateView = false
text = nil
size = .large
accessibilityCustomActions = []
isAccessibilityElement = true
accessibilityTraits = .link
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -100,6 +100,7 @@ open class TextLinkCaret: ButtonBase {
open override func reset() {
super.reset()
iconPosition = .right
text = nil
}
//--------------------------------------------------

View File

@ -252,6 +252,7 @@ open class Checkbox: Control, Errorable, Changeable {
open override func reset() {
super.reset()
shouldUpdateView = false
label.reset()
childLabel.reset()
errorLabel.reset()
@ -272,7 +273,8 @@ open class Checkbox: Control, Errorable, Changeable {
value = nil
isSelected = false
updateSelector()
shouldUpdateView = true
setNeedsUpdate()
}
/// This will checkbox the state of the Selector and execute the actionBlock if provided.

View File

@ -23,7 +23,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
//--------------------------------------------------
private var initialSetupPerformed = false
open var shouldUpdateView: Bool = true
open var shouldUpdateView: Bool = true
open var useAttributedText: Bool = false
@ -102,6 +102,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
open func setup() {}
open func reset() {
shouldUpdateView = false
surface = .light
disabled = false
attributes = nil
@ -111,6 +112,8 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
attributedText = nil
numberOfLines = 0
backgroundColor = .clear
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -231,6 +231,8 @@ open class Notification: View {
open override func reset() {
super.reset()
shouldUpdateView = false
titleLabel.reset()
titleLabel.text = ""
titleLabel.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall
@ -255,6 +257,9 @@ open class Notification: View {
layout = .vertical
hideCloseButton = false
fullBleed = false
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -204,6 +204,7 @@ open class RadioBox: Control, Changeable {
open override func reset() {
super.reset()
shouldUpdateView = false
textLabel.reset()
subTextLabel.reset()
subTextRightLabel.reset()
@ -227,7 +228,8 @@ open class RadioBox: Control, Changeable {
isSelected = false
updateSelector()
shouldUpdateView = true
setNeedsUpdate()
}
/// This will radioBox the state of the Selector and execute the actionBlock if provided.

View File

@ -240,6 +240,7 @@ open class RadioButton: Control, Errorable, Changeable {
open override func reset() {
super.reset()
shouldUpdateView = false
label.reset()
childLabel.reset()
errorLabel.reset()
@ -261,7 +262,9 @@ open class RadioButton: Control, Errorable, Changeable {
isSelected = false
updateSelector()
shouldUpdateView = true
setNeedsUpdate()
}
/// This will checkbox the state of the Selector and execute the actionBlock if provided.

View File

@ -91,7 +91,7 @@ open class RadioSwatch: Control {
open override func reset() {
super.reset()
shouldUpdateView = false
fillImage = nil
text = ""
primaryColor = nil
@ -99,7 +99,8 @@ open class RadioSwatch: Control {
strikethrough = false
inputId = nil
value = nil
shouldUpdateView = true
setNeedsUpdate()
setNeedsDisplay()
}

View File

@ -191,7 +191,17 @@ open class TileContainer: Control {
open override func reset() {
super.reset()
shouldUpdateView = false
color = .white
padding = .padding4X
aspectRatio = .ratio1x1
imageFallbackColor = .light
width = nil
height = nil
showBorder = false
showDropShadows = false
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -256,15 +256,17 @@ open class Tilelet: TileContainer {
}
open override func reset() {
shouldUpdateView = false
aspectRatio = .none
color = .black
//models
badgeModel = nil
titleModel = nil
subTitleModel = nil
descriptiveIconModel = nil
directionalIconModel = nil
directionalIconModel = nil
shouldUpdateView = true
setNeedsUpdate()
}
//--------------------------------------------------

View File

@ -176,7 +176,11 @@ open class TitleLockup: View {
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
//style
open var otherTextStyle: OtherTextStyle = UIDevice.isIPad ? .bodyLarge : .bodyMedium { didSet { setNeedsUpdate() }}
open var otherTextStyle: OtherTextStyle = UIDevice.isIPad ? .bodyLarge : .bodyMedium {
didSet {
setNeedsUpdate()
}
}
//first row
open var eyebrowLabel = Label().with {
@ -218,17 +222,14 @@ open class TitleLockup: View {
open override func reset() {
super.reset()
titleLabel.reset()
eyebrowLabel.reset()
subTitleLabel.reset()
shouldUpdateView = false
textPosition = .left
eyebrowModel = nil
titleModel = 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 titleTextIsEmpty = true
var subTitleTextIsEmpty = true
if let eyebrowModel, !eyebrowModel.text.isEmpty {
eyebrowTextIsEmpty = false
eyebrowLabel.textPosition = allLabelsTextPosition

View File

@ -272,9 +272,9 @@ open class Toggle: Control, Changeable {
open override func reset() {
super.reset()
shouldUpdateView = false
label.reset()
isOn = false
isAnimated = true
showText = false
onText = "On"
@ -284,9 +284,10 @@ open class Toggle: Control, Changeable {
textPosition = .left
inputId = nil
value = nil
toggleView.backgroundColor = toggleColorConfiguration.getColor(self)
knobView.backgroundColor = knobColorConfiguration.getColor(self)
shouldUpdateView = true
setNeedsUpdate()
}
/// This will toggle the state of the Toggle and execute the actionBlock if provided.

View File

@ -138,12 +138,15 @@ open class Tooltip: Control, TooltipLaunchable {
open override func reset() {
super.reset()
shouldUpdateView = false
size = .medium
title = ""
content = ""
fillColor = .primary
closeButtonText = "Close"
imageView.image = nil
shouldUpdateView = true
setNeedsUpdate()
}
open override func updateView() {

View File

@ -40,7 +40,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
open var tooltipContent: String = "" { didSet { setNeedsUpdate() } }
open var tooltipYOffset: CGFloat = 0 { didSet { setNeedsUpdate() } }
//--------------------------------------------------
// MARK: - Overrides
//--------------------------------------------------
@ -75,6 +74,20 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
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()
}
}