Skip to content

Commit

Permalink
Deployment mode (#948)
Browse files Browse the repository at this point in the history
Co-authored-by: MichaelBrew <[email protected]>
Co-authored-by: Michael Brew <[email protected]>
Co-authored-by: Arman Dezfuli-Arjomandi <[email protected]>
  • Loading branch information
4 people authored Sep 20, 2021
1 parent 82c438c commit 243b39d
Show file tree
Hide file tree
Showing 27 changed files with 799 additions and 215 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ SPEC CHECKSUMS:
EXSecureStore: 1b571851e6068b30b8ec097be848a04603c03bae
EXSplashScreen: ab5984afcca91e0af6b3138f01a8c47dc4955c51
FBLazyVector: 49cbe4b43e445b06bf29199b6ad2057649e4c8f5
FBReactNativeSpec: 3560256311b67bbddc2ce503625e9edde9a6ee1d
FBReactNativeSpec: ef7076047ecfe23933320b0fb2b844474516e2e8
glog: 7a8788d88d2a384c05df45e95c5e763e4d81f3ad
lottie-ios: 48fac6be217c76937e36e340e2d09cf7b10b7f5f
lottie-react-native: 4dff8fe8d10ddef9e7880e770080f4a56121397e
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"react-qr-code": "^1.0.3",
"react-redux": "^7.2.2",
"redux-thunk": "^2.3.0",
"rn-swipe-button": "^1.3.6",
"tinycolor2": "^1.4.2",
"use-debounce": "^5.2.0",
"use-state-with-callback": "^2.0.3"
Expand Down
6 changes: 6 additions & 0 deletions src/assets/images/deployModeIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/lockIconRed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions src/components/Bullet.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import React, { ReactNode } from 'react'
import { ViewStyle } from 'react-native'
import Box from './Box'
import Text from './Text'

type Props = { children?: ReactNode; color?: string }
const Bullet = ({ children, color = 'black' }: Props) => (
<Box flexDirection="row" alignItems="flex-start" marginBottom="s">
type Props = {
children?: ReactNode
color?: string
style?: ViewStyle
}
const Bullet = ({ children, color = 'black', style = {} }: Props) => (
<Box
flexDirection="row"
alignItems="flex-start"
marginBottom="s"
style={style}
>
<Text style={{ color }} fontSize={24} lineHeight={22} marginRight="s">
&bull;
</Text>
Expand Down
104 changes: 15 additions & 89 deletions src/components/HeliumActionSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
/* eslint-disable react/jsx-props-no-spreading */
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react'
import { BoxProps } from '@shopify/restyle'
import Close from '@assets/images/close.svg'
import CarotDown from '@assets/images/carot-down.svg'
import Kabob from '@assets/images/kabob.svg'
import { useTranslation } from 'react-i18next'
import { Modal, StyleSheet } from 'react-native'
import { StyleSheet } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import {
useAnimatedStyle,
useSharedValue,
withSpring,
} from 'react-native-reanimated'
import { FlatList } from 'react-native-gesture-handler'
import { Colors, Theme } from '../theme/theme'
import HeliumActionSheetItem, {
Expand All @@ -22,9 +16,7 @@ import { useColors } from '../theme/themeHooks'
import Text, { TextProps } from './Text'
import Box from './Box'
import TouchableOpacityBox from './TouchableOpacityBox'
import BlurBox from './BlurBox'
import { ReAnimatedBox } from './AnimatedBox'
import useVisible from '../utils/useVisible'
import HeliumBottomSheet from './HeliumBottomSheet'

type Props = BoxProps<Theme> & {
data: Array<HeliumActionSheetItemType>
Expand Down Expand Up @@ -66,40 +58,19 @@ const HeliumActionSheet = ({
const [data, setData] = useState<Array<HeliumActionSheetItemType>>([])
const { t } = useTranslation()
const colors = useColors()
const offset = useSharedValue(0)

useEffect(() => {
setData(propsData)
}, [propsData])

const animatedStyles = useAnimatedStyle(() => {
return {
transform: [{ translateY: offset.value + sheetHeight }],
}
})

const animate = useCallback(
(val: number) => {
offset.value = withSpring(val, {
damping: 80,
overshootClamping: true,
restDisplacementThreshold: 0.1,
restSpeedThreshold: 0.1,
stiffness: 500,
})
},
[offset],
)

useEffect(() => {
let nextSheetHeight =
data.length * HeliumActionSheetItemHeight + 156 + (insets?.bottom || 0)
if (maxModalHeight && nextSheetHeight > maxModalHeight) {
nextSheetHeight = maxModalHeight
}
setSheetHeight(nextSheetHeight)
animate(nextSheetHeight)
}, [animate, data.length, insets?.bottom, maxModalHeight])
}, [data.length, insets?.bottom, maxModalHeight])

const handlePresentModalPress = useCallback(async () => {
setModalVisible(true)
Expand All @@ -109,15 +80,6 @@ const HeliumActionSheet = ({
setModalVisible(false)
}, [])

useVisible({ onDisappear: handleClose })

useEffect(() => {
if (modalVisible) {
offset.value = 0
animate(-sheetHeight)
}
}, [animate, modalVisible, offset, sheetHeight])

const keyExtractor = useCallback((item) => item.value, [])

const buttonTitle = useMemo(() => {
Expand Down Expand Up @@ -247,55 +209,19 @@ const HeliumActionSheet = ({
return (
<Box {...boxProps}>
{displayText}

<Modal
transparent
visible={modalVisible}
onRequestClose={handleClose}
animationType="fade"
<HeliumBottomSheet
isVisible={modalVisible}
onClose={handleClose}
sheetHeight={sheetHeight}
title={title}
>
<BlurBox position="absolute" top={0} bottom={0} left={0} right={0} />
<Box flex={1}>
<TouchableOpacityBox flex={1} onPress={handleClose} />
<ReAnimatedBox
style={animatedStyles}
borderTopLeftRadius="l"
borderTopRightRadius="l"
height={sheetHeight}
backgroundColor="white"
paddingHorizontal="lx"
>
<Box
flexDirection="row"
borderBottomWidth={1}
style={styles.divider}
marginTop="s"
marginBottom="m"
justifyContent="space-between"
alignItems="center"
>
<Text color="purpleGray" variant="body2">
{title}
</Text>
<TouchableOpacityBox
onPress={handleClose}
height={50}
justifyContent="center"
paddingHorizontal="m"
marginEnd="n_m"
>
<Close color={colors.purpleGray} height={14} width={14} />
</TouchableOpacityBox>
</Box>
<FlatList
data={data}
keyExtractor={keyExtractor}
renderItem={renderItem}
/>
{footer}
</ReAnimatedBox>
</Box>
</Modal>
<FlatList
data={data}
keyExtractor={keyExtractor}
renderItem={renderItem}
/>
{footer}
</HeliumBottomSheet>
</Box>
)
}
Expand Down
122 changes: 122 additions & 0 deletions src/components/HeliumBottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import React, { memo, useCallback, useEffect } from 'react'
import { BoxProps } from '@shopify/restyle'
import Close from '@assets/images/close.svg'
import { Modal, StyleSheet } from 'react-native'
import {
useAnimatedStyle,
useSharedValue,
withSpring,
} from 'react-native-reanimated'
import { Theme } from '../theme/theme'
import { useColors } from '../theme/themeHooks'
import Text from './Text'
import Box from './Box'
import TouchableOpacityBox from './TouchableOpacityBox'
import BlurBox from './BlurBox'
import { ReAnimatedBox } from './AnimatedBox'
import useVisible from '../utils/useVisible'

type Props = BoxProps<Theme> & {
children?: React.ReactNode
hideHeaderBorder?: boolean
isVisible: boolean
onClose: () => void
sheetHeight?: number
title?: string
}

const HeliumBottomSheet = ({
children,
hideHeaderBorder = false,
isVisible,
onClose,
sheetHeight = 260,
title,
}: Props) => {
const colors = useColors()
const offset = useSharedValue(0)

const animatedStyles = useAnimatedStyle(() => {
return {
transform: [{ translateY: offset.value + sheetHeight }],
}
})

const animate = useCallback(
(val: number) => {
offset.value = withSpring(val, {
damping: 80,
overshootClamping: true,
restDisplacementThreshold: 0.1,
restSpeedThreshold: 0.1,
stiffness: 500,
})
},
[offset],
)

const handleClose = useCallback(async () => {
onClose()
}, [onClose])

useVisible({ onDisappear: handleClose })

useEffect(() => {
if (isVisible) {
offset.value = 0
animate(-sheetHeight)
}
}, [animate, isVisible, offset, sheetHeight])

return (
<Modal
transparent
visible={isVisible}
onRequestClose={handleClose}
animationType="fade"
>
<BlurBox position="absolute" top={0} bottom={0} left={0} right={0} />
<Box flex={1}>
<TouchableOpacityBox flex={1} onPress={handleClose} />
<ReAnimatedBox
style={animatedStyles}
borderTopLeftRadius="l"
borderTopRightRadius="l"
height={sheetHeight}
backgroundColor="white"
paddingHorizontal="lx"
>
<Box
flexDirection="row"
borderBottomWidth={hideHeaderBorder ? 0 : 1}
style={styles.divider}
marginTop="s"
marginBottom="m"
justifyContent="space-between"
alignItems="center"
>
<Text color="purpleGray" variant="body2">
{title}
</Text>
<TouchableOpacityBox
onPress={handleClose}
height={50}
justifyContent="center"
paddingHorizontal="m"
marginEnd="n_m"
>
<Close color={colors.purpleLightText} height={14} width={14} />
</TouchableOpacityBox>
</Box>
{children}
</ReAnimatedBox>
</Box>
</Modal>
)
}

const styles = StyleSheet.create({
divider: { borderBottomColor: '#F0F0F5' },
})

export default memo(HeliumBottomSheet)
Loading

0 comments on commit 243b39d

Please sign in to comment.