color and indicator inversion
This commit is contained in:
parent
dfd32f1408
commit
b83abf673e
@ -68,12 +68,7 @@ open class BarsIndicatorView: CarouselIndicator {
|
|||||||
get { return super.indicatorColor }
|
get { return super.indicatorColor }
|
||||||
set (newColor) {
|
set (newColor) {
|
||||||
super.indicatorColor = newColor
|
super.indicatorColor = newColor
|
||||||
|
refreshBarColors(with: newColor)
|
||||||
if isEnabled {
|
|
||||||
for (i, barTuple) in barReferences.enumerated() {
|
|
||||||
barTuple.view.backgroundColor = i == currentIndex ? currentIndicatorColor : newColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +97,15 @@ open class BarsIndicatorView: CarouselIndicator {
|
|||||||
// MARK: - Methods
|
// 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() {
|
func generateBars() {
|
||||||
|
|
||||||
var bars = [(View, NSLayoutConstraint)]()
|
var bars = [(View, NSLayoutConstraint)]()
|
||||||
@ -142,7 +146,7 @@ open class BarsIndicatorView: CarouselIndicator {
|
|||||||
|
|
||||||
guard let model = model as? BarsCarouselIndicatorModel else { return }
|
guard let model = model as? BarsCarouselIndicatorModel else { return }
|
||||||
|
|
||||||
currentIndicatorColor = model.currentIndicatorColor.uiColor
|
currentIndicatorColor = model.inverted ? model.indicatorColor_inverted.uiColor : model.currentIndicatorColor.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -78,8 +78,20 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var indicatorColor: UIColor {
|
public var indicatorColor: UIColor {
|
||||||
get { return carouselIndicatorModel?.indicatorColor.uiColor ?? .mvmBlack }
|
get {
|
||||||
set { carouselIndicatorModel?.indicatorColor = Color(uiColor: newValue) }
|
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? {
|
var accessibilityValueFormat: String? {
|
||||||
@ -191,7 +203,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
|||||||
|
|
||||||
guard let model = model as? CarouselIndicatorModel else { return }
|
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
|
disabledIndicatorColor = model.disabledIndicatorColor.uiColor
|
||||||
currentIndex = model.currentIndex
|
currentIndex = model.currentIndex
|
||||||
isEnabled = model.enabled
|
isEnabled = model.enabled
|
||||||
|
|||||||
@ -26,11 +26,13 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
public var currentIndex: Int = 0
|
public var currentIndex: Int = 0
|
||||||
public var animated: Bool = true
|
public var animated: Bool = true
|
||||||
public var hidesForSinglePage: Bool = false
|
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
|
/// 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 accessibilityHasSlidesInsteadOfPage: Bool = false
|
||||||
public var enabled: Bool = true
|
public var enabled: Bool = true
|
||||||
public var disabledIndicatorColor: Color = Color(uiColor: .mvmCoolGray3)
|
public var disabledIndicatorColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
public var indicatorColor: Color = Color(uiColor: .mvmBlack)
|
public var indicatorColor: Color = Color(uiColor: .mvmBlack)
|
||||||
|
public var indicatorColor_inverted: Color = Color(uiColor: .mvmWhite)
|
||||||
public var position: Float?
|
public var position: Float?
|
||||||
|
|
||||||
/// Allows sendActions() to trigger even if index is already at min/max index.
|
/// 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 disabledIndicatorColor
|
||||||
case indicatorColor
|
case indicatorColor
|
||||||
case position
|
case position
|
||||||
|
case inverted
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -72,6 +75,10 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
self.alwaysSendAction = alwaysSendAction
|
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) {
|
if let position = try typeContainer.decodeIfPresent(Float.self, forKey: .position) {
|
||||||
self.position = position
|
self.position = position
|
||||||
}
|
}
|
||||||
@ -112,6 +119,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro
|
|||||||
try container.encode(hidesForSinglePage, forKey: .hidesForSinglePage)
|
try container.encode(hidesForSinglePage, forKey: .hidesForSinglePage)
|
||||||
try container.encode(accessibilityHasSlidesInsteadOfPage, forKey: .accessibilityHasSlidesInsteadOfPage)
|
try container.encode(accessibilityHasSlidesInsteadOfPage, forKey: .accessibilityHasSlidesInsteadOfPage)
|
||||||
try container.encode(enabled, forKey: .enabled)
|
try container.encode(enabled, forKey: .enabled)
|
||||||
|
try container.encode(inverted, forKey: .inverted)
|
||||||
try container.encode(disabledIndicatorColor, forKey: .disabledIndicatorColor)
|
try container.encode(disabledIndicatorColor, forKey: .disabledIndicatorColor)
|
||||||
try container.encode(indicatorColor, forKey: .indicatorColor)
|
try container.encode(indicatorColor, forKey: .indicatorColor)
|
||||||
try container.encodeIfPresent(position, forKey: .position)
|
try container.encodeIfPresent(position, forKey: .position)
|
||||||
|
|||||||
@ -34,6 +34,7 @@ extension UIColor {
|
|||||||
"green33": (.mvmGreen33, "#ABE4BF"),
|
"green33": (.mvmGreen33, "#ABE4BF"),
|
||||||
"green66": (.mvmGreen66, "#57C880"),
|
"green66": (.mvmGreen66, "#57C880"),
|
||||||
"greenShade2": (.mvmGreenShade2, "#0F5B25"),
|
"greenShade2": (.mvmGreenShade2, "#0F5B25"),
|
||||||
|
"greenInverted": (.mvmGreenInverted, "#00AC3E"),
|
||||||
"orange": (.mvmOrange, "#ED7000"),
|
"orange": (.mvmOrange, "#ED7000"),
|
||||||
"orange66": (.mvmOrange66, "#F3A157"),
|
"orange66": (.mvmOrange66, "#F3A157"),
|
||||||
"orange33": (.mvmOrange33, "#F9D0AB"),
|
"orange33": (.mvmOrange33, "#F9D0AB"),
|
||||||
@ -45,6 +46,7 @@ extension UIColor {
|
|||||||
"blue66": (.mvmBlue66, "#57B1DF"),
|
"blue66": (.mvmBlue66, "#57B1DF"),
|
||||||
"blueShade1": (.mvmBlueShade1, "#136598"),
|
"blueShade1": (.mvmBlueShade1, "#136598"),
|
||||||
"blueShade2": (.mvmBlueShade2, "#0B4467"),
|
"blueShade2": (.mvmBlueShade2, "#0B4467"),
|
||||||
|
"blueInverted": (.mvmBlueInverted, "#0088CE"),
|
||||||
"yellow": (.mvmYellow, "#FFBC3D"),
|
"yellow": (.mvmYellow, "#FFBC3D"),
|
||||||
"coolGray1": (.mvmCoolGray1, "#F6F6F6"),
|
"coolGray1": (.mvmCoolGray1, "#F6F6F6"),
|
||||||
"coolGray3": (.mvmCoolGray3, "#D8DADA"),
|
"coolGray3": (.mvmCoolGray3, "#D8DADA"),
|
||||||
@ -147,6 +149,9 @@ extension UIColor {
|
|||||||
/// HEX: #0F5B25
|
/// HEX: #0F5B25
|
||||||
public static let mvmGreenShade2 = UIColor.color8Bits(red: 15, green: 91, blue: 37)
|
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
|
// MARK: - Blue
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -166,6 +171,9 @@ extension UIColor {
|
|||||||
/// HEX: #0B4467
|
/// HEX: #0B4467
|
||||||
public static let mvmBlueShade2 = UIColor.color8Bits(red: 11, green: 68, blue: 103)
|
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
|
// MARK: - Yellow
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user