Skip to content

Commit 894f999

Browse files
add docs for other models related to modal
1 parent 8e5f60e commit 894f999

File tree

4 files changed

+63
-20
lines changed

4 files changed

+63
-20
lines changed

Sources/ComponentsKit/Modal/Models/ModalRadius.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import Foundation
22

3+
/// Defines the corner radius options for a modal's content area.
34
public enum ModalRadius: Hashable {
5+
/// No corner radius is applied, resulting in sharp edges.
46
case none
7+
/// A small corner radius is applied.
58
case small
9+
/// A medium corner radius is applied.
610
case medium
11+
/// A large corner radius is applied.
712
case large
13+
/// A custom corner radius specified by a `CGFloat` value.
14+
///
15+
/// - Parameter value: The custom radius value to be applied.
816
case custom(CGFloat)
917
}
1018

Sources/ComponentsKit/Modal/Models/ModalSize.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import Foundation
22

3+
/// Defines the size options for a modal.
34
public enum ModalSize {
5+
/// A small modal size.
46
case small
7+
/// A medium modal size.
58
case medium
9+
/// A large modal size.
610
case large
11+
/// A full-screen modal that occupies the entire screen.
712
case full
813
}
914

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
import Foundation
22

3-
public struct ModalTransition: Hashable {
4-
var value: TimeInterval
5-
6-
init(_ value: CGFloat) {
7-
self.value = value
8-
}
3+
/// Defines the transition speed options for a modal's appearance and dismissal animations.
4+
public enum ModalTransition: Hashable {
5+
/// No transition is applied; the modal appears and disappears instantly.
6+
case none
7+
/// A slow transition speed.
8+
case slow
9+
/// A normal transition speed.
10+
case normal
11+
/// A fast transition speed.
12+
case fast
13+
/// A custom transition speed defined by a specific time interval.
14+
///
15+
/// - Parameter duration: The duration of the custom transition in seconds.
16+
case custom(TimeInterval)
917
}
1018

1119
extension ModalTransition {
12-
public static var none: Self {
13-
return Self(0.0)
14-
}
15-
public static var slow: Self {
16-
return Self(0.5)
17-
}
18-
public static var normal: Self {
19-
return Self(0.3)
20-
}
21-
public static var fast: Self {
22-
return Self(0.2)
23-
}
24-
public static func custom(_ value: CGFloat) -> Self {
25-
return Self(value)
20+
var value: TimeInterval {
21+
switch self {
22+
case .none:
23+
return 0.0
24+
case .slow:
25+
return 0.5
26+
case .normal:
27+
return 0.3
28+
case .fast:
29+
return 0.2
30+
case .custom(let value):
31+
return max(0, value)
32+
}
2633
}
2734
}

Sources/ComponentsKit/Modal/Models/Paddings.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,48 @@
11
import Foundation
22

3+
/// Defines padding values for each edge.
34
public struct Paddings: Hashable {
5+
/// The padding value for the top edge.
46
public var top: CGFloat
7+
8+
/// The padding value for the leading edge.
59
public var leading: CGFloat
10+
11+
/// The padding value for the bottom edge.
612
public var bottom: CGFloat
13+
14+
/// The padding value for the trailing edge.
715
public var trailing: CGFloat
816

17+
/// Initializes a new `Paddings` instance with specific values for all edges.
18+
///
19+
/// - Parameters:
20+
/// - top: The padding value for the top edge.
21+
/// - leading: The padding value for the leading edge.
22+
/// - bottom: The padding value for the bottom edge.
23+
/// - trailing: The padding value for the trailing edge.
924
public init(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat) {
1025
self.top = top
1126
self.leading = leading
1227
self.bottom = bottom
1328
self.trailing = trailing
1429
}
1530

31+
/// Initializes a new `Paddings` instance with uniform horizontal and vertical values.
32+
///
33+
/// - Parameters:
34+
/// - horizontal: The padding value applied to both the leading and trailing edges.
35+
/// - vertical: The padding value applied to both the top and bottom edges.
1636
public init(horizontal: CGFloat, vertical: CGFloat) {
1737
self.top = vertical
1838
self.leading = horizontal
1939
self.bottom = vertical
2040
self.trailing = horizontal
2141
}
2242

43+
/// Initializes a new `Paddings` instance with the same padding value applied to all edges.
44+
///
45+
/// - Parameter padding: The uniform padding value for the top, leading, bottom, and trailing edges.
2346
public init(padding: CGFloat) {
2447
self.top = padding
2548
self.leading = padding

0 commit comments

Comments
 (0)