File tree 5 files changed +26
-17
lines changed
SimpleAppIntegration/SimpleAppIntegration.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
SwiftUIExample/SwiftUIExample
5 files changed +26
-17
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"pins" : [
3
- {
4
- "identity" : " mobile-buy-sdk-ios" ,
5
- "kind" : " remoteSourceControl" ,
6
- "location" : " https://github.com/Shopify/mobile-buy-sdk-ios" ,
7
- "state" : {
8
- "revision" : " e6e85dcf8f9eb95baaa8336ad3d7967ea8c36ade" ,
9
- "version" : " 11.3.0"
10
- }
11
- },
12
3
{
13
4
"identity" : " swiftlintplugin" ,
14
5
"kind" : " remoteSourceControl" ,
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ struct SwiftUIExampleApp: App {
29
29
init ( ) {
30
30
ShopifyCheckoutSheetKit . configure {
31
31
$0. preloading. enabled = true
32
+ $0. logLevel = . all
32
33
}
33
34
}
34
35
@@ -55,7 +56,7 @@ struct RootTabView: View {
55
56
CartView ( cartManager: cartManager, checkoutURL: $checkoutURL, isShowingCheckout: $isShowingCheckout)
56
57
. navigationTitle ( " Cart " )
57
58
. navigationBarTitleDisplayMode ( . inline)
58
- . padding ( 20 )
59
+ . padding ( 10 )
59
60
. toolbar {
60
61
if cartManager. cart? . lines != nil {
61
62
ToolbarItem ( placement: . navigationBarTrailing) {
Original file line number Diff line number Diff line change @@ -150,9 +150,12 @@ struct CartLines: View {
150
150
HStack {
151
151
if let imageUrl = variant? . product. featuredImage? . url {
152
152
AsyncImage ( url: imageUrl) { image in
153
- image. image? . resizable ( ) . aspectRatio ( contentMode: . fit)
153
+ image. image?
154
+ . resizable ( )
155
+ . aspectRatio ( contentMode: . fill)
156
+ . frame ( width: 80 , height: 105 )
157
+ . clipped ( )
154
158
}
155
- . frame ( width: 60 , height: 120 )
156
159
}
157
160
158
161
VStack ( alignment: . leading, spacing: 8
@@ -170,6 +173,8 @@ struct CartLines: View {
170
173
if let price = variant? . price. formattedString ( ) {
171
174
HStack ( spacing: 80 ) {
172
175
Text ( " \( price) " )
176
+ . lineLimit ( 1 )
177
+ . minimumScaleFactor ( 0.5 )
173
178
. foregroundColor ( . gray)
174
179
175
180
HStack ( spacing: 20 ) {
@@ -262,5 +267,6 @@ struct CartViewPreviewContent: View {
262
267
263
268
var body : some View {
264
269
CartView ( cartManager: CartManager . shared, checkoutURL: $checkoutURL, isShowingCheckout: $isShowingCheckout)
270
+ . padding ( 10 )
265
271
}
266
272
}
Original file line number Diff line number Diff line change @@ -45,7 +45,10 @@ struct CatalogView: View {
45
45
var body : some View {
46
46
NavigationView {
47
47
VStack {
48
- if let product = product, let price = product. variants. nodes. first? . price. formattedString ( ) {
48
+ if
49
+ let product = product,
50
+ let first = product. variants. nodes. first,
51
+ let price = first. price. formattedString ( ) {
49
52
VStack {
50
53
VStack ( alignment: . leading) {
51
54
AsyncImage ( url: product. featuredImage? . url) { image in
@@ -81,6 +84,7 @@ struct CatalogView: View {
81
84
Text ( product. description)
82
85
. padding ( 2 )
83
86
. bold ( )
87
+ . lineLimit ( 3 )
84
88
. foregroundColor ( . gray)
85
89
} . padding ( . horizontal, 15 )
86
90
@@ -103,15 +107,16 @@ struct CatalogView: View {
103
107
. foregroundColor ( . white)
104
108
. cornerRadius ( 10 )
105
109
} else {
106
- Text ( " Add to cart - \( price) " )
110
+ Text ( product . availableForSale ? ( first . price . amount == 0 ? " Add to cart - Free " : " Add to cart - \( price) " ) : " Out of stock " )
107
111
. font ( . headline)
108
112
. padding ( )
109
113
. frame ( maxWidth: 400 )
110
- . background ( Color . blue)
114
+ . background ( product . availableForSale ? Color . blue : Color . gray )
111
115
. foregroundColor ( . white)
112
116
. cornerRadius ( 10 )
113
117
}
114
118
} )
119
+ . disabled ( !product. availableForSale)
115
120
. accessibilityIdentifier ( " addToCartButton " )
116
121
. sheet ( isPresented: $isShowingCart) {
117
122
NavigationView {
Original file line number Diff line number Diff line change @@ -179,8 +179,11 @@ extension Storefront.ProductQuery {
179
179
. title ( )
180
180
. description ( )
181
181
. vendor ( )
182
+ . availableForSale ( )
182
183
. featuredImage { $0
183
- . url ( )
184
+ . url (
185
+ transform: Storefront . ImageTransformInput ( maxWidth: 932 )
186
+ )
184
187
}
185
188
. variants ( first: 1 ) { $0
186
189
. nodes { $0
@@ -216,8 +219,11 @@ extension Storefront.CartQuery {
216
219
. product { $0
217
220
. title ( )
218
221
. vendor ( )
222
+ . availableForSale ( )
219
223
. featuredImage { $0
220
- . url ( )
224
+ . url (
225
+ transform: Storefront . ImageTransformInput ( maxWidth: 120 )
226
+ )
221
227
}
222
228
}
223
229
}
You can’t perform that action at this time.
0 commit comments