mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at verify-intent 154 lines 5.9 kB view raw
1import React, {Fragment, useEffect, useRef} from 'react' 2import {StyleSheet} from 'react-native' 3import {SafeAreaView} from 'react-native-safe-area-context' 4import BottomSheet from '@discord/bottom-sheet/src' 5 6import {usePalette} from '#/lib/hooks/usePalette' 7import {useModalControls, useModals} from '#/state/modals' 8import {FullWindowOverlay} from '#/components/FullWindowOverlay' 9import {createCustomBackdrop} from '../util/BottomSheetCustomBackdrop' 10import * as AddAppPassword from './AddAppPasswords' 11import * as ChangeEmailModal from './ChangeEmail' 12import * as ChangeHandleModal from './ChangeHandle' 13import * as ChangePasswordModal from './ChangePassword' 14import * as CreateOrEditListModal from './CreateOrEditList' 15import * as DeleteAccountModal from './DeleteAccount' 16import * as EditProfileModal from './EditProfile' 17import * as InAppBrowserConsentModal from './InAppBrowserConsent' 18import * as InviteCodesModal from './InviteCodes' 19import * as ContentLanguagesSettingsModal from './lang-settings/ContentLanguagesSettings' 20import * as PostLanguagesSettingsModal from './lang-settings/PostLanguagesSettings' 21import * as LinkWarningModal from './LinkWarning' 22import * as ListAddUserModal from './ListAddRemoveUsers' 23import * as SelfLabelModal from './SelfLabel' 24import * as UserAddRemoveListsModal from './UserAddRemoveLists' 25import * as VerifyEmailModal from './VerifyEmail' 26 27const DEFAULT_SNAPPOINTS = ['90%'] 28const HANDLE_HEIGHT = 24 29 30export function ModalsContainer() { 31 const {isModalActive, activeModals} = useModals() 32 const {closeModal} = useModalControls() 33 const bottomSheetRef = useRef<BottomSheet>(null) 34 const pal = usePalette('default') 35 const activeModal = activeModals[activeModals.length - 1] 36 37 const onBottomSheetChange = async (snapPoint: number) => { 38 if (snapPoint === -1) { 39 closeModal() 40 } 41 } 42 43 const onClose = () => { 44 bottomSheetRef.current?.close() 45 closeModal() 46 } 47 48 useEffect(() => { 49 if (isModalActive) { 50 bottomSheetRef.current?.snapToIndex(0) 51 } else { 52 bottomSheetRef.current?.close() 53 } 54 }, [isModalActive, bottomSheetRef, activeModal?.name]) 55 56 let snapPoints: (string | number)[] = DEFAULT_SNAPPOINTS 57 let element 58 if (activeModal?.name === 'edit-profile') { 59 snapPoints = EditProfileModal.snapPoints 60 element = <EditProfileModal.Component {...activeModal} /> 61 } else if (activeModal?.name === 'create-or-edit-list') { 62 snapPoints = CreateOrEditListModal.snapPoints 63 element = <CreateOrEditListModal.Component {...activeModal} /> 64 } else if (activeModal?.name === 'user-add-remove-lists') { 65 snapPoints = UserAddRemoveListsModal.snapPoints 66 element = <UserAddRemoveListsModal.Component {...activeModal} /> 67 } else if (activeModal?.name === 'list-add-remove-users') { 68 snapPoints = ListAddUserModal.snapPoints 69 element = <ListAddUserModal.Component {...activeModal} /> 70 } else if (activeModal?.name === 'delete-account') { 71 snapPoints = DeleteAccountModal.snapPoints 72 element = <DeleteAccountModal.Component /> 73 } else if (activeModal?.name === 'self-label') { 74 snapPoints = SelfLabelModal.snapPoints 75 element = <SelfLabelModal.Component {...activeModal} /> 76 } else if (activeModal?.name === 'change-handle') { 77 snapPoints = ChangeHandleModal.snapPoints 78 element = <ChangeHandleModal.Component {...activeModal} /> 79 } else if (activeModal?.name === 'invite-codes') { 80 snapPoints = InviteCodesModal.snapPoints 81 element = <InviteCodesModal.Component /> 82 } else if (activeModal?.name === 'add-app-password') { 83 snapPoints = AddAppPassword.snapPoints 84 element = <AddAppPassword.Component /> 85 } else if (activeModal?.name === 'content-languages-settings') { 86 snapPoints = ContentLanguagesSettingsModal.snapPoints 87 element = <ContentLanguagesSettingsModal.Component /> 88 } else if (activeModal?.name === 'post-languages-settings') { 89 snapPoints = PostLanguagesSettingsModal.snapPoints 90 element = <PostLanguagesSettingsModal.Component /> 91 } else if (activeModal?.name === 'verify-email') { 92 snapPoints = VerifyEmailModal.snapPoints 93 element = <VerifyEmailModal.Component {...activeModal} /> 94 } else if (activeModal?.name === 'change-email') { 95 snapPoints = ChangeEmailModal.snapPoints 96 element = <ChangeEmailModal.Component /> 97 } else if (activeModal?.name === 'change-password') { 98 snapPoints = ChangePasswordModal.snapPoints 99 element = <ChangePasswordModal.Component /> 100 } else if (activeModal?.name === 'link-warning') { 101 snapPoints = LinkWarningModal.snapPoints 102 element = <LinkWarningModal.Component {...activeModal} /> 103 } else if (activeModal?.name === 'in-app-browser-consent') { 104 snapPoints = InAppBrowserConsentModal.snapPoints 105 element = <InAppBrowserConsentModal.Component {...activeModal} /> 106 } else { 107 return null 108 } 109 110 if (snapPoints[0] === 'fullscreen') { 111 return ( 112 <SafeAreaView style={[styles.fullscreenContainer, pal.view]}> 113 {element} 114 </SafeAreaView> 115 ) 116 } 117 118 const Container = activeModal ? FullWindowOverlay : Fragment 119 120 return ( 121 <Container> 122 <BottomSheet 123 ref={bottomSheetRef} 124 snapPoints={snapPoints} 125 handleHeight={HANDLE_HEIGHT} 126 index={isModalActive ? 0 : -1} 127 enablePanDownToClose 128 android_keyboardInputMode="adjustResize" 129 keyboardBlurBehavior="restore" 130 backdropComponent={ 131 isModalActive ? createCustomBackdrop(onClose) : undefined 132 } 133 handleIndicatorStyle={{backgroundColor: pal.text.color}} 134 handleStyle={[styles.handle, pal.view]} 135 onChange={onBottomSheetChange}> 136 {element} 137 </BottomSheet> 138 </Container> 139 ) 140} 141 142const styles = StyleSheet.create({ 143 handle: { 144 borderTopLeftRadius: 10, 145 borderTopRightRadius: 10, 146 }, 147 fullscreenContainer: { 148 position: 'absolute', 149 top: 0, 150 left: 0, 151 bottom: 0, 152 right: 0, 153 }, 154})