Digital ACT-191 ONEAPP-6827 story: removed unused and commented code

This commit is contained in:
vasavk 2024-03-14 15:05:01 +05:30
parent a39e088711
commit 2703112148
3 changed files with 23 additions and 63 deletions

View File

@ -17,17 +17,6 @@ final class BreadcrumbCellItem: UICollectionViewCell {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
internal var crumbWidthConstraint: NSLayoutConstraint?
var crumb : BreadcrumbItem? {
didSet {
guard let crumb = crumb else { return }
breadCrumbItem = crumb
crumbWidthConstraint?.constant = crumb.intrinsicContentSize.width
crumbWidthConstraint?.isActive = true
}
}
internal var stackView: UIStackView = { internal var stackView: UIStackView = {
return UIStackView().with { return UIStackView().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
@ -50,12 +39,6 @@ final class BreadcrumbCellItem: UICollectionViewCell {
private let textColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark) private let textColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
private var crumbTextColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal)
$0.setSurfaceColors(VDSColor.interactiveActiveOnlight, VDSColor.interactiveActiveOndark, forState: .highlighted)
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected)
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//-------------------------------------------------- //--------------------------------------------------
@ -76,15 +59,14 @@ final class BreadcrumbCellItem: UICollectionViewCell {
separator.backgroundColor = .clear separator.backgroundColor = .clear
} }
///Updating UI based on selected index, current index along with surface ///Updating the breadCrumbItem and UI based on the selected flag along with the surface
func update(surface: Surface, hideSlash: Bool, breadCrumbItem: BreadcrumbItem) { func update(surface: Surface, hideSlash: Bool, breadCrumbItem: BreadcrumbItem) {
stackView.removeAllArrangedSubviews() stackView.removeAllArrangedSubviews()
stackView.addArrangedSubview(separator) stackView.addArrangedSubview(separator)
stackView.addArrangedSubview(breadCrumbItem) stackView.addArrangedSubview(breadCrumbItem)
stackView.setCustomSpacing(VDSLayout.Spacing.space1X.value, after: breadCrumbItem) stackView.setCustomSpacing(VDSLayout.Spacing.space1X.value, after: separator)
separator.textColor = textColorConfiguration.getColor(surface) separator.textColor = textColorConfiguration.getColor(surface)
separator.isHidden = hideSlash separator.isHidden = hideSlash
print("selected: \(breadCrumbItem.isSelected), hideSlash: \(hideSlash), text: \(String(describing: breadCrumbItem.text)))")
self.breadCrumbItem = breadCrumbItem self.breadCrumbItem = breadCrumbItem
layoutIfNeeded() layoutIfNeeded()
} }

View File

@ -66,8 +66,6 @@ open class BreadcrumbItem: ButtonBase {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
var separator = " /"
private var textColorConfiguration = ControlColorConfiguration().with { private var textColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal) $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .normal)
$0.setSurfaceColors(VDSColor.interactiveActiveOnlight, VDSColor.interactiveActiveOndark, forState: .highlighted) $0.setSurfaceColors(VDSColor.interactiveActiveOnlight, VDSColor.interactiveActiveOndark, forState: .highlighted)
@ -88,24 +86,6 @@ open class BreadcrumbItem: ButtonBase {
/// Used to make changes to the View based off a change events or from local properties. /// Used to make changes to the View based off a change events or from local properties.
open override func updateView() { open override func updateView() {
//always call last so the label is rendered //always call last so the label is rendered
// if (text != nil) {
// var newText: String = text ?? ""
// if isSelected {
// if newText.contains(separator) {
// let result = newText.dropLast(2)
// newText = String(result)
// }
// } else {
// if !newText.contains(separator) {
// newText = (text ?? "") + separator
// }
// }
// print("newText:\(newText), isSelected: \(isSelected)")
// text = newText
// if let titleLabel {
// titleLabel.text = text
// }
// }
super.updateView() super.updateView()
} }

View File

@ -15,6 +15,25 @@ import Combine
@objc(VDSBreadcrumbs) @objc(VDSBreadcrumbs)
open class Breadcrumbs: View { open class Breadcrumbs: View {
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
/// Array of Breadcrumb Items that are shown in the group.
open var breadcrumbItems: [BreadcrumbItem] = [] { didSet { setNeedsUpdate() } }
/// Whether this object is enabled or not
override open var isEnabled: Bool {
didSet {
breadcrumbItems.forEach { $0.isEnabled = isEnabled }
}
}
/// Current Surface and this is used to pass down to child objects that implement Surfacable
override open var surface: Surface {
didSet {
breadcrumbItems.forEach { $0.surface = surface }
}
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
@ -40,26 +59,6 @@ open class Breadcrumbs: View {
return collectionView return collectionView
}() }()
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
/// Array of Breadcrumb Items that are shown in the group.
open var breadcrumbItems: [ButtonBase] = [] { didSet { setNeedsUpdate() } }
/// Whether this object is enabled or not
override open var isEnabled: Bool {
didSet {
breadcrumbItems.forEach { $0.isEnabled = isEnabled }
}
}
/// Current Surface and this is used to pass down to child objects that implement Surfacable
override open var surface: Surface {
didSet {
breadcrumbItems.forEach { $0.surface = surface }
}
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides
//-------------------------------------------------- //--------------------------------------------------
@ -73,7 +72,7 @@ open class Breadcrumbs: View {
super.initialSetup() super.initialSetup()
addSubview(collectionView) addSubview(collectionView)
collectionView.pinToSuperView() collectionView.pinToSuperView()
collectionView.heightAnchor.constraint(equalToConstant: 100).activate() collectionView.heightAnchor.constraint(equalToConstant: 80).activate()
} }
/// Resets to default settings. /// Resets to default settings.
@ -98,9 +97,8 @@ extension Breadcrumbs: UICollectionViewDelegate, UICollectionViewDataSource {
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BreadcrumbCellItem.identifier, for: indexPath) as? BreadcrumbCellItem else { return UICollectionViewCell() } guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BreadcrumbCellItem.identifier, for: indexPath) as? BreadcrumbCellItem else { return UICollectionViewCell() }
let breadcrumb : BreadcrumbItem = breadcrumbItems[indexPath.row] as! BreadcrumbItem
let hideSlash = (indexPath.row == 0) let hideSlash = (indexPath.row == 0)
cell.update(surface: surface, hideSlash: hideSlash, breadCrumbItem: breadcrumb) cell.update(surface: surface, hideSlash: hideSlash, breadCrumbItem: breadcrumbItems[indexPath.row])
return cell return cell
} }