@lookiero/checkout 0.5.7 → 0.6.0-beta.0
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/README.md +0 -9
- package/dist/domain/checkout/command/markCheckoutAsPaid.d.ts +13 -0
- package/dist/domain/checkout/command/markCheckoutAsPaid.js +4 -0
- package/dist/domain/checkout/model/checkoutPaid.d.ts +13 -0
- package/dist/domain/checkout/model/checkoutPaid.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.d.ts +5 -0
- package/dist/infrastructure/domain/checkout/model/httpCheckoutsMarkAsPaid.js +13 -0
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.d.ts +13 -0
- package/dist/infrastructure/domain/checkout/react/useMarkCheckoutAsPaid.js +16 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +13 -0
- package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +14 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.d.ts +12 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/httpBookedSizeChangeProductsVariantsForCheckoutItemView.js +9 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.d.ts +10 -0
- package/dist/infrastructure/projection/bookedSizeChangeProductsVariants/react/useViewBookedSizeChangeProductsVariantsForCheckoutItem.js +12 -0
- package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.d.ts +12 -0
- package/dist/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByCheckoutIdView.js +9 -0
- package/dist/infrastructure/ui/Root.d.ts +4 -2
- package/dist/infrastructure/ui/Root.js +16 -6
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.js +1 -2
- package/dist/infrastructure/ui/i18n/i18n.d.ts +1 -3
- package/dist/infrastructure/ui/i18n/i18n.js +0 -2
- package/dist/infrastructure/ui/routing/Routing.js +4 -12
- package/dist/infrastructure/ui/views/App.style.d.ts +4 -0
- package/dist/infrastructure/ui/views/App.style.js +16 -0
- package/dist/infrastructure/ui/views/checkout/Checkout.js +5 -12
- package/dist/infrastructure/ui/views/checkout/Checkout.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/checkout/Checkout.style.js +3 -0
- package/dist/infrastructure/ui/views/feedback/Feedback.d.ts +0 -2
- package/dist/infrastructure/ui/views/feedback/Feedback.js +2 -9
- package/dist/infrastructure/ui/views/feedback/Feedback.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/feedback/Feedback.style.js +3 -0
- package/dist/infrastructure/ui/views/header/Header.d.ts +15 -0
- package/dist/infrastructure/ui/views/header/Header.js +90 -0
- package/dist/infrastructure/ui/views/header/Header.style.d.ts +35 -0
- package/dist/infrastructure/ui/views/header/Header.style.js +38 -0
- package/dist/infrastructure/ui/views/header/components/Logo.d.ts +7 -0
- package/dist/infrastructure/ui/views/header/components/Logo.js +11 -0
- package/dist/infrastructure/ui/views/header/components/Logo.style.d.ts +7 -0
- package/dist/infrastructure/ui/{components/templates/SafeAreaScrollView.style.ts.js → views/header/components/Logo.style.js} +3 -2
- package/dist/infrastructure/ui/views/intro/Intro.js +1 -1
- package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/intro/Intro.style.js +3 -0
- package/dist/infrastructure/ui/views/item/Item.js +1 -9
- package/dist/infrastructure/ui/views/item/Item.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/item/Item.style.js +3 -0
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.d.ts +0 -1
- package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.js +1 -6
- package/dist/infrastructure/ui/views/summary/Summary.js +1 -8
- package/dist/infrastructure/ui/views/summary/Summary.style.d.ts +3 -0
- package/dist/infrastructure/ui/views/summary/Summary.style.js +3 -0
- package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.d.ts +10 -0
- package/dist/projection/bookedSizeChangeProductsVariants/bookedSizeChangeProductsVariants.js +1 -0
- package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.d.ts +25 -0
- package/dist/projection/bookedSizeChangeProductsVariants/viewBookedSizeChangeProductVariantsForCheckoutItem.js +8 -0
- package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.d.ts +25 -0
- package/dist/projection/checkoutFeedback/viewCheckoutFeedbackByCheckoutId.js +8 -0
- package/dist/shared/logging/SentryLogger.d.ts +15 -0
- package/dist/shared/logging/SentryLogger.js +39 -0
- package/dist/shared/notifications/domain/notification/command/removeNotification.tes.d.ts +1 -0
- package/dist/shared/notifications/domain/notification/command/removeNotification.tes.js +9 -0
- package/dist/shared/ui/components/atoms/field/Field.js +5 -13
- package/dist/shared/ui/components/atoms/field/Field.style.js +2 -2
- package/dist/shared/ui/components/molecules/inputField/InputField.js +2 -2
- package/dist/shared/ui/components/molecules/inputField/InputField.style.d.ts +1 -0
- package/dist/shared/ui/components/molecules/inputField/InputField.style.js +1 -0
- package/package.json +9 -13
- package/dist/infrastructure/tracking/tracking.d.ts +0 -9
- package/dist/infrastructure/tracking/tracking.js +0 -10
- package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.ts.d.ts +0 -6
- package/dist/infrastructure/ui/views/notFound/NotFound.d.ts +0 -8
- package/dist/infrastructure/ui/views/notFound/NotFound.js +0 -43
- package/dist/infrastructure/ui/views/notFound/NotFound.style.d.ts +0 -16
- package/dist/infrastructure/ui/views/notFound/NotFound.style.js +0 -19
- package/dist/public/images/not-found.png +0 -0
- package/dist/shared/tracking/infrastructure/useEmitUserEvent.d.ts +0 -6
- package/dist/shared/tracking/infrastructure/useEmitUserEvent.js +0 -7
- package/dist/shared/tracking/infrastructure/usePageView.d.ts +0 -13
- package/dist/shared/tracking/infrastructure/usePageView.js +0 -21
- package/dist/shared/tracking/tracking.d.ts +0 -19
- package/dist/shared/tracking/tracking.js +0 -9
- package/dist/shared/ui/components/atoms/aspectRatioView/AspectRatioView.d.ts +0 -12
- package/dist/shared/ui/components/atoms/aspectRatioView/AspectRatioView.js +0 -16
|
@@ -7,8 +7,8 @@ import { Icon } from "../../atoms/icon/Icon";
|
|
|
7
7
|
import { Input } from "../../atoms/input/Input";
|
|
8
8
|
import { style } from "./InputField.style";
|
|
9
9
|
const { colorBase, colorContent, colorGrayscaleL, colorPrimary, spaceM, iconSize } = theme();
|
|
10
|
-
const inputPaddingRightWithIcon = iconSize + spaceM
|
|
11
|
-
const inputPaddingRightWithoutIcon = spaceM
|
|
10
|
+
const inputPaddingRightWithIcon = iconSize + spaceM;
|
|
11
|
+
const inputPaddingRightWithoutIcon = spaceM;
|
|
12
12
|
const InputField = ({ label, placeholder, value, multiline = false, minHeight, error, style: customStyle, onChange = () => void 0, icon, ...inputRestProps }) => {
|
|
13
13
|
const [isFocused, setIsFocused] = useState(false);
|
|
14
14
|
const handleOnChange = useCallback((text) => onChange(text), [onChange]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-beta.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"ios": "expo start --ios",
|
|
16
16
|
"web": "expo start --web",
|
|
17
17
|
"export-analyze-web": "BUNDLE_ANALYZE=true NODE_ENV=production expo export:web",
|
|
18
|
-
"build": "tsc -b tsconfig.build.json
|
|
18
|
+
"build": "tsc -b tsconfig.build.json",
|
|
19
19
|
"build:app": "tsc -p ./tsconfig.build-app.json --noemit && ENTRY_POINT='./src/Expo.tsx' NODE_ENV=production expo export:web --clear",
|
|
20
20
|
"lint": "eslint --fix --cache --cache-location ./node_modules/.cache/.eslintcache --ext ts,tsx .",
|
|
21
21
|
"format": "prettier --write \"**/*.+(json|css|ts|tsx|md)\"",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@lookiero/messaging": "^8.0.0",
|
|
34
34
|
"@lookiero/messaging-react": "^8.0.0",
|
|
35
35
|
"@react-spring/native": "^9.5.5",
|
|
36
|
+
"@sentry/react-native": "^4.12.0",
|
|
36
37
|
"inline-style-prefixer": "6.0.1",
|
|
37
38
|
"react-native-safe-area-context": "^4.4.1",
|
|
38
39
|
"react-native-svg": "^12.1.1",
|
|
@@ -46,8 +47,7 @@
|
|
|
46
47
|
"@lookiero/data-sources": "^0.3",
|
|
47
48
|
"@lookiero/event": "^0.3",
|
|
48
49
|
"@lookiero/locale": "^0.3",
|
|
49
|
-
"@lookiero/payments-front": "^0.16.
|
|
50
|
-
"@lookiero/user-tracking-front": "0.0.37",
|
|
50
|
+
"@lookiero/payments-front": "^0.16.5",
|
|
51
51
|
"apollo-boost": "0.4.4",
|
|
52
52
|
"graphql": "16.6.0",
|
|
53
53
|
"graphql-tag": "2.12.6",
|
|
@@ -68,30 +68,27 @@
|
|
|
68
68
|
"@lookiero/data-sources": "^0.3",
|
|
69
69
|
"@lookiero/event": "^0.3",
|
|
70
70
|
"@lookiero/locale": "^0.3",
|
|
71
|
-
"@lookiero/payments-front": "^0.16.
|
|
72
|
-
"@lookiero/user-tracking-front": "0.0.37",
|
|
71
|
+
"@lookiero/payments-front": "^0.16.5",
|
|
73
72
|
"@pact-foundation/pact": "^10.1.4",
|
|
74
73
|
"@pact-foundation/pact-node": "^10.17.6",
|
|
75
|
-
"@react-native-firebase/analytics": "10.5.1",
|
|
76
|
-
"@react-native-firebase/app": "10.5.0",
|
|
77
74
|
"@testing-library/react": "^13.4.0",
|
|
78
75
|
"@testing-library/react-hooks": "^8.0.1",
|
|
79
|
-
"@testing-library/react-native": "^11.
|
|
76
|
+
"@testing-library/react-native": "^11.0.0",
|
|
80
77
|
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
|
|
81
78
|
"@types/jest": "^29.2.4",
|
|
82
|
-
"@types/react": "~18.0.
|
|
79
|
+
"@types/react": "~18.0.0",
|
|
83
80
|
"@types/react-dom": "~18.0.0",
|
|
84
81
|
"@types/react-native": "~0.69.1",
|
|
85
82
|
"@types/uuid": "^9.0.0",
|
|
86
83
|
"apollo-boost": "0.4.4",
|
|
87
|
-
"eslint": "^8.
|
|
84
|
+
"eslint": "^8.24.0",
|
|
88
85
|
"eslint-config-prettier": "^8.5.0",
|
|
89
86
|
"eslint-config-react-app": "^7.0.1",
|
|
90
87
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
91
88
|
"eslint-plugin-import": "^2.26.0",
|
|
92
89
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
93
90
|
"eslint-plugin-prettier": "^4.2.1",
|
|
94
|
-
"eslint-plugin-react": "^7.31.
|
|
91
|
+
"eslint-plugin-react": "^7.31.8",
|
|
95
92
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
96
93
|
"eslint-plugin-react-native": "^4.0.0",
|
|
97
94
|
"expo": "~46.0.8",
|
|
@@ -110,7 +107,6 @@
|
|
|
110
107
|
"react": "^18.0.0",
|
|
111
108
|
"react-dom": "^18.0.0",
|
|
112
109
|
"react-native": "^0.70.6",
|
|
113
|
-
"react-native-adjust": "^4.33.0",
|
|
114
110
|
"react-native-get-random-values": "^1.8.0",
|
|
115
111
|
"react-native-unimodules": "^0.14.10",
|
|
116
112
|
"react-native-web": "^0.18.9",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const PROJECT = "checkout";
|
|
2
|
-
var TrackingPage;
|
|
3
|
-
(function (TrackingPage) {
|
|
4
|
-
TrackingPage["ITEM"] = "item";
|
|
5
|
-
TrackingPage["CHECKOUT"] = "checkout";
|
|
6
|
-
TrackingPage["SUMMARY"] = "summary";
|
|
7
|
-
TrackingPage["FEEDBACK"] = "feedback";
|
|
8
|
-
TrackingPage["NOT_FOUND"] = "not_found";
|
|
9
|
-
})(TrackingPage || (TrackingPage = {}));
|
|
10
|
-
export { PROJECT, TrackingPage };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
|
-
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
3
|
-
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import { QueryStatus } from "@lookiero/messaging-react";
|
|
5
|
-
import React, { useCallback } from "react";
|
|
6
|
-
import { Image, Platform } from "react-native";
|
|
7
|
-
import { useNavigate } from "react-router-native";
|
|
8
|
-
import { usePageView } from "../../../../shared/tracking/infrastructure/usePageView";
|
|
9
|
-
import { AspectRatioView } from "../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
|
|
10
|
-
import { Spinner } from "../../../../shared/ui/components/atoms/spinner/Spinner";
|
|
11
|
-
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
12
|
-
import { TrackingPage } from "../../../tracking/tracking";
|
|
13
|
-
import { Body } from "../../components/layouts/body/Body";
|
|
14
|
-
import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
|
|
15
|
-
import { I18nMessages } from "../../i18n/i18n";
|
|
16
|
-
import { Routes } from "../../routing/routes";
|
|
17
|
-
import { useBasePath } from "../../routing/useBasePath";
|
|
18
|
-
import { HEADER_HEIGHT } from "../navigation/components/header/Header.style";
|
|
19
|
-
import { style } from "./NotFound.style";
|
|
20
|
-
const NotFound = ({ customerId, country }) => {
|
|
21
|
-
const descriptionText = useI18nMessage({ id: I18nMessages.NOT_FOUND_DESCRIPTION });
|
|
22
|
-
const buttonText = useI18nMessage({ id: I18nMessages.NOT_FOUND_BUTTON });
|
|
23
|
-
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
24
|
-
usePageView({
|
|
25
|
-
page: TrackingPage.NOT_FOUND,
|
|
26
|
-
country,
|
|
27
|
-
checkoutId: checkout?.id,
|
|
28
|
-
});
|
|
29
|
-
const navigate = useNavigate();
|
|
30
|
-
const basePath = useBasePath();
|
|
31
|
-
const handleOnPress = useCallback(() => navigate(`${basePath}/${Routes.HOME}`), [basePath, navigate]);
|
|
32
|
-
const dependenciesLoadedStatuses = [QueryStatus.ERROR, QueryStatus.SUCCESS];
|
|
33
|
-
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus);
|
|
34
|
-
if (!dependenciesLoaded)
|
|
35
|
-
return React.createElement(Spinner, null);
|
|
36
|
-
return (React.createElement(SafeAreaScrollView, { scrollerPaddingTop: Platform.OS === "web" || Platform.OS === "android" ? HEADER_HEIGHT : 0, style: { scrollView: style.container } },
|
|
37
|
-
React.createElement(Body, { style: { column: style.bodyColumn } },
|
|
38
|
-
React.createElement(AspectRatioView, { aspectRatio: 1.25 },
|
|
39
|
-
React.createElement(Image, { resizeMode: "contain", source: require("../../../../public/images/not-found.png"), style: style.image, testID: "not-found-image" })),
|
|
40
|
-
React.createElement(Text, { level: 1, style: style.description, body: true }, descriptionText),
|
|
41
|
-
React.createElement(Button, { onPress: handleOnPress }, buttonText))));
|
|
42
|
-
};
|
|
43
|
-
export { NotFound };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from "react-native";
|
|
2
|
-
import { theme } from "../../theme/theme";
|
|
3
|
-
const { spaceXL } = theme();
|
|
4
|
-
const style = StyleSheet.create({
|
|
5
|
-
bodyColumn: {
|
|
6
|
-
paddingHorizontal: spaceXL,
|
|
7
|
-
},
|
|
8
|
-
container: {
|
|
9
|
-
flex: 1,
|
|
10
|
-
},
|
|
11
|
-
description: {
|
|
12
|
-
marginBottom: spaceXL,
|
|
13
|
-
textAlign: "center",
|
|
14
|
-
},
|
|
15
|
-
image: {
|
|
16
|
-
flex: 1,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
export { style };
|
|
Binary file
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { emitUserEvent as emit } from "@lookiero/user-tracking-front";
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
const useEmitUserEvent = () => {
|
|
4
|
-
const emitUserEvent = useCallback((event) => emit(event), []);
|
|
5
|
-
return emitUserEvent;
|
|
6
|
-
};
|
|
7
|
-
export { useEmitUserEvent };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { TrackingPage } from "../../../infrastructure/tracking/tracking";
|
|
2
|
-
import { Country } from "../../../projection/shared/country";
|
|
3
|
-
interface UsePageViewFunctionArgs {
|
|
4
|
-
readonly page: TrackingPage;
|
|
5
|
-
readonly country: Country;
|
|
6
|
-
readonly checkoutId?: string;
|
|
7
|
-
readonly checkoutItemId?: string;
|
|
8
|
-
}
|
|
9
|
-
interface UsePageViewFunction {
|
|
10
|
-
(agrs: UsePageViewFunctionArgs): void;
|
|
11
|
-
}
|
|
12
|
-
declare const usePageView: UsePageViewFunction;
|
|
13
|
-
export { usePageView };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect } from "react";
|
|
2
|
-
import { PROJECT } from "../../../infrastructure/tracking/tracking";
|
|
3
|
-
import { TrackingEvent, TrackingEventCategory } from "../tracking";
|
|
4
|
-
import { useEmitUserEvent } from "./useEmitUserEvent";
|
|
5
|
-
const usePageView = ({ page, country, checkoutId, checkoutItemId }) => {
|
|
6
|
-
const emitUserEvent = useEmitUserEvent();
|
|
7
|
-
useLayoutEffect(() => {
|
|
8
|
-
if (!checkoutId) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
emitUserEvent({
|
|
12
|
-
event: TrackingEvent.PAGEVIEW,
|
|
13
|
-
eventCategory: TrackingEventCategory.NAVIGATION,
|
|
14
|
-
section: `${PROJECT}_${page}`,
|
|
15
|
-
store: country,
|
|
16
|
-
checkoutId,
|
|
17
|
-
checkoutItemId,
|
|
18
|
-
});
|
|
19
|
-
}, [checkoutId, checkoutItemId, country, emitUserEvent, page]);
|
|
20
|
-
};
|
|
21
|
-
export { usePageView };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Country } from "../../projection/shared/country";
|
|
2
|
-
declare enum TrackingEvent {
|
|
3
|
-
PAGEVIEW = "pageview"
|
|
4
|
-
}
|
|
5
|
-
declare enum TrackingEventCategory {
|
|
6
|
-
NAVIGATION = "navigation"
|
|
7
|
-
}
|
|
8
|
-
interface BaseTrackingEvent {
|
|
9
|
-
readonly event: TrackingEvent;
|
|
10
|
-
readonly eventCategory: TrackingEventCategory;
|
|
11
|
-
readonly section: string;
|
|
12
|
-
readonly store: Country;
|
|
13
|
-
readonly checkoutId: string;
|
|
14
|
-
}
|
|
15
|
-
interface PageViewTrackingEvent extends BaseTrackingEvent {
|
|
16
|
-
readonly checkoutItemId?: string;
|
|
17
|
-
}
|
|
18
|
-
export type { BaseTrackingEvent, PageViewTrackingEvent };
|
|
19
|
-
export { TrackingEvent, TrackingEventCategory };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var TrackingEvent;
|
|
2
|
-
(function (TrackingEvent) {
|
|
3
|
-
TrackingEvent["PAGEVIEW"] = "pageview";
|
|
4
|
-
})(TrackingEvent || (TrackingEvent = {}));
|
|
5
|
-
var TrackingEventCategory;
|
|
6
|
-
(function (TrackingEventCategory) {
|
|
7
|
-
TrackingEventCategory["NAVIGATION"] = "navigation";
|
|
8
|
-
})(TrackingEventCategory || (TrackingEventCategory = {}));
|
|
9
|
-
export { TrackingEvent, TrackingEventCategory };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from "react";
|
|
2
|
-
declare enum AspectRatioViewResizeDirection {
|
|
3
|
-
VERTICAL = "VERTICAL",
|
|
4
|
-
HORIZONTAL = "HORIZONTAL"
|
|
5
|
-
}
|
|
6
|
-
interface AspectRatioViewProps {
|
|
7
|
-
readonly aspectRatio?: number;
|
|
8
|
-
readonly resizeDirection?: AspectRatioViewResizeDirection;
|
|
9
|
-
readonly children: ReactNode;
|
|
10
|
-
}
|
|
11
|
-
declare const AspectRatioView: FC<AspectRatioViewProps>;
|
|
12
|
-
export { AspectRatioView, AspectRatioViewResizeDirection };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
var AspectRatioViewResizeDirection;
|
|
4
|
-
(function (AspectRatioViewResizeDirection) {
|
|
5
|
-
AspectRatioViewResizeDirection["VERTICAL"] = "VERTICAL";
|
|
6
|
-
AspectRatioViewResizeDirection["HORIZONTAL"] = "HORIZONTAL";
|
|
7
|
-
})(AspectRatioViewResizeDirection || (AspectRatioViewResizeDirection = {}));
|
|
8
|
-
const AspectRatioView = ({ aspectRatio = 1, resizeDirection = AspectRatioViewResizeDirection.HORIZONTAL, children, }) => {
|
|
9
|
-
const [{ width, height }, setDimension] = useState({});
|
|
10
|
-
const handleOnLayout = useCallback(({ nativeEvent: { layout } }) => setDimension(resizeDirection === AspectRatioViewResizeDirection.HORIZONTAL
|
|
11
|
-
? { width: layout.width, height: layout.width * aspectRatio }
|
|
12
|
-
: { width: layout.height * aspectRatio, height: layout.height }), [aspectRatio, resizeDirection]);
|
|
13
|
-
return (React.createElement(View, { onLayout: handleOnLayout },
|
|
14
|
-
React.createElement(View, { style: { width, height } }, children)));
|
|
15
|
-
};
|
|
16
|
-
export { AspectRatioView, AspectRatioViewResizeDirection };
|