Merge branch 'bugfix/setDefaults' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios.git into mbruce/bugfix

This commit is contained in:
Matt Bruce 2024-08-15 14:42:49 -05:00
commit c534072a12
11 changed files with 79 additions and 43 deletions

View File

@ -111,10 +111,14 @@ open class SelectorBase: Control, SelectorControlable {
open override func setDefaults() {
super.setDefaults()
showError = false
onClick = { control in
control.toggle()
}
onChange = nil
bridge_accessibilityLabelBlock = { [weak self] in
guard let self else { return "" }
return "\(Self.self)\(showError ? ", error" : "")"

View File

@ -123,6 +123,7 @@ open class SelectorGroupBase<SelectorItemType: Groupable>: Control, SelectorGrou
open override func setDefaults() {
super.setDefaults()
onChange = nil
items = []
}
/// Handler for the Group to override on a select event.
@ -137,13 +138,6 @@ open class SelectorGroupBase<SelectorItemType: Groupable>: Control, SelectorGrou
self?.sendActions(for: .valueChanged)
}
}
/// Resets to default settings.
open override func reset() {
super.reset()
items.forEach{ $0.reset() }
setItemsActions()
}
}

View File

@ -117,10 +117,11 @@ open class Breadcrumbs: View {
containerView.pinToSuperView()
}
/// Resets to default settings.
open override func reset() {
super.reset()
breadcrumbs.forEach { $0.reset() }
open override func setDefaults() {
super.setDefaults()
breadcrumbs = []
breadcrumbModels = []
isEnabled = true
}
/// Used to make changes to the View based off a change events or from local properties.

View File

@ -173,6 +173,7 @@ open class ButtonGroup: View {
rowQuantityTablet = 0
alignment = .center
childWidth = nil
buttons = []
}
open override func reset() {

View File

@ -106,14 +106,15 @@ open class CarouselScrollbar: View {
/// A callback when the scrubber position changes. Passes parameters (position).
open var onScrubberDrag: ((Int) -> Void)? {
get { nil }
set {
didSet {
onScrubberDragCancellable?.cancel()
if let newValue {
if let onScrubberDrag {
onScrubberDragCancellable = onScrubberDragPublisher
.sink { c in
newValue(c)
onScrubberDrag(c)
}
} else {
onScrubberDragCancellable = nil
}
}
}
@ -124,14 +125,15 @@ open class CarouselScrollbar: View {
/// A callback when the thumb move forward. Passes parameters (position).
open var onMoveForward: ((Int) -> Void)? {
get { nil }
set {
didSet {
onMoveForwardCancellable?.cancel()
if let newValue {
if let onMoveForward {
onMoveForwardCancellable = onMoveForwardPublisher
.sink { c in
newValue(c)
onMoveForward(c)
}
} else {
onMoveForwardCancellable = nil
}
}
}
@ -142,14 +144,15 @@ open class CarouselScrollbar: View {
/// A callback when the thumb move backward. Passes parameters (position).
open var onMoveBackward: ((Int) -> Void)? {
get { nil }
set {
didSet {
onMoveBackwardCancellable?.cancel()
if let newValue {
if let onMoveBackward {
onMoveBackwardCancellable = onMoveBackwardPublisher
.sink { c in
newValue(c)
onMoveBackward(c)
}
} else {
onMoveBackwardCancellable = nil
}
}
}
@ -160,14 +163,15 @@ open class CarouselScrollbar: View {
/// A callback when the thumb touch start. Passes parameters (position).
open var onThumbTouchStart: ((Int) -> Void)? {
get { nil }
set {
didSet {
onThumbTouchStartCancellable?.cancel()
if let newValue {
if let onThumbTouchStart {
onThumbTouchStartCancellable = onThumbTouchStartPublisher
.sink { c in
newValue(c)
onThumbTouchStart(c)
}
} else {
onThumbTouchStartCancellable = nil
}
}
}
@ -178,14 +182,15 @@ open class CarouselScrollbar: View {
/// A callback when the thumb touch end. Passes parameters (position).
open var onThumbTouchEnd: ((Int) -> Void)? {
get { nil }
set {
didSet {
onThumbTouchEndCancellable?.cancel()
if let newValue {
if let onThumbTouchEnd {
onThumbTouchEndCancellable = onThumbTouchEndPublisher
.sink { c in
newValue(c)
onThumbTouchEnd(c)
}
} else {
onThumbTouchEndCancellable = nil
}
}
}
@ -294,6 +299,19 @@ open class CarouselScrollbar: View {
thumbView.layer.addSublayer(thumbViewLayer)
}
open override func setDefaults() {
super.setDefaults()
onMoveForward = nil
onMoveBackward = nil
onScrubberDrag = nil
onThumbTouchEnd = nil
onThumbTouchStart = nil
layout = .oneUP
numberOfSlides = 1
totalPositions = 1
position = 1
}
open override func updateView() {
super.updateView()
trackView.backgroundColor = trackColorConfiguration.getColor(surface)

View File

@ -62,6 +62,11 @@ open class Checkbox: SelectorBase {
selectorColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forState: .selected)
}
open override func setDefaults() {
super.setDefaults()
isAnimated = false
}
/// This will change the state of the Selector and execute the actionBlock if provided.
open override func toggle() {
guard isEnabled else { return }

View File

@ -87,6 +87,12 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
mainStackView.spacing = VDSLayout.space6X
}
open override func setDefaults() {
super.setDefaults()
showError = false
inputId = nil
}
public override func didSelect(_ selectedControl: CheckboxItem) {
selectedControl.toggle()
if selectedControl.isSelected, showError{

View File

@ -56,6 +56,11 @@ open class CheckboxItem: SelectorItemBase<Checkbox> {
print(foo.customView.isAnimated)
}
open override func setDefaults() {
super.setDefaults()
isAnimated = false
}
/// Used to make changes to the View based off a change events or from local properties.
open override func updateView() {
selectorView.isAnimated = isAnimated

View File

@ -82,24 +82,15 @@ open class DropdownSelect: EntryFieldBase<String> {
open var inlineDisplayLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
$0.textAlignment = .left
$0.textStyle = .boldBodyLarge
$0.numberOfLines = 1
$0.sizeToFit()
}
open var selectedOptionLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
$0.textAlignment = .left
$0.textStyle = .bodyLarge
$0.numberOfLines = 1
}
open var dropdownField = UITextField().with {
$0.translatesAutoresizingMaskIntoConstraints = false
$0.tintColor = UIColor.clear
$0.font = TextStyle.bodyLarge.font
}
open var optionsPicker = UIPickerView()
@ -163,13 +154,25 @@ open class DropdownSelect: EntryFieldBase<String> {
super.setDefaults()
showInlineLabel = false
selectId = nil
inlineDisplayLabel.textAlignment = .left
inlineDisplayLabel.textStyle = .boldBodyLarge
inlineDisplayLabel.numberOfLines = 1
selectedOptionLabel.textAlignment = .left
selectedOptionLabel.textStyle = .bodyLarge
selectedOptionLabel.numberOfLines = 1
dropdownField.tintColor = UIColor.clear
dropdownField.font = TextStyle.bodyLarge.font
showInlineLabel = false
options = []
selectId = nil
}
open override func reset() {
inlineDisplayLabel.reset()
selectedOptionLabel.reset()
super.reset()
}
open override func getFieldContainer() -> UIView {
let controlStackView = UIStackView().with {
$0.translatesAutoresizingMaskIntoConstraints = false

View File

@ -57,7 +57,7 @@ open class Pagination: View {
///Next button to select next page
public let nextButton: PaginationButton = .init(type: .next)
/// A callback when the page changes. Passes parameters (selectedPage).
public var onPageDidSelect: ((Int) -> Void)?
open var onPageDidSelect: ((Int) -> Void)?
/// Total number of pages, allows limit ranging from 0 to 9999.
@Clamping(range: 0...9999)
public var total: Int {
@ -70,7 +70,7 @@ open class Pagination: View {
}
}
///Selected active page number and clips to total pages if selected index is greater than the total pages.
public var selectedPage: Int {
open var selectedPage: Int {
set {
if newValue >= total {
_selectedPageIndex = total - 1

View File

@ -288,7 +288,6 @@ open class TitleLockup: View {
subTitleModel = nil
}
var labelViews = [UIView]()
/// Used to make changes to the View based off a change events or from local properties.
open override func updateView() {
super.updateView()