From 84616a6143fea58899eafa915a73592eaad25361 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 7 Dec 2020 19:19:50 -0500 Subject: [TMA-409] Delete Moments (#124) * edit profile to use HeaderHeight instead of percentage * delete moment done with TODOs for backend * actually hitting the endpoint * ops * moved isProfileView check to drawer component * misunderstood suggestion, now is better * an extra layer of indirection * fixed some bugs and code improvement --- src/components/common/GenericMoreInfoDrawer.tsx | 93 +++++++++++++++++++++++++ src/components/common/index.ts | 1 + 2 files changed, 94 insertions(+) create mode 100644 src/components/common/GenericMoreInfoDrawer.tsx (limited to 'src/components/common') diff --git a/src/components/common/GenericMoreInfoDrawer.tsx b/src/components/common/GenericMoreInfoDrawer.tsx new file mode 100644 index 00000000..5c58f903 --- /dev/null +++ b/src/components/common/GenericMoreInfoDrawer.tsx @@ -0,0 +1,93 @@ +import React from 'react'; +import { + GestureResponderEvent, + StyleSheet, + Text, + TouchableOpacity, + View, + ViewProps, + ViewStyle, +} from 'react-native'; +import {useSafeAreaInsets} from 'react-native-safe-area-context'; +import {BottomDrawer} from '.'; +import {TAGG_TEXT_LIGHT_BLUE} from '../../constants'; +import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; + +// conforms the JSX onPress attribute type +type OnPressHandler = (event: GestureResponderEvent) => void; + +interface GenericMoreInfoDrawerProps extends ViewProps { + isOpen: boolean; + setIsOpen: (visible: boolean) => void; + showIcons: boolean; + // An array of title, onPressHandler, and icon component + buttons: [string, OnPressHandler, JSX.Element?][]; +} + +const GenericMoreInfoDrawer: React.FC = (props) => { + const {buttons, showIcons} = props; + // each button is 80px high, cancel button is always there + const initialSnapPosition = + (buttons.length + 1) * 80 + useSafeAreaInsets().bottom; + let panelButtonStyle: ViewStyle[] = [ + { + height: 80, + flexDirection: 'row', + alignItems: 'center', + }, + showIcons ? {} : {justifyContent: 'center'}, + ]; + return ( + + + {buttons.map(([title, action, icon], index) => ( + + + {showIcons && {icon}} + {title} + + + + ))} + props.setIsOpen(false)}> + {/* a dummy icon for aligning the cancel button */} + {showIcons && } + Cancel + + + + ); +}; + +const styles = StyleSheet.create({ + panel: { + height: SCREEN_HEIGHT, + backgroundColor: 'white', + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + }, + panelButtonTitle: { + fontSize: 18, + fontWeight: 'bold', + color: 'black', + }, + icon: { + height: 25, + width: 25, + marginLeft: SCREEN_WIDTH * 0.3, + marginRight: 25, + }, + panelButtonTitleCancel: { + fontSize: 18, + fontWeight: 'bold', + color: TAGG_TEXT_LIGHT_BLUE, + }, + divider: {height: 1, borderWidth: 1, borderColor: '#e7e7e7'}, +}); + +export default GenericMoreInfoDrawer; diff --git a/src/components/common/index.ts b/src/components/common/index.ts index f6521497..661d2f52 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -16,3 +16,4 @@ export {default as PostCarousel} from './PostCarousel'; export {default as TaggDatePicker} from './TaggDatePicker'; export {default as BottomDrawer} from './BottomDrawer'; export {default as TaggLoadingTndicator} from './TaggLoadingIndicator'; +export {default as GenericMoreInfoDrawer} from './GenericMoreInfoDrawer'; -- cgit v1.2.3-70-g09d2