21
21
- [X] Create Example SwiftUI project to demonstrate package usage for previews
22
22
- [X] Provide a way to customize lorem in different categories (like creditCard, phoneNumber, name, price etc..) (works for auto generated init)
23
23
- [ ] Provide a way to customize loreming for the supported built-in types (to completely determine what to receive for the lorem data)
24
- - [ ] Improve diagnostic
25
24
- [ ] Implement unit test
26
25
27
26
---
@@ -38,116 +37,34 @@ Then use `StructName.lorem()` or `ClassName.lorem()` or `EnumName.lorem()`. Basi
38
37
39
38
40
39
``` swift
41
- import LoremSwiftify
42
-
43
- @LoremSwiftify
44
- class Book {
45
- let name: String
46
- let published: Date
47
- let author: Author
48
-
49
- init (name : String , published : Date, author : Author) {
50
- self .name = name
51
- self .published = published
52
- self .author = author
53
- }
54
-
40
+ extension ContentView {
55
41
@LoremSwiftify
56
- class Author {
57
- let name: String
58
- let surname: String
59
- var nickName: String ?
60
- let age: Int
61
-
62
- init (_ name : String , surname : String , nickName : String ? = nil , age : Int ) {
63
- self .name = name
64
- self .surname = surname
65
- self .nickName = nickName
66
- self .age = age
67
- }
68
- }
69
- // Expands
70
- extension Book .Author: LoremIpsumize {
71
- public static func lorem () -> Self {
72
- Book.Author (
73
- _ : .lorem (),
74
- surname : .lorem (),
75
- nickName : nil ,
76
- age : .lorem ()
77
- ) as! Self
78
- }
79
- }
80
- }
81
- // Expands
82
- extension Book : LoremIpsumize {
83
- public static func lorem () -> Self {
84
- Book (
85
- name : .lorem (),
86
- published : .lorem (),
87
- author : .lorem ()
88
- ) as! Self
89
- }
90
- }
91
-
92
- print (Book.lorem ())
42
+ struct Display {
43
+ let developers: [Developer]
93
44
94
- @LoremSwiftify
95
- struct Hotel {
96
- @Lorem (.string (.name ))
97
- let name: String
98
-
99
- @Lorem (.string (.phoneNumber ))
100
- let phoneNumber: String
45
+ @LoremSwiftify
46
+ struct Developer : Identifiable {
47
+ let id: String = UUID ().uuidString
101
48
102
- @Lorem (.url (. website ))
103
- let website: URL
49
+ @Lorem (.string (. name ))
50
+ let name: String
104
51
105
- let rooms: [Room]
52
+ @Lorem (.string (.email ))
53
+ let email: String
106
54
107
- @LoremSwiftify
108
- struct Room {
109
- let id: UUID
110
- let capacity: Capacity
55
+ @Lorem (.string (.phoneNumber ))
56
+ let phoneNumber: String
111
57
112
- @Lorem (.url (.image ))
113
- let image : URL
58
+ @Lorem (.url (.image ))
59
+ let imageURL : URL
114
60
115
- @LoremSwiftify
116
- enum Capacity : Int {
117
- case one = 1
118
- case two = 2
119
- case three = 3
120
- case four = 4
121
- }
122
- // Expands
123
- extension Hotel .Room.Capacity: LoremIpsumize {
124
- public static func lorem () -> Self {
125
- Hotel.Room .Capacity .one
126
- }
127
- }
128
- }
129
- // Expands
130
- extension Hotel .Room: LoremIpsumize {
131
- public static func lorem () -> Self {
132
- Hotel.Room (
133
- id : .lorem (),
134
- capacity : .lorem (),
135
- image : .lorem (.url (.image ))
136
- )
61
+ @Lorem (.url (.website ))
62
+ let profileURL: URL
137
63
}
138
64
}
139
65
}
140
- // Expands
141
- extension Hotel : LoremIpsumize {
142
- public static func lorem () -> Self {
143
- Hotel (
144
- name : .lorem (.string (.name )),
145
- phoneNumber : .lorem (.string (.phoneNumber )),
146
- website : .lorem (.url (.website )),
147
- rooms : .lorem ()
148
- )
149
- }
150
- }
151
66
152
- print (Hotel.lorem ())
67
+ #Preview {
68
+ ContentView (display : .lorem ())
69
+ }
153
70
```
0 commit comments