From 4b33cdb7ec20ba449941083f29726bea28f0f25b Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 26 Jan 2023 22:25:38 -0600 Subject: Implement modals for web --- src/view/com/modals/EditProfile.tsx | 10 ++--- src/view/com/modals/Modal.web.tsx | 85 +++++++++++++++++++++++++++++++++++++ src/view/com/modals/ServerInput.tsx | 8 ++-- src/view/com/modals/util.tsx | 4 ++ src/view/com/modals/util.web.tsx | 1 + src/view/shell/web/index.tsx | 3 ++ 6 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 src/view/com/modals/Modal.web.tsx create mode 100644 src/view/com/modals/util.tsx create mode 100644 src/view/com/modals/util.web.tsx (limited to 'src') diff --git a/src/view/com/modals/EditProfile.tsx b/src/view/com/modals/EditProfile.tsx index 380e76e79..1c139e9bd 100644 --- a/src/view/com/modals/EditProfile.tsx +++ b/src/view/com/modals/EditProfile.tsx @@ -7,7 +7,7 @@ import { View, } from 'react-native' import LinearGradient from 'react-native-linear-gradient' -import {BottomSheetScrollView, BottomSheetTextInput} from '@gorhom/bottom-sheet' +import {ScrollView, TextInput} from './util' import {Image as PickedImage} from '../util/images/ImageCropPicker' import {Text} from '../util/text/Text' import {ErrorMessage} from '../util/error/ErrorMessage' @@ -102,7 +102,7 @@ export function Component({ return ( - + Edit my profile Display Name - Description - Cancel - + ) } diff --git a/src/view/com/modals/Modal.web.tsx b/src/view/com/modals/Modal.web.tsx new file mode 100644 index 000000000..25493312d --- /dev/null +++ b/src/view/com/modals/Modal.web.tsx @@ -0,0 +1,85 @@ +import React from 'react' +import {TouchableWithoutFeedback, StyleSheet, View} from 'react-native' +import {observer} from 'mobx-react-lite' +import {useStores} from '../../../state' +import {usePalette} from '../../lib/hooks/usePalette' + +import * as models from '../../../state/models/shell-ui' + +import * as ConfirmModal from './Confirm' +import * as EditProfileModal from './EditProfile' +import * as ServerInputModal from './ServerInput' +import * as ReportPostModal from './ReportPost' +import * as ReportAccountModal from './ReportAccount' + +export const Modal = observer(function Modal() { + const store = useStores() + const pal = usePalette('default') + + if (!store.shell.isModalActive) { + return null + } + + const onClose = () => { + store.shell.closeModal() + } + const onInnerPress = () => { + // do nothing, we just want to stop it from bubbling + } + + let element + if (store.shell.activeModal?.name === 'confirm') { + element = ( + + ) + } else if (store.shell.activeModal?.name === 'edit-profile') { + element = ( + + ) + } else if (store.shell.activeModal?.name === 'server-input') { + element = ( + + ) + } else if (store.shell.activeModal?.name === 'report-post') { + element = + } else if (store.shell.activeModal?.name === 'report-account') { + element = + } else { + return null + } + + return ( + + + + {element} + + + + ) +}) + +const styles = StyleSheet.create({ + mask: { + position: 'absolute', + top: 0, + left: 0, + width: '100%', + height: '100%', + backgroundColor: '#000c', + alignItems: 'center', + justifyContent: 'center', + }, + container: { + width: 500, + paddingVertical: 20, + paddingHorizontal: 24, + borderRadius: 8, + }, +}) diff --git a/src/view/com/modals/ServerInput.tsx b/src/view/com/modals/ServerInput.tsx index 85c0d70b7..dde836719 100644 --- a/src/view/com/modals/ServerInput.tsx +++ b/src/view/com/modals/ServerInput.tsx @@ -4,7 +4,7 @@ import { FontAwesomeIcon, FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' -import {BottomSheetScrollView, BottomSheetTextInput} from '@gorhom/bottom-sheet' +import {ScrollView, TextInput} from './util' import {Text} from '../util/text/Text' import {useStores} from '../../../state' import {s, colors} from '../../lib/styles' @@ -32,7 +32,7 @@ export function Component({onSelect}: {onSelect: (url: string) => void}) { return ( Choose Service - + {LOGIN_INCLUDE_DEV_SERVERS ? ( <> @@ -69,7 +69,7 @@ export function Component({onSelect}: {onSelect: (url: string) => void}) { Other service - void}) { - + ) } diff --git a/src/view/com/modals/util.tsx b/src/view/com/modals/util.tsx new file mode 100644 index 000000000..06f394ec4 --- /dev/null +++ b/src/view/com/modals/util.tsx @@ -0,0 +1,4 @@ +export { + BottomSheetScrollView as ScrollView, + BottomSheetTextInput as TextInput, +} from '@gorhom/bottom-sheet' diff --git a/src/view/com/modals/util.web.tsx b/src/view/com/modals/util.web.tsx new file mode 100644 index 000000000..acd10c2a6 --- /dev/null +++ b/src/view/com/modals/util.web.tsx @@ -0,0 +1 @@ +export {ScrollView, TextInput} from 'react-native' diff --git a/src/view/shell/web/index.tsx b/src/view/shell/web/index.tsx index 44a4dd8e5..a4232eab2 100644 --- a/src/view/shell/web/index.tsx +++ b/src/view/shell/web/index.tsx @@ -9,6 +9,7 @@ import {Onboard} from '../../screens/Onboard' import {Login} from '../../screens/Login' import {ErrorBoundary} from '../../com/util/ErrorBoundary' import {Lightbox} from '../../com/lightbox/Lightbox' +import {Modal} from '../../com/modals/Modal' import {usePalette} from '../../lib/hooks/usePalette' import {s} from '../../lib/styles' @@ -21,6 +22,7 @@ export const WebShell: React.FC = observer(() => { return ( + ) } @@ -47,6 +49,7 @@ export const WebShell: React.FC = observer(() => { ))} + ) -- cgit 1.4.1