@lookiero/checkout 14.7.0 → 14.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/ExpoRoot.js +2 -3
- package/dist/src/infrastructure/delivery/bootstrap.mock.js +2 -2
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +2 -3
- package/dist/src/infrastructure/projection/pricing/pricing.d.ts +1 -18
- package/dist/src/infrastructure/projection/pricing/pricing.js +1 -12
- package/dist/src/infrastructure/projection/pricing/pricing.mock.d.ts +2 -9
- package/dist/src/infrastructure/projection/pricing/pricing.mock.js +10 -50
- package/dist/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.d.ts +2 -2
- package/dist/src/infrastructure/tracking/useTrackCheckout.d.ts +2 -2
- package/dist/src/infrastructure/tracking/useTrackCheckout.js +3 -3
- package/dist/src/infrastructure/ui/components/atoms/price/Price.d.ts +7 -2
- package/dist/src/infrastructure/ui/components/atoms/price/Price.js +7 -7
- package/dist/src/infrastructure/ui/views/checkout/Checkout.js +2 -2
- package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.js +1 -1
- package/dist/src/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +2 -1
- package/dist/src/infrastructure/ui/views/item/components/productVariantSlider/components/aspectRatioView/AspectRatioView.d.ts +15 -0
- package/dist/src/infrastructure/ui/views/item/components/productVariantSlider/components/aspectRatioView/AspectRatioView.js +16 -0
- package/dist/src/infrastructure/ui/views/return/components/price/Price.d.ts +7 -2
- package/dist/src/infrastructure/ui/views/return/components/price/Price.js +7 -7
- package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +1 -1
- package/dist/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.js +1 -1
- package/dist/src/infrastructure/ui/views/summary/Summary.js +3 -3
- package/dist/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.d.ts +2 -5
- package/dist/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.js +4 -4
- package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.d.ts +2 -5
- package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.js +16 -18
- package/dist/src/projection/customer/customer.d.ts +0 -1
- package/dist/src/projection/pricing/pricing.d.ts +6 -24
- package/dist/src/projection/pricing/pricing.js +1 -1
- package/dist/src/projection/pricing/viewPricingByCheckoutId.d.ts +2 -2
- package/dist/src/version.d.ts +2 -2
- package/dist/src/version.js +2 -2
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +2 -3
- package/src/infrastructure/delivery/bootstrap.mock.ts +2 -2
- package/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.test.ts +3 -7
- package/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.ts +3 -8
- package/src/infrastructure/projection/pricing/pricing.mock.ts +11 -61
- package/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.test.ts +3 -3
- package/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.ts +2 -2
- package/src/infrastructure/tracking/useTrackCheckout.test.tsx +9 -9
- package/src/infrastructure/tracking/useTrackCheckout.ts +5 -5
- package/src/infrastructure/ui/components/atoms/price/Price.test.tsx +22 -4
- package/src/infrastructure/ui/components/atoms/price/Price.tsx +14 -9
- package/src/infrastructure/ui/hooks/useCheckoutFlow.test.tsx +2 -2
- package/src/infrastructure/ui/views/checkout/Checkout.test.tsx +4 -10
- package/src/infrastructure/ui/views/checkout/Checkout.tsx +2 -7
- package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.tsx +1 -1
- package/src/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.tsx +1 -1
- package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +198 -192
- package/src/infrastructure/ui/views/item/components/productVariantSlider/components/aspectRatioView/AspectRatioView.tsx +46 -0
- package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +594 -576
- package/src/infrastructure/ui/views/return/components/price/Price.test.tsx +22 -4
- package/src/infrastructure/ui/views/return/components/price/Price.tsx +14 -9
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +6 -1
- package/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.tsx +6 -1
- package/src/infrastructure/ui/views/summary/Summary.test.tsx +4 -10
- package/src/infrastructure/ui/views/summary/Summary.tsx +1 -5
- package/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.test.tsx +10 -24
- package/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.tsx +5 -15
- package/src/infrastructure/ui/views/summary/components/collapsiblePricing/__snapshots__/CollapsiblePricing.test.tsx.snap +2 -2
- package/src/infrastructure/ui/views/summary/components/pricing/Pricing.tsx +42 -38
- package/src/projection/customer/customer.ts +0 -1
- package/src/projection/pricing/pricing.ts +6 -26
- package/src/projection/pricing/viewPricingByCheckoutId.test.ts +4 -5
- package/src/projection/pricing/viewPricingByCheckoutId.ts +2 -2
- package/src/infrastructure/projection/pricing/pricing.ts +0 -32
|
@@ -97,143 +97,146 @@ exports[`ProductVariantSlider matches the snapshot 1`] = `
|
|
|
97
97
|
onLayout={[Function]}
|
|
98
98
|
>
|
|
99
99
|
<View
|
|
100
|
-
|
|
101
|
-
[
|
|
102
|
-
{
|
|
103
|
-
"aspectRatio": NaN,
|
|
104
|
-
"height": undefined,
|
|
105
|
-
"width": "100%",
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"alignSelf": undefined,
|
|
109
|
-
},
|
|
110
|
-
]
|
|
111
|
-
}
|
|
100
|
+
onLayout={[Function]}
|
|
112
101
|
>
|
|
113
102
|
<View
|
|
114
103
|
style={
|
|
115
104
|
[
|
|
116
105
|
{
|
|
117
|
-
"
|
|
106
|
+
"height": undefined,
|
|
107
|
+
"width": undefined,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"alignSelf": undefined,
|
|
118
111
|
},
|
|
119
|
-
[
|
|
120
|
-
{
|
|
121
|
-
"flex": 1,
|
|
122
|
-
},
|
|
123
|
-
null,
|
|
124
|
-
],
|
|
125
112
|
]
|
|
126
113
|
}
|
|
127
|
-
testID="product-variant-image"
|
|
128
114
|
>
|
|
129
115
|
<View
|
|
130
116
|
style={
|
|
131
117
|
[
|
|
132
118
|
{
|
|
133
|
-
"
|
|
119
|
+
"position": "relative",
|
|
134
120
|
},
|
|
121
|
+
[
|
|
122
|
+
{
|
|
123
|
+
"flex": 1,
|
|
124
|
+
},
|
|
125
|
+
null,
|
|
126
|
+
],
|
|
135
127
|
]
|
|
136
128
|
}
|
|
137
|
-
testID="
|
|
129
|
+
testID="product-variant-image"
|
|
138
130
|
>
|
|
139
131
|
<View
|
|
140
|
-
onLayout={[Function]}
|
|
141
132
|
style={
|
|
142
133
|
[
|
|
143
134
|
{
|
|
144
|
-
"backgroundColor": "#F8F7F7",
|
|
145
135
|
"flex": 1,
|
|
146
|
-
"height": undefined,
|
|
147
|
-
"overflow": "hidden",
|
|
148
|
-
"width": undefined,
|
|
149
136
|
},
|
|
150
137
|
]
|
|
151
138
|
}
|
|
139
|
+
testID="lazy-image-skeleton"
|
|
152
140
|
>
|
|
153
141
|
<View
|
|
154
|
-
|
|
155
|
-
duration={1200}
|
|
142
|
+
onLayout={[Function]}
|
|
156
143
|
style={
|
|
157
144
|
[
|
|
158
145
|
{
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
"
|
|
164
|
-
"transform": [
|
|
165
|
-
{
|
|
166
|
-
"translateX": -375,
|
|
167
|
-
},
|
|
168
|
-
],
|
|
146
|
+
"backgroundColor": "#F8F7F7",
|
|
147
|
+
"flex": 1,
|
|
148
|
+
"height": undefined,
|
|
149
|
+
"overflow": "hidden",
|
|
150
|
+
"width": undefined,
|
|
169
151
|
},
|
|
170
152
|
]
|
|
171
153
|
}
|
|
172
154
|
>
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
4292532440,
|
|
178
|
-
4292532440,
|
|
179
|
-
16777215,
|
|
180
|
-
]
|
|
181
|
-
}
|
|
182
|
-
endPoint={
|
|
183
|
-
[
|
|
184
|
-
1,
|
|
185
|
-
0,
|
|
186
|
-
]
|
|
187
|
-
}
|
|
188
|
-
locations={
|
|
189
|
-
[
|
|
190
|
-
0,
|
|
191
|
-
0.25,
|
|
192
|
-
0.75,
|
|
193
|
-
1,
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
startPoint={
|
|
155
|
+
<View
|
|
156
|
+
collapsable={false}
|
|
157
|
+
duration={1200}
|
|
158
|
+
style={
|
|
197
159
|
[
|
|
198
|
-
|
|
199
|
-
|
|
160
|
+
{
|
|
161
|
+
"height": "100%",
|
|
162
|
+
"width": "100%",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"left": 0,
|
|
166
|
+
"transform": [
|
|
167
|
+
{
|
|
168
|
+
"translateX": -375,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
200
172
|
]
|
|
201
173
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
174
|
+
>
|
|
175
|
+
<ViewManagerAdapter_ExpoLinearGradient
|
|
176
|
+
colors={
|
|
177
|
+
[
|
|
178
|
+
16777215,
|
|
179
|
+
4292532440,
|
|
180
|
+
4292532440,
|
|
181
|
+
16777215,
|
|
182
|
+
]
|
|
206
183
|
}
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
endPoint={
|
|
185
|
+
[
|
|
186
|
+
1,
|
|
187
|
+
0,
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
locations={
|
|
191
|
+
[
|
|
192
|
+
0,
|
|
193
|
+
0.25,
|
|
194
|
+
0.75,
|
|
195
|
+
1,
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
startPoint={
|
|
199
|
+
[
|
|
200
|
+
0,
|
|
201
|
+
0,
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
style={
|
|
205
|
+
{
|
|
206
|
+
"height": "100%",
|
|
207
|
+
"width": "100%",
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/>
|
|
211
|
+
</View>
|
|
209
212
|
</View>
|
|
210
213
|
</View>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
source={
|
|
216
|
-
{
|
|
217
|
-
"uri": "https://cdn-catalog-back-prod.envs.lookiero.tech/1a/28/1a28f712-a76c-4172-8a11-f15002981dc0.jpg?w=600&f=auto",
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
style={
|
|
221
|
-
[
|
|
222
|
-
{
|
|
223
|
-
"flex": 1,
|
|
224
|
-
"height": "100%",
|
|
225
|
-
"position": "absolute",
|
|
226
|
-
"width": "100%",
|
|
227
|
-
"zIndex": 10,
|
|
228
|
-
},
|
|
229
|
-
undefined,
|
|
214
|
+
<Image
|
|
215
|
+
onLoad={[Function]}
|
|
216
|
+
resizeMode="contain"
|
|
217
|
+
source={
|
|
230
218
|
{
|
|
231
|
-
"
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
219
|
+
"uri": "https://cdn-catalog-back-prod.envs.lookiero.tech/1a/28/1a28f712-a76c-4172-8a11-f15002981dc0.jpg?w=600&f=auto",
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
style={
|
|
223
|
+
[
|
|
224
|
+
{
|
|
225
|
+
"flex": 1,
|
|
226
|
+
"height": "100%",
|
|
227
|
+
"position": "absolute",
|
|
228
|
+
"width": "100%",
|
|
229
|
+
"zIndex": 10,
|
|
230
|
+
},
|
|
231
|
+
undefined,
|
|
232
|
+
{
|
|
233
|
+
"opacity": 0,
|
|
234
|
+
},
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
testID="lazy-image-main-image"
|
|
238
|
+
/>
|
|
239
|
+
</View>
|
|
237
240
|
</View>
|
|
238
241
|
</View>
|
|
239
242
|
</View>
|
|
@@ -255,143 +258,146 @@ exports[`ProductVariantSlider matches the snapshot 1`] = `
|
|
|
255
258
|
onLayout={[Function]}
|
|
256
259
|
>
|
|
257
260
|
<View
|
|
258
|
-
|
|
259
|
-
[
|
|
260
|
-
{
|
|
261
|
-
"aspectRatio": NaN,
|
|
262
|
-
"height": undefined,
|
|
263
|
-
"width": "100%",
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
"alignSelf": undefined,
|
|
267
|
-
},
|
|
268
|
-
]
|
|
269
|
-
}
|
|
261
|
+
onLayout={[Function]}
|
|
270
262
|
>
|
|
271
263
|
<View
|
|
272
264
|
style={
|
|
273
265
|
[
|
|
274
266
|
{
|
|
275
|
-
"
|
|
267
|
+
"height": undefined,
|
|
268
|
+
"width": undefined,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"alignSelf": undefined,
|
|
276
272
|
},
|
|
277
|
-
[
|
|
278
|
-
{
|
|
279
|
-
"flex": 1,
|
|
280
|
-
},
|
|
281
|
-
null,
|
|
282
|
-
],
|
|
283
273
|
]
|
|
284
274
|
}
|
|
285
|
-
testID="product-variant-image"
|
|
286
275
|
>
|
|
287
276
|
<View
|
|
288
277
|
style={
|
|
289
278
|
[
|
|
290
279
|
{
|
|
291
|
-
"
|
|
280
|
+
"position": "relative",
|
|
292
281
|
},
|
|
282
|
+
[
|
|
283
|
+
{
|
|
284
|
+
"flex": 1,
|
|
285
|
+
},
|
|
286
|
+
null,
|
|
287
|
+
],
|
|
293
288
|
]
|
|
294
289
|
}
|
|
295
|
-
testID="
|
|
290
|
+
testID="product-variant-image"
|
|
296
291
|
>
|
|
297
292
|
<View
|
|
298
|
-
onLayout={[Function]}
|
|
299
293
|
style={
|
|
300
294
|
[
|
|
301
295
|
{
|
|
302
|
-
"backgroundColor": "#F8F7F7",
|
|
303
296
|
"flex": 1,
|
|
304
|
-
"height": undefined,
|
|
305
|
-
"overflow": "hidden",
|
|
306
|
-
"width": undefined,
|
|
307
297
|
},
|
|
308
298
|
]
|
|
309
299
|
}
|
|
300
|
+
testID="lazy-image-skeleton"
|
|
310
301
|
>
|
|
311
302
|
<View
|
|
312
|
-
|
|
313
|
-
duration={1200}
|
|
303
|
+
onLayout={[Function]}
|
|
314
304
|
style={
|
|
315
305
|
[
|
|
316
306
|
{
|
|
317
|
-
"
|
|
318
|
-
"
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
"
|
|
322
|
-
"transform": [
|
|
323
|
-
{
|
|
324
|
-
"translateX": -375,
|
|
325
|
-
},
|
|
326
|
-
],
|
|
307
|
+
"backgroundColor": "#F8F7F7",
|
|
308
|
+
"flex": 1,
|
|
309
|
+
"height": undefined,
|
|
310
|
+
"overflow": "hidden",
|
|
311
|
+
"width": undefined,
|
|
327
312
|
},
|
|
328
313
|
]
|
|
329
314
|
}
|
|
330
315
|
>
|
|
331
|
-
<
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
4292532440,
|
|
336
|
-
4292532440,
|
|
337
|
-
16777215,
|
|
338
|
-
]
|
|
339
|
-
}
|
|
340
|
-
endPoint={
|
|
341
|
-
[
|
|
342
|
-
1,
|
|
343
|
-
0,
|
|
344
|
-
]
|
|
345
|
-
}
|
|
346
|
-
locations={
|
|
347
|
-
[
|
|
348
|
-
0,
|
|
349
|
-
0.25,
|
|
350
|
-
0.75,
|
|
351
|
-
1,
|
|
352
|
-
]
|
|
353
|
-
}
|
|
354
|
-
startPoint={
|
|
316
|
+
<View
|
|
317
|
+
collapsable={false}
|
|
318
|
+
duration={1200}
|
|
319
|
+
style={
|
|
355
320
|
[
|
|
356
|
-
|
|
357
|
-
|
|
321
|
+
{
|
|
322
|
+
"height": "100%",
|
|
323
|
+
"width": "100%",
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"left": 0,
|
|
327
|
+
"transform": [
|
|
328
|
+
{
|
|
329
|
+
"translateX": -375,
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
},
|
|
358
333
|
]
|
|
359
334
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
335
|
+
>
|
|
336
|
+
<ViewManagerAdapter_ExpoLinearGradient
|
|
337
|
+
colors={
|
|
338
|
+
[
|
|
339
|
+
16777215,
|
|
340
|
+
4292532440,
|
|
341
|
+
4292532440,
|
|
342
|
+
16777215,
|
|
343
|
+
]
|
|
364
344
|
}
|
|
365
|
-
|
|
366
|
-
|
|
345
|
+
endPoint={
|
|
346
|
+
[
|
|
347
|
+
1,
|
|
348
|
+
0,
|
|
349
|
+
]
|
|
350
|
+
}
|
|
351
|
+
locations={
|
|
352
|
+
[
|
|
353
|
+
0,
|
|
354
|
+
0.25,
|
|
355
|
+
0.75,
|
|
356
|
+
1,
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
startPoint={
|
|
360
|
+
[
|
|
361
|
+
0,
|
|
362
|
+
0,
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
style={
|
|
366
|
+
{
|
|
367
|
+
"height": "100%",
|
|
368
|
+
"width": "100%",
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/>
|
|
372
|
+
</View>
|
|
367
373
|
</View>
|
|
368
374
|
</View>
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
source={
|
|
374
|
-
{
|
|
375
|
-
"uri": "https://cdn-catalog-back-prod.envs.lookiero.tech/15/ac/15aca112-4e71-4646-8db5-7f9723bc0130.jpg?w=600&f=auto",
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
style={
|
|
379
|
-
[
|
|
380
|
-
{
|
|
381
|
-
"flex": 1,
|
|
382
|
-
"height": "100%",
|
|
383
|
-
"position": "absolute",
|
|
384
|
-
"width": "100%",
|
|
385
|
-
"zIndex": 10,
|
|
386
|
-
},
|
|
387
|
-
undefined,
|
|
375
|
+
<Image
|
|
376
|
+
onLoad={[Function]}
|
|
377
|
+
resizeMode="contain"
|
|
378
|
+
source={
|
|
388
379
|
{
|
|
389
|
-
"
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
380
|
+
"uri": "https://cdn-catalog-back-prod.envs.lookiero.tech/15/ac/15aca112-4e71-4646-8db5-7f9723bc0130.jpg?w=600&f=auto",
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
style={
|
|
384
|
+
[
|
|
385
|
+
{
|
|
386
|
+
"flex": 1,
|
|
387
|
+
"height": "100%",
|
|
388
|
+
"position": "absolute",
|
|
389
|
+
"width": "100%",
|
|
390
|
+
"zIndex": 10,
|
|
391
|
+
},
|
|
392
|
+
undefined,
|
|
393
|
+
{
|
|
394
|
+
"opacity": 0,
|
|
395
|
+
},
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
testID="lazy-image-main-image"
|
|
399
|
+
/>
|
|
400
|
+
</View>
|
|
395
401
|
</View>
|
|
396
402
|
</View>
|
|
397
403
|
</View>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { FC, ReactNode, useCallback, useState } from "react";
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, View, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
interface Dimension {
|
|
5
|
+
readonly width?: number | undefined;
|
|
6
|
+
readonly height?: number | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
enum AspectRatioViewResizeDirection {
|
|
10
|
+
VERTICAL = "VERTICAL",
|
|
11
|
+
HORIZONTAL = "HORIZONTAL",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface AspectRatioViewProps {
|
|
15
|
+
readonly children: ReactNode;
|
|
16
|
+
readonly aspectRatio?: number;
|
|
17
|
+
readonly resizeDirection?: AspectRatioViewResizeDirection;
|
|
18
|
+
readonly multiplier?: number;
|
|
19
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
20
|
+
}
|
|
21
|
+
const AspectRatioView: FC<AspectRatioViewProps> = ({
|
|
22
|
+
aspectRatio = 1,
|
|
23
|
+
resizeDirection = AspectRatioViewResizeDirection.HORIZONTAL,
|
|
24
|
+
multiplier = 1,
|
|
25
|
+
style: customStyle = {},
|
|
26
|
+
children,
|
|
27
|
+
}) => {
|
|
28
|
+
const [{ width, height }, setDimension] = useState<Dimension>({});
|
|
29
|
+
const handleOnLayout = useCallback(
|
|
30
|
+
({ nativeEvent: { layout } }: LayoutChangeEvent) =>
|
|
31
|
+
setDimension(
|
|
32
|
+
resizeDirection === AspectRatioViewResizeDirection.HORIZONTAL
|
|
33
|
+
? { width: layout.width * multiplier, height: layout.width * aspectRatio }
|
|
34
|
+
: { width: layout.height * aspectRatio, height: layout.height },
|
|
35
|
+
),
|
|
36
|
+
[aspectRatio, multiplier, resizeDirection],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View onLayout={handleOnLayout}>
|
|
41
|
+
<View style={[{ width, height }, customStyle]}>{children}</View>
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { AspectRatioView, AspectRatioViewResizeDirection };
|