55
66import SwiftUI
77
8+ /// A handle type. It could be a rectangle, rounded rectangle, circle, capsule, or a symbol.
89public enum HandleType : Equatable {
910 case rectangle
1011 case roundedRectangle
@@ -14,18 +15,30 @@ public enum HandleType: Equatable {
1415 case `default`
1516}
1617
18+ /// A handle alignment with the progress view. It could be inside, center, or outside.
19+ ///
20+ /// - inside: The handle is inside the progress view.
21+ /// - center: The handle is in the center of the edge of the progress view.
22+ /// - outside: The handle is outside the progress view.
1723public enum HandleProgressAlignment : Equatable {
1824 case inside, center, outside
1925}
2026
2127/// A handle style.
2228public struct HandleStyle : Equatable {
29+ /// The handle type.
2330 public let type : HandleType
31+ /// The visibility of the handle. It could be always visible, hidden, or visible on focus (on drag or hover).
2432 public let visibility : CompactSliderVisibility
33+ /// The alignment of the handle with the progress view.
2534 public let progressAlignment : HandleProgressAlignment
35+ /// The color of the handle.
2636 public let color : Color
37+ /// The width of the handle.
2738 public let width : CGFloat
39+ /// The corner radius of the handle.
2840 public let cornerRadius : CGFloat
41+ /// The stroke style of the handle. If it's nil the handle will be filled.
2942 public let strokeStyle : StrokeStyle ?
3043
3144 init (
@@ -50,6 +63,14 @@ public struct HandleStyle: Equatable {
5063// MARK: - Constructors
5164
5265extension HandleStyle {
66+ /// Creates a rectangle handle style.
67+ ///
68+ /// - Parameters:
69+ /// - visibility: a visibility of the handle.
70+ /// - progressAlignment: a handle alignment with the progress view.
71+ /// - color: a handle color.
72+ /// - width: a handle width. It's used to calculate the position of the handle and progress view.
73+ /// - strokeStyle: a handle stroke style. If it's nil the handle will be filled.
5374 public static func rectangle(
5475 visibility: CompactSliderVisibility = . default,
5576 progressAlignment: HandleProgressAlignment = . center,
@@ -68,6 +89,15 @@ extension HandleStyle {
6889 )
6990 }
7091
92+ /// Creates a rounded rectangle handle style.
93+ ///
94+ /// - Parameters:
95+ /// - visibility: a visibility of the handle.
96+ /// - progressAlignment: a handle alignment with the progress view.
97+ /// - color: a handle color.
98+ /// - width: a handle width. It's used to calculate the position of the handle and progress view.
99+ /// - cornerRadius: a handle corner radius.
100+ /// - strokeStyle: a handle stroke style. If it's nil the handle will be filled.
71101 public static func roundedRectangle(
72102 visibility: CompactSliderVisibility = . default,
73103 progressAlignment: HandleProgressAlignment = . center,
@@ -87,6 +117,14 @@ extension HandleStyle {
87117 )
88118 }
89119
120+ /// Creates a circle handle style.
121+ ///
122+ /// - Parameters:
123+ /// - visibility: a visibility of the handle.
124+ /// - progressAlignment: a handle alignment with the progress view.
125+ /// - color: a handle color.
126+ /// - radius: a handle radius. It's used to calculate the position of the handle and progress view.
127+ /// - strokeStyle: a handle stroke style. If it's nil the handle will be filled.
90128 public static func circle(
91129 visibility: CompactSliderVisibility = . default,
92130 progressAlignment: HandleProgressAlignment = . center,
@@ -105,6 +143,14 @@ extension HandleStyle {
105143 )
106144 }
107145
146+ /// Creates a capsule handle style.
147+ ///
148+ /// - Parameters:
149+ /// - visibility: a visibility of the handle.
150+ /// - progressAlignment: a handle alignment with the progress view.
151+ /// - color: a handle color.
152+ /// - width: a handle width. It's used to calculate the position of the handle and progress view.
153+ /// - strokeStyle: a handle stroke style. If it's nil the handle will be filled.
108154 public static func capsule(
109155 visibility: CompactSliderVisibility = . default,
110156 progressAlignment: HandleProgressAlignment = . center,
@@ -123,6 +169,14 @@ extension HandleStyle {
123169 )
124170 }
125171
172+ /// Creates a symbol handle style. The symbol is a system image. For example, "circle.fill".
173+ ///
174+ /// - Parameters:
175+ /// - name: a system image name.
176+ /// - visibility: a visibility of the handle.
177+ /// - progressAlignment: a handle alignment with the progress view.
178+ /// - color: a handle color.
179+ /// - width: a handle width. It's used to calculate the position of the handle and progress view.
126180 public static func symbol(
127181 _ name: String ,
128182 visibility: CompactSliderVisibility = . default,
0 commit comments