From bf27d19ae15032208ae4b8c76916211c195eb213 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 19 Dec 2019 14:25:26 -0500 Subject: [PATCH] change float to cgfloat for nslayoutconstraint --- MVMCoreUI/Models/Molecules/CarouselModel.swift | 12 ++++++------ MVMCoreUI/Organisms/Carousel.swift | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Models/Molecules/CarouselModel.swift b/MVMCoreUI/Models/Molecules/CarouselModel.swift index 08bddafd..47e36518 100644 --- a/MVMCoreUI/Models/Molecules/CarouselModel.swift +++ b/MVMCoreUI/Models/Molecules/CarouselModel.swift @@ -13,11 +13,11 @@ import UIKit public var backgroundColor: String? public var molecules: [CarouselItemModel] - public var spacing: Float? + public var spacing: CGFloat? public var border: Bool? public var loop: Bool? - public var height: Float? - public var itemWidthPercent: Float? + public var height: CGFloat? + public var itemWidthPercent: CGFloat? public var itemAlignment: String? public var pagingMolecule: PagingMoleculeProtocol? @@ -40,11 +40,11 @@ import UIKit required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules) - spacing = try typeContainer.decodeIfPresent(Float.self, forKey: .spacing) + spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border) loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop) - height = try typeContainer.decodeIfPresent(Float.self, forKey: .height) - itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent) + height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) + itemWidthPercent = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .itemWidthPercent) itemAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .itemAlignment) pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol } diff --git a/MVMCoreUI/Organisms/Carousel.swift b/MVMCoreUI/Organisms/Carousel.swift index 116f1135..6af1224b 100644 --- a/MVMCoreUI/Organisms/Carousel.swift +++ b/MVMCoreUI/Organisms/Carousel.swift @@ -98,11 +98,11 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { registerCells(with: caroselModel, delegateObject: delegateObject) setupLayout(with: caroselModel) prepareMolecules(with: caroselModel) - itemWidthPercent = CGFloat((caroselModel.itemWidthPercent ?? 100) / 100) + itemWidthPercent = (caroselModel.itemWidthPercent ?? 100) / 100 setAlignment(with: caroselModel.itemAlignment) if let height = caroselModel.height { - collectionViewHeight?.constant = CGFloat(height) + collectionViewHeight?.constant = height collectionViewHeight?.isActive = true } @@ -122,7 +122,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol { func setupLayout(with carouselModel: CarouselModel?) { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal - layout.minimumLineSpacing = CGFloat(carouselModel?.spacing ?? 1) + layout.minimumLineSpacing = carouselModel?.spacing ?? 1 layout.minimumInteritemSpacing = 0 collectionView.collectionViewLayout = layout }