add start logic for badges appearance
This commit is contained in:
parent
8064c6d8e8
commit
8a00fe0d90
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue