File tree Expand file tree Collapse file tree 3 files changed +42
-15
lines changed
Expand file tree Collapse file tree 3 files changed +42
-15
lines changed Original file line number Diff line number Diff line change 11import SwiftUI
22
3+ /// A SwiftUI component that serves as a container for provided content.
4+ ///
5+ /// - Example:
6+ /// ```swift
7+ /// SUCard(
8+ /// model: .init(),
9+ /// content: {
10+ /// Text("This is the content of the card.")
11+ /// }
12+ /// )
313public struct SUCard < Content: View > : View {
4- let model : CardVM
14+ // MARK: - Properties
15+
16+ /// A model that defines the appearance properties.
17+ public let model : CardVM
518
619 @ViewBuilder private let content : ( ) -> Content
720
8- public init ( model: CardVM , content: @escaping ( ) -> Content ) {
21+ // MARK: - Initialization
22+
23+ /// Initializer.
24+ ///
25+ /// - Parameters:
26+ /// - model: A model that defines the appearance properties.
27+ /// - content: The content that is displayed in the card.
28+ public init (
29+ model: CardVM ,
30+ content: @escaping ( ) -> Content
31+ ) {
932 self . model = model
1033 self . content = content
1134 }
1235
36+ // MARK: - Body
37+
1338 public var body : some View {
1439 self . content ( )
1540 . padding ( self . model. contentPaddings. edgeInsets)
@@ -23,14 +48,3 @@ public struct SUCard<Content: View>: View {
2348 . shadow ( self . model. shadow)
2449 }
2550}
26-
27- extension View {
28- func shadow( _ shadow: Shadow ) -> some View {
29- self . shadow (
30- color: shadow. color. color,
31- radius: shadow. radius,
32- x: shadow. offset. width,
33- y: shadow. offset. height
34- )
35- }
36- }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import UIKit
77/// ```swift
88/// let banner = UKCard(
99/// model: .init(),
10- /// content: { _ in
10+ /// content: {
1111/// let label = UILabel()
1212/// label.text = "This is the content of the card."
1313/// label.numberOfLines = 0
Original file line number Diff line number Diff line change 1- import Foundation
1+ import SwiftUI
22
33/// Defines shadow options for components.
44public enum Shadow : Hashable {
@@ -50,3 +50,16 @@ extension Shadow {
5050 }
5151 }
5252}
53+
54+ // MARK: - SwiftUI + Shadow
55+
56+ extension View {
57+ func shadow( _ shadow: Shadow ) -> some View {
58+ self . shadow (
59+ color: shadow. color. color,
60+ radius: shadow. radius,
61+ x: shadow. offset. width,
62+ y: shadow. offset. height
63+ )
64+ }
65+ }
You can’t perform that action at this time.
0 commit comments