react-native-hold-menu-actions 0.1.6
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/LICENCE +21 -0
- package/README.md +38 -0
- package/lib/commonjs/components/backdrop/Backdrop.js +104 -0
- package/lib/commonjs/components/backdrop/Backdrop.js.map +1 -0
- package/lib/commonjs/components/backdrop/constants.js +14 -0
- package/lib/commonjs/components/backdrop/constants.js.map +1 -0
- package/lib/commonjs/components/backdrop/index.js +16 -0
- package/lib/commonjs/components/backdrop/index.js.map +1 -0
- package/lib/commonjs/components/backdrop/styles.js +17 -0
- package/lib/commonjs/components/backdrop/styles.js.map +1 -0
- package/lib/commonjs/components/flatList/FlatList.js +35 -0
- package/lib/commonjs/components/flatList/FlatList.js.map +1 -0
- package/lib/commonjs/components/flatList/index.js +16 -0
- package/lib/commonjs/components/flatList/index.js.map +1 -0
- package/lib/commonjs/components/holdItem/HoldItem.js +369 -0
- package/lib/commonjs/components/holdItem/HoldItem.js.map +1 -0
- package/lib/commonjs/components/holdItem/index.js +16 -0
- package/lib/commonjs/components/holdItem/index.js.map +1 -0
- package/lib/commonjs/components/holdItem/styles.js +22 -0
- package/lib/commonjs/components/holdItem/styles.js.map +1 -0
- package/lib/commonjs/components/holdItem/types.d.js +2 -0
- package/lib/commonjs/components/holdItem/types.d.js.map +1 -0
- package/lib/commonjs/components/icon/Icon.js +43 -0
- package/lib/commonjs/components/icon/Icon.js.map +1 -0
- package/lib/commonjs/components/icon/index.js +16 -0
- package/lib/commonjs/components/icon/index.js.map +1 -0
- package/lib/commonjs/components/menu/Menu.js +57 -0
- package/lib/commonjs/components/menu/Menu.js.map +1 -0
- package/lib/commonjs/components/menu/MenuItem.js +85 -0
- package/lib/commonjs/components/menu/MenuItem.js.map +1 -0
- package/lib/commonjs/components/menu/MenuItems.js +35 -0
- package/lib/commonjs/components/menu/MenuItems.js.map +1 -0
- package/lib/commonjs/components/menu/MenuList.js +121 -0
- package/lib/commonjs/components/menu/MenuList.js.map +1 -0
- package/lib/commonjs/components/menu/Separator.js +47 -0
- package/lib/commonjs/components/menu/Separator.js.map +1 -0
- package/lib/commonjs/components/menu/calculations.js +31 -0
- package/lib/commonjs/components/menu/calculations.js.map +1 -0
- package/lib/commonjs/components/menu/constants.js +21 -0
- package/lib/commonjs/components/menu/constants.js.map +1 -0
- package/lib/commonjs/components/menu/index.js +16 -0
- package/lib/commonjs/components/menu/index.js.map +1 -0
- package/lib/commonjs/components/menu/styles.js +77 -0
- package/lib/commonjs/components/menu/styles.js.map +1 -0
- package/lib/commonjs/components/menu/types.d.js +2 -0
- package/lib/commonjs/components/menu/types.d.js.map +1 -0
- package/lib/commonjs/components/provider/Provider.js +98 -0
- package/lib/commonjs/components/provider/Provider.js.map +1 -0
- package/lib/commonjs/components/provider/index.js +16 -0
- package/lib/commonjs/components/provider/index.js.map +1 -0
- package/lib/commonjs/components/provider/reducer.js +50 -0
- package/lib/commonjs/components/provider/reducer.js.map +1 -0
- package/lib/commonjs/components/provider/types.d.js +2 -0
- package/lib/commonjs/components/provider/types.d.js.map +1 -0
- package/lib/commonjs/constants.js +60 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/context/index.js +14 -0
- package/lib/commonjs/context/index.js.map +1 -0
- package/lib/commonjs/context/internal.js +13 -0
- package/lib/commonjs/context/internal.js.map +1 -0
- package/lib/commonjs/hooks/index.js +24 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useDeviceOrientation.js +38 -0
- package/lib/commonjs/hooks/useDeviceOrientation.js.map +1 -0
- package/lib/commonjs/hooks/useInternal.js +15 -0
- package/lib/commonjs/hooks/useInternal.js.map +1 -0
- package/lib/commonjs/index.js +40 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/styleGuide.js +39 -0
- package/lib/commonjs/styleGuide.js.map +1 -0
- package/lib/commonjs/utils/calculations.js +73 -0
- package/lib/commonjs/utils/calculations.js.map +1 -0
- package/lib/commonjs/utils/validations.js +43 -0
- package/lib/commonjs/utils/validations.js.map +1 -0
- package/lib/module/components/backdrop/Backdrop.js +83 -0
- package/lib/module/components/backdrop/Backdrop.js.map +1 -0
- package/lib/module/components/backdrop/constants.js +4 -0
- package/lib/module/components/backdrop/constants.js.map +1 -0
- package/lib/module/components/backdrop/index.js +2 -0
- package/lib/module/components/backdrop/index.js.map +1 -0
- package/lib/module/components/backdrop/styles.js +7 -0
- package/lib/module/components/backdrop/styles.js.map +1 -0
- package/lib/module/components/flatList/FlatList.js +17 -0
- package/lib/module/components/flatList/FlatList.js.map +1 -0
- package/lib/module/components/flatList/index.js +2 -0
- package/lib/module/components/flatList/index.js.map +1 -0
- package/lib/module/components/holdItem/HoldItem.js +344 -0
- package/lib/module/components/holdItem/HoldItem.js.map +1 -0
- package/lib/module/components/holdItem/index.js +2 -0
- package/lib/module/components/holdItem/index.js.map +1 -0
- package/lib/module/components/holdItem/styles.js +12 -0
- package/lib/module/components/holdItem/styles.js.map +1 -0
- package/lib/module/components/holdItem/types.d.js +2 -0
- package/lib/module/components/holdItem/types.d.js.map +1 -0
- package/lib/module/components/icon/Icon.js +26 -0
- package/lib/module/components/icon/Icon.js.map +1 -0
- package/lib/module/components/icon/index.js +2 -0
- package/lib/module/components/icon/index.js.map +1 -0
- package/lib/module/components/menu/Menu.js +37 -0
- package/lib/module/components/menu/Menu.js.map +1 -0
- package/lib/module/components/menu/MenuItem.js +59 -0
- package/lib/module/components/menu/MenuItem.js.map +1 -0
- package/lib/module/components/menu/MenuItems.js +19 -0
- package/lib/module/components/menu/MenuItems.js.map +1 -0
- package/lib/module/components/menu/MenuList.js +93 -0
- package/lib/module/components/menu/MenuList.js.map +1 -0
- package/lib/module/components/menu/Separator.js +29 -0
- package/lib/module/components/menu/Separator.js.map +1 -0
- package/lib/module/components/menu/calculations.js +17 -0
- package/lib/module/components/menu/calculations.js.map +1 -0
- package/lib/module/components/menu/constants.js +8 -0
- package/lib/module/components/menu/constants.js.map +1 -0
- package/lib/module/components/menu/index.js +2 -0
- package/lib/module/components/menu/index.js.map +1 -0
- package/lib/module/components/menu/styles.js +63 -0
- package/lib/module/components/menu/styles.js.map +1 -0
- package/lib/module/components/menu/types.d.js +2 -0
- package/lib/module/components/menu/types.d.js.map +1 -0
- package/lib/module/components/provider/Provider.js +75 -0
- package/lib/module/components/provider/Provider.js.map +1 -0
- package/lib/module/components/provider/index.js +2 -0
- package/lib/module/components/provider/index.js.map +1 -0
- package/lib/module/components/provider/reducer.js +38 -0
- package/lib/module/components/provider/reducer.js.map +1 -0
- package/lib/module/components/provider/types.d.js +2 -0
- package/lib/module/components/provider/types.d.js.map +1 -0
- package/lib/module/constants.js +37 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/context/index.js +2 -0
- package/lib/module/context/index.js.map +1 -0
- package/lib/module/context/internal.js +4 -0
- package/lib/module/context/internal.js.map +1 -0
- package/lib/module/hooks/index.js +3 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useDeviceOrientation.js +27 -0
- package/lib/module/hooks/useDeviceOrientation.js.map +1 -0
- package/lib/module/hooks/useInternal.js +4 -0
- package/lib/module/hooks/useInternal.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/styleGuide.js +30 -0
- package/lib/module/styleGuide.js.map +1 -0
- package/lib/module/utils/calculations.js +51 -0
- package/lib/module/utils/calculations.js.map +1 -0
- package/lib/module/utils/validations.js +38 -0
- package/lib/module/utils/validations.js.map +1 -0
- package/lib/typescript/components/backdrop/Backdrop.d.ts +3 -0
- package/lib/typescript/components/backdrop/constants.d.ts +2 -0
- package/lib/typescript/components/backdrop/index.d.ts +1 -0
- package/lib/typescript/components/backdrop/styles.d.ts +10 -0
- package/lib/typescript/components/flatList/FlatList.d.ts +5 -0
- package/lib/typescript/components/flatList/index.d.ts +2 -0
- package/lib/typescript/components/holdItem/HoldItem.d.ts +4 -0
- package/lib/typescript/components/holdItem/index.d.ts +2 -0
- package/lib/typescript/components/holdItem/styles.d.ts +15 -0
- package/lib/typescript/components/holdItem/types.d.ts +131 -0
- package/lib/typescript/components/icon/Icon.d.ts +7 -0
- package/lib/typescript/components/icon/index.d.ts +1 -0
- package/lib/typescript/components/menu/Menu.d.ts +3 -0
- package/lib/typescript/components/menu/MenuItem.d.ts +8 -0
- package/lib/typescript/components/menu/MenuItems.d.ts +6 -0
- package/lib/typescript/components/menu/MenuList.d.ts +3 -0
- package/lib/typescript/components/menu/Separator.d.ts +3 -0
- package/lib/typescript/components/menu/calculations.d.ts +4 -0
- package/lib/typescript/components/menu/constants.d.ts +7 -0
- package/lib/typescript/components/menu/index.d.ts +1 -0
- package/lib/typescript/components/menu/styles.d.ts +59 -0
- package/lib/typescript/components/menu/types.d.ts +28 -0
- package/lib/typescript/components/provider/Provider.d.ts +10 -0
- package/lib/typescript/components/provider/index.d.ts +2 -0
- package/lib/typescript/components/provider/reducer.d.ts +20 -0
- package/lib/typescript/components/provider/types.d.ts +33 -0
- package/lib/typescript/constants.d.ts +29 -0
- package/lib/typescript/context/index.d.ts +1 -0
- package/lib/typescript/context/internal.d.ts +16 -0
- package/lib/typescript/hooks/index.d.ts +2 -0
- package/lib/typescript/hooks/useDeviceOrientation.d.ts +3 -0
- package/lib/typescript/hooks/useInternal.d.ts +1 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/styleGuide.d.ts +28 -0
- package/lib/typescript/utils/calculations.d.ts +14 -0
- package/lib/typescript/utils/validations.d.ts +3 -0
- package/package.json +106 -0
- package/src/components/backdrop/Backdrop.tsx +138 -0
- package/src/components/backdrop/constants.ts +8 -0
- package/src/components/backdrop/index.ts +1 -0
- package/src/components/backdrop/styles.ts +8 -0
- package/src/components/flatList/FlatList.tsx +23 -0
- package/src/components/flatList/index.ts +2 -0
- package/src/components/holdItem/HoldItem.tsx +449 -0
- package/src/components/holdItem/index.ts +2 -0
- package/src/components/holdItem/styles.ts +11 -0
- package/src/components/holdItem/types.d.ts +131 -0
- package/src/components/icon/Icon.tsx +33 -0
- package/src/components/icon/index.ts +1 -0
- package/src/components/menu/Menu.tsx +57 -0
- package/src/components/menu/MenuItem.tsx +79 -0
- package/src/components/menu/MenuItems.tsx +26 -0
- package/src/components/menu/MenuList.tsx +151 -0
- package/src/components/menu/Separator.tsx +28 -0
- package/src/components/menu/calculations.ts +49 -0
- package/src/components/menu/constants.ts +9 -0
- package/src/components/menu/index.ts +1 -0
- package/src/components/menu/styles.ts +64 -0
- package/src/components/menu/types.d.ts +28 -0
- package/src/components/provider/Provider.tsx +105 -0
- package/src/components/provider/index.ts +2 -0
- package/src/components/provider/reducer.ts +48 -0
- package/src/components/provider/types.d.ts +33 -0
- package/src/constants.ts +54 -0
- package/src/context/index.ts +1 -0
- package/src/context/internal.ts +19 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useDeviceOrientation.ts +28 -0
- package/src/hooks/useInternal.ts +4 -0
- package/src/index.ts +4 -0
- package/src/styleGuide.ts +31 -0
- package/src/utils/calculations.ts +110 -0
- package/src/utils/validations.ts +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MenuItems.tsx"],"names":["React","memo","MenuItem","isEqual","MenuItemsComponent","items","map","item","index","length","MenuItems"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,IAAhB,QAA4B,OAA5B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,OAAOC,OAAP,MAAoB,gBAApB;;AAGA,MAAMC,kBAAkB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAA2C;AACpE,sBACE,0CACGA,KAAK,CAACC,GAAN,CAAU,CAACC,IAAD,EAAsBC,KAAtB,KAAwC;AACjD,wBACE,oBAAC,QAAD;AACE,MAAA,GAAG,EAAEA,KADP;AAEE,MAAA,IAAI,EAAED,IAFR;AAGE,MAAA,MAAM,EAAEF,KAAK,CAACI,MAAN,KAAiBD,KAAK,GAAG;AAHnC,MADF;AAOD,GARA,CADH,CADF;AAaD,CAdD;;AAgBA,MAAME,SAAS,gBAAGT,IAAI,CAACG,kBAAD,EAAqBD,OAArB,CAAtB;AAEA,eAAeO,SAAf","sourcesContent":["import React, { memo } from 'react';\n\nimport MenuItem from './MenuItem';\n\nimport isEqual from 'lodash.isequal';\nimport { MenuItemProps } from './types';\n\nconst MenuItemsComponent = ({ items }: { items: MenuItemProps[] }) => {\n return (\n <>\n {items.map((item: MenuItemProps, index: number) => {\n return (\n <MenuItem\n key={index}\n item={item}\n isLast={items.length === index + 1}\n />\n );\n })}\n </>\n );\n};\n\nconst MenuItems = memo(MenuItemsComponent, isEqual);\n\nexport default MenuItems;\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import Animated, { runOnJS, useAnimatedProps, useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
4
|
+
import { calculateMenuHeight, menuAnimationAnchor } from '../../utils/calculations'; // @ts-ignore
|
|
5
|
+
|
|
6
|
+
import { BlurView } from '@react-native-community/blur';
|
|
7
|
+
import MenuItems from './MenuItems';
|
|
8
|
+
import { SPRING_CONFIGURATION_MENU, HOLD_ITEM_TRANSFORM_DURATION, IS_IOS, CONTEXT_MENU_STATE } from '../../constants';
|
|
9
|
+
import styles from './styles';
|
|
10
|
+
import { useInternal } from '../../hooks';
|
|
11
|
+
import { deepEqual } from '../../utils/validations';
|
|
12
|
+
import { leftOrRight } from './calculations';
|
|
13
|
+
const AnimatedView = Animated.createAnimatedComponent(BlurView);
|
|
14
|
+
|
|
15
|
+
const MenuListComponent = () => {
|
|
16
|
+
const {
|
|
17
|
+
state,
|
|
18
|
+
theme,
|
|
19
|
+
menuProps
|
|
20
|
+
} = useInternal();
|
|
21
|
+
const [itemList, setItemList] = React.useState([]);
|
|
22
|
+
const menuHeight = useDerivedValue(() => {
|
|
23
|
+
const itemsWithSeparator = menuProps.value.items.filter(item => item.withSeparator);
|
|
24
|
+
return calculateMenuHeight(menuProps.value.items.length, itemsWithSeparator.length);
|
|
25
|
+
}, [menuProps]);
|
|
26
|
+
const prevList = useSharedValue([]);
|
|
27
|
+
const messageStyles = useAnimatedStyle(() => {
|
|
28
|
+
const itemsWithSeparator = menuProps.value.items.filter(item => item.withSeparator);
|
|
29
|
+
const translate = menuAnimationAnchor(menuProps.value.anchorPosition, menuProps.value.itemWidth, menuProps.value.items.length, itemsWithSeparator.length);
|
|
30
|
+
|
|
31
|
+
const _leftPosition = leftOrRight(menuProps);
|
|
32
|
+
|
|
33
|
+
const menuScaleAnimation = () => state.value === CONTEXT_MENU_STATE.ACTIVE ? withSpring(1, SPRING_CONFIGURATION_MENU) : withTiming(0, {
|
|
34
|
+
duration: HOLD_ITEM_TRANSFORM_DURATION
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const opacityAnimation = () => withTiming(state.value === CONTEXT_MENU_STATE.ACTIVE ? 1 : 0, {
|
|
38
|
+
duration: HOLD_ITEM_TRANSFORM_DURATION
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
left: _leftPosition,
|
|
43
|
+
height: menuHeight.value,
|
|
44
|
+
opacity: opacityAnimation(),
|
|
45
|
+
transform: [{
|
|
46
|
+
translateX: translate.beginningTransformations.translateX
|
|
47
|
+
}, {
|
|
48
|
+
translateY: translate.beginningTransformations.translateY
|
|
49
|
+
}, {
|
|
50
|
+
scale: menuScaleAnimation()
|
|
51
|
+
}, {
|
|
52
|
+
translateX: translate.endingTransformations.translateX
|
|
53
|
+
}, {
|
|
54
|
+
translateY: translate.endingTransformations.translateY
|
|
55
|
+
}]
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
const animatedInnerContainerStyle = useAnimatedStyle(() => {
|
|
59
|
+
return {
|
|
60
|
+
backgroundColor: theme.value === 'light' ? IS_IOS ? 'rgba(255, 255, 255, .75)' : 'rgba(255, 255, 255, .95)' : IS_IOS ? 'rgba(0,0,0,0.5)' : 'rgba(39, 39, 39, .8)'
|
|
61
|
+
};
|
|
62
|
+
}, [theme]);
|
|
63
|
+
const animatedProps = useAnimatedProps(() => {
|
|
64
|
+
return {
|
|
65
|
+
blurType: theme.value
|
|
66
|
+
};
|
|
67
|
+
}, [theme]);
|
|
68
|
+
|
|
69
|
+
const setter = items => {
|
|
70
|
+
setItemList(items);
|
|
71
|
+
prevList.value = items;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
useAnimatedReaction(() => menuProps.value.items, _items => {
|
|
75
|
+
if (!deepEqual(_items, prevList.value)) {
|
|
76
|
+
runOnJS(setter)(_items);
|
|
77
|
+
}
|
|
78
|
+
}, [menuProps]);
|
|
79
|
+
return /*#__PURE__*/React.createElement(AnimatedView, {
|
|
80
|
+
blurAmount: 100 //@ts-ignore
|
|
81
|
+
,
|
|
82
|
+
animatedProps: animatedProps,
|
|
83
|
+
style: [styles.menuContainer, messageStyles]
|
|
84
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
85
|
+
style: [StyleSheet.absoluteFillObject, styles.menuInnerContainer, animatedInnerContainerStyle]
|
|
86
|
+
}, /*#__PURE__*/React.createElement(MenuItems, {
|
|
87
|
+
items: itemList
|
|
88
|
+
})));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const MenuList = /*#__PURE__*/React.memo(MenuListComponent);
|
|
92
|
+
export default MenuList;
|
|
93
|
+
//# sourceMappingURL=MenuList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MenuList.tsx"],"names":["React","StyleSheet","Animated","runOnJS","useAnimatedProps","useAnimatedReaction","useAnimatedStyle","useDerivedValue","useSharedValue","withSpring","withTiming","calculateMenuHeight","menuAnimationAnchor","BlurView","MenuItems","SPRING_CONFIGURATION_MENU","HOLD_ITEM_TRANSFORM_DURATION","IS_IOS","CONTEXT_MENU_STATE","styles","useInternal","deepEqual","leftOrRight","AnimatedView","createAnimatedComponent","MenuListComponent","state","theme","menuProps","itemList","setItemList","useState","menuHeight","itemsWithSeparator","value","items","filter","item","withSeparator","length","prevList","messageStyles","translate","anchorPosition","itemWidth","_leftPosition","menuScaleAnimation","ACTIVE","duration","opacityAnimation","left","height","opacity","transform","translateX","beginningTransformations","translateY","scale","endingTransformations","animatedInnerContainerStyle","backgroundColor","animatedProps","blurType","setter","_items","menuContainer","absoluteFillObject","menuInnerContainer","MenuList","memo"],"mappings":"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","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport Animated, {\n runOnJS,\n useAnimatedProps,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\n\nimport {\n calculateMenuHeight,\n menuAnimationAnchor,\n} from '../../utils/calculations';\n// @ts-ignore\nimport { BlurView } from '@react-native-community/blur';\n\nimport MenuItems from './MenuItems';\n\nimport {\n SPRING_CONFIGURATION_MENU,\n HOLD_ITEM_TRANSFORM_DURATION,\n IS_IOS,\n CONTEXT_MENU_STATE,\n} from '../../constants';\n\nimport styles from './styles';\nimport { MenuItemProps } from './types';\nimport { useInternal } from '../../hooks';\nimport { deepEqual } from '../../utils/validations';\nimport { leftOrRight } from './calculations';\n\nconst AnimatedView = Animated.createAnimatedComponent(BlurView);\n\nconst MenuListComponent = () => {\n const { state, theme, menuProps } = useInternal();\n\n const [itemList, setItemList] = React.useState<MenuItemProps[]>([]);\n\n const menuHeight = useDerivedValue(() => {\n const itemsWithSeparator = menuProps.value.items.filter(\n item => item.withSeparator\n );\n return calculateMenuHeight(\n menuProps.value.items.length,\n itemsWithSeparator.length\n );\n }, [menuProps]);\n const prevList = useSharedValue<MenuItemProps[]>([]);\n\n const messageStyles = useAnimatedStyle(() => {\n const itemsWithSeparator = menuProps.value.items.filter(\n item => item.withSeparator\n );\n\n const translate = menuAnimationAnchor(\n menuProps.value.anchorPosition,\n menuProps.value.itemWidth,\n menuProps.value.items.length,\n itemsWithSeparator.length\n );\n\n const _leftPosition = leftOrRight(menuProps);\n\n const menuScaleAnimation = () =>\n state.value === CONTEXT_MENU_STATE.ACTIVE\n ? withSpring(1, SPRING_CONFIGURATION_MENU)\n : withTiming(0, {\n duration: HOLD_ITEM_TRANSFORM_DURATION,\n });\n\n const opacityAnimation = () =>\n withTiming(state.value === CONTEXT_MENU_STATE.ACTIVE ? 1 : 0, {\n duration: HOLD_ITEM_TRANSFORM_DURATION,\n });\n\n return {\n left: _leftPosition,\n height: menuHeight.value,\n opacity: opacityAnimation(),\n transform: [\n { translateX: translate.beginningTransformations.translateX },\n { translateY: translate.beginningTransformations.translateY },\n {\n scale: menuScaleAnimation(),\n },\n { translateX: translate.endingTransformations.translateX },\n { translateY: translate.endingTransformations.translateY },\n ],\n };\n });\n\n const animatedInnerContainerStyle = useAnimatedStyle(() => {\n return {\n backgroundColor:\n theme.value === 'light'\n ? IS_IOS\n ? 'rgba(255, 255, 255, .75)'\n : 'rgba(255, 255, 255, .95)'\n : IS_IOS\n ? 'rgba(0,0,0,0.5)'\n : 'rgba(39, 39, 39, .8)',\n };\n }, [theme]);\n\n const animatedProps = useAnimatedProps(() => {\n return { blurType: theme.value };\n }, [theme]);\n\n const setter = (items: MenuItemProps[]) => {\n setItemList(items);\n prevList.value = items;\n };\n\n useAnimatedReaction(\n () => menuProps.value.items,\n _items => {\n if (!deepEqual(_items, prevList.value)) {\n runOnJS(setter)(_items);\n }\n },\n [menuProps]\n );\n\n return (\n <AnimatedView\n blurAmount={100}\n //@ts-ignore\n animatedProps={animatedProps}\n style={[styles.menuContainer, messageStyles]}\n >\n <Animated.View\n style={[\n StyleSheet.absoluteFillObject,\n styles.menuInnerContainer,\n animatedInnerContainerStyle,\n ]}\n >\n <MenuItems items={itemList} />\n </Animated.View>\n </AnimatedView>\n );\n};\n\nconst MenuList = React.memo(MenuListComponent);\n\nexport default MenuList;\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
4
|
+
import { useInternal } from '../../hooks';
|
|
5
|
+
import { BORDER_LIGHT_COLOR, BORDER_DARK_COLOR } from './constants';
|
|
6
|
+
|
|
7
|
+
const Separator = () => {
|
|
8
|
+
const {
|
|
9
|
+
theme
|
|
10
|
+
} = useInternal();
|
|
11
|
+
const separatorStyles = useAnimatedStyle(() => {
|
|
12
|
+
return {
|
|
13
|
+
backgroundColor: theme.value === 'dark' ? BORDER_DARK_COLOR : BORDER_LIGHT_COLOR
|
|
14
|
+
};
|
|
15
|
+
}, [theme]);
|
|
16
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
17
|
+
style: [styles.separator, { ...separatorStyles
|
|
18
|
+
}]
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default /*#__PURE__*/memo(Separator);
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
separator: {
|
|
25
|
+
width: '100%',
|
|
26
|
+
height: 8
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=Separator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Separator.tsx"],"names":["React","memo","StyleSheet","Animated","useAnimatedStyle","useInternal","BORDER_LIGHT_COLOR","BORDER_DARK_COLOR","Separator","theme","separatorStyles","backgroundColor","value","styles","separator","create","width","height"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,IAAhB,QAA4B,OAA5B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,QAAP,IAAmBC,gBAAnB,QAA2C,yBAA3C;AACA,SAASC,WAAT,QAA4B,aAA5B;AAEA,SAASC,kBAAT,EAA6BC,iBAA7B,QAAsD,aAAtD;;AAEA,MAAMC,SAAS,GAAG,MAAM;AACtB,QAAM;AAAEC,IAAAA;AAAF,MAAYJ,WAAW,EAA7B;AAEA,QAAMK,eAAe,GAAGN,gBAAgB,CAAC,MAAM;AAC7C,WAAO;AACLO,MAAAA,eAAe,EACbF,KAAK,CAACG,KAAN,KAAgB,MAAhB,GAAyBL,iBAAzB,GAA6CD;AAF1C,KAAP;AAID,GALuC,EAKrC,CAACG,KAAD,CALqC,CAAxC;AAOA,sBAAO,oBAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,CAACI,MAAM,CAACC,SAAR,EAAmB,EAAE,GAAGJ;AAAL,KAAnB;AAAtB,IAAP;AACD,CAXD;;AAaA,4BAAeT,IAAI,CAACO,SAAD,CAAnB;AAEA,MAAMK,MAAM,GAAGX,UAAU,CAACa,MAAX,CAAkB;AAC/BD,EAAAA,SAAS,EAAE;AACTE,IAAAA,KAAK,EAAE,MADE;AAETC,IAAAA,MAAM,EAAE;AAFC;AADoB,CAAlB,CAAf","sourcesContent":["import React, { memo } from 'react';\nimport { StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\nimport { useInternal } from '../../hooks';\n\nimport { BORDER_LIGHT_COLOR, BORDER_DARK_COLOR } from './constants';\n\nconst Separator = () => {\n const { theme } = useInternal();\n\n const separatorStyles = useAnimatedStyle(() => {\n return {\n backgroundColor:\n theme.value === 'dark' ? BORDER_DARK_COLOR : BORDER_LIGHT_COLOR,\n };\n }, [theme]);\n\n return <Animated.View style={[styles.separator, { ...separatorStyles }]} />;\n};\n\nexport default memo(Separator);\n\nconst styles = StyleSheet.create({\n separator: {\n width: '100%',\n height: 8,\n },\n});\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MENU_WIDTH } from '../../constants';
|
|
2
|
+
import { MENU_TEXT_DARK_COLOR, MENU_TEXT_DESTRUCTIVE_COLOR_DARK, MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT, MENU_TEXT_LIGHT_COLOR, MENU_TITLE_COLOR } from './constants';
|
|
3
|
+
export const leftOrRight = menuProps => {
|
|
4
|
+
'worklet';
|
|
5
|
+
|
|
6
|
+
const anchorPositionHorizontal = menuProps.value.anchorPosition.split('-')[1];
|
|
7
|
+
const itemWidth = menuProps.value.itemWidth;
|
|
8
|
+
let leftPosition = 0;
|
|
9
|
+
anchorPositionHorizontal === 'right' ? leftPosition = -MENU_WIDTH + itemWidth : anchorPositionHorizontal === 'left' ? leftPosition = 0 : leftPosition = -menuProps.value.itemWidth - MENU_WIDTH / 2 + menuProps.value.itemWidth / 2;
|
|
10
|
+
return leftPosition;
|
|
11
|
+
};
|
|
12
|
+
export const getColor = (isTitle, isDestructive, themeValue) => {
|
|
13
|
+
'worklet';
|
|
14
|
+
|
|
15
|
+
return isTitle ? MENU_TITLE_COLOR : isDestructive ? themeValue === 'dark' ? MENU_TEXT_DESTRUCTIVE_COLOR_DARK : MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT : themeValue === 'dark' ? MENU_TEXT_DARK_COLOR : MENU_TEXT_LIGHT_COLOR;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=calculations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["calculations.ts"],"names":["MENU_WIDTH","MENU_TEXT_DARK_COLOR","MENU_TEXT_DESTRUCTIVE_COLOR_DARK","MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT","MENU_TEXT_LIGHT_COLOR","MENU_TITLE_COLOR","leftOrRight","menuProps","anchorPositionHorizontal","value","anchorPosition","split","itemWidth","leftPosition","getColor","isTitle","isDestructive","themeValue"],"mappings":"AAEA,SAASA,UAAT,QAA2B,iBAA3B;AACA,SACEC,oBADF,EAEEC,gCAFF,EAGEC,iCAHF,EAIEC,qBAJF,EAKEC,gBALF,QAMO,aANP;AASA,OAAO,MAAMC,WAAW,GACtBC,SADyB,IAEtB;AACH;;AAEA,QAAMC,wBAAwB,GAAGD,SAAS,CAACE,KAAV,CAAgBC,cAAhB,CAA+BC,KAA/B,CAAqC,GAArC,EAA0C,CAA1C,CAAjC;AACA,QAAMC,SAAS,GAAGL,SAAS,CAACE,KAAV,CAAgBG,SAAlC;AAEA,MAAIC,YAAY,GAAG,CAAnB;AACAL,EAAAA,wBAAwB,KAAK,OAA7B,GACKK,YAAY,GAAG,CAACb,UAAD,GAAcY,SADlC,GAEIJ,wBAAwB,KAAK,MAA7B,GACCK,YAAY,GAAG,CADhB,GAECA,YAAY,GACX,CAACN,SAAS,CAACE,KAAV,CAAgBG,SAAjB,GACAZ,UAAU,GAAG,CADb,GAEAO,SAAS,CAACE,KAAV,CAAgBG,SAAhB,GAA4B,CAPlC;AASA,SAAOC,YAAP;AACD,CAnBM;AAqBP,OAAO,MAAMC,QAAQ,GAAG,CACtBC,OADsB,EAEtBC,aAFsB,EAGtBC,UAHsB,KAInB;AACH;;AACA,SAAOF,OAAO,GACVV,gBADU,GAEVW,aAAa,GACbC,UAAU,KAAK,MAAf,GACEf,gCADF,GAEEC,iCAHW,GAIbc,UAAU,KAAK,MAAf,GACAhB,oBADA,GAEAG,qBARJ;AASD,CAfM","sourcesContent":["import Animated from 'react-native-reanimated';\n\nimport { MENU_WIDTH } from '../../constants';\nimport {\n MENU_TEXT_DARK_COLOR,\n MENU_TEXT_DESTRUCTIVE_COLOR_DARK,\n MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT,\n MENU_TEXT_LIGHT_COLOR,\n MENU_TITLE_COLOR,\n} from './constants';\nimport type { MenuInternalProps } from './types';\n\nexport const leftOrRight = (\n menuProps: Animated.SharedValue<MenuInternalProps>\n) => {\n 'worklet';\n\n const anchorPositionHorizontal = menuProps.value.anchorPosition.split('-')[1];\n const itemWidth = menuProps.value.itemWidth;\n\n let leftPosition = 0;\n anchorPositionHorizontal === 'right'\n ? (leftPosition = -MENU_WIDTH + itemWidth)\n : anchorPositionHorizontal === 'left'\n ? (leftPosition = 0)\n : (leftPosition =\n -menuProps.value.itemWidth -\n MENU_WIDTH / 2 +\n menuProps.value.itemWidth / 2);\n\n return leftPosition;\n};\n\nexport const getColor = (\n isTitle: boolean | undefined,\n isDestructive: boolean | undefined,\n themeValue: 'light' | 'dark'\n) => {\n 'worklet';\n return isTitle\n ? MENU_TITLE_COLOR\n : isDestructive\n ? themeValue === 'dark'\n ? MENU_TEXT_DESTRUCTIVE_COLOR_DARK\n : MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT\n : themeValue === 'dark'\n ? MENU_TEXT_DARK_COLOR\n : MENU_TEXT_LIGHT_COLOR;\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const BORDER_LIGHT_COLOR = 'rgba(0, 0, 0, 0.1)';
|
|
2
|
+
export const BORDER_DARK_COLOR = 'rgba(255, 255, 255, 0.1)';
|
|
3
|
+
export const MENU_TITLE_COLOR = 'gray';
|
|
4
|
+
export const MENU_TEXT_LIGHT_COLOR = 'rgba(0, 0, 0, 1)';
|
|
5
|
+
export const MENU_TEXT_DARK_COLOR = 'rgb(255, 255, 255)';
|
|
6
|
+
export const MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT = 'rgb(255, 59,48)';
|
|
7
|
+
export const MENU_TEXT_DESTRUCTIVE_COLOR_DARK = 'rgb(255, 69,58)';
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["constants.ts"],"names":["BORDER_LIGHT_COLOR","BORDER_DARK_COLOR","MENU_TITLE_COLOR","MENU_TEXT_LIGHT_COLOR","MENU_TEXT_DARK_COLOR","MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT","MENU_TEXT_DESTRUCTIVE_COLOR_DARK"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAG,oBAA3B;AACP,OAAO,MAAMC,iBAAiB,GAAG,0BAA1B;AAEP,OAAO,MAAMC,gBAAgB,GAAG,MAAzB;AACP,OAAO,MAAMC,qBAAqB,GAAG,kBAA9B;AACP,OAAO,MAAMC,oBAAoB,GAAG,oBAA7B;AAEP,OAAO,MAAMC,iCAAiC,GAAG,iBAA1C;AACP,OAAO,MAAMC,gCAAgC,GAAG,iBAAzC","sourcesContent":["export const BORDER_LIGHT_COLOR = 'rgba(0, 0, 0, 0.1)';\nexport const BORDER_DARK_COLOR = 'rgba(255, 255, 255, 0.1)';\n\nexport const MENU_TITLE_COLOR = 'gray';\nexport const MENU_TEXT_LIGHT_COLOR = 'rgba(0, 0, 0, 1)';\nexport const MENU_TEXT_DARK_COLOR = 'rgb(255, 255, 255)';\n\nexport const MENU_TEXT_DESTRUCTIVE_COLOR_LIGHT = 'rgb(255, 59,48)';\nexport const MENU_TEXT_DESTRUCTIVE_COLOR_DARK = 'rgb(255, 69,58)';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,QAAxB","sourcesContent":["export { default } from './Menu';\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { MENU_WIDTH } from '../../constants';
|
|
3
|
+
import styleGuide from '../../styleGuide';
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
menuWrapper: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
left: 0,
|
|
8
|
+
zIndex: 10
|
|
9
|
+
},
|
|
10
|
+
menuContainer: {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
top: 0,
|
|
13
|
+
width: MENU_WIDTH,
|
|
14
|
+
borderRadius: styleGuide.spacing * 1.5,
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
justifyContent: 'flex-start',
|
|
18
|
+
alignItems: 'flex-start',
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
zIndex: 15
|
|
21
|
+
},
|
|
22
|
+
menuInnerContainer: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
justifyContent: 'flex-start',
|
|
26
|
+
alignItems: 'center'
|
|
27
|
+
},
|
|
28
|
+
menuItem: {
|
|
29
|
+
width: '100%',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
justifyContent: 'space-between',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
paddingHorizontal: styleGuide.spacing * 2,
|
|
35
|
+
paddingVertical: styleGuide.spacing * 1.25
|
|
36
|
+
},
|
|
37
|
+
border: {
|
|
38
|
+
borderBottomWidth: 1,
|
|
39
|
+
borderBottomColor: 'rgba(255, 255, 255, 0.1)'
|
|
40
|
+
},
|
|
41
|
+
menuItemText: {
|
|
42
|
+
fontSize: styleGuide.typography.callout.fontSize,
|
|
43
|
+
lineHeight: styleGuide.typography.callout.lineHeight,
|
|
44
|
+
textAlign: 'left',
|
|
45
|
+
width: '100%',
|
|
46
|
+
flex: 1
|
|
47
|
+
},
|
|
48
|
+
menuItemTitleText: {
|
|
49
|
+
fontSize: styleGuide.typography.callout2.fontSize,
|
|
50
|
+
lineHeight: styleGuide.typography.callout2.lineHeight,
|
|
51
|
+
textAlign: 'center',
|
|
52
|
+
width: '100%',
|
|
53
|
+
flex: 1
|
|
54
|
+
},
|
|
55
|
+
textDark: {
|
|
56
|
+
color: 'black'
|
|
57
|
+
},
|
|
58
|
+
textLight: {
|
|
59
|
+
color: 'white'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
export default styles;
|
|
63
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["styles.ts"],"names":["StyleSheet","MENU_WIDTH","styleGuide","styles","create","menuWrapper","position","left","zIndex","menuContainer","top","width","borderRadius","spacing","display","flexDirection","justifyContent","alignItems","overflow","menuInnerContainer","menuItem","paddingHorizontal","paddingVertical","border","borderBottomWidth","borderBottomColor","menuItemText","fontSize","typography","callout","lineHeight","textAlign","flex","menuItemTitleText","callout2","textDark","color","textLight"],"mappings":"AAAA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,iBAA3B;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AAEA,MAAMC,MAAM,GAAGH,UAAU,CAACI,MAAX,CAAkB;AAC/BC,EAAAA,WAAW,EAAE;AACXC,IAAAA,QAAQ,EAAE,UADC;AAEXC,IAAAA,IAAI,EAAE,CAFK;AAGXC,IAAAA,MAAM,EAAE;AAHG,GADkB;AAM/BC,EAAAA,aAAa,EAAE;AACbH,IAAAA,QAAQ,EAAE,UADG;AAEbI,IAAAA,GAAG,EAAE,CAFQ;AAGbC,IAAAA,KAAK,EAAEV,UAHM;AAIbW,IAAAA,YAAY,EAAEV,UAAU,CAACW,OAAX,GAAqB,GAJtB;AAKbC,IAAAA,OAAO,EAAE,MALI;AAMbC,IAAAA,aAAa,EAAE,KANF;AAObC,IAAAA,cAAc,EAAE,YAPH;AAQbC,IAAAA,UAAU,EAAE,YARC;AASbC,IAAAA,QAAQ,EAAE,QATG;AAUbV,IAAAA,MAAM,EAAE;AAVK,GANgB;AAkB/BW,EAAAA,kBAAkB,EAAE;AAClBL,IAAAA,OAAO,EAAE,MADS;AAElBC,IAAAA,aAAa,EAAE,QAFG;AAGlBC,IAAAA,cAAc,EAAE,YAHE;AAIlBC,IAAAA,UAAU,EAAE;AAJM,GAlBW;AAwB/BG,EAAAA,QAAQ,EAAE;AACRT,IAAAA,KAAK,EAAE,MADC;AAERG,IAAAA,OAAO,EAAE,MAFD;AAGRC,IAAAA,aAAa,EAAE,KAHP;AAIRC,IAAAA,cAAc,EAAE,eAJR;AAKRC,IAAAA,UAAU,EAAE,QALJ;AAMRI,IAAAA,iBAAiB,EAAEnB,UAAU,CAACW,OAAX,GAAqB,CANhC;AAORS,IAAAA,eAAe,EAAEpB,UAAU,CAACW,OAAX,GAAqB;AAP9B,GAxBqB;AAiC/BU,EAAAA,MAAM,EAAE;AACNC,IAAAA,iBAAiB,EAAE,CADb;AAENC,IAAAA,iBAAiB,EAAE;AAFb,GAjCuB;AAqC/BC,EAAAA,YAAY,EAAE;AACZC,IAAAA,QAAQ,EAAEzB,UAAU,CAAC0B,UAAX,CAAsBC,OAAtB,CAA8BF,QAD5B;AAEZG,IAAAA,UAAU,EAAE5B,UAAU,CAAC0B,UAAX,CAAsBC,OAAtB,CAA8BC,UAF9B;AAGZC,IAAAA,SAAS,EAAE,MAHC;AAIZpB,IAAAA,KAAK,EAAE,MAJK;AAKZqB,IAAAA,IAAI,EAAE;AALM,GArCiB;AA4C/BC,EAAAA,iBAAiB,EAAE;AACjBN,IAAAA,QAAQ,EAAEzB,UAAU,CAAC0B,UAAX,CAAsBM,QAAtB,CAA+BP,QADxB;AAEjBG,IAAAA,UAAU,EAAE5B,UAAU,CAAC0B,UAAX,CAAsBM,QAAtB,CAA+BJ,UAF1B;AAGjBC,IAAAA,SAAS,EAAE,QAHM;AAIjBpB,IAAAA,KAAK,EAAE,MAJU;AAKjBqB,IAAAA,IAAI,EAAE;AALW,GA5CY;AAmD/BG,EAAAA,QAAQ,EAAE;AACRC,IAAAA,KAAK,EAAE;AADC,GAnDqB;AAsD/BC,EAAAA,SAAS,EAAE;AACTD,IAAAA,KAAK,EAAE;AADE;AAtDoB,CAAlB,CAAf;AA2DA,eAAejC,MAAf","sourcesContent":["import { StyleSheet } from 'react-native';\nimport { MENU_WIDTH } from '../../constants';\nimport styleGuide from '../../styleGuide';\n\nconst styles = StyleSheet.create({\n menuWrapper: {\n position: 'absolute',\n left: 0,\n zIndex: 10,\n },\n menuContainer: {\n position: 'absolute',\n top: 0,\n width: MENU_WIDTH,\n borderRadius: styleGuide.spacing * 1.5,\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n overflow: 'hidden',\n zIndex: 15,\n },\n menuInnerContainer: {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'flex-start',\n alignItems: 'center',\n },\n menuItem: {\n width: '100%',\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n paddingHorizontal: styleGuide.spacing * 2,\n paddingVertical: styleGuide.spacing * 1.25,\n },\n border: {\n borderBottomWidth: 1,\n borderBottomColor: 'rgba(255, 255, 255, 0.1)',\n },\n menuItemText: {\n fontSize: styleGuide.typography.callout.fontSize,\n lineHeight: styleGuide.typography.callout.lineHeight,\n textAlign: 'left',\n width: '100%',\n flex: 1,\n },\n menuItemTitleText: {\n fontSize: styleGuide.typography.callout2.fontSize,\n lineHeight: styleGuide.typography.callout2.lineHeight,\n textAlign: 'center',\n width: '100%',\n flex: 1,\n },\n textDark: {\n color: 'black',\n },\n textLight: {\n color: 'white',\n },\n});\n\nexport default styles;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { memo, useEffect, useMemo } from 'react';
|
|
2
|
+
import { PortalProvider } from '@gorhom/portal';
|
|
3
|
+
import Animated, { useSharedValue, useAnimatedReaction, runOnJS } from 'react-native-reanimated';
|
|
4
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler'; // Components
|
|
5
|
+
|
|
6
|
+
import { Backdrop } from '../backdrop'; // Utils
|
|
7
|
+
|
|
8
|
+
import { InternalContext } from '../../context/internal';
|
|
9
|
+
import { CONTEXT_MENU_STATE } from '../../constants';
|
|
10
|
+
import Menu from '../menu';
|
|
11
|
+
export let AnimatedIcon;
|
|
12
|
+
|
|
13
|
+
const ProviderComponent = ({
|
|
14
|
+
children,
|
|
15
|
+
theme: selectedTheme,
|
|
16
|
+
iconComponent,
|
|
17
|
+
safeAreaInsets,
|
|
18
|
+
onOpen,
|
|
19
|
+
onClose
|
|
20
|
+
}) => {
|
|
21
|
+
if (iconComponent) AnimatedIcon = Animated.createAnimatedComponent(iconComponent);
|
|
22
|
+
const state = useSharedValue(CONTEXT_MENU_STATE.UNDETERMINED);
|
|
23
|
+
const theme = useSharedValue(selectedTheme || 'light');
|
|
24
|
+
const menuProps = useSharedValue({
|
|
25
|
+
itemHeight: 0,
|
|
26
|
+
itemWidth: 0,
|
|
27
|
+
itemX: 0,
|
|
28
|
+
itemY: 0,
|
|
29
|
+
items: [],
|
|
30
|
+
anchorPosition: 'top-center',
|
|
31
|
+
menuHeight: 0,
|
|
32
|
+
transformValue: 0,
|
|
33
|
+
actionParams: {}
|
|
34
|
+
});
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
theme.value = selectedTheme || 'light'; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [selectedTheme]);
|
|
38
|
+
useAnimatedReaction(() => state.value, state => {
|
|
39
|
+
switch (state) {
|
|
40
|
+
case CONTEXT_MENU_STATE.ACTIVE:
|
|
41
|
+
{
|
|
42
|
+
if (onOpen) runOnJS(onOpen)();
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
case CONTEXT_MENU_STATE.END:
|
|
47
|
+
{
|
|
48
|
+
if (onClose) runOnJS(onClose)();
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, [state]);
|
|
53
|
+
const internalContextVariables = useMemo(() => ({
|
|
54
|
+
state,
|
|
55
|
+
theme,
|
|
56
|
+
menuProps,
|
|
57
|
+
safeAreaInsets: safeAreaInsets || {
|
|
58
|
+
top: 0,
|
|
59
|
+
bottom: 0,
|
|
60
|
+
left: 0,
|
|
61
|
+
right: 0
|
|
62
|
+
}
|
|
63
|
+
}), [state, theme, menuProps, safeAreaInsets]);
|
|
64
|
+
return /*#__PURE__*/React.createElement(GestureHandlerRootView, {
|
|
65
|
+
style: {
|
|
66
|
+
flex: 1
|
|
67
|
+
}
|
|
68
|
+
}, /*#__PURE__*/React.createElement(InternalContext.Provider, {
|
|
69
|
+
value: internalContextVariables
|
|
70
|
+
}, /*#__PURE__*/React.createElement(PortalProvider, null, children, /*#__PURE__*/React.createElement(Backdrop, null), /*#__PURE__*/React.createElement(Menu, null))));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const Provider = /*#__PURE__*/memo(ProviderComponent);
|
|
74
|
+
export default Provider;
|
|
75
|
+
//# sourceMappingURL=Provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Provider.tsx"],"names":["React","memo","useEffect","useMemo","PortalProvider","Animated","useSharedValue","useAnimatedReaction","runOnJS","GestureHandlerRootView","Backdrop","InternalContext","CONTEXT_MENU_STATE","Menu","AnimatedIcon","ProviderComponent","children","theme","selectedTheme","iconComponent","safeAreaInsets","onOpen","onClose","createAnimatedComponent","state","UNDETERMINED","menuProps","itemHeight","itemWidth","itemX","itemY","items","anchorPosition","menuHeight","transformValue","actionParams","value","ACTIVE","END","internalContextVariables","top","bottom","left","right","flex","Provider"],"mappings":"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","sourcesContent":["import React, { memo, useEffect, useMemo } from 'react';\nimport { PortalProvider } from '@gorhom/portal';\nimport Animated, { useSharedValue, useAnimatedReaction, runOnJS } from 'react-native-reanimated';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n// Components\nimport { Backdrop } from '../backdrop';\n\n// Utils\nimport { InternalContext } from '../../context/internal';\nimport { HoldMenuProviderProps } from './types';\nimport { StateProps, Action } from './reducer';\nimport { CONTEXT_MENU_STATE } from '../../constants';\nimport { MenuInternalProps } from '../menu/types';\nimport Menu from '../menu';\n\nexport interface Store {\n state: StateProps;\n dispatch?: React.Dispatch<Action>;\n}\n\nexport let AnimatedIcon: any;\n\nconst ProviderComponent = ({\n children,\n theme: selectedTheme,\n iconComponent,\n safeAreaInsets,\n onOpen,\n onClose,\n}: HoldMenuProviderProps) => {\n if (iconComponent)\n AnimatedIcon = Animated.createAnimatedComponent(iconComponent);\n\n const state = useSharedValue<CONTEXT_MENU_STATE>(\n CONTEXT_MENU_STATE.UNDETERMINED\n );\n const theme = useSharedValue<'light' | 'dark'>(selectedTheme || 'light');\n const menuProps = useSharedValue<MenuInternalProps>({\n itemHeight: 0,\n itemWidth: 0,\n itemX: 0,\n itemY: 0,\n items: [],\n anchorPosition: 'top-center',\n menuHeight: 0,\n transformValue: 0,\n actionParams: {},\n });\n\n useEffect(() => {\n theme.value = selectedTheme || 'light';\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedTheme]);\n\n useAnimatedReaction(\n () => state.value,\n state => {\n switch (state) {\n case CONTEXT_MENU_STATE.ACTIVE: {\n if (onOpen)\n runOnJS(onOpen)();\n break\n }\n case CONTEXT_MENU_STATE.END: {\n if (onClose)\n runOnJS(onClose)();\n break\n }\n }\n },\n [state]\n );\n\n const internalContextVariables = useMemo(\n () => ({\n state,\n theme,\n menuProps,\n safeAreaInsets: safeAreaInsets || {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n }),\n [state, theme, menuProps, safeAreaInsets]\n );\n\n return (\n <GestureHandlerRootView style={{ flex: 1 }}>\n <InternalContext.Provider value={internalContextVariables}>\n <PortalProvider>\n {children}\n <Backdrop />\n <Menu />\n </PortalProvider>\n </InternalContext.Provider>\n </GestureHandlerRootView>\n );\n};\n\nconst Provider = memo(ProviderComponent);\n\nexport default Provider;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,YAAxB","sourcesContent":["export { default } from './Provider';\nexport type { HoldMenuProviderProps } from './types';\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CONTEXT_MENU_STATE } from '../../constants';
|
|
2
|
+
export let ActionType;
|
|
3
|
+
|
|
4
|
+
(function (ActionType) {
|
|
5
|
+
ActionType["Active"] = "Active";
|
|
6
|
+
ActionType["End"] = "End";
|
|
7
|
+
ActionType["Theme"] = "Theme";
|
|
8
|
+
})(ActionType || (ActionType = {}));
|
|
9
|
+
|
|
10
|
+
export const reducer = (state, action) => {
|
|
11
|
+
switch (action.type) {
|
|
12
|
+
case ActionType.Active:
|
|
13
|
+
return { ...state,
|
|
14
|
+
active: CONTEXT_MENU_STATE.ACTIVE,
|
|
15
|
+
activeItem: action.activeItem
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
case ActionType.End:
|
|
19
|
+
return { ...state,
|
|
20
|
+
active: CONTEXT_MENU_STATE.END,
|
|
21
|
+
activeItem: null
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
case ActionType.Theme:
|
|
25
|
+
return { ...state,
|
|
26
|
+
theme: state.theme === 'dark' ? 'light' : 'dark'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
default:
|
|
30
|
+
return state;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const initialState = {
|
|
34
|
+
active: 0,
|
|
35
|
+
activeItem: null,
|
|
36
|
+
theme: 'light'
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["reducer.ts"],"names":["CONTEXT_MENU_STATE","ActionType","reducer","state","action","type","Active","active","ACTIVE","activeItem","End","END","Theme","theme","initialState"],"mappings":"AAAA,SAASA,kBAAT,QAAmC,iBAAnC;AAQA,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,KAAAA,U;;AAWZ,OAAO,MAAMC,OAAO,GAAG,CAACC,KAAD,EAAoBC,MAApB,KAAmD;AACxE,UAAQA,MAAM,CAACC,IAAf;AACE,SAAKJ,UAAU,CAACK,MAAhB;AACE,aAAO,EACL,GAAGH,KADE;AAELI,QAAAA,MAAM,EAAEP,kBAAkB,CAACQ,MAFtB;AAGLC,QAAAA,UAAU,EAAEL,MAAM,CAACK;AAHd,OAAP;;AAKF,SAAKR,UAAU,CAACS,GAAhB;AACE,aAAO,EACL,GAAGP,KADE;AAELI,QAAAA,MAAM,EAAEP,kBAAkB,CAACW,GAFtB;AAGLF,QAAAA,UAAU,EAAE;AAHP,OAAP;;AAKF,SAAKR,UAAU,CAACW,KAAhB;AACE,aAAO,EACL,GAAGT,KADE;AAELU,QAAAA,KAAK,EAAEV,KAAK,CAACU,KAAN,KAAgB,MAAhB,GAAyB,OAAzB,GAAmC;AAFrC,OAAP;;AAIF;AACE,aAAOV,KAAP;AAnBJ;AAqBD,CAtBM;AAwBP,OAAO,MAAMW,YAAwB,GAAG;AACtCP,EAAAA,MAAM,EAAE,CAD8B;AAEtCE,EAAAA,UAAU,EAAE,IAF0B;AAGtCI,EAAAA,KAAK,EAAE;AAH+B,CAAjC","sourcesContent":["import { CONTEXT_MENU_STATE } from '../../constants';\n\nexport type StateProps = {\n active: number;\n activeItem: string | null;\n theme: 'light' | 'dark';\n};\n\nexport enum ActionType {\n Active = 'Active',\n End = 'End',\n Theme = 'Theme',\n}\n\nexport type Action =\n | { type: ActionType.Active; activeItem: string | null }\n | { type: ActionType.End }\n | { type: ActionType.Theme };\n\nexport const reducer = (state: StateProps, action: Action): StateProps => {\n switch (action.type) {\n case ActionType.Active:\n return {\n ...state,\n active: CONTEXT_MENU_STATE.ACTIVE,\n activeItem: action.activeItem,\n };\n case ActionType.End:\n return {\n ...state,\n active: CONTEXT_MENU_STATE.END,\n activeItem: null,\n };\n case ActionType.Theme:\n return {\n ...state,\n theme: state.theme === 'dark' ? 'light' : 'dark',\n };\n default:\n return state;\n }\n};\n\nexport const initialState: StateProps = {\n active: 0,\n activeItem: null,\n theme: 'light',\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Dimensions, Platform } from 'react-native';
|
|
2
|
+
const HOLD_ITEM_TRANSFORM_DURATION = 150;
|
|
3
|
+
const HOLD_ITEM_SCALE_DOWN_VALUE = 0.95;
|
|
4
|
+
const HOLD_ITEM_SCALE_DOWN_DURATION = 210;
|
|
5
|
+
const SPRING_CONFIGURATION = {
|
|
6
|
+
damping: 33,
|
|
7
|
+
mass: 1.03,
|
|
8
|
+
stiffness: 500,
|
|
9
|
+
restDisplacementThreshold: 0.001,
|
|
10
|
+
restSpeedThreshold: 0.001
|
|
11
|
+
};
|
|
12
|
+
const SPRING_CONFIGURATION_MENU = {
|
|
13
|
+
damping: 39,
|
|
14
|
+
mass: 1.09,
|
|
15
|
+
stiffness: 500,
|
|
16
|
+
restDisplacementThreshold: 0.001,
|
|
17
|
+
restSpeedThreshold: 0.001
|
|
18
|
+
};
|
|
19
|
+
var CONTEXT_MENU_STATE;
|
|
20
|
+
|
|
21
|
+
(function (CONTEXT_MENU_STATE) {
|
|
22
|
+
CONTEXT_MENU_STATE[CONTEXT_MENU_STATE["UNDETERMINED"] = 0] = "UNDETERMINED";
|
|
23
|
+
CONTEXT_MENU_STATE[CONTEXT_MENU_STATE["ACTIVE"] = 1] = "ACTIVE";
|
|
24
|
+
CONTEXT_MENU_STATE[CONTEXT_MENU_STATE["END"] = 2] = "END";
|
|
25
|
+
})(CONTEXT_MENU_STATE || (CONTEXT_MENU_STATE = {}));
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
height: WINDOW_HEIGHT,
|
|
29
|
+
width: WINDOW_WIDTH
|
|
30
|
+
} = Dimensions.get('screen');
|
|
31
|
+
const MENU_CONTAINER_WIDTH = 100;
|
|
32
|
+
const MENU_WIDTH = WINDOW_WIDTH * 60 / 100;
|
|
33
|
+
const MENU_TRANSFORM_ORIGIN_TOLERENCE = 10;
|
|
34
|
+
const IS_IOS = Platform.OS === 'ios';
|
|
35
|
+
const FONT_SCALE = Dimensions.get('screen').fontScale;
|
|
36
|
+
export { CONTEXT_MENU_STATE, WINDOW_HEIGHT, WINDOW_WIDTH, MENU_WIDTH, MENU_CONTAINER_WIDTH, HOLD_ITEM_TRANSFORM_DURATION, HOLD_ITEM_SCALE_DOWN_VALUE, HOLD_ITEM_SCALE_DOWN_DURATION, SPRING_CONFIGURATION, SPRING_CONFIGURATION_MENU, MENU_TRANSFORM_ORIGIN_TOLERENCE, IS_IOS, FONT_SCALE };
|
|
37
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["constants.ts"],"names":["Dimensions","Platform","HOLD_ITEM_TRANSFORM_DURATION","HOLD_ITEM_SCALE_DOWN_VALUE","HOLD_ITEM_SCALE_DOWN_DURATION","SPRING_CONFIGURATION","damping","mass","stiffness","restDisplacementThreshold","restSpeedThreshold","SPRING_CONFIGURATION_MENU","CONTEXT_MENU_STATE","height","WINDOW_HEIGHT","width","WINDOW_WIDTH","get","MENU_CONTAINER_WIDTH","MENU_WIDTH","MENU_TRANSFORM_ORIGIN_TOLERENCE","IS_IOS","OS","FONT_SCALE","fontScale"],"mappings":"AAAA,SAASA,UAAT,EAAqBC,QAArB,QAAqC,cAArC;AAEA,MAAMC,4BAA4B,GAAG,GAArC;AACA,MAAMC,0BAA0B,GAAG,IAAnC;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AAEA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,OAAO,EAAE,EADkB;AAE3BC,EAAAA,IAAI,EAAE,IAFqB;AAG3BC,EAAAA,SAAS,EAAE,GAHgB;AAI3BC,EAAAA,yBAAyB,EAAE,KAJA;AAK3BC,EAAAA,kBAAkB,EAAE;AALO,CAA7B;AAQA,MAAMC,yBAAyB,GAAG;AAChCL,EAAAA,OAAO,EAAE,EADuB;AAEhCC,EAAAA,IAAI,EAAE,IAF0B;AAGhCC,EAAAA,SAAS,EAAE,GAHqB;AAIhCC,EAAAA,yBAAyB,EAAE,KAJK;AAKhCC,EAAAA,kBAAkB,EAAE;AALY,CAAlC;IAQKE,kB;;WAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;GAAAA,kB,KAAAA,kB;;AAML,MAAM;AAAEC,EAAAA,MAAM,EAAEC,aAAV;AAAyBC,EAAAA,KAAK,EAAEC;AAAhC,IAAiDhB,UAAU,CAACiB,GAAX,CAAe,QAAf,CAAvD;AAEA,MAAMC,oBAAoB,GAAG,GAA7B;AACA,MAAMC,UAAU,GAAIH,YAAY,GAAG,EAAhB,GAAsB,GAAzC;AAEA,MAAMI,+BAA+B,GAAG,EAAxC;AAEA,MAAMC,MAAM,GAAGpB,QAAQ,CAACqB,EAAT,KAAgB,KAA/B;AAEA,MAAMC,UAAU,GAAGvB,UAAU,CAACiB,GAAX,CAAe,QAAf,EAAyBO,SAA5C;AAEA,SACEZ,kBADF,EAEEE,aAFF,EAGEE,YAHF,EAIEG,UAJF,EAKED,oBALF,EAMEhB,4BANF,EAOEC,0BAPF,EAQEC,6BARF,EASEC,oBATF,EAUEM,yBAVF,EAWES,+BAXF,EAYEC,MAZF,EAaEE,UAbF","sourcesContent":["import { Dimensions, Platform } from 'react-native';\n\nconst HOLD_ITEM_TRANSFORM_DURATION = 150;\nconst HOLD_ITEM_SCALE_DOWN_VALUE = 0.95;\nconst HOLD_ITEM_SCALE_DOWN_DURATION = 210;\n\nconst SPRING_CONFIGURATION = {\n damping: 33,\n mass: 1.03,\n stiffness: 500,\n restDisplacementThreshold: 0.001,\n restSpeedThreshold: 0.001,\n};\n\nconst SPRING_CONFIGURATION_MENU = {\n damping: 39,\n mass: 1.09,\n stiffness: 500,\n restDisplacementThreshold: 0.001,\n restSpeedThreshold: 0.001,\n};\n\nenum CONTEXT_MENU_STATE {\n UNDETERMINED = 0,\n ACTIVE,\n END,\n}\n\nconst { height: WINDOW_HEIGHT, width: WINDOW_WIDTH } = Dimensions.get('screen');\n\nconst MENU_CONTAINER_WIDTH = 100;\nconst MENU_WIDTH = (WINDOW_WIDTH * 60) / 100;\n\nconst MENU_TRANSFORM_ORIGIN_TOLERENCE = 10;\n\nconst IS_IOS = Platform.OS === 'ios';\n\nconst FONT_SCALE = Dimensions.get('screen').fontScale;\n\nexport {\n CONTEXT_MENU_STATE,\n WINDOW_HEIGHT,\n WINDOW_WIDTH,\n MENU_WIDTH,\n MENU_CONTAINER_WIDTH,\n HOLD_ITEM_TRANSFORM_DURATION,\n HOLD_ITEM_SCALE_DOWN_VALUE,\n HOLD_ITEM_SCALE_DOWN_DURATION,\n SPRING_CONFIGURATION,\n SPRING_CONFIGURATION_MENU,\n MENU_TRANSFORM_ORIGIN_TOLERENCE,\n IS_IOS,\n FONT_SCALE,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["InternalContext"],"mappings":"AAAA,SAASA,eAAT,QAAgC,YAAhC","sourcesContent":["export { InternalContext } from './internal';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["internal.ts"],"names":["createContext","InternalContext"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AAiBA;AACA,OAAO,MAAMC,eAAe,gBAAGD,aAAa,EAArC","sourcesContent":["import { createContext } from 'react';\nimport type Animated from 'react-native-reanimated';\nimport type { CONTEXT_MENU_STATE } from '../constants';\nimport { MenuInternalProps } from '../components/menu/types';\n\nexport type InternalContextType = {\n state: Animated.SharedValue<CONTEXT_MENU_STATE>;\n theme: Animated.SharedValue<'light' | 'dark'>;\n menuProps: Animated.SharedValue<MenuInternalProps>;\n safeAreaInsets?: {\n top: number;\n right: number;\n bottom: number;\n left: number;\n };\n};\n\n// @ts-ignore\nexport const InternalContext = createContext<InternalContextType>();\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["default","useDeviceOrientation","useInternal"],"mappings":"AAAA,SAASA,OAAO,IAAIC,oBAApB,QAAgD,wBAAhD;AACA,SAASC,WAAT,QAA4B,eAA5B","sourcesContent":["export { default as useDeviceOrientation } from './useDeviceOrientation';\nexport { useInternal } from './useInternal';\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { Dimensions } from 'react-native';
|
|
3
|
+
|
|
4
|
+
function getWindowOrientation() {
|
|
5
|
+
const {
|
|
6
|
+
width,
|
|
7
|
+
height
|
|
8
|
+
} = Dimensions.get('window');
|
|
9
|
+
return height >= width ? 'portrait' : 'landscape';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function useDeviceOrientation() {
|
|
13
|
+
const [deviceOrientation, setDeviceOrientation] = useState(getWindowOrientation());
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
function updateState() {
|
|
16
|
+
setDeviceOrientation(getWindowOrientation());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const changeEvent = Dimensions.addEventListener('change', updateState); // @ts-ignore
|
|
20
|
+
|
|
21
|
+
return () => changeEvent.remove();
|
|
22
|
+
}, []);
|
|
23
|
+
return deviceOrientation;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default useDeviceOrientation;
|
|
27
|
+
//# sourceMappingURL=useDeviceOrientation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useDeviceOrientation.ts"],"names":["useState","useEffect","Dimensions","getWindowOrientation","width","height","get","useDeviceOrientation","deviceOrientation","setDeviceOrientation","updateState","changeEvent","addEventListener","remove"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;;AAIA,SAASC,oBAAT,GAA6C;AAC3C,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoBH,UAAU,CAACI,GAAX,CAAe,QAAf,CAA1B;AACA,SAAOD,MAAM,IAAID,KAAV,GAAkB,UAAlB,GAA+B,WAAtC;AACD;;AAED,SAASG,oBAAT,GAAgC;AAC9B,QAAM,CAACC,iBAAD,EAAoBC,oBAApB,IAA4CT,QAAQ,CACxDG,oBAAoB,EADoC,CAA1D;AAIAF,EAAAA,SAAS,CAAC,MAAM;AACd,aAASS,WAAT,GAAuB;AACrBD,MAAAA,oBAAoB,CAACN,oBAAoB,EAArB,CAApB;AACD;;AACD,UAAMQ,WAAW,GAAGT,UAAU,CAACU,gBAAX,CAA4B,QAA5B,EAAsCF,WAAtC,CAApB,CAJc,CAKd;;AACA,WAAO,MAAMC,WAAW,CAACE,MAAZ,EAAb;AACD,GAPQ,EAON,EAPM,CAAT;AASA,SAAOL,iBAAP;AACD;;AAED,eAAeD,oBAAf","sourcesContent":["import { useState, useEffect } from 'react';\nimport { Dimensions } from 'react-native';\n\ntype Orientation = 'landscape' | 'portrait';\n\nfunction getWindowOrientation(): Orientation {\n const { width, height } = Dimensions.get('window');\n return height >= width ? 'portrait' : 'landscape';\n}\n\nfunction useDeviceOrientation() {\n const [deviceOrientation, setDeviceOrientation] = useState<Orientation>(\n getWindowOrientation()\n );\n\n useEffect(() => {\n function updateState() {\n setDeviceOrientation(getWindowOrientation());\n }\n const changeEvent = Dimensions.addEventListener('change', updateState);\n // @ts-ignore\n return () => changeEvent.remove();\n }, []);\n\n return deviceOrientation;\n}\n\nexport default useDeviceOrientation;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useInternal.ts"],"names":["useContext","InternalContext","useInternal"],"mappings":"AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,SAASC,eAAT,QAAgC,YAAhC;AAEA,OAAO,MAAMC,WAAW,GAAG,MAAMF,UAAU,CAACC,eAAD,CAApC","sourcesContent":["import { useContext } from 'react';\nimport { InternalContext } from '../context';\n\nexport const useInternal = () => useContext(InternalContext);\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as HoldItem } from './components/holdItem';
|
|
2
|
+
export { default as HoldMenuProvider } from './components/provider';
|
|
3
|
+
export { default as HoldMenuFlatList } from './components/flatList';
|
|
4
|
+
export { default as HoldMenuIcon } from './components/icon';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["default","HoldItem","HoldMenuProvider","HoldMenuFlatList","HoldMenuIcon"],"mappings":"AAAA,SAASA,OAAO,IAAIC,QAApB,QAAoC,uBAApC;AACA,SAASD,OAAO,IAAIE,gBAApB,QAA4C,uBAA5C;AACA,SAASF,OAAO,IAAIG,gBAApB,QAA4C,uBAA5C;AACA,SAASH,OAAO,IAAII,YAApB,QAAwC,mBAAxC","sourcesContent":["export { default as HoldItem } from './components/holdItem';\nexport { default as HoldMenuProvider } from './components/provider';\nexport { default as HoldMenuFlatList } from './components/flatList';\nexport { default as HoldMenuIcon } from './components/icon';\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native';
|
|
2
|
+
const styleGuide = {
|
|
3
|
+
spacing: 8,
|
|
4
|
+
dimensionWidth: Dimensions.get('screen').width,
|
|
5
|
+
dimensionHeight: Dimensions.get('screen').height,
|
|
6
|
+
palette: {
|
|
7
|
+
primary: '#0072ff',
|
|
8
|
+
secondary: '#e2e2e2',
|
|
9
|
+
common: {
|
|
10
|
+
white: '#fff',
|
|
11
|
+
black: '#000'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
typography: {
|
|
15
|
+
body: {
|
|
16
|
+
fontSize: 17,
|
|
17
|
+
lineHeight: 20
|
|
18
|
+
},
|
|
19
|
+
callout: {
|
|
20
|
+
fontSize: 16,
|
|
21
|
+
lineHeight: 20
|
|
22
|
+
},
|
|
23
|
+
callout2: {
|
|
24
|
+
fontSize: 14,
|
|
25
|
+
lineHeight: 18
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export default styleGuide;
|
|
30
|
+
//# sourceMappingURL=styleGuide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["styleGuide.ts"],"names":["Dimensions","styleGuide","spacing","dimensionWidth","get","width","dimensionHeight","height","palette","primary","secondary","common","white","black","typography","body","fontSize","lineHeight","callout","callout2"],"mappings":"AAAA,SAASA,UAAT,QAA2B,cAA3B;AAEA,MAAMC,UAAU,GAAG;AACjBC,EAAAA,OAAO,EAAE,CADQ;AAEjBC,EAAAA,cAAc,EAAEH,UAAU,CAACI,GAAX,CAAe,QAAf,EAAyBC,KAFxB;AAGjBC,EAAAA,eAAe,EAAEN,UAAU,CAACI,GAAX,CAAe,QAAf,EAAyBG,MAHzB;AAIjBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,OAAO,EAAE,SADF;AAEPC,IAAAA,SAAS,EAAE,SAFJ;AAGPC,IAAAA,MAAM,EAAE;AACNC,MAAAA,KAAK,EAAE,MADD;AAENC,MAAAA,KAAK,EAAE;AAFD;AAHD,GAJQ;AAYjBC,EAAAA,UAAU,EAAE;AACVC,IAAAA,IAAI,EAAE;AACJC,MAAAA,QAAQ,EAAE,EADN;AAEJC,MAAAA,UAAU,EAAE;AAFR,KADI;AAKVC,IAAAA,OAAO,EAAE;AACPF,MAAAA,QAAQ,EAAE,EADH;AAEPC,MAAAA,UAAU,EAAE;AAFL,KALC;AASVE,IAAAA,QAAQ,EAAE;AACRH,MAAAA,QAAQ,EAAE,EADF;AAERC,MAAAA,UAAU,EAAE;AAFJ;AATA;AAZK,CAAnB;AA4BA,eAAehB,UAAf","sourcesContent":["import { Dimensions } from 'react-native';\n\nconst styleGuide = {\n spacing: 8,\n dimensionWidth: Dimensions.get('screen').width,\n dimensionHeight: Dimensions.get('screen').height,\n palette: {\n primary: '#0072ff',\n secondary: '#e2e2e2',\n common: {\n white: '#fff',\n black: '#000',\n },\n },\n typography: {\n body: {\n fontSize: 17,\n lineHeight: 20,\n },\n callout: {\n fontSize: 16,\n lineHeight: 20,\n },\n callout2: {\n fontSize: 14,\n lineHeight: 18,\n },\n },\n};\n\nexport default styleGuide;\n"]}
|