From 3c92411703ce5c13bef7a55e23f719001ad6ddb0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Aug 2024 16:03:38 -0500 Subject: [PATCH 1/2] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 5cc7ae1c..3e5d50bc 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1589,7 +1589,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1627,7 +1627,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; From baf9136e26054553b5641576b74cdd5efba42cc3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 17 Aug 2024 14:36:59 -0500 Subject: [PATCH 2/2] code refactor into setDefaults() Signed-off-by: Matt Bruce --- .../BadgeIndicator/BadgeIndicator.swift | 21 +++++++------- VDS/Components/Checkbox/CheckboxItem.swift | 28 ------------------- VDS/Components/DatePicker/DatePicker.swift | 18 ++++++------ .../Notification/Notification.swift | 8 +++--- VDS/Components/Pagination/Pagination.swift | 4 +++ VDS/Components/Tabs/Tab.swift | 4 +++ VDS/Components/Tilelet/Tilelet.swift | 19 +++++++------ VDS/Components/Tooltip/Tooltip.swift | 20 ++++++------- 8 files changed, 52 insertions(+), 70 deletions(-) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index dc200cd8..daecddf4 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -293,16 +293,6 @@ open class BadgeIndicator: View { label.centerYAnchor.constraint(equalTo: badgeView.centerYAnchor).isActive = true labelContraints.isActive = true - bridge_accessibilityLabelBlock = { [weak self] in - guard let self else { return "" } - if let accessibilityText { - return kind == .numbered ? label.text + " " + accessibilityText : accessibilityText - } else if kind == .numbered { - return label.text - } else { - return "Simple" - } - } } open override func setDefaults() { @@ -324,6 +314,17 @@ open class BadgeIndicator: View { height = nil accessibilityText = nil maximumDigits = .two + + bridge_accessibilityLabelBlock = { [weak self] in + guard let self else { return "" } + if let accessibilityText { + return kind == .numbered ? label.text + " " + accessibilityText : accessibilityText + } else if kind == .numbered { + return label.text + } else { + return "Simple" + } + } } /// Resets to default settings. diff --git a/VDS/Components/Checkbox/CheckboxItem.swift b/VDS/Components/Checkbox/CheckboxItem.swift index d3af344b..e489edea 100644 --- a/VDS/Components/Checkbox/CheckboxItem.swift +++ b/VDS/Components/Checkbox/CheckboxItem.swift @@ -49,13 +49,6 @@ open class CheckboxItem: SelectorItemBase { sendActions(for: .valueChanged) } - open override func setup() { - super.setup() - let foo = ConcreteClass(customView: Checkbox()) - - print(foo.customView.isAnimated) - } - open override func setDefaults() { super.setDefaults() isAnimated = false @@ -67,24 +60,3 @@ open class CheckboxItem: SelectorItemBase { super.updateView() } } - - -@objcMembers -open class GenericClass: NSObject { - public var customView: T - - public init(customView: T = T()) { - self.customView = customView - } -} - -@objcMembers -@objc(VDSConcreteClass) -open class ConcreteClass: GenericClass { - -} - -@objcMembers -@objc(VDSConcreteCheckboxClass) -open class ConcreteCheckboxClass: ConcreteClass {} - diff --git a/VDS/Components/DatePicker/DatePicker.swift b/VDS/Components/DatePicker/DatePicker.swift index d2d64380..e8802c69 100644 --- a/VDS/Components/DatePicker/DatePicker.swift +++ b/VDS/Components/DatePicker/DatePicker.swift @@ -152,15 +152,7 @@ open class DatePicker: EntryFieldBase { // setting color config selectedDateLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable() - - // tap gesture - containerView.onClick = { [weak self] _ in - guard let self else { return } - if isEnabled && !isReadOnly { - showPopover() - } - } - + NotificationCenter.default .publisher(for: UIDevice.orientationDidChangeNotification).sink { [weak self] _ in guard let self else { return } @@ -177,6 +169,14 @@ open class DatePicker: EntryFieldBase { calendarModel = .init() dateFormat = .shortNumeric selectedDateLabel.textStyle = .bodyLarge + + // tap gesture + containerView.onClick = { [weak self] _ in + guard let self else { return } + if isEnabled && !isReadOnly { + showPopover() + } + } } open override func getFieldContainer() -> UIView { diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index e188faf7..59d2b78f 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -268,10 +268,6 @@ open class Notification: View { closeButton.accessibilityTraits = [.button] closeButton.accessibilityLabel = "Close Notification" - typeIcon.bridge_accessibilityLabelBlock = { [weak self] in - guard let self else { return "" } - return style.accessibleText - } } open override func setDefaults() { @@ -296,6 +292,10 @@ open class Notification: View { hideCloseButton = false + typeIcon.bridge_accessibilityLabelBlock = { [weak self] in + guard let self else { return "" } + return style.accessibleText + } } /// Resets to default settings. diff --git a/VDS/Components/Pagination/Pagination.swift b/VDS/Components/Pagination/Pagination.swift index 1e51f4ef..cf4f9183 100644 --- a/VDS/Components/Pagination/Pagination.swift +++ b/VDS/Components/Pagination/Pagination.swift @@ -145,6 +145,10 @@ open class Pagination: View { .sink { [weak self] value in self?.collectionViewWidthAnchor?.constant = value //As cell width is dynamic i.e cell may contain 2 or 3 or 4 charcters. Make sure that all the visible cells are displayed. }.store(in: &subscribers) + } + + open override func setDefaults() { + super.setDefaults() collectionContainerView.onAccessibilityIncrement = { [weak self] in guard let self else { return } self.selectedPage = max(0, self.selectedPage + 1) diff --git a/VDS/Components/Tabs/Tab.swift b/VDS/Components/Tabs/Tab.swift index edc8af55..0b97568b 100644 --- a/VDS/Components/Tabs/Tab.swift +++ b/VDS/Components/Tabs/Tab.swift @@ -150,6 +150,10 @@ extension Tabs { labelLeadingConstraint = label.pinLeading(anchor: layoutGuide.leadingAnchor) labelBottomConstraint = label.pinBottom(anchor: layoutGuide.bottomAnchor, priority: .defaultHigh) + } + + open override func setDefaults() { + super.setDefaults() bridge_accessibilityLabelBlock = { [weak self] in guard let self else { return "" } return text diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 86dd346a..cb154056 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -379,15 +379,6 @@ open class Tilelet: TileContainerBase { titleLockupSubTitleLabelHeightGreaterThanConstraint?.priority = .defaultHigh titleLockupSubTitleLabelHeightGreaterThanConstraint?.activate() - directionalIcon.bridge_accessibilityLabelBlock = { [weak self] in - guard let self, let directionalIconModel else { return nil } - return directionalIconModel.accessibleText - } - - descriptiveIcon.bridge_accessibilityLabelBlock = { [weak self] in - guard let self, let descriptiveIconModel else { return nil } - return descriptiveIconModel.accessibleText - } } open override func setDefaults() { @@ -403,6 +394,16 @@ open class Tilelet: TileContainerBase { subTitleModel = nil descriptiveIconModel = nil directionalIconModel = nil + + directionalIcon.bridge_accessibilityLabelBlock = { [weak self] in + guard let self, let directionalIconModel else { return nil } + return directionalIconModel.accessibleText + } + + descriptiveIcon.bridge_accessibilityLabelBlock = { [weak self] in + guard let self, let descriptiveIconModel else { return nil } + return descriptiveIconModel.accessibleText + } } /// Used to make changes to the View based off a change events or from local properties. diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index effafa07..1c2e2061 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -129,6 +129,16 @@ open class Tooltip: Control, TooltipLaunchable { isAccessibilityElement = true accessibilityTraits = .button + } + + open override func setDefaults() { + super.setDefaults() + closeButtonText = "Close" + fillColor = .primary + size = .medium + title = nil + content = nil + contentView = nil onClick = { [weak self] tooltip in guard let self else { return} @@ -158,16 +168,6 @@ open class Tooltip: Control, TooltipLaunchable { return isEnabled ? "Double tap to open." : "" } } - - open override func setDefaults() { - super.setDefaults() - closeButtonText = "Close" - fillColor = .primary - size = .medium - title = nil - content = nil - contentView = nil - } /// Used to make changes to the View based off a change events or from local properties.