diff --git a/packages/block-library/src/spacer/edit.native.js b/packages/block-library/src/spacer/edit.native.js index 09fbb04e83a245..e0d0d3245cdd20 100644 --- a/packages/block-library/src/spacer/edit.native.js +++ b/packages/block-library/src/spacer/edit.native.js @@ -49,7 +49,6 @@ const SpacerEdit = ( { isSelected, attributes, setAttributes, getStylesFromColor { if ( isValueEditable ) { startEditing(); @@ -183,7 +189,9 @@ class BottomSheetCell extends Component { }; const iconStyle = getStylesFromColorScheme( styles.icon, styles.iconDark ); + const resetButtonStyle = getStylesFromColorScheme( styles.resetButton, styles.resetButtonDark ); const containerPointerEvents = this.state.isScreenReaderEnabled && accessible ? 'none' : 'auto'; + const { title, handler } = customActionButton || {}; return ( { drawTopSeparator && ( ) } - - - { icon && ( - - - - - ) } - - { label } - + + + + { icon && ( + + + + + ) } + + { label } + + + { customActionButton && + { title } + + } { showValue && getValueComponent() } { children } diff --git a/packages/components/src/mobile/bottom-sheet/range-cell.native.js b/packages/components/src/mobile/bottom-sheet/range-cell.native.js index 56c146b04160aa..3e59a80198401b 100644 --- a/packages/components/src/mobile/bottom-sheet/range-cell.native.js +++ b/packages/components/src/mobile/bottom-sheet/range-cell.native.js @@ -1,19 +1,21 @@ /** * External dependencies */ -import { Platform, AccessibilityInfo, findNodeHandle, TextInput, Slider } from 'react-native'; +import { Platform, AccessibilityInfo, findNodeHandle, TextInput, Slider, View, PixelRatio, AppState } from 'react-native'; /** * WordPress dependencies */ import { _x, __, sprintf } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; +import { withPreferredColorScheme } from '@wordpress/compose'; /** * Internal dependencies */ import Cell from './cell'; import styles from './range-cell.scss'; +import borderStyles from './borderStyles.scss'; class BottomSheetRangeCell extends Component { constructor( props ) { @@ -24,10 +26,12 @@ class BottomSheetRangeCell extends Component { this.handleReset = this.handleReset.bind( this ); this.onChangeValue = this.onChangeValue.bind( this ); this.onCellPress = this.onCellPress.bind( this ); + this.handleChangePixelRatio = this.handleChangePixelRatio.bind( this ); const initialValue = this.validateInput( props.value || props.defaultValue || props.minimumValue ); + const fontScale = this.getFontScale(); - this.state = { accessible: true, sliderValue: initialValue, initialValue, hasFocus: false }; + this.state = { accessible: true, sliderValue: initialValue, initialValue, hasFocus: false, fontScale }; } componentDidUpdate( ) { @@ -37,8 +41,23 @@ class BottomSheetRangeCell extends Component { } } + componentDidMount() { + AppState.addEventListener( 'change', this.handleChangePixelRatio ); + } + componentWillUnmount() { this.handleToggleFocus(); + AppState.removeEventListener( 'change', this.handleChangePixelRatio ); + } + + getFontScale() { + return PixelRatio.getFontScale() < 1 ? 1 : PixelRatio.getFontScale(); + } + + handleChangePixelRatio( nextAppState ) { + if ( nextAppState === 'active' ) { + this.setState( { fontScale: this.getFontScale() } ); + } } handleChange( text ) { @@ -115,13 +134,16 @@ class BottomSheetRangeCell extends Component { maximumValue = 10, disabled, step = 1, - minimumTrackTintColor = '#00669b', + preferredColorScheme, + minimumTrackTintColor = preferredColorScheme === 'light' ? '#00669b' : '#5198d9', maximumTrackTintColor = Platform.OS === 'ios' ? '#e9eff3' : '#909090', thumbTintColor = Platform.OS === 'android' && '#00669b', + getStylesFromColorScheme, + allowReset = true, ...cellProps } = this.props; - const { hasFocus, sliderValue, accessible } = this.state; + const { hasFocus, sliderValue, accessible, fontScale } = this.state; const accessibilityLabel = sprintf( @@ -130,49 +152,63 @@ class BottomSheetRangeCell extends Component { cellProps.label, value ); + const defaultSliderStyle = getStylesFromColorScheme( styles.sliderTextInput, styles.sliderDarkTextInput ); + const resetButtonText = Platform.OS === 'ios' ? __( 'Reset' ) : __( 'RESET' ); + const resetButton = { title: resetButtonText, handler: this.handleReset }; + return ( - { - this.sliderRef = slider; - } } - style={ styles.slider } - accessibilityRole={ 'adjustable' } - /> - + + { + this.sliderRef = slider; + } } + style={ styles.slider } + accessibilityRole={ 'adjustable' } + /> + + ); } } -export default BottomSheetRangeCell; +export default withPreferredColorScheme( BottomSheetRangeCell ); 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 93099e7a8a6415..21a7051d20ced9 100644 --- a/packages/components/src/mobile/bottom-sheet/range-cell.native.scss +++ b/packages/components/src/mobile/bottom-sheet/range-cell.native.scss @@ -3,18 +3,38 @@ } .sliderTextInput { - width: 40px; - height: 25px; + min-height: 25px; align-self: center; margin-left: 10px; - border-width: 1px; - border-radius: 4px; - border-color: $dark-gray-150; + border-color: $light-gray-400; padding-top: 0; padding-bottom: 0; + text-align: center; +} + +.sliderDarkTextInput { + border-color: $gray-70; } .isSelected { border-width: 2px; border-color: $blue-wordpress; } + +.container { + flex-direction: row; + align-items: center; + min-height: 48px; +} + +.cellContainerStyles { + flex-direction: column; + align-items: flex-start; +} + +.cellRowStyles { + min-height: 48px; + margin-bottom: -13px; + width: 100%; + justify-content: space-between; +} diff --git a/packages/components/src/mobile/bottom-sheet/styles.native.scss b/packages/components/src/mobile/bottom-sheet/styles.native.scss index 86422f3228cac4..b098b4e5bdbf79 100644 --- a/packages/components/src/mobile/bottom-sheet/styles.native.scss +++ b/packages/components/src/mobile/bottom-sheet/styles.native.scss @@ -76,6 +76,15 @@ padding: 5px; } +.resetButton { + font-size: 17px; + color: $blue-wordpress; +} + +.resetButtonDark { + color: $blue-30; +} + // Cell .cellContainer { @@ -101,6 +110,7 @@ .cellRowContainer { flex-direction: row; align-items: center; + flex-shrink: 1; } .cellIcon {