From dcd4dde59dac0a182ff416f854263adacdd24e77 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 19 Sep 2022 11:50:51 -0400 Subject: [PATCH] Added temporary corner rounding --- MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift | 9 ++++++++- MVMCoreUI/Containers/Views/Container.swift | 5 +++++ MVMCoreUI/Containers/Views/ContainerModel.swift | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift index a37fe016..301a2274 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/CarouselItem.swift @@ -22,7 +22,8 @@ open class CarouselItem: MoleculeCollectionViewCell, CarouselItemProtocol { open override func setupView() { super.setupView() - + clipsToBounds = true + // Covers the card when peaking. peakingCover.backgroundColor = .white peakingCover.alpha = 0 @@ -51,6 +52,12 @@ open class CarouselItem: MoleculeCollectionViewCell, CarouselItemProtocol { super.set(with: model, delegateObject, additionalData) guard let collectionModel = model as? CarouselItemModel else { return } + if let cornerRadius = (model as? ContainerModel)?.cornerRadius { + layer.cornerRadius = cornerRadius + } else { + layer.cornerRadius = 0 + } + // Handles peaking. allowsPeaking = collectionModel.peakingUI ?? false if let peakingArrowColor = collectionModel.peakingArrowColor { diff --git a/MVMCoreUI/Containers/Views/Container.swift b/MVMCoreUI/Containers/Views/Container.swift index 32c22b54..281f8d1b 100644 --- a/MVMCoreUI/Containers/Views/Container.swift +++ b/MVMCoreUI/Containers/Views/Container.swift @@ -31,6 +31,11 @@ open class Container: View, ContainerProtocol { guard let containerModel = model as? ContainerModelProtocol else { return } containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol) + if let cornerRadius = (containerModel as? ContainerModel)?.cornerRadius { + layer.cornerRadius = cornerRadius + } else { + layer.cornerRadius = 0 + } } override open func reset() { diff --git a/MVMCoreUI/Containers/Views/ContainerModel.swift b/MVMCoreUI/Containers/Views/ContainerModel.swift index caa949df..731e9c95 100644 --- a/MVMCoreUI/Containers/Views/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/ContainerModel.swift @@ -23,6 +23,8 @@ open class ContainerModel: ContainerModelProtocol, Codable { public var topPadding: CGFloat? public var bottomPadding: CGFloat? + public var cornerRadius: CGFloat? + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -36,6 +38,7 @@ open class ContainerModel: ContainerModelProtocol, Codable { case useVerticalMargins case topPadding case bottomPadding + case cornerRadius } //-------------------------------------------------- @@ -83,6 +86,7 @@ open class ContainerModel: ContainerModelProtocol, Codable { useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins) topPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .topPadding) bottomPadding = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .bottomPadding) + cornerRadius = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .cornerRadius) setDefaults() } @@ -96,5 +100,6 @@ open class ContainerModel: ContainerModelProtocol, Codable { try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins) try container.encodeIfPresent(topPadding, forKey: .topPadding) try container.encodeIfPresent(bottomPadding, forKey: .bottomPadding) + try container.encodeIfPresent(cornerRadius, forKey: .cornerRadius) } }