Skip to content

Commit 08b29dc

Browse files
rudrankriyamclaude
andcommitted
Update stepper components with liquid glass styling and native fonts
- Add liquid glass button style to WideStepperButton - Update ControlView, WideStepper, WideSlider with accessibility labels - Remove custom font extensions, use native SwiftUI fonts - Add color and step parameters for flexibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 13088cb commit 08b29dc

11 files changed

Lines changed: 165 additions & 200 deletions

‎Sources/BlocKit/Button/GradientButton.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct GradientButton: View {
2626
Button(action: action) {
2727
Text(title)
2828
.kerning(1.0)
29-
.font(type: .poppins, weight: .light, style: .callout)
29+
.font(.callout.weight(.light))
3030
}
3131
.padding(.bottom)
3232
.buttonStyle(GradientButtonStyle())

‎Sources/BlocKit/Button/WideStepperButton.swift‎

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,47 @@
77

88
import SwiftUI
99

10-
enum StepperButtonImage: String {
10+
public enum StepperButtonImage: String, Sendable {
1111
case plus
1212
case minus
1313
}
1414

15-
struct WideStepperButton: View {
16-
var condition: Bool
17-
var systemName: StepperButtonImage
18-
var action: () -> ()
19-
20-
var body: some View {
15+
public struct WideStepperButton: View {
16+
public var condition: Bool
17+
public var color: Color
18+
public var systemName: StepperButtonImage
19+
public var accessibilityLabel: LocalizedStringKey
20+
public var action: () -> ()
21+
22+
public init(
23+
condition: Bool,
24+
color: Color = .accentColor,
25+
systemName: StepperButtonImage,
26+
accessibilityLabel: LocalizedStringKey = "Value",
27+
action: @escaping () -> ()
28+
) {
29+
self.condition = condition
30+
self.color = color
31+
self.systemName = systemName
32+
self.accessibilityLabel = accessibilityLabel
33+
self.action = action
34+
}
35+
36+
public var body: some View {
2137
Button(action: action) {
2238
Image(systemName: systemName.rawValue)
23-
.foregroundColor(condition ? .accentColor : .secondaryBackground)
24-
.padding(2)
39+
.foregroundColor(condition ? color : .secondary.opacity(0.5))
40+
.frame(width: 32, height: 32)
2541
}
26-
.buttonStyle(StepperButtonStyle())
42+
.buttonStyle(.glass)
43+
.buttonBorderShape(.circle)
44+
.disabled(!condition)
45+
.opacity(condition ? 1.0 : 0.3)
46+
.accessibilityLabel((systemName == .plus ? Text("Increase") : Text("Decrease")) + Text(" ") + Text(accessibilityLabel))
47+
.accessibilityHint(Text("Double tap to ") + (systemName == .plus ? Text("increase") : Text("decrease")) + Text(" ") + Text(accessibilityLabel) + Text(" by one"))
2748
}
2849
}
2950

30-
struct WideStepperButton_Previews: PreviewProvider {
31-
static var previews: some View {
32-
WideStepperButton(condition: true, systemName: .minus, action: {})
33-
}
51+
#Preview {
52+
WideStepperButton(condition: true, color: .red, systemName: .minus, action: {})
3453
}

‎Sources/BlocKit/Extensions/Text.swift‎

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ import SwiftUI
1010
extension Text {
1111
public func customTitleText(size: CGFloat) -> some View {
1212
self
13-
.font(type: .poppins, weight: .black, style: .largeTitle)
13+
.font(.largeTitle.weight(.black))
1414
.multilineTextAlignment(.center)
1515
}
16-
16+
1717
public func titleText() -> some View {
1818
self
19-
.font(type: .poppins, weight: .bold, style: .title1)
19+
.font(.title.weight(.bold))
2020
}
21-
22-
public func largeTitleText(type: FontType, topPadding: CGFloat = 37) -> some View {
21+
22+
public func largeTitleText(topPadding: CGFloat = 37) -> some View {
2323
self
24-
.font(type: type, weight: .bold, style: .largeTitle)
24+
.font(.largeTitle.weight(.bold))
2525
.foregroundColor(.primary)
2626
.frame(maxWidth: .infinity, alignment: .leading)
2727
.padding(.top, topPadding)
2828
}
29-
29+
3030
public func buttonText() -> some View {
3131
self
32-
.font(type: .poppins, weight: .bold, style: .headline)
32+
.font(.headline.weight(.bold))
3333
.kerning(1.0)
3434
}
35-
35+
3636
public func blurredBackgroundText() -> some View {
3737
self
38-
.font(type: .poppins, weight: .regular, style: .caption1)
38+
.font(.caption)
3939
.baselineOffset(1)
4040
.foregroundColor(.primary)
4141
.accessibility(addTraits: .isHeader)
@@ -45,33 +45,3 @@ extension Text {
4545
.background(RoundedRectangle(cornerRadius: Constants.cornerRadius / 1.5).fill(Color.white.opacity(0.25)))
4646
}
4747
}
48-
49-
struct OffsetText<S>: View where S: StringProtocol {
50-
private var content: S
51-
private var font: CustomFont
52-
53-
@ScaledMetric(relativeTo: .body) var baselineOffset = 1
54-
55-
init(_ content: S, font: CustomFont) {
56-
self.content = content
57-
self.font = font
58-
}
59-
60-
var body: some View {
61-
Text(content)
62-
.font(font)
63-
.baselineOffset(baselineOffset)
64-
.padding(.top, 1)
65-
}
66-
}
67-
68-
struct CustomFont: Sendable {
69-
var type: FontType
70-
var weight: FontWeight
71-
var style: UIFont.TextStyle
72-
}
73-
74-
extension CustomFont {
75-
static let appButton = CustomFont(type: .poppins, weight: .light, style: .caption1)
76-
}
77-

‎Sources/BlocKit/Extensions/View+CustomFont.swift‎

Lines changed: 0 additions & 66 deletions
This file was deleted.

‎Sources/BlocKit/Slider/WideSlider.swift‎

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,34 @@
77

88
import SwiftUI
99

10-
struct WideSlider: View {
10+
public struct WideSlider: View {
1111
@Binding var value: Double
12-
13-
init(_ value: Binding<Double>) {
12+
public var color: Color
13+
public var step: Double
14+
public var accessibilityLabel: LocalizedStringKey
15+
16+
public init(
17+
_ value: Binding<Double>,
18+
color: Color = .accentColor,
19+
step: Double = 255,
20+
accessibilityLabel: LocalizedStringKey = "Value"
21+
) {
1422
self._value = value
23+
self.color = color
24+
self.step = step
25+
self.accessibilityLabel = accessibilityLabel
1526
}
16-
17-
var colors: [Color] {
18-
[.accentColor.opacity(0.8), .accentColor]
19-
}
20-
21-
var body: some View {
22-
CustomSlider(value: $value, range: (0, 1)) { modifiers in
23-
ZStack(alignment: .center) {
24-
25-
LinearGradient(gradient: Gradient(colors: [.traitsBackground]), startPoint: .leading, endPoint: .trailing)
26-
.modifier(modifiers.barRight)
27-
.overlay(RoundedRectangle(cornerRadius: Constants.cornerRadius)
28-
.stroke(Color.stroke))
29-
30-
LinearGradient(gradient: Gradient(colors: colors), startPoint: .leading, endPoint: .trailing)
31-
.modifier(modifiers.barLeft)
32-
33-
Circle()
34-
.fill(Color.accentColor)
35-
.overlay(Circle().fill(Color.white.opacity(0.15)))
36-
.modifier(modifiers.knob)
37-
}
38-
.cornerRadius(Constants.cornerRadius)
39-
}
40-
.frame(height: 25)
27+
28+
public var body: some View {
29+
Slider(value: $value, in: 0...1)
30+
.tint(color)
31+
.accentColor(color)
32+
.accessibilityLabel(accessibilityLabel)
33+
.accessibilityValue(Text("\(Int(round(value * step))) out of \(Int(step))"))
34+
.accessibilityHint(Text("Swipe up or down to adjust") + Text(" ") + Text(accessibilityLabel) + Text(" from 0 to \(Int(step))"))
4135
}
4236
}
37+
38+
#Preview {
39+
WideSlider(.constant(0.5), color: .red, step: 255, accessibilityLabel: "Red")
40+
}
Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,59 @@
11
//
2-
// CustomStepper.swift
2+
// WideStepper.swift
33
// BlocKit
44
//
55
// Created by Rudrank Riyam on 29/03/21.
66
//
77

88
import SwiftUI
9-
import AVFoundation
109

11-
struct WideStepper<Content: View>: View {
10+
public struct WideStepper<Content: View>: View {
1211
@Binding var value: Double
13-
12+
public var color: Color
13+
public var accessibilityLabel: LocalizedStringKey
14+
public var step: Double
15+
1416
let onIncrement: () -> ()
1517
let onDecrement: () -> ()
1618
let content: Content
17-
18-
init(_ value: Binding<Double>, onIncrement: @escaping () -> (), onDecrement: @escaping () -> (), @ViewBuilder content: () -> Content) {
19+
20+
public init(
21+
_ value: Binding<Double>,
22+
color: Color = .accentColor,
23+
accessibilityLabel: LocalizedStringKey = "Value",
24+
step: Double = 255,
25+
onIncrement: @escaping () -> (),
26+
onDecrement: @escaping () -> (),
27+
@ViewBuilder content: () -> Content
28+
) {
1929
self._value = value
2030
self.onIncrement = onIncrement
2131
self.onDecrement = onDecrement
32+
self.color = color
33+
self.accessibilityLabel = accessibilityLabel
34+
self.step = step
2235
self.content = content()
2336
}
24-
25-
var body: some View {
37+
38+
public var body: some View {
2639
HStack {
27-
WideStepperButton(condition: value > 0, systemName: .minus, action: onDecrement)
28-
40+
WideStepperButton(
41+
condition: value > 0,
42+
color: color,
43+
systemName: .minus,
44+
accessibilityLabel: accessibilityLabel,
45+
action: onDecrement
46+
)
47+
2948
content
30-
31-
WideStepperButton(condition: value < 1, systemName: .plus, action: onIncrement)
49+
50+
WideStepperButton(
51+
condition: value < 1,
52+
color: color,
53+
systemName: .plus,
54+
accessibilityLabel: accessibilityLabel,
55+
action: onIncrement
56+
)
3257
}
3358
}
3459
}

0 commit comments

Comments
 (0)