Merge branch 'mbruce/bugfix' into 'develop'
Fixed bug in ButtonGroup See merge request BPHV_MIPS/vds_ios!287
This commit is contained in:
commit
633a8d3b78
@ -111,9 +111,13 @@ 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 "" }
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -173,6 +173,7 @@ open class ButtonGroup: View {
|
||||
rowQuantityTablet = 0
|
||||
alignment = .center
|
||||
childWidth = nil
|
||||
buttons = []
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
|
||||
@ -49,56 +49,53 @@ class ButtonCollectionViewRow {
|
||||
func layout(for position: ButtonGroup.Alignment, with collectionViewWidth: CGFloat){
|
||||
var offset = 0.0
|
||||
let height = rowHeight
|
||||
|
||||
attributes.last?.spacing = 0
|
||||
|
||||
//filter only the buttons since this is the only
|
||||
//object we can change the frames for.
|
||||
let buttonAttributes = attributes.filter{$0.isButton}
|
||||
|
||||
//check to see if you have buttons and there is a percentage
|
||||
if let buttonPercentage, hasButtons, buttonPercentage > 0 {
|
||||
if !buttonAttributes.isEmpty {
|
||||
let buttonCount = CGFloat(buttonAttributes.count)
|
||||
|
||||
var usedSpace = 0.0
|
||||
//get the width for the buttons
|
||||
for attribute in attributes {
|
||||
if !attribute.isButton {
|
||||
usedSpace += attribute.frame.width
|
||||
}
|
||||
usedSpace += attribute.spacing
|
||||
}
|
||||
let buttonAvailableSpace = collectionViewWidth - usedSpace
|
||||
let realPercentage = (buttonPercentage / 100)
|
||||
let buttonWidth = realPercentage * buttonAvailableSpace
|
||||
// print("buttonPercentage :\(realPercentage)")
|
||||
// print("collectionView width:\(collectionViewWidth)")
|
||||
// print("usedSpace width:\(usedSpace)")
|
||||
// print("button available width:\(buttonAvailableSpace)")
|
||||
// print("each button width:\(buttonWidth)\n")
|
||||
// print("minimum widht:\(ButtonSize.large.minimumWidth)")
|
||||
// test sizing
|
||||
var testSize = 0.0
|
||||
var buttonCount = 0.0
|
||||
for attribute in attributes {
|
||||
if attribute.isButton {
|
||||
testSize += buttonWidth
|
||||
buttonCount += 1
|
||||
}
|
||||
///Calculate the spaces between items in the row
|
||||
let totalSpacingBetweenAttributes = attributes.reduce(0.0) { $0 + $1.spacing }
|
||||
|
||||
//see how much of the rows width is used for
|
||||
//non-buttons that are BaseButton Subclasses that are not "Button"
|
||||
let nonButtonSpace = attributes.filter { !$0.isButton }.reduce(0.0) { $0 + $1.frame.width }
|
||||
|
||||
//getting available button space since textlinks need their space
|
||||
let buttonsAvailableSpace = collectionViewWidth - nonButtonSpace - totalSpacingBetweenAttributes
|
||||
let buttonEqualSpacing = buttonsAvailableSpace / buttonCount
|
||||
var maxButtonWidth = buttonEqualSpacing //default to equal spacing
|
||||
var buttonCalculatedPercentage: CGFloat = 0.0
|
||||
|
||||
//check to see if you have buttons and there is a percentage
|
||||
if let buttonPercentage, hasButtons, buttonPercentage > 0 {
|
||||
buttonCalculatedPercentage = CGFloat(buttonPercentage / 100.0)
|
||||
let buttonPercentageWidth = buttonCalculatedPercentage * buttonsAvailableSpace
|
||||
maxButtonWidth = min(max(buttonPercentageWidth, Button.Size.large.minimumWidth), maxButtonWidth)
|
||||
}
|
||||
|
||||
if buttonWidth >= Button.Size.large.minimumWidth {
|
||||
if testSize <= buttonAvailableSpace {
|
||||
for attribute in attributes {
|
||||
if attribute.isButton {
|
||||
attribute.frame.size.width = buttonWidth
|
||||
}
|
||||
//resize the buttonAttributes
|
||||
if maxButtonWidth >= Button.Size.large.minimumWidth {
|
||||
//if there is enough room for all buttons
|
||||
if maxButtonWidth * buttonCount <= buttonsAvailableSpace {
|
||||
for attribute in buttonAttributes {
|
||||
attribute.frame.size.width = buttonCalculatedPercentage.isZero ? min(attribute.frame.size.width, maxButtonWidth) : maxButtonWidth
|
||||
}
|
||||
} else {
|
||||
let distributedSize = buttonAvailableSpace / buttonCount
|
||||
for attribute in attributes {
|
||||
if attribute.isButton {
|
||||
attribute.frame.size.width = distributedSize
|
||||
}
|
||||
//if not enough room, give all buttons the same width
|
||||
for attribute in buttonAttributes {
|
||||
attribute.frame.size.width = buttonEqualSpacing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update the offset based on position
|
||||
switch position {
|
||||
case .left:
|
||||
break
|
||||
@ -181,7 +178,7 @@ class ButtonGroupPositionLayout: UICollectionViewLayout {
|
||||
var rows = [ButtonCollectionViewRow]()
|
||||
rows.append(ButtonCollectionViewRow())
|
||||
|
||||
let collectionViewWidth = collectionView.frame.width
|
||||
let collectionViewWidth = collectionView.horizontalPinnedWidth() ?? collectionView.frame.width
|
||||
|
||||
for item in 0..<totalItems {
|
||||
|
||||
@ -200,7 +197,8 @@ class ButtonGroupPositionLayout: UICollectionViewLayout {
|
||||
// determine if the current button will fit in the row
|
||||
let rowItemCount = rows.last?.attributes.count ?? 0
|
||||
|
||||
if (layoutWidthIterator + itemSize.width) > collectionViewWidth || (rowQuantity > 0 && rowItemCount == rowQuantity) {
|
||||
if (layoutWidthIterator + itemSize.width) > collectionViewWidth && rowQuantity == 0
|
||||
|| (rowQuantity > 0 && rowItemCount == rowQuantity) {
|
||||
|
||||
// If the current row width (after this item being laid out) is exceeding
|
||||
// the width of the collection view content, put it in the next line
|
||||
@ -318,3 +316,5 @@ class ButtonGroupPositionLayout: UICollectionViewLayout {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 }
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -55,6 +55,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() {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
1.0.72
|
||||
----------------
|
||||
- ONEAPP-9311 - InputStepper - Finished
|
||||
- ONEAPP-9314 - PriceLockup - Finished
|
||||
- CXTDT-599736 - All classes refactored workflow setup(), reset(), setDefaults()
|
||||
|
||||
1.0.71
|
||||
----------------
|
||||
- CXTDT-581800 - DatePicker - Selected Error state icon
|
||||
|
||||
Loading…
Reference in New Issue
Block a user