adjusting
This commit is contained in:
parent
bd9391f401
commit
edf1a478f7
@ -173,6 +173,7 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
|||||||
get { return _currentIndicatorColor }
|
get { return _currentIndicatorColor }
|
||||||
set (newColor) {
|
set (newColor) {
|
||||||
_currentIndicatorColor = newColor
|
_currentIndicatorColor = newColor
|
||||||
|
carouselIndicatorModel?.currentIndicatorColor = Color(uiColor: newColor)
|
||||||
|
|
||||||
if isBarIndicator() {
|
if isBarIndicator() {
|
||||||
if let barIndicator = indicatorView as? BarsIndicatorView {
|
if let barIndicator = indicatorView as? BarsIndicatorView {
|
||||||
@ -235,6 +236,9 @@ open class CarouselIndicator: Control, CarouselPageControlProtocol {
|
|||||||
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(swipeLeft))
|
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(swipeLeft))
|
||||||
let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(swipeRight))
|
let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(swipeRight))
|
||||||
|
|
||||||
|
leftSwipe.direction = .left
|
||||||
|
rightSwipe.direction = .right
|
||||||
|
|
||||||
addGestureRecognizer(tap)
|
addGestureRecognizer(tap)
|
||||||
addGestureRecognizer(leftSwipe)
|
addGestureRecognizer(leftSwipe)
|
||||||
addGestureRecognizer(rightSwipe)
|
addGestureRecognizer(rightSwipe)
|
||||||
|
|||||||
@ -14,27 +14,26 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
|
||||||
|
|
||||||
public static var identifier: String {
|
public static var identifier: String {
|
||||||
return "carouselIndicator"
|
return "carouselIndicator"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var backgroundColor: Color?
|
||||||
public var moleculeName: String?
|
public var moleculeName: String?
|
||||||
public var type: String? = "hybrid"
|
public var type: String = "hybrid"
|
||||||
public var hybridThreshold: Int = 5
|
public var hybridThreshold: Int = 5
|
||||||
public var barsColor: Color?
|
public var barsColor: Color?
|
||||||
public var currentBarColor: Color?
|
public var currentBarColor: Color?
|
||||||
public var currentIndex: Int? = 0
|
public var currentIndex: Int = 0
|
||||||
public var numberOfPages: Int? = 0
|
public var numberOfPages: Int = 0
|
||||||
public var alwaysSendEvent: Bool? = false
|
public var alwaysSendEvent: Bool = false
|
||||||
public var isAnimated: Bool? = true
|
public var isAnimated: Bool = true
|
||||||
public var hidesForSinglePage: Bool? = false
|
public var hidesForSinglePage: Bool = false
|
||||||
public var accessibilityHasSlidesInsteadOfPage: Bool? = false
|
public var accessibilityHasSlidesInsteadOfPage: Bool = false
|
||||||
public var isEnabled: Bool? = false
|
public var isEnabled: Bool = false
|
||||||
public var disabledIndicatorColor: Color? = Color(uiColor: .mvmCoolGray3)
|
public var disabledIndicatorColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
public var indicatorTintColor: Color? = Color(uiColor: .mvmBlack)
|
public var indicatorTintColor: Color = Color(uiColor: .mvmBlack)
|
||||||
public var currentIndicatorColor: Color? = Color(uiColor: .mvmBlack)
|
public var currentIndicatorColor: Color = Color(uiColor: .mvmBlack)
|
||||||
public var position: Float?
|
public var position: Float?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -70,20 +69,56 @@ public class CarouselIndicatorModel: CarouselPagingModelProtocol {
|
|||||||
currentBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentBarColor)
|
currentBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentBarColor)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
barsColor = try typeContainer.decodeIfPresent(Color.self, forKey: .barsColor)
|
barsColor = try typeContainer.decodeIfPresent(Color.self, forKey: .barsColor)
|
||||||
type = try typeContainer.decodeIfPresent(String.self, forKey: .type) ?? "hybrid"
|
|
||||||
hybridThreshold = try typeContainer.decodeIfPresent(Int.self, forKey: .hybridThreshold) ?? 5
|
|
||||||
barsColor = try typeContainer.decodeIfPresent(Color.self, forKey: .barsColor)
|
barsColor = try typeContainer.decodeIfPresent(Color.self, forKey: .barsColor)
|
||||||
currentBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentBarColor)
|
currentBarColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentBarColor)
|
||||||
currentIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .currentIndex) ?? 0
|
|
||||||
numberOfPages = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfPages) ?? 0
|
if let type = try typeContainer.decodeIfPresent(String.self, forKey: .type) {
|
||||||
alwaysSendEvent = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysSendEvent) ?? false
|
self.type = type
|
||||||
isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) ?? true
|
}
|
||||||
hidesForSinglePage = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesForSinglePage) ?? false
|
|
||||||
accessibilityHasSlidesInsteadOfPage = try typeContainer.decodeIfPresent(Bool.self, forKey: .accessibilityHasSlidesInsteadOfPage) ?? false
|
if let hybridThreshold = try typeContainer.decodeIfPresent(Int.self, forKey: .hybridThreshold) {
|
||||||
isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) ?? false
|
self.hybridThreshold = hybridThreshold
|
||||||
disabledIndicatorColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledIndicatorColor) ?? Color(uiColor: .mvmCoolGray3)
|
}
|
||||||
indicatorTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indicatorTintColor) ?? Color(uiColor: .mvmBlack)
|
|
||||||
currentIndicatorColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentIndicatorColor) ?? Color(uiColor: .mvmBlack)
|
if let currentIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .currentIndex) {
|
||||||
|
self.currentIndex = currentIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
if let numberOfPages = try typeContainer.decodeIfPresent(Int.self, forKey: .numberOfPages) {
|
||||||
|
self.numberOfPages = numberOfPages
|
||||||
|
}
|
||||||
|
|
||||||
|
if let alwaysSendEvent = try typeContainer.decodeIfPresent(Bool.self, forKey: .alwaysSendEvent) {
|
||||||
|
self.alwaysSendEvent = alwaysSendEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
if let isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) {
|
||||||
|
self.isAnimated = isAnimated
|
||||||
|
}
|
||||||
|
|
||||||
|
if let hidesForSinglePage = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidesForSinglePage) {
|
||||||
|
self.hidesForSinglePage = hidesForSinglePage
|
||||||
|
}
|
||||||
|
|
||||||
|
if let accessibilityHasSlidesInsteadOfPage = try typeContainer.decodeIfPresent(Bool.self, forKey: .accessibilityHasSlidesInsteadOfPage) {
|
||||||
|
self.accessibilityHasSlidesInsteadOfPage = accessibilityHasSlidesInsteadOfPage
|
||||||
|
}
|
||||||
|
|
||||||
|
if let isEnabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEnabled) {
|
||||||
|
self.isEnabled = isEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if let disabledIndicatorColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledIndicatorColor) {
|
||||||
|
self.disabledIndicatorColor = disabledIndicatorColor
|
||||||
|
}
|
||||||
|
|
||||||
|
if let indicatorTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .indicatorTintColor) {
|
||||||
|
self.indicatorTintColor = indicatorTintColor
|
||||||
|
}
|
||||||
|
|
||||||
|
if let currentIndicatorColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentIndicatorColor) {
|
||||||
|
self.currentIndicatorColor = currentIndicatorColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -69,10 +69,9 @@ open class BarsIndicatorView: View, IndicatorViewProtocol {
|
|||||||
isUserInteractionEnabled = false
|
isUserInteractionEnabled = false
|
||||||
|
|
||||||
heightAnchor.constraint(equalToConstant: 4).isActive = true
|
heightAnchor.constraint(equalToConstant: 4).isActive = true
|
||||||
|
|
||||||
stackView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
stackView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
||||||
stackView.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor).isActive = true
|
stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
trailingAnchor.constraint(greaterThanOrEqualTo: stackView.trailingAnchor).isActive = true
|
trailingAnchor.constraint(equalTo: stackView.trailingAnchor).isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -226,8 +226,9 @@ open class Carousel: View {
|
|||||||
open func addPaging(view: (UIView & CarouselPageControlProtocol)?, position: CGFloat) {
|
open func addPaging(view: (UIView & CarouselPageControlProtocol)?, position: CGFloat) {
|
||||||
|
|
||||||
pagingView?.removeFromSuperview()
|
pagingView?.removeFromSuperview()
|
||||||
guard var pagingView = view else {
|
|
||||||
bottomPin?.isActive = false
|
bottomPin?.isActive = false
|
||||||
|
|
||||||
|
guard var pagingView = view else {
|
||||||
bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor)
|
bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor)
|
||||||
bottomPin?.isActive = true
|
bottomPin?.isActive = true
|
||||||
return
|
return
|
||||||
@ -236,8 +237,6 @@ open class Carousel: View {
|
|||||||
addSubview(pagingView)
|
addSubview(pagingView)
|
||||||
pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true
|
pagingView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true
|
||||||
collectionView.bottomAnchor.constraint(equalTo: pagingView.bottomAnchor, constant: position).isActive = true
|
collectionView.bottomAnchor.constraint(equalTo: pagingView.bottomAnchor, constant: position).isActive = true
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: pagingView.bottomAnchor).isActive = true
|
|
||||||
bottomPin?.isActive = false
|
|
||||||
bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor)
|
bottomPin = bottomAnchor.constraint(equalTo: collectionView.bottomAnchor)
|
||||||
bottomPin?.priority = .defaultLow
|
bottomPin?.priority = .defaultLow
|
||||||
bottomPin?.isActive = true
|
bottomPin?.isActive = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user