From e21a5c1b80be703ed90bfefab01af65b7415d250 Mon Sep 17 00:00:00 2001 From: Letty Date: Thu, 6 Jul 2023 20:03:57 +0200 Subject: [PATCH] Mobile: Fixes #8027: Fixed link modal position on devices with notch (#8029) --- .gitignore | 1 + packages/app-mobile/components/Modal.tsx | 32 +++++++++++++++++++ packages/app-mobile/components/ModalDialog.js | 25 ++++++++------- .../components/NoteEditor/EditLinkDialog.tsx | 25 +++++++-------- packages/app-mobile/ios/Podfile.lock | 8 ++++- packages/app-mobile/package.json | 1 + yarn.lock | 10 ++++++ 7 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 packages/app-mobile/components/Modal.tsx diff --git a/.gitignore b/.gitignore index 2f04098ad1..e99f6bb549 100644 --- a/.gitignore +++ b/.gitignore @@ -352,6 +352,7 @@ packages/app-mobile/components/CustomButton.js packages/app-mobile/components/Dropdown.js packages/app-mobile/components/ExtendedWebView.js packages/app-mobile/components/FolderPicker.js +packages/app-mobile/components/Modal.js packages/app-mobile/components/NoteBodyViewer/NoteBodyViewer.js packages/app-mobile/components/NoteBodyViewer/hooks/useOnMessage.js packages/app-mobile/components/NoteBodyViewer/hooks/useOnResourceLongPress.js diff --git a/packages/app-mobile/components/Modal.tsx b/packages/app-mobile/components/Modal.tsx new file mode 100644 index 0000000000..080bc0f477 --- /dev/null +++ b/packages/app-mobile/components/Modal.tsx @@ -0,0 +1,32 @@ +import * as React from 'react'; +import { Modal, ModalProps, StyleSheet, View, ViewStyle } from 'react-native'; +import { hasNotch } from 'react-native-device-info'; + +interface ModalElementProps extends ModalProps { + children: React.ReactNode; + containerStyle?: ViewStyle; + elevation?: Number; +} + +const ModalElement: React.FC = ({ + children, + containerStyle, + ...modalProps +}) => { + return ( + + + {children} + + + ); +}; + +const styleSheet = StyleSheet.create({ + modalContainer: { + marginTop: hasNotch() ? 65 : 15, + marginBottom: hasNotch() ? 35 : 15, + }, +}); + +export default ModalElement; diff --git a/packages/app-mobile/components/ModalDialog.js b/packages/app-mobile/components/ModalDialog.js index 6a716545d3..65495d30a1 100644 --- a/packages/app-mobile/components/ModalDialog.js +++ b/packages/app-mobile/components/ModalDialog.js @@ -1,8 +1,10 @@ const React = require('react'); -const { Text, Modal, View, StyleSheet, Button } = require('react-native'); +const { Text, View, StyleSheet, Button } = require('react-native'); const { themeStyle } = require('./global-style.js'); const { _ } = require('@joplin/lib/locale'); +import Modal from './Modal'; + class ModalDialog extends React.Component { constructor() { super(); @@ -30,6 +32,7 @@ class ModalDialog extends React.Component { margin: 20, padding: 10, borderRadius: 5, + elevation: 10, }, modalContentWrapper2: { flex: 1, @@ -56,17 +59,15 @@ class ModalDialog extends React.Component { return ( - {}}> - - {this.props.title} - {ContentComponent} - - - - - - - + {}} containerStyle={this.styles().modalContentWrapper}> + {this.props.title} + {ContentComponent} + + + + + + diff --git a/packages/app-mobile/components/NoteEditor/EditLinkDialog.tsx b/packages/app-mobile/components/NoteEditor/EditLinkDialog.tsx index e471ed0e6d..36a4d29f48 100644 --- a/packages/app-mobile/components/NoteEditor/EditLinkDialog.tsx +++ b/packages/app-mobile/components/NoteEditor/EditLinkDialog.tsx @@ -3,8 +3,9 @@ const React = require('react'); const { useState, useEffect, useMemo, useRef } = require('react'); const { StyleSheet } = require('react-native'); -const { View, Modal, Text, TextInput, Button } = require('react-native'); +const { View, Text, TextInput, Button } = require('react-native'); +import Modal from '../Modal'; import { themeStyle } from '@joplin/lib/theme'; import { _ } from '@joplin/lib/locale'; import { EditorControl } from './types'; @@ -43,7 +44,6 @@ const EditLinkDialog = (props: LinkDialogProps) => { margin: 15, padding: 30, backgroundColor: theme.backgroundColor, - elevation: 5, shadowOffset: { width: 1, @@ -132,23 +132,22 @@ const EditLinkDialog = (props: LinkDialogProps) => { return ( { props.editorControl.hideLinkDialog(); }}> - - {_('Edit link')} - - {linkTextInput} - {linkURLInput} - -