You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
11 KiB

{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport { EventEmitter } from 'expo-modules-core';\nimport React, { useEffect, useState, useRef, useMemo } from 'react';\nimport Animated from \"react-native-web/dist/exports/Animated\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport Text from \"react-native-web/dist/exports/Text\";\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport View from \"react-native-web/dist/exports/View\";\nimport DevLoadingViewNativeModule from \"./DevLoadingViewNativeModule\";\nimport { getInitialSafeArea } from \"./getInitialSafeArea\";\nexport default function DevLoadingView() {\n var _useState = useState('Refreshing...'),\n _useState2 = _slicedToArray(_useState, 2),\n message = _useState2[0],\n setMessage = _useState2[1];\n var _useState3 = useState(false),\n _useState4 = _slicedToArray(_useState3, 2),\n isDevLoading = _useState4[0],\n setIsDevLoading = _useState4[1];\n var _useState5 = useState(false),\n _useState6 = _slicedToArray(_useState5, 2),\n isAnimating = _useState6[0],\n setIsAnimating = _useState6[1];\n var translateY = useRef(new Animated.Value(0)).current;\n var emitter = useMemo(function () {\n try {\n return new EventEmitter(DevLoadingViewNativeModule);\n } catch (error) {\n throw new Error('Failed to instantiate native emitter in `DevLoadingView` because the native module `DevLoadingView` is undefined: ' + error.message);\n }\n }, []);\n useEffect(function () {\n if (!emitter) return;\n function handleShowMessage(event) {\n setMessage(event.message);\n translateY.setValue(0);\n setIsDevLoading(true);\n }\n function handleHide() {\n setIsAnimating(true);\n setIsDevLoading(false);\n Animated.timing(translateY, {\n toValue: 150,\n delay: 1000,\n duration: 350,\n useNativeDriver: Platform.OS !== 'web'\n }).start(function (_ref) {\n var finished = _ref.finished;\n if (finished) {\n setIsAnimating(false);\n translateY.setValue(0);\n }\n });\n }\n var showMessageSubscription = emitter.addListener('devLoadingView:showMessage', handleShowMessage);\n var hideSubscription = emitter.addListener('devLoadingView:hide', handleHide);\n return function cleanup() {\n showMessageSubscription.remove();\n hideSubscription.remove();\n };\n }, [translateY, emitter]);\n if (!isDevLoading && !isAnimating) {\n return null;\n }\n return React.createElement(Animated.View, {\n style: [styles.animatedContainer, {\n transform: [{\n translateY: translateY\n }]\n }],\n pointerEvents: \"none\"\n }, React.createElement(View, {\n style: styles.banner\n }, React.createElement(View, {\n style: styles.contentContainer\n }, React.createElement(View, {\n style: {\n flexDirection: 'row'\n }\n }, React.createElement(Text, {\n style: styles.text\n }, message)), React.createElement(View, {\n style: {\n flex: 1\n }\n }, React.createElement(Text, {\n style: styles.subtitle\n }, isDevLoading ? 'Using Fast Refresh' : \"Don't see your changes? Reload the app\")))));\n}\nvar styles = StyleSheet.create({\n animatedContainer: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 42\n },\n banner: {\n flex: 1,\n overflow: 'visible',\n backgroundColor: 'rgba(0,0,0,0.75)',\n paddingBottom: getInitialSafeArea().bottom\n },\n contentContainer: {\n flex: 1,\n paddingTop: 10,\n paddingBottom: 5,\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center'\n },\n text: {\n color: '#fff',\n fontSize: 15\n },\n subtitle: {\n color: 'rgba(255,255,255,0.8)'\n }\n});","map":{"version":3,"mappings":";AAAA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,OAAOC,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAAC;AAAA;AAAA;AAAA;AAAA;AAGpE,OAAOC,0BAA0B;AACjC,SAASC,kBAAkB;AAE3B,eAAc,SAAUC,cAAc;EACpC,gBAA8BL,QAAQ,CAAC,eAAe,CAAC;IAAA;IAAhDM,OAAO;IAAEC,UAAU;EAC1B,iBAAwCP,QAAQ,CAAC,KAAK,CAAC;IAAA;IAAhDQ,YAAY;IAAEC,eAAe;EACpC,iBAAsCT,QAAQ,CAAC,KAAK,CAAC;IAAA;IAA9CU,WAAW;IAAEC,cA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AAE,CAAC;IACPY,UAAU,EAAE,EAAE;IACdD,aAAa,EAAE,CAAC;IAChBE,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,SAAS,EAAE;GACZ;EACDhB,IAAI,EAAE;IACJiB,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE;GACX;EACDhB,QAAQ,EAAE;IACRe,KAAK,EAAE;;CAEV,CAAC","names":["EventEmitter","React","useEffect","useState","useRef","useMemo","DevLoadingViewNativeModule","getInitialSafeArea","DevLoadingView","message","setMessage","isDevLoading","setIsDevLoading","isAnimating","setIsAnimating","translateY","Animated","Value","current","emitter","error","Error","handleShowMessage","event","setValue","handleHide","timing","toValue","delay","duration","useNativeDriver","Platform","OS","start","finished","showMessageSubscription","addListener","hideSubscription","cleanup","remove","View","style","styles","animatedContainer","transform","pointerEvents","banner","contentContainer","flexDirection","Text","text","flex","subtitle","StyleSheet","create","position","bottom","left","right","zIndex","overflow","backgroundColor","paddingBottom","paddingTop","alignItems","justifyContent","textAlign","color","fontSize"],"sources":["/Users/mathildejean/Documents/BUT/LaSuperMeteo/LaSuperMeteo/iut-expo-starter/node_modules/expo/src/environment/DevLoadingView.tsx"],"sourcesContent":["import { EventEmitter } from 'expo-modules-core';\nimport React, { useEffect, useState, useRef, useMemo } from 'react';\nimport { Animated, StyleSheet, Text, Platform, View } from 'react-native';\n\nimport DevLoadingViewNativeModule from './DevLoadingViewNativeModule';\nimport { getInitialSafeArea } from './getInitialSafeArea';\n\nexport default function DevLoadingView() {\n const [message, setMessage] = useState('Refreshing...');\n const [isDevLoading, setIsDevLoading] = useState(false);\n const [isAnimating, setIsAnimating] = useState(false);\n const translateY = useRef(new Animated.Value(0)).current;\n const emitter = useMemo<EventEmitter>(() => {\n try {\n return new EventEmitter(DevLoadingViewNativeModule);\n } catch (error) {\n throw new Error(\n 'Failed to instantiate native emitter in `DevLoadingView` because the native module `DevLoadingView` is undefined: ' +\n error.message\n );\n }\n }, []);\n\n useEffect(() => {\n if (!emitter) return;\n\n function handleShowMessage(event: { message: string }) {\n setMessage(event.message);\n // TODO: if we show the refreshing banner and don't get a hide message\n // for 3 seconds, warn the user that it's taking a while and suggest\n // they reload\n\n translateY.setValue(0);\n setIsDevLoading(true);\n }\n\n function handleHide() {\n // TODO: if we showed the 'refreshing' banner less than 250ms ago, delay\n // switching to the 'finished' banner\n\n setIsAnimating(true);\n setIsDevLoading(false);\n Animated.timing(translateY, {\n toValue: 150,\n delay: 1000,\n duration: 350,\n useNativeDriver: Platform.OS !== 'web',\n }).start(({ finished }) => {\n if (finished) {\n setIsAnimating(false);\n translateY.setValue(0);\n }\n });\n }\n\n const showMessageSubscription = emitter.addListener(\n 'devLoadingView:showMessage',\n handleShowMessage\n );\n const hideSubscription = emitter.addListener('devLoadingView:hide', handleHide);\n\n return function cleanup() {\n showMessageSubscription.remove();\n hideSubscription.remove();\n };\n }, [translateY, emitter]);\n\n if (!isDevLoading && !isAnimating) {\n return null;\n }\n\n return (\n <Animated.View\n style={[styles.animatedContainer, { transform: [{ translateY }] }]}\n pointerEvents=\"none\">\n <View style={styles.banner}>\n <View style={styles.contentContainer}>\n <View style={{ flexDirection: 'row' }}>\n <Text style={styles.text}>{message}</Text>\n </View>\n\n <View style={{ flex: 1 }}>\n <Text style={styles.subtitle}>\n {isDevLoading ? 'Using Fast Refresh' : \"Don't see your changes? Reload the app\"}\n </Text>\n </View>\n </View>\n </View>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n animatedContainer: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 42, // arbitrary\n },\n\n banner: {\n flex: 1,\n overflow: 'visible',\n backgroundColor: 'rgba(0,0,0,0.75)',\n paddingBottom: getInitialSafeArea().bottom,\n },\n contentContainer: {\n flex: 1,\n paddingTop: 10,\n paddingBottom: 5,\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n },\n text: {\n color: '#fff',\n fontSize: 15,\n },\n subtitle: {\n color: 'rgba(255,255,255,0.8)',\n },\n});\n"]},"metadata":{},"sourceType":"module","externalDependencies":[]}