From c8155a57dbc945876cbbe1d3ccedbe74d38bd290 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 1 May 2020 16:47:45 -0400 Subject: [PATCH] resolving gitlab --- MVMCoreUI.xcodeproj/project.pbxproj | 1 - MVMCoreUI/Atomic/Atoms/Views/Arrow.swift | 22 +++---------------- MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift | 16 ++++++++++++++ .../BarsCarouselIndicatorModel.swift | 1 + .../CarouselIndicator/BarsIndicatorView.swift | 2 ++ .../CarouselIndicator/CarouselIndicator.swift | 16 ++++---------- MVMCoreUI/Atomic/Organisms/Carousel.swift | 13 +++-------- MVMCoreUI/BaseClasses/ImageView.swift | 9 -------- 8 files changed, 29 insertions(+), 51 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 7fada32e..3915b055 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -2045,7 +2045,6 @@ D29E28D823D21AB800ACEA85 /* StringAndMoleculeView.swift in Sources */, 01EB369023609801006832FA /* MoleculeListItemModel.swift in Sources */, 0A9D09212433796500D2E6C0 /* CarouselIndicatorModel.swift in Sources */, - D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */, EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */, D28A838323CCBD3F00DFE4FC /* WheelModel.swift in Sources */, D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift index 81b244e1..b618d43d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Arrow.swift @@ -20,8 +20,8 @@ open class Arrow: View { return model as? ArrowModel } - public var direction: Direction { - get { return Direction(rawValue: degrees) ?? .right} + public var direction: ArrowModel.Direction { + get { return ArrowModel.Direction(rawValue: degrees) ?? .right} set { degrees = newValue.rawValue } } @@ -54,23 +54,7 @@ open class Arrow: View { get { return arrowModel?.lineWidth ?? 1 } set { arrowModel?.lineWidth = newValue } } - - //-------------------------------------------------- - // MARK: - Enum - //-------------------------------------------------- - - /// Conveniece for readability of arrow pointing direction. - public enum Direction: Float { - case right = 0 - case upperRight = 45 - case up = 90 - case upperLeft = 135 - case left = 180 - case bottomLeft = 225 - case down = 270 - case bottomRight = 315 - } - + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift index 14d98ee3..ac2b2d90 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift @@ -28,6 +28,22 @@ open class ArrowModel: MoleculeModelProtocol { public var width: CGFloat = 12 public var enabled: Bool = true + //-------------------------------------------------- + // MARK: - Enum + //-------------------------------------------------- + + /// Conveniece for readability of arrow pointing direction. + public enum Direction: Float { + case right = 0 + case upperRight = 45 + case up = 90 + case upperLeft = 135 + case left = 180 + case bottomLeft = 225 + case down = 270 + case bottomRight = 315 + } + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsCarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsCarouselIndicatorModel.swift index 89369987..1b5cae14 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsCarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsCarouselIndicatorModel.swift @@ -45,5 +45,6 @@ open class BarsCarouselIndicatorModel: CarouselIndicatorModel { public override func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(currentIndicatorColor, forKey: .currentIndicatorColor) + try super.encode(to: encoder) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 3bfe8585..acd7f5d0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -147,6 +147,8 @@ open class BarsIndicatorView: CarouselIndicator { public override func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) { + guard newIndex < totalCount else { return } + guard !barReferences.isEmpty else { generateBars() return diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 589bf794..4857f9a0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -29,7 +29,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { } /// Set this closure to perform an action when a different indicator was selected. - /// Passes through oldInde and newIndex, respectively. + /// Passes through oldIndex and newIndex, respectively. public var indicatorTouchAction: ((CarouselPageControlProtocol) -> ())? open override var isEnabled: Bool { @@ -60,7 +60,6 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { /// Holds the total number of pages displayed by the carousel. /// Updating this property will potentially update the UI. - /// The maxmum count of pages before the indicatorView forces a Numeric Indicator in place of Bar. public var numberOfPages: Int { get { return carouselIndicatorModel?.numberOfPages ?? 0 } set (newTotal) { @@ -106,16 +105,11 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { // MARK: - Lifecycle //-------------------------------------------------- - public override func initialSetup() { - super.initialSetup() - - isAccessibilityElement = true - accessibilityTraits = .adjustable - } - open override func setupView() { super.setupView() + isAccessibilityElement = true + accessibilityTraits = .adjustable setupGestures() } @@ -192,9 +186,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { super.set(with: model, delegateObject, additionalData) guard let model = model as? CarouselIndicatorModel else { return } - - indicatorColor = model.indicatorColor.uiColor - disabledIndicatorColor = model.disabledIndicatorColor.uiColor + currentIndex = model.currentIndex isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Organisms/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel.swift index e6604ffa..5fd0df36 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel.swift @@ -127,7 +127,7 @@ open class Carousel: View { collectionView.backgroundColor = backgroundColor collectionView.layer.borderColor = backgroundColor?.cgColor - collectionView.layer.borderWidth = carouselModel.border! ? 1 : 0 + collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0 backgroundColor = .white registerCells(with: carouselModel, delegateObject: delegateObject) @@ -178,16 +178,9 @@ open class Carousel: View { // Sets up the row data with buffer cells on each side (for illusion of endless scroll... also has one more buffer cell on each side in case we can peek that cell). loop = true - if let last = newMolecules.last { - molecules?.insert(last, at: 0) - } - + molecules?.insert(newMolecules.last!, at: 0) molecules?.insert(newMolecules[(newMolecules.count - 2)], at: 0) - - if let first = newMolecules.first { - molecules?.append(first) - } - + molecules?.append(newMolecules.first!) molecules?.append(newMolecules[1]) } diff --git a/MVMCoreUI/BaseClasses/ImageView.swift b/MVMCoreUI/BaseClasses/ImageView.swift index 461397a8..2f0d47e1 100644 --- a/MVMCoreUI/BaseClasses/ImageView.swift +++ b/MVMCoreUI/BaseClasses/ImageView.swift @@ -13,7 +13,6 @@ open class ImageView: UIImageView, ModelMoleculeViewProtocol { // MARK: - Properties //-------------------------------------------------- - open var json: [AnyHashable: Any]? open var model: MoleculeModelProtocol? private var initialSetupPerformed = false @@ -96,14 +95,6 @@ extension ImageView: MVMCoreViewProtocol { // MARK:- MVMCoreUIMoleculeViewProtocol extension ImageView: MVMCoreUIMoleculeViewProtocol { - open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - self.json = json - - if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { - backgroundColor = UIColor.mfGet(forHex: backgroundColorString) - } - } - open func reset() { backgroundColor = .clear }