This commit is contained in:
Kevin G Christiano 2020-03-09 10:35:45 -04:00
parent 61bc283770
commit a011eb73a4
7 changed files with 209 additions and 125 deletions

View File

@ -98,6 +98,8 @@
0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */; }; 0A7EF86523D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86423D8AFFF00B2AAD1 /* ItemDropdownEntryFieldModel.swift */; };
0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */; }; 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF86623D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift */; };
0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; }; 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; };
0AAF8E2A240EA57D008DD263 /* BarsCarouselIndicatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAF8E29240EA57D008DD263 /* BarsCarouselIndicatorModel.swift */; };
0AAF8E2C240EA594008DD263 /* NumericCarouselIndicatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAF8E2B240EA594008DD263 /* NumericCarouselIndicatorModel.swift */; };
0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; };
0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; };
0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; };
@ -450,6 +452,8 @@
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = "<group>"; }; 0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = "<group>"; };
0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = "<group>"; }; 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = "<group>"; };
0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = "<group>"; }; 0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = "<group>"; };
0AAF8E29240EA57D008DD263 /* BarsCarouselIndicatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsCarouselIndicatorModel.swift; sourceTree = "<group>"; };
0AAF8E2B240EA594008DD263 /* NumericCarouselIndicatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumericCarouselIndicatorModel.swift; sourceTree = "<group>"; };
0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = "<group>"; }; 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = "<group>"; };
0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = "<group>"; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = "<group>"; };
0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
@ -791,20 +795,14 @@
0A14F6B023E8C27A00EDF7F7 /* CarouselIndicator */ = { 0A14F6B023E8C27A00EDF7F7 /* CarouselIndicator */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
0A14F6B723ECA7F900EDF7F7 /* IndicatorViews */,
0A14F69223E349EF00EDF7F7 /* CarouselIndicator.swift */, 0A14F69223E349EF00EDF7F7 /* CarouselIndicator.swift */,
0A14F6A823E8750300EDF7F7 /* CarouselIndicatorModel.swift */, 0A14F6A823E8750300EDF7F7 /* CarouselIndicatorModel.swift */,
); 0AAF8E29240EA57D008DD263 /* BarsCarouselIndicatorModel.swift */,
path = CarouselIndicator;
sourceTree = "<group>";
};
0A14F6B723ECA7F900EDF7F7 /* IndicatorViews */ = {
isa = PBXGroup;
children = (
0A4253AE23F5C2C000554656 /* BarsIndicatorView.swift */, 0A4253AE23F5C2C000554656 /* BarsIndicatorView.swift */,
0AAF8E2B240EA594008DD263 /* NumericCarouselIndicatorModel.swift */,
0A14F6B323E8C29700EDF7F7 /* NumericIndicatorView.swift */, 0A14F6B323E8C29700EDF7F7 /* NumericIndicatorView.swift */,
); );
path = IndicatorViews; path = CarouselIndicator;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
0A5D59C323AD488600EFD9E9 /* Protocols */ = { 0A5D59C323AD488600EFD9E9 /* Protocols */ = {
@ -1096,7 +1094,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
525019E3240684E500EED91C /* FourColumn */, 525019E3240684E500EED91C /* FourColumn */,
52267A0523FFE0A900906CBA /* OneColumn */,
D22B38ED23F4E11100490EF6 /* ThreeColumn */, D22B38ED23F4E11100490EF6 /* ThreeColumn */,
); );
path = SectionDividers; path = SectionDividers;
@ -1810,6 +1807,7 @@
0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */,
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */, 0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */,
0AAF8E2C240EA594008DD263 /* NumericCarouselIndicatorModel.swift in Sources */,
014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */,
AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */, AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */,
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */, 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
@ -1995,6 +1993,7 @@
C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */, C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */,
01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */, 01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */,
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */, 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */,
0AAF8E2A240EA57D008DD263 /* BarsCarouselIndicatorModel.swift in Sources */,
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,

View File

@ -0,0 +1,43 @@
//
// BarsCarouselIndicatorModel.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 3/3/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
/*
open class BarsCarouselIndicatorModel: CarouselIndicatorModel {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public class var identifier: String {
return "barsCarouselIndicator"
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
}
}
*/

View File

@ -9,7 +9,7 @@
import UIKit import UIKit
open class BarsIndicatorView: View, IndicatorViewProtocol { open class BarsIndicatorView: CarouselIndicator {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Stored Properties // MARK: - Stored Properties
//-------------------------------------------------- //--------------------------------------------------
@ -37,15 +37,15 @@ open class BarsIndicatorView: View, IndicatorViewProtocol {
public var parentCarouselIndicator: CarouselIndicator? { public var parentCarouselIndicator: CarouselIndicator? {
return superview as? CarouselIndicator return superview as? CarouselIndicator
} }
//
open var isEnabled: Bool = true { // open override var isEnabled: Bool = true {
didSet { // didSet {
barReferences.forEach { view, heightConstraint in // barReferences.forEach { view, heightConstraint in
view.backgroundColor = isEnabled ? parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack : parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3 // view.backgroundColor = isEnabled ? parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack : parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3
} // }
} // }
} // }
//
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//-------------------------------------------------- //--------------------------------------------------
@ -89,7 +89,7 @@ open class BarsIndicatorView: View, IndicatorViewProtocol {
for i in 0..<numberOfPages { for i in 0..<numberOfPages {
let bar = View() let bar = View()
bar.widthAnchor.constraint(equalToConstant: BarsIndicatorView.indicatorBarWidth).isActive = true bar.widthAnchor.constraint(equalToConstant: BarsIndicatorView.indicatorBarWidth).isActive = true
bar.backgroundColor = isEnabled ? parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack : parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3 // bar.backgroundColor = isEnabled ? parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack : parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3
let barHeight = i == currentIndex ? BarsIndicatorView.indicatorBarHeight.selected : BarsIndicatorView.indicatorBarHeight.unselected let barHeight = i == currentIndex ? BarsIndicatorView.indicatorBarHeight.selected : BarsIndicatorView.indicatorBarHeight.unselected
let heightConstraint = bar.heightAnchor.constraint(equalToConstant: barHeight) let heightConstraint = bar.heightAnchor.constraint(equalToConstant: barHeight)
heightConstraint.isActive = true heightConstraint.isActive = true

View File

@ -9,11 +9,11 @@
import Foundation import Foundation
/// Set protocols for all indicator faces of the Carousel Indicator. /// Set protocols for all indicator faces of the Carousel Indicator.
public protocol IndicatorViewProtocol { //public protocol IndicatorViewProtocol {
func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool) // func updateUI(previousIndex: Int, newIndex: Int, totalCount: Int, isAnimated: Bool)
func reset() // func reset()
var isEnabled: Bool { get set } // var isEnabled: Bool { get set }
} //}
open class CarouselIndicator: Control, CarouselPageControlProtocol { open class CarouselIndicator: Control, CarouselPageControlProtocol {
@ -21,7 +21,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
public typealias IndicatorView = UIView & IndicatorViewProtocol // public typealias IndicatorView = UIView & IndicatorViewProtocol
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Constraints // MARK: - Constraints
@ -35,21 +35,21 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
//-------------------------------------------------- //--------------------------------------------------
/// The types of indicators that can appear. /// The types of indicators that can appear.
public enum IndicatorType: String { // public enum IndicatorType: String {
case bars // case bars
case numeric // case numeric
case hybrid // bar & numeric // case hybrid // bar & numeric
} // }
/// Determines interactivity and appearance of the indicator. /// Determines interactivity and appearance of the indicator.
public var indicatorType: IndicatorType = .hybrid { // public var indicatorType: IndicatorType = .hybrid {
didSet { assignIndicatorView() } // didSet { assignIndicatorView() }
} // }
public var uiGestures: Set<UIGestureRecognizer> = [] public var uiGestures: Set<UIGestureRecognizer> = []
/// The currently active indicator view. /// The currently active indicator view.
public var currentIndicator: IndicatorView? // public var currentIndicator: IndicatorView?
/// Convenience to access the model. /// Convenience to access the model.
public var carouselIndicatorModel: CarouselIndicatorModel? { public var carouselIndicatorModel: CarouselIndicatorModel? {
@ -57,25 +57,25 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
} }
/// The view control relative to the state of the indicator type. /// The view control relative to the state of the indicator type.
private(set) var indicatorView: IndicatorView? { // private(set) var indicatorView: IndicatorView? {
willSet { indicatorView?.removeFromSuperview() } // willSet { indicatorView?.removeFromSuperview() }
didSet { // didSet {
indicatorView?.removeFromSuperview() // indicatorView?.removeFromSuperview()
//
guard let indicatorView = indicatorView else { return } // guard let indicatorView = indicatorView else { return }
addSubview(indicatorView) // addSubview(indicatorView)
//
topConstraint = indicatorView.topAnchor.constraint(equalTo: topAnchor, constant: PaddingTwo) // topConstraint = indicatorView.topAnchor.constraint(equalTo: topAnchor, constant: PaddingTwo)
topConstraint?.isActive = true // topConstraint?.isActive = true
//
bottomConstraint = bottomAnchor.constraint(equalTo: indicatorView.bottomAnchor, constant: PaddingTwo) // bottomConstraint = bottomAnchor.constraint(equalTo: indicatorView.bottomAnchor, constant: PaddingTwo)
bottomConstraint?.isActive = true // bottomConstraint?.isActive = true
//
indicatorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true // indicatorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: indicatorView.trailingAnchor).isActive = true // trailingAnchor.constraint(equalTo: indicatorView.trailingAnchor).isActive = true
updateUI() // updateUI()
} // }
} // }
/// Set this closure to perform an action when a different indicator was selected. /// Set this closure to perform an action when a different indicator was selected.
/// Passes through oldInde and newIndex, respectively. /// Passes through oldInde and newIndex, respectively.
@ -84,7 +84,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
public override var isEnabled: Bool { public override var isEnabled: Bool {
didSet { didSet {
isUserInteractionEnabled = isEnabled isUserInteractionEnabled = isEnabled
indicatorView?.isEnabled = isEnabled // indicatorView?.isEnabled = isEnabled
} }
} }
@ -118,9 +118,9 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
isHidden = carouselIndicatorModel?.hidesForSinglePage ?? false && newTotal <= 1 isHidden = carouselIndicatorModel?.hidesForSinglePage ?? false && newTotal <= 1
if isBarIndicator() { // if isBarIndicator() {
(indicatorView as? BarsIndicatorView)?.generateBars() // (indicatorView as? BarsIndicatorView)?.generateBars()
} // }
updateUI() updateUI()
} }
@ -135,11 +135,11 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
set (newColor) { set (newColor) {
carouselIndicatorModel?.indicatorColor = Color(uiColor: newColor) carouselIndicatorModel?.indicatorColor = Color(uiColor: newColor)
if isBarIndicator(), let barIndicator = indicatorView as? BarsIndicatorView { // if isBarIndicator(), let barIndicator = indicatorView as? BarsIndicatorView {
for (i, barTuple) in barIndicator.barReferences.enumerated() where i != currentIndex { // for (i, barTuple) in barIndicator.barReferences.enumerated() where i != currentIndex {
barTuple.view.backgroundColor = newColor // barTuple.view.backgroundColor = newColor
} // }
} // }
} }
} }
@ -152,11 +152,11 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
_currentIndicatorColor = newColor _currentIndicatorColor = newColor
carouselIndicatorModel?.currentIndicatorColor = Color(uiColor: newColor) carouselIndicatorModel?.currentIndicatorColor = Color(uiColor: newColor)
if isBarIndicator() { // if isBarIndicator() {
if let barIndicator = indicatorView as? BarsIndicatorView, !barIndicator.barReferences.isEmpty { // if let barIndicator = indicatorView as? BarsIndicatorView, !barIndicator.barReferences.isEmpty {
barIndicator.barReferences[currentIndex].view.backgroundColor = newColor // barIndicator.barReferences[currentIndex].view.backgroundColor = newColor
} // }
} // }
} }
} }
@ -172,10 +172,10 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
self.init(frame: .zero) self.init(frame: .zero)
} }
public init(indicatorType: IndicatorType) { // public init(indicatorType: IndicatorType) {
self.indicatorType = indicatorType // self.indicatorType = indicatorType
super.init(frame: .zero) // super.init(frame: .zero)
} // }
required public init?(coder: NSCoder) { required public init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
@ -195,7 +195,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
open override func setupView() { open override func setupView() {
super.setupView() super.setupView()
assignIndicatorView() // assignIndicatorView()
setupGestures() setupGestures()
} }
@ -245,17 +245,17 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
let touchPoint = tapGesture?.location(in: self) let touchPoint = tapGesture?.location(in: self)
let touchPoint_X = touchPoint?.x ?? 0.0 let touchPoint_X = touchPoint?.x ?? 0.0
if isBarIndicator(), let bars = (indicatorView as? BarsIndicatorView)?.barReferences { // if isBarIndicator(), let bars = (indicatorView as? BarsIndicatorView)?.barReferences {
currentIndex = bars.firstIndex { $0.0.frame.maxX >= touchPoint_X && $0.0.frame.minX <= touchPoint_X } ?? 0 // currentIndex = bars.firstIndex { $0.0.frame.maxX >= touchPoint_X && $0.0.frame.minX <= touchPoint_X } ?? 0
//
} else { // } else {
// Determine which half of the view was touched. // // Determine which half of the view was touched.
if touchPoint_X > bounds.width / 2 { // if touchPoint_X > bounds.width / 2 {
incrementCurrentIndex() // incrementCurrentIndex()
} else { // } else {
decrementCurrentIndex() // decrementCurrentIndex()
} // }
} // }
} }
//-------------------------------------------------- //--------------------------------------------------
@ -264,10 +264,10 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
public func updateUI() { public func updateUI() {
indicatorView?.updateUI(previousIndex: previousIndex, // indicatorView?.updateUI(previousIndex: previousIndex,
newIndex: currentIndex, // newIndex: currentIndex,
totalCount: numberOfPages, // totalCount: numberOfPages,
isAnimated: carouselIndicatorModel?.isAnimated ?? true) // isAnimated: carouselIndicatorModel?.isAnimated ?? true)
} }
public func performAction() { public func performAction() {
@ -277,25 +277,25 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
} }
/// Sets the indicatorView based on the current indicatorType. /// Sets the indicatorView based on the current indicatorType.
func assignIndicatorView() { // func assignIndicatorView() {
//
switch indicatorType { // switch indicatorType {
case .bars: // case .bars:
indicatorView = BarsIndicatorView() // indicatorView = BarsIndicatorView()
//
case .numeric: // case .numeric:
indicatorView = NumericIndicatorView() // indicatorView = NumericIndicatorView()
//
case .hybrid: // case .hybrid:
//
indicatorView = numberOfPages >= carouselIndicatorModel?.hybridThreshold ?? 0 ? NumericIndicatorView() : BarsIndicatorView() // indicatorView = numberOfPages >= carouselIndicatorModel?.hybridThreshold ?? 0 ? NumericIndicatorView() : BarsIndicatorView()
} // }
} // }
/// Convenience to determine if current view is displaying bars. /// Convenience to determine if current view is displaying bars.
func isBarIndicator() -> Bool { // func isBarIndicator() -> Bool {
return indicatorType == .bars || indicatorType == .hybrid && numberOfPages <= carouselIndicatorModel?.hybridThreshold ?? 5 // return indicatorType == .bars || indicatorType == .hybrid && numberOfPages <= carouselIndicatorModel?.hybridThreshold ?? 5
} // }
public func scrollViewDidScroll(_ collectionView: UICollectionView) { } public func scrollViewDidScroll(_ collectionView: UICollectionView) { }
@ -309,7 +309,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
indicatorType = IndicatorType(rawValue: model.type) ?? .hybrid // indicatorType = IndicatorType(rawValue: model.type) ?? .hybrid
currentIndicatorColor = model.currentIndicatorColor.uiColor currentIndicatorColor = model.currentIndicatorColor.uiColor
indicatorTintColor = model.indicatorColor.uiColor indicatorTintColor = model.indicatorColor.uiColor
isEnabled = model.isEnabled isEnabled = model.isEnabled

View File

@ -14,8 +14,8 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
public static var identifier: String { public class var identifier: String {
return "carouselIndicator" return ""
} }
public var backgroundColor: Color? public var backgroundColor: Color?
@ -23,7 +23,7 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
public var type: String = "hybrid" public var type: String = "hybrid"
/// The maxmum count of pages before the indicatorView forces a Numeric Indicator in place of Bar. /// The maxmum count of pages before the indicatorView forces a Numeric Indicator in place of Bar.
public var hybridThreshold: Int = 5 // public var hybridThreshold: Int = 5
public var numberOfPages: Int = 0 public var numberOfPages: Int = 0
public var isAnimated: Bool = true public var isAnimated: Bool = true
public var hidesForSinglePage: Bool = false public var hidesForSinglePage: Bool = false
@ -46,7 +46,7 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case type case type
case hybridThreshold // case hybridThreshold
case numberOfPages case numberOfPages
case alwaysSendAction case alwaysSendAction
case isAnimated case isAnimated
@ -72,9 +72,9 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
self.type = type self.type = type
} }
if let hybridThreshold = try typeContainer.decodeIfPresent(Int.self, forKey: .hybridThreshold) { // if let hybridThreshold = try typeContainer.decodeIfPresent(Int.self, forKey: .hybridThreshold) {
self.hybridThreshold = hybridThreshold // self.hybridThreshold = hybridThreshold
} // }
if let numberOfPages = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfPages) { if let numberOfPages = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfPages) {
self.numberOfPages = numberOfPages self.numberOfPages = numberOfPages
@ -122,7 +122,7 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
try container.encode(moleculeName, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(type, forKey: .type) try container.encodeIfPresent(type, forKey: .type)
try container.encodeIfPresent(hybridThreshold, forKey: .hybridThreshold) // try container.encodeIfPresent(hybridThreshold, forKey: .hybridThreshold)
try container.encodeIfPresent(numberOfPages, forKey: .numberOfPages) try container.encodeIfPresent(numberOfPages, forKey: .numberOfPages)
try container.encodeIfPresent(alwaysSendAction, forKey: .alwaysSendAction) try container.encodeIfPresent(alwaysSendAction, forKey: .alwaysSendAction)
try container.encodeIfPresent(isAnimated, forKey: .isAnimated) try container.encodeIfPresent(isAnimated, forKey: .isAnimated)

View File

@ -0,0 +1,42 @@
//
// NumericCarouselIndicatorModel.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 3/3/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
/*
class NumericCarouselIndicatorModel: CarouselIndicatorModel {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public class var identifier: String {
return "numericCarouselIndicator"
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
}
public override func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
}
}
*/

View File

@ -9,7 +9,7 @@
import UIKit import UIKit
open class NumericIndicatorView: View, IndicatorViewProtocol { open class NumericIndicatorView: CarouselIndicator {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
@ -42,15 +42,15 @@ open class NumericIndicatorView: View, IndicatorViewProtocol {
return superview as? CarouselIndicator return superview as? CarouselIndicator
} }
open var isEnabled: Bool = true { // open var isEnabled: Bool = true {
didSet { // didSet {
let enabledColor = parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack // let enabledColor = parentCarouselIndicator?.indicatorTintColor ?? .mvmBlack
let disabledColor = parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3 // let disabledColor = parentCarouselIndicator?.disabledIndicatorColor ?? .mvmCoolGray3
pageCount.textColor = isEnabled ? enabledColor : disabledColor // pageCount.textColor = isEnabled ? enabledColor : disabledColor
leftArrow.tintColor = isEnabled ? enabledColor : disabledColor // leftArrow.tintColor = isEnabled ? enabledColor : disabledColor
rightArrow.tintColor = isEnabled ? enabledColor : disabledColor // rightArrow.tintColor = isEnabled ? enabledColor : disabledColor
} // }
} // }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers