correcting layout issue

This commit is contained in:
Kevin G Christiano 2020-05-07 10:38:10 -04:00
parent 38e9141810
commit 0501c2daae
4 changed files with 30 additions and 10 deletions

View File

@ -98,6 +98,18 @@ open class BarsIndicatorView: CarouselIndicator {
])
}
open override func layoutSubviews() {
super.layoutSubviews()
if barReferences.isEmpty {
generateBars()
updateUI(previousIndex: previousIndex,
newIndex: currentIndex,
totalCount: numberOfPages,
isAnimated: false)
}
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------

View File

@ -66,6 +66,17 @@ open class NumericIndicatorView: CarouselIndicator {
pageCount.updateView(size)
}
open override func layoutSubviews() {
super.layoutSubviews()
if pageCount.text?.isEmpty == nil {
updateUI(previousIndex: previousIndex,
newIndex: currentIndex,
totalCount: numberOfPages,
isAnimated: false)
}
}
//--------------------------------------------------
// MARK: - Setup
//--------------------------------------------------

View File

@ -26,10 +26,8 @@ open class Carousel: View {
/// The index of the page, does not include dummy cells.
public var pageIndex: Int {
get {
return loop ? currentIndex - 2 : currentIndex
}
set(newIndex) {
get { return loop ? currentIndex - 2 : currentIndex }
set (newIndex) {
currentIndex = loop ? newIndex + 2 : newIndex
}
}
@ -90,6 +88,7 @@ open class Carousel: View {
}
}
//--------------------------------------------------
// MARK: - MVMCoreViewProtocol
//--------------------------------------------------
@ -194,7 +193,7 @@ open class Carousel: View {
pagingView = MoleculeObjectMapping.shared()?.createMolecule(molecule, delegateObject: delegateObject) as? (UIView & CarouselPageControlProtocol)
}
addPaging(view: pagingView , position: (CGFloat(molecule?.position ?? 20)))
addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20)))
}
/// Registers the cells with the collection view
@ -213,9 +212,7 @@ open class Carousel: View {
/// Returns the (identifier, class) of the molecule for the given map.
func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? {
guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else {
return nil
}
guard let className = MoleculeObjectMapping.shared()?.getMoleculeClass(molecule) else { return nil }
return (className.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule)
}

View File

@ -45,8 +45,8 @@ extension MoleculeViewProtocol {
}
// Do nothing, optionals.
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {}
public func reset() {}
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { }
public func reset() { }
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil