@@ -3,10 +3,23 @@ import SwiftUI
33struct BadgeStyleModifier : ViewModifier {
44 let isActive : Bool
55
6+ @ Environment ( \. controlSize ) private var controlSize
7+
8+ private var textStyle : Font . TextStyle {
9+ switch controlSize {
10+ case . mini : . caption2
11+ case . small : . caption
12+ case . regular : . body
13+ case . large : . title3
14+ case . extraLarge : . title2
15+ @ unknown default : . body
16+ }
17+ }
18+
619 func body ( content : Content ) -> some View {
720 content
821 . padding ( Padding . md )
9- . font ( . sligoilMicroBold ( . caption ) )
22+ . font ( . sligoilMicroBold ( textStyle ) )
1023 . foregroundStyle (
1124 isActive
1225 ? . themePrimary
@@ -18,7 +31,7 @@ struct BadgeStyleModifier: ViewModifier {
1831 . fill ( . tint )
1932 } else {
2033 RoundedRectangle ( cornerRadius : Radius . md )
21- . stroke ( . themePrimaryInverted )
34+ . stroke ( . themePrimaryInverted , lineWidth : LineWidth . sm )
2235 }
2336 }
2437 }
@@ -72,6 +85,7 @@ struct FilterBar: View {
7285 . toggleStyle ( . badge )
7386 }
7487 }
88+ . padding ( 1 )
7589 }
7690 }
7791}
@@ -85,12 +99,15 @@ private struct TestBadge: View {
8599 VStack {
86100 Text ( " Badge " )
87101 . badgeStyle ( )
102+ . controlSize ( . small )
88103
89104 Toggle ( " Toggle " , isOn : $isOn1 )
90105 . toggleStyle ( . badge )
106+ . controlSize ( . regular )
91107
92108 Toggle ( " Tinted toggle " , isOn : $isOn2 )
93109 . toggleStyle ( . badge )
110+ . controlSize ( . large )
94111 . tint ( . blue )
95112 }
96113 }
@@ -119,7 +136,7 @@ private struct CompleteView: View {
119136 }
120137
121138 private var filteredItems : [ Item ] {
122- guard selectedFilter != . all else {
139+ if selectedFilter == . all {
123140 return items
124141 }
125142
@@ -145,11 +162,11 @@ private struct CompleteView: View {
145162 Divider ( )
146163 }
147164 }
148- // .border(.red)
149165 }
150166 . padding ( . horizontal )
151167 }
152168}
169+
153170#Preview ( " Filter Bar " ) {
154171 CompleteView ( )
155172}
0 commit comments