Digital ACT-191 ONEAPP-6827 story: container size changes

This commit is contained in:
vasavk 2024-03-19 17:33:19 +05:30
parent 4c9c844b1d
commit 868c728f63

View File

@ -38,6 +38,11 @@ open class Breadcrumbs: View {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
// Sizes are from InVision design specs.
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
internal var heightConstraint: NSLayoutConstraint?
let layout: UICollectionViewFlowLayout = LeftAlignedCollectionViewFlowLayout().with { let layout: UICollectionViewFlowLayout = LeftAlignedCollectionViewFlowLayout().with {
$0.estimatedItemSize = UICollectionViewFlowLayout.automaticSize $0.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
$0.minimumInteritemSpacing = VDSLayout.Spacing.space1X.value $0.minimumInteritemSpacing = VDSLayout.Spacing.space1X.value
@ -60,12 +65,16 @@ open class Breadcrumbs: View {
return collectionView return collectionView
}() }()
//-------------------------------------------------- //------------------------------------------s--------
// MARK: - Overrides // MARK: - Overrides
//-------------------------------------------------- //--------------------------------------------------
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
open override func setup() { open override func setup() {
super.setup() super.setup()
//create the wrapping view
heightConstraint = self.heightAnchor.constraint(equalToConstant: containerSize.height)
heightConstraint?.priority = .defaultHigh
heightConstraint?.isActive = true
} }
/// Executed on initialization for this View. /// Executed on initialization for this View.
@ -73,7 +82,6 @@ open class Breadcrumbs: View {
super.initialSetup() super.initialSetup()
addSubview(collectionView) addSubview(collectionView)
collectionView.pinToSuperView() collectionView.pinToSuperView()
collectionView.heightAnchor.constraint(equalToConstant: 80).activate()
} }
/// Resets to default settings. /// Resets to default settings.
@ -89,6 +97,8 @@ open class Breadcrumbs: View {
open override func updateView() { open override func updateView() {
super.updateView() super.updateView()
collectionView.reloadData() collectionView.reloadData()
heightConstraint?.constant = collectionView.collectionViewLayout.collectionViewContentSize.height
heightConstraint?.isActive = true
} }
open override func layoutSubviews() { open override func layoutSubviews() {