-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mobile] UI for size image settings (#13728)
* Mobile: Importing SelectControl as native picker for iOS and Android * Adding iOS version of SelectControl as UIActionSheet. * Mobile: select-cell name change * Adding Android selector control based on modal. * Fix lint issues * Fix lint issues * Updated Android selector to show as BottomSheet * Moving SelectControl to components/mobile as `Picker` * Fix lint issues * Remove mobile `modal` component import * Updated SelectCell to PickerCell * Fix lint issues * Renaming styles.scss to styles.native.scss
- Loading branch information
Showing
8 changed files
with
214 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/editor/src/components/mobile/bottom-sheet/picker-cell.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Cell from './cell'; | ||
import Picker from '../picker'; | ||
|
||
export default function PickerCell( props ) { | ||
const { | ||
options, | ||
onChangeValue, | ||
...cellProps | ||
} = props; | ||
|
||
let picker; | ||
|
||
const onCellPress = () => { | ||
picker.presentPicker(); | ||
}; | ||
|
||
const onChange = ( newValue ) => { | ||
onChangeValue( newValue ); | ||
}; | ||
|
||
return ( | ||
<Cell onPress={ onCellPress } editable={ false } { ...cellProps } > | ||
<Picker | ||
ref={ ( instance ) => picker = instance } | ||
options={ options } | ||
onChange={ onChange } | ||
/> | ||
</Cell> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
background-color: $light-gray-400; | ||
height: 1px; | ||
width: 100%; | ||
margin-bottom: 14px; | ||
} | ||
|
||
.content { | ||
|
62 changes: 62 additions & 0 deletions
62
packages/editor/src/components/mobile/picker/index.android.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { Component } from '@wordpress/element'; | ||
import { BottomSheet } from '@wordpress/editor'; | ||
|
||
export default class Picker extends Component { | ||
constructor() { | ||
super( ...arguments ); | ||
this.onClose = this.onClose.bind( this ); | ||
this.onCellPress = this.onCellPress.bind( this ); | ||
|
||
this.state = { | ||
isVisible: false, | ||
}; | ||
} | ||
|
||
presentPicker() { | ||
this.setState( { isVisible: true } ); | ||
} | ||
|
||
onClose() { | ||
this.setState( { isVisible: false } ); | ||
} | ||
|
||
onCellPress( value ) { | ||
this.props.onChange( value ); | ||
this.onClose(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<BottomSheet | ||
isVisible={ this.state.isVisible } | ||
onClose={ this.onClose } | ||
hideHeader | ||
> | ||
<View> | ||
{ this.props.options.map( ( option, index ) => | ||
<BottomSheet.Cell | ||
key={ index } | ||
label={ option.label } | ||
onPress={ () => this.onCellPress( option.value ) } | ||
/> | ||
) } | ||
<BottomSheet.Cell | ||
label={ __( 'Cancel' ) } | ||
onPress={ this.onClose } | ||
drawSeparator={ false } | ||
/> | ||
</View> | ||
</BottomSheet> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { ActionSheetIOS } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { Component } from '@wordpress/element'; | ||
|
||
class Picker extends Component { | ||
presentPicker() { | ||
const { options, onChange } = this.props; | ||
const labels = options.map( ( { label } ) => label ); | ||
const fullOptions = [ __( 'Cancel' ) ].concat( labels ); | ||
|
||
ActionSheetIOS.showActionSheetWithOptions( { | ||
options: fullOptions, | ||
cancelButtonIndex: 0, | ||
}, | ||
( buttonIndex ) => { | ||
if ( buttonIndex === 0 ) { | ||
return; | ||
} | ||
const selected = options[ buttonIndex - 1 ]; | ||
onChange( selected.value ); | ||
}, | ||
); | ||
} | ||
|
||
render() { | ||
return null; | ||
} | ||
} | ||
|
||
export default Picker; |
10 changes: 10 additions & 0 deletions
10
packages/editor/src/components/mobile/picker/styles.android.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.cellContainer { | ||
min-height: 48; | ||
align-items: flex-start; | ||
} | ||
|
||
.cellLabel { | ||
font-size: 17px; | ||
color: #2e4453; | ||
margin-right: 12px; | ||
} |