diff --git a/packages/block-editor/src/components/block-settings/container.native.js b/packages/block-editor/src/components/block-settings/container.native.js index a316b2c86cf5f3..a91fc582d589de 100644 --- a/packages/block-editor/src/components/block-settings/container.native.js +++ b/packages/block-editor/src/components/block-settings/container.native.js @@ -27,6 +27,7 @@ function BottomSheetSettings( { onClose={ closeGeneralSidebar } hideHeader contentStyle={ styles.content } + withNavigation { ...props } > diff --git a/packages/block-editor/src/components/inserter/menu.native.js b/packages/block-editor/src/components/inserter/menu.native.js index c05ae07048b676..5a430617a4e911 100644 --- a/packages/block-editor/src/components/inserter/menu.native.js +++ b/packages/block-editor/src/components/inserter/menu.native.js @@ -133,11 +133,11 @@ export class InserterMenu extends Component { isVisible={ true } onClose={ this.onClose } hideHeader - isChildrenScrollable + withNavigation > - { ( { listProps } ) => ( + { ( { listProps, safeAreaBottomInset } ) => ( item.name } renderItem={ this.renderItem } { ...listProps } + contentContainerStyle={ [ + ...listProps.contentContainerStyle, + { + paddingBottom: + safeAreaBottomInset || + styles.list.paddingBottom, + }, + ] } /> ) } diff --git a/packages/block-editor/src/components/inserter/style.native.scss b/packages/block-editor/src/components/inserter/style.native.scss index 19db583d514864..77456c9587d1dd 100644 --- a/packages/block-editor/src/components/inserter/style.native.scss +++ b/packages/block-editor/src/components/inserter/style.native.scss @@ -15,3 +15,7 @@ .columnPadding { padding: $grid-unit-20; } + +.list { + padding-bottom: 20; +} diff --git a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/README.md b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/README.md index 4ad61cc91f66d8..1922d4f5f8637f 100644 --- a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/README.md +++ b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/README.md @@ -85,4 +85,18 @@ This prop is used as a Screen name. The component that should be rendered as content. - Type: React Element -- Required: Yes \ No newline at end of file +- Required: Yes + +### isScrollable + +This prop determines whether the screen should be wrapped into the ScrollView - this is needed if the screen contains FlatList or any other list inside. Thanks to that we do not nest List into the ScrollView with the same orientation. + +- Type: `Boolean` +- Required: No + +### fullScreen + +This prop determines if the screen should have full height of device. + +- Type: `Boolean` +- Required: No \ No newline at end of file diff --git a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js index 26c66a2d89e010..afa238b144d0c9 100644 --- a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +++ b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js @@ -15,6 +15,7 @@ import { useCallback, Children, useRef, + cloneElement, } from '@wordpress/element'; import { usePreferredColorSchemeStyle } from '@wordpress/compose'; @@ -108,12 +109,19 @@ function BottomSheetNavigationContainer( { children, animate, main, theme } ) { const screens = useMemo( () => { return Children.map( children, ( child ) => { + let screen = child; const { name, ...otherProps } = child.props; + if ( ! main ) { + screen = cloneElement( child, { + ...child.props, + isNested: true, + } ); + } return ( child } + children={ () => screen } /> ); } ); diff --git a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js index b29f18ee86f512..10f594b964f1b2 100644 --- a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +++ b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js @@ -6,7 +6,7 @@ import { useNavigation, useFocusEffect, } from '@react-navigation/native'; -import { View } from 'react-native'; +import { View, ScrollView, TouchableHighlight } from 'react-native'; import { debounce } from 'lodash'; /** @@ -20,8 +20,14 @@ import { useRef, useCallback, useContext, useMemo } from '@wordpress/element'; * Internal dependencies */ import { BottomSheetNavigationContext } from './bottom-sheet-navigation-context'; +import styles from './styles.scss'; -const BottomSheetNavigationScreen = ( { children, fullScreen } ) => { +const BottomSheetNavigationScreen = ( { + children, + fullScreen, + isScrollable, + isNested, +} ) => { const navigation = useNavigation(); const heightRef = useRef( { maxHeight: 0 } ); const isFocused = useIsFocused(); @@ -29,6 +35,8 @@ const BottomSheetNavigationScreen = ( { children, fullScreen } ) => { onHandleHardwareButtonPress, shouldEnableBottomSheetMaxHeight, setIsFullScreen, + listProps, + safeAreaBottomInset, } = useContext( BottomSheetContext ); const { setHeight } = useContext( BottomSheetNavigationContext ); @@ -69,10 +77,28 @@ const BottomSheetNavigationScreen = ( { children, fullScreen } ) => { setHeightDebounce( height ); } }; - return useMemo( () => { - return { children }; - }, [ children, isFocused ] ); + return isScrollable || isNested ? ( + { children } + ) : ( + + + + { children } + { ! isNested && ( + + ) } + + + + ); + }, [ children, isFocused, safeAreaBottomInset, listProps ] ); }; export default BottomSheetNavigationScreen; diff --git a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/styles.native.scss b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/styles.native.scss index d783d85ffd6714..ec15871537452a 100644 --- a/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/styles.native.scss +++ b/packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/styles.native.scss @@ -5,3 +5,7 @@ .backgroundDark { background-color: $modal-background-dark; } + +.scrollableContent { + padding-bottom: $grid-unit-20; +} diff --git a/packages/components/src/mobile/bottom-sheet/index.native.js b/packages/components/src/mobile/bottom-sheet/index.native.js index 0bdc06bbc1e800..5dd86326f6f5a0 100644 --- a/packages/components/src/mobile/bottom-sheet/index.native.js +++ b/packages/components/src/mobile/bottom-sheet/index.native.js @@ -7,9 +7,9 @@ import { Platform, PanResponder, Dimensions, - ScrollView, Keyboard, StatusBar, + ScrollView, TouchableHighlight, } from 'react-native'; import Modal from 'react-native-modal'; @@ -284,9 +284,9 @@ class BottomSheet extends Component { contentStyle = {}, getStylesFromColorScheme, onDismiss, - isChildrenScrollable, children, withHeaderSeparator = false, + withNavigation, ...rest } = this.props; const { @@ -343,8 +343,6 @@ class BottomSheet extends Component { styles.content, hideHeader && styles.emptyHeader, contentStyle, - isChildrenScrollable && this.getContentStyle(), - contentStyle, isFullScreen && { flexGrow: 1 }, ], style: listStyle, @@ -353,7 +351,7 @@ class BottomSheet extends Component { automaticallyAdjustContentInsets: false, }; - const WrapperView = isChildrenScrollable ? View : ScrollView; + const WrapperView = withNavigation ? View : ScrollView; const getHeader = () => ( <> @@ -370,7 +368,6 @@ class BottomSheet extends Component { { withHeaderSeparator && } ); - return ( @@ -438,14 +435,25 @@ class BottomSheet extends Component { .onHandleHardwareButtonPress, listProps, setIsFullScreen: this.setIsFullScreen, + safeAreaBottomInset, } } > - + { withNavigation ? ( <>{ children } - + ) : ( + + <>{ children } + + ) } - { ! isChildrenScrollable && ( - + { ! withNavigation && ( + ) } diff --git a/packages/components/src/mobile/bottom-sheet/range-cell.native.scss b/packages/components/src/mobile/bottom-sheet/range-cell.native.scss index ed7ecb16ab372b..e7af8b29fe984e 100644 --- a/packages/components/src/mobile/bottom-sheet/range-cell.native.scss +++ b/packages/components/src/mobile/bottom-sheet/range-cell.native.scss @@ -29,6 +29,7 @@ .container { flex-direction: row; align-items: center; + flex: 1; } .cellContainerStyles { diff --git a/packages/components/src/mobile/link-picker/index.native.js b/packages/components/src/mobile/link-picker/index.native.js index 7bf2aa2a26ae2c..14630cf4938472 100644 --- a/packages/components/src/mobile/link-picker/index.native.js +++ b/packages/components/src/mobile/link-picker/index.native.js @@ -2,7 +2,7 @@ * External dependencies */ import { useState } from 'react'; -import { SafeAreaView, TouchableOpacity } from 'react-native'; +import { SafeAreaView, TouchableOpacity, View } from 'react-native'; import { lowerCase, startsWith } from 'lodash'; /** @@ -81,48 +81,50 @@ export const LinkPicker = ( { ); return ( - + - - { value !== '' && ( - - - + + + { value !== '' && ( + + + + ) } + + { !! value && ( + ) } - - { !! value && ( - - ) } + ); }; diff --git a/packages/components/src/mobile/link-picker/link-picker-results.native.js b/packages/components/src/mobile/link-picker/link-picker-results.native.js index ea25f0fb6778a2..83f1ccd92e7876 100644 --- a/packages/components/src/mobile/link-picker/link-picker-results.native.js +++ b/packages/components/src/mobile/link-picker/link-picker-results.native.js @@ -116,7 +116,7 @@ export default function LinkPickerResults( { { ...listProps } contentContainerStyle={ [ ...listProps.contentContainerStyle, - { paddingBottom: 0 }, + styles.list, ] } /> ) } diff --git a/packages/components/src/mobile/link-picker/styles.native.scss b/packages/components/src/mobile/link-picker/styles.native.scss index 5ff8542f229148..867c2d8eb6ceda 100644 --- a/packages/components/src/mobile/link-picker/styles.native.scss +++ b/packages/components/src/mobile/link-picker/styles.native.scss @@ -1,8 +1,6 @@ .omniCell { border-bottom-width: 1px; border-bottom-color: $light-gray-400; - padding-left: 16px; - padding-right: 16px; } .omniCellDark { @@ -29,3 +27,19 @@ .iconDark { color: $dark-tertiary; } + +.contentContainer { + padding-left: $grid-unit-20; + padding-right: $grid-unit-20; + flex: 1; +} + +.safeArea { + height: 100%; +} + +.list { + padding-left: 0; + padding-right: 0; + padding-bottom: $grid-unit-20; +} diff --git a/packages/format-library/src/link/modal-screens/link-settings-screen.native.js b/packages/format-library/src/link/modal-screens/link-settings-screen.native.js index 569675a28176ab..b69d347e065c1f 100644 --- a/packages/format-library/src/link/modal-screens/link-settings-screen.native.js +++ b/packages/format-library/src/link/modal-screens/link-settings-screen.native.js @@ -3,7 +3,6 @@ */ import React from 'react'; import { useNavigation, useRoute } from '@react-navigation/native'; -import { View } from 'react-native'; /** * WordPress dependencies */ @@ -140,37 +139,30 @@ const LinkSettingsScreen = ( { return useMemo( () => { return ( <> - - - - - - - + + + ); diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index fe9261933c7ae2..278e75b386f06d 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -19,10 +19,10 @@ const ModalLinkUI = ( { isVisible, ...restProps } ) => { return useMemo( () => { return ( @@ -30,6 +30,7 @@ const ModalLinkUI = ( { isVisible, ...restProps } ) => { diff --git a/packages/format-library/src/link/modal.native.scss b/packages/format-library/src/link/modal.native.scss index 3462a913be7ff6..be63cf5ffbe821 100644 --- a/packages/format-library/src/link/modal.native.scss +++ b/packages/format-library/src/link/modal.native.scss @@ -8,3 +8,9 @@ padding-right: $block-edge-to-content; padding-top: $block-edge-to-content/2; } + +.content { + padding-left: $grid-unit-20; + padding-right: $grid-unit-20; + padding-bottom: 0; +} diff --git a/test/native/__mocks__/styleMock.js b/test/native/__mocks__/styleMock.js index 55fa4dd0a954c9..de672610c66eb0 100644 --- a/test/native/__mocks__/styleMock.js +++ b/test/native/__mocks__/styleMock.js @@ -93,4 +93,7 @@ module.exports = { defaultBlock: { marginTop: 16, }, + scrollableContent: { + paddingBottom: 20, + }, };