86 lines
2.9 KiB
Swift
86 lines
2.9 KiB
Swift
//
|
|
// BreadcrumbCellItem.swift
|
|
// VDS
|
|
//
|
|
// Created by Kanamarlapudi, Vasavi on 11/03/24.
|
|
//
|
|
|
|
import UIKit
|
|
import VDSColorTokens
|
|
|
|
///This is customised view for Breadcrumb cell item
|
|
final class BreadcrumbCellItem: UICollectionViewCell {
|
|
|
|
///Identifier for the BreadcrumbCellItem
|
|
static let identifier: String = String(describing: BreadcrumbCellItem.self)
|
|
|
|
//--------------------------------------------------
|
|
// MARK: - Private Properties
|
|
//--------------------------------------------------
|
|
internal var stackView: UIStackView = {
|
|
return UIStackView().with {
|
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
|
$0.axis = .horizontal
|
|
$0.distribution = .fill
|
|
$0.alignment = .fill
|
|
$0.spacing = VDSLayout.Spacing.space1X.value
|
|
}
|
|
}()
|
|
|
|
internal var breadCrumbItem: BreadcrumbItem?
|
|
|
|
///separator label
|
|
private var separator: Label = Label().with {
|
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
|
$0.textAlignment = .left
|
|
$0.numberOfLines = 1
|
|
$0.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
|
|
$0.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
|
$0.text = "/"
|
|
}
|
|
|
|
private let textColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
|
|
|
//--------------------------------------------------
|
|
// MARK: - Initializers
|
|
//--------------------------------------------------
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
setUp()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
super.init(coder: coder)
|
|
setUp()
|
|
}
|
|
|
|
///Configuring the cell with default setup
|
|
private func setUp() {
|
|
separator.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
|
// contentView.addSubview(stackView)
|
|
// stackView.pinToSuperView()
|
|
separator.backgroundColor = .clear
|
|
}
|
|
|
|
///Updating the breadCrumbItem and UI based on the selected flag along with the surface
|
|
func update(surface: Surface, hideSlash: Bool, breadCrumbItem: BreadcrumbItem) {
|
|
contentView.subviews.forEach { $0.removeFromSuperview() }
|
|
contentView.addSubview(breadCrumbItem)
|
|
breadCrumbItem.pinToSuperView()
|
|
|
|
// separator.surface = surface
|
|
// breadCrumbItem.surface = surface
|
|
// separator.removeFromSuperview()
|
|
// self.breadCrumbItem?.removeFromSuperview()
|
|
//
|
|
//// stackView.addArrangedSubview(separator)
|
|
// stackView.addArrangedSubview(breadCrumbItem)
|
|
//// stackView.setCustomSpacing(VDSLayout.Spacing.space1X.value, after: separator)
|
|
//
|
|
// separator.textColor = textColorConfiguration.getColor(surface)
|
|
// separator.isHidden = hideSlash
|
|
self.breadCrumbItem = breadCrumbItem
|
|
layoutIfNeeded()
|
|
}
|
|
}
|