diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift index 972ea7ca..9dc4a0bd 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/BarsIndicatorView.swift @@ -68,12 +68,7 @@ open class BarsIndicatorView: CarouselIndicator { get { return super.indicatorColor } set (newColor) { super.indicatorColor = newColor - - if isEnabled { - for (i, barTuple) in barReferences.enumerated() { - barTuple.view.backgroundColor = i == currentIndex ? currentIndicatorColor : newColor - } - } + refreshBarColors(with: newColor) } } @@ -102,6 +97,15 @@ open class BarsIndicatorView: CarouselIndicator { // MARK: - Methods //-------------------------------------------------- + private func refreshBarColors(with color: UIColor) { + + if isEnabled { + for (i, barTuple) in barReferences.enumerated() { + barTuple.view.backgroundColor = i == currentIndex ? currentIndicatorColor : color + } + } + } + func generateBars() { var bars = [(View, NSLayoutConstraint)]() @@ -142,7 +146,7 @@ open class BarsIndicatorView: CarouselIndicator { guard let model = model as? BarsCarouselIndicatorModel else { return } - currentIndicatorColor = model.currentIndicatorColor.uiColor + currentIndicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.currentIndicatorColor.uiColor } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 9380e8c0..e202a212 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -78,8 +78,20 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { } public var indicatorColor: UIColor { - get { return carouselIndicatorModel?.indicatorColor.uiColor ?? .mvmBlack } - set { carouselIndicatorModel?.indicatorColor = Color(uiColor: newValue) } + get { + if let model = carouselIndicatorModel, model.inverted { + return carouselIndicatorModel?.indicatorColor_inverted.uiColor ?? .mvmWhite + } else { + return carouselIndicatorModel?.indicatorColor.uiColor ?? .mvmBlack + } + } + set { + if let model = carouselIndicatorModel, model.inverted { + carouselIndicatorModel?.indicatorColor_inverted = Color(uiColor: newValue) + } else { + carouselIndicatorModel?.indicatorColor = Color(uiColor: newValue) + } + } } var accessibilityValueFormat: String? { @@ -191,7 +203,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol { guard let model = model as? CarouselIndicatorModel else { return } - indicatorColor = model.indicatorColor.uiColor + indicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.indicatorColor.uiColor disabledIndicatorColor = model.disabledIndicatorColor.uiColor currentIndex = model.currentIndex isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index a0ac2273..359fe98a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -26,11 +26,13 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro public var currentIndex: Int = 0 public var animated: Bool = true public var hidesForSinglePage: Bool = false + public var inverted: Bool = false /// Set true to make the accessibility value as "Slide #currentPage of #totalPage", otherwise will be "Page #currentPage of #totalPage", default is false public var accessibilityHasSlidesInsteadOfPage: Bool = false public var enabled: Bool = true public var disabledIndicatorColor: Color = Color(uiColor: .mvmCoolGray3) public var indicatorColor: Color = Color(uiColor: .mvmBlack) + public var indicatorColor_inverted: Color = Color(uiColor: .mvmWhite) public var position: Float? /// Allows sendActions() to trigger even if index is already at min/max index. @@ -53,6 +55,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro case disabledIndicatorColor case indicatorColor case position + case inverted } //-------------------------------------------------- @@ -72,6 +75,10 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro self.alwaysSendAction = alwaysSendAction } + if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { + self.inverted = inverted + } + if let position = try typeContainer.decodeIfPresent(Float.self, forKey: .position) { self.position = position } @@ -112,6 +119,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro try container.encode(hidesForSinglePage, forKey: .hidesForSinglePage) try container.encode(accessibilityHasSlidesInsteadOfPage, forKey: .accessibilityHasSlidesInsteadOfPage) try container.encode(enabled, forKey: .enabled) + try container.encode(inverted, forKey: .inverted) try container.encode(disabledIndicatorColor, forKey: .disabledIndicatorColor) try container.encode(indicatorColor, forKey: .indicatorColor) try container.encodeIfPresent(position, forKey: .position) diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 1ef2e217..2ca287d1 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -34,6 +34,7 @@ extension UIColor { "green33": (.mvmGreen33, "#ABE4BF"), "green66": (.mvmGreen66, "#57C880"), "greenShade2": (.mvmGreenShade2, "#0F5B25"), + "greenInverted": (.mvmGreenInverted, "#00AC3E"), "orange": (.mvmOrange, "#ED7000"), "orange66": (.mvmOrange66, "#F3A157"), "orange33": (.mvmOrange33, "#F9D0AB"), @@ -45,6 +46,7 @@ extension UIColor { "blue66": (.mvmBlue66, "#57B1DF"), "blueShade1": (.mvmBlueShade1, "#136598"), "blueShade2": (.mvmBlueShade2, "#0B4467"), + "blueInverted": (.mvmBlueInverted, "#0088CE"), "yellow": (.mvmYellow, "#FFBC3D"), "coolGray1": (.mvmCoolGray1, "#F6F6F6"), "coolGray3": (.mvmCoolGray3, "#D8DADA"), @@ -147,6 +149,9 @@ extension UIColor { /// HEX: #0F5B25 public static let mvmGreenShade2 = UIColor.color8Bits(red: 15, green: 91, blue: 37) + /// HEX: #00AC3E + public static let mvmGreenInverted = UIColor.color8Bits(red: 0, green: 172, blue: 62) + //-------------------------------------------------- // MARK: - Blue //-------------------------------------------------- @@ -166,6 +171,9 @@ extension UIColor { /// HEX: #0B4467 public static let mvmBlueShade2 = UIColor.color8Bits(red: 11, green: 68, blue: 103) + /// HEX: #0088CE + public static let mvmBlueInverted = UIColor.color8Bits(red: 0, green: 136, blue: 206) + //-------------------------------------------------- // MARK: - Yellow //--------------------------------------------------