diff --git a/Segmentio/Source/Cells/SegmentioCell.swift b/Segmentio/Source/Cells/SegmentioCell.swift index 6432d66..ac9fc47 100644 --- a/Segmentio/Source/Cells/SegmentioCell.swift +++ b/Segmentio/Source/Cells/SegmentioCell.swift @@ -144,6 +144,7 @@ class SegmentioCell: UICollectionViewCell { segmentTitleLabel?.font = defaultState.titleFont segmentTitleLabel?.text = content.title } + configurateBadgeWithCount(content.badgeCount) } private func setupConstraint(indicatorOptions indicatorOptions: SegmentioIndicatorOptions) { @@ -155,6 +156,12 @@ class SegmentioCell: UICollectionViewCell { } } + private func configurateBadgeWithCount(count: Int?) { + if let count = count { + + } + } + // MARK: - Vertical separator private func addVerticalSeparator() { diff --git a/Segmentio/Source/Segmentio.swift b/Segmentio/Source/Segmentio.swift index dd1c991..dbee146 100644 --- a/Segmentio/Source/Segmentio.swift +++ b/Segmentio/Source/Segmentio.swift @@ -203,6 +203,11 @@ public class Segmentio: UIView { setupHorizontalSeparatorIfPossible() } + public func setupBadgeAtIndex(index: Int, count: Int, image: UIImage) { + segmentioItems[index].setupBadgeWithCount(count) + segmentioCollectionView?.reloadData() + } + // MARK: Collection view setup private func setupCellWithStyle(style: SegmentioStyle) { @@ -620,6 +625,7 @@ extension Segmentio: UIScrollViewDelegate { } extension Segmentio.Points { + init(context: Segmentio.Context, item: Segmentio.ItemInSuperview, pointY: CGFloat) { let cellWidth = item.cellFrameInSuperview.width diff --git a/Segmentio/Source/SegmentioOptions.swift b/Segmentio/Source/SegmentioOptions.swift index 4cf0395..ccb48e5 100644 --- a/Segmentio/Source/SegmentioOptions.swift +++ b/Segmentio/Source/SegmentioOptions.swift @@ -13,12 +13,17 @@ import UIKit public struct SegmentioItem { var title: String? var image: UIImage? + var badgeCount: Int? public init(title: String?, image: UIImage?) { self.title = title self.image = image } + public mutating func setupBadgeWithCount(count: Int) { + self.badgeCount = count + } + } // MARK: - Content view