Skip to content

Commit

Permalink
Merge pull request #171 from adevinta/feature/component/badge-modific…
Browse files Browse the repository at this point in the history
…ators

Added modifiers to badge view
  • Loading branch information
alex-vecherov authored Jun 12, 2023
2 parents 1e2883a + 120290a commit 18adb2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/Demo/Classes/BadgeView_Previews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct BadgeView_Previews: PreviewProvider {
@State var smallCustomBadgeSize: BadgeSize = .small
@State var smallCustomBadgeIsOutlined: Bool = true
@State var smallCustomBadgeType: BadgeIntentType = .alert
@State var badgeFormat: BadgeFormat = .default
@State var badgeFormat: BadgeFormat = .overflowCounter(maxValue: 10)

@State var standartDangerBadgeType: BadgeIntentType = .danger

Expand Down Expand Up @@ -62,10 +62,11 @@ struct BadgeView_Previews: PreviewProvider {
BadgeView(
theme: theme,
badgeType: .primary,
value: standartBadgeValue
value: 3
)
.format(badgeFormat)
.outlined(standartBadgeIsOutlined)
.value(standartBadgeValue)
.offset(x: 100, y: -15)
}
ZStack(alignment: .leading) {
Expand Down
16 changes: 16 additions & 0 deletions core/Sources/Components/Badge/View/SwiftUI/BadgeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,20 @@ public struct BadgeView: View {
self.viewModel.badgeFormat = badgeFormat
return self
}

/// Controlls spark theme of the Badge. See more details in ``Theme``.
///
/// Use @State variable to control ``Theme`` based on this variable.
public func theme(_ theme: Theme) -> Self {
self.viewModel.theme = theme
return self
}

/// Controlls badge intent type. See more details in ``BadgeIntentType``
///
/// Use @State variable to control ``BadgeIntentType`` based on this variable.
public func value(_ value: Int?) -> Self {
self.viewModel.value = value
return self
}
}

0 comments on commit 18adb2d

Please sign in to comment.