change float to cgfloat for nslayoutconstraint
This commit is contained in:
parent
d17ab73d34
commit
bf27d19ae1
@ -13,11 +13,11 @@ import UIKit
|
|||||||
public var backgroundColor: String?
|
public var backgroundColor: String?
|
||||||
public var molecules: [CarouselItemModel]
|
public var molecules: [CarouselItemModel]
|
||||||
|
|
||||||
public var spacing: Float?
|
public var spacing: CGFloat?
|
||||||
public var border: Bool?
|
public var border: Bool?
|
||||||
public var loop: Bool?
|
public var loop: Bool?
|
||||||
public var height: Float?
|
public var height: CGFloat?
|
||||||
public var itemWidthPercent: Float?
|
public var itemWidthPercent: CGFloat?
|
||||||
public var itemAlignment: String?
|
public var itemAlignment: String?
|
||||||
public var pagingMolecule: PagingMoleculeProtocol?
|
public var pagingMolecule: PagingMoleculeProtocol?
|
||||||
|
|
||||||
@ -40,11 +40,11 @@ import UIKit
|
|||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
molecules = try typeContainer.decode([CarouselItemModel].self, forKey: .molecules)
|
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)
|
border = try typeContainer.decodeIfPresent(Bool.self, forKey: .border)
|
||||||
loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop)
|
loop = try typeContainer.decodeIfPresent(Bool.self, forKey: .loop)
|
||||||
height = try typeContainer.decodeIfPresent(Float.self, forKey: .height)
|
height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height)
|
||||||
itemWidthPercent = try typeContainer.decodeIfPresent(Float.self, forKey: .itemWidthPercent)
|
itemWidthPercent = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .itemWidthPercent)
|
||||||
itemAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .itemAlignment)
|
itemAlignment = try typeContainer.decodeIfPresent(String.self, forKey: .itemAlignment)
|
||||||
pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol
|
pagingMolecule = try typeContainer.decodeIfPresent(codingKey: .pagingMolecule) as? PagingMoleculeProtocol
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,11 +98,11 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
|
|||||||
registerCells(with: caroselModel, delegateObject: delegateObject)
|
registerCells(with: caroselModel, delegateObject: delegateObject)
|
||||||
setupLayout(with: caroselModel)
|
setupLayout(with: caroselModel)
|
||||||
prepareMolecules(with: caroselModel)
|
prepareMolecules(with: caroselModel)
|
||||||
itemWidthPercent = CGFloat((caroselModel.itemWidthPercent ?? 100) / 100)
|
itemWidthPercent = (caroselModel.itemWidthPercent ?? 100) / 100
|
||||||
setAlignment(with: caroselModel.itemAlignment)
|
setAlignment(with: caroselModel.itemAlignment)
|
||||||
|
|
||||||
if let height = caroselModel.height {
|
if let height = caroselModel.height {
|
||||||
collectionViewHeight?.constant = CGFloat(height)
|
collectionViewHeight?.constant = height
|
||||||
collectionViewHeight?.isActive = true
|
collectionViewHeight?.isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
|
|||||||
func setupLayout(with carouselModel: CarouselModel?) {
|
func setupLayout(with carouselModel: CarouselModel?) {
|
||||||
let layout = UICollectionViewFlowLayout()
|
let layout = UICollectionViewFlowLayout()
|
||||||
layout.scrollDirection = .horizontal
|
layout.scrollDirection = .horizontal
|
||||||
layout.minimumLineSpacing = CGFloat(carouselModel?.spacing ?? 1)
|
layout.minimumLineSpacing = carouselModel?.spacing ?? 1
|
||||||
layout.minimumInteritemSpacing = 0
|
layout.minimumInteritemSpacing = 0
|
||||||
collectionView.collectionViewLayout = layout
|
collectionView.collectionViewLayout = layout
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user