Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Media & Text alignment options #18300

Merged
merged 4 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export class BlockList extends Component {
}

render() {
const { clearSelectedBlock, blockClientIds, isFullyBordered, title, header, withFooter = true, renderAppender, isFirstBlock, selectedBlockParentId } = this.props;
const { clearSelectedBlock, blockClientIds, isFullyBordered, title, header, withFooter = true, renderAppender, isFirstBlock, selectedBlockParentId, isRootList } = this.props;

const showFloatingToolbar = isFirstBlock && selectedBlockParentId !== '';
return (
<View
style={ { flex: 1 } }
style={ { flex: isRootList ? 1 : 0 } }
onAccessibilityEscape={ clearSelectedBlock }
>
{ showFloatingToolbar && <FloatingToolbar.Slot fillProps={ { innerFloatingToolbar: showFloatingToolbar } } /> }
Expand All @@ -86,7 +86,7 @@ export class BlockList extends Component {
innerRef={ this.scrollViewInnerRef }
extraScrollHeight={ innerToolbarHeight + 10 }
keyboardShouldPersistTaps="always"
style={ styles.list }
scrollViewStyle={ { flex: isRootList ? 1 : 0 } }
data={ blockClientIds }
extraData={ [ isFullyBordered ] }
keyExtractor={ identity }
Expand Down Expand Up @@ -212,6 +212,7 @@ export default compose( [
selectedBlockClientId,
isFirstBlock,
selectedBlockParentId,
isRootList: rootClientId === undefined,
};
} ),
withDispatch( ( dispatch ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
background-color: #fff;
}

.list {
flex: 1;
}

.switch {
flex-direction: row;
justify-content: flex-start;
Expand Down
15 changes: 7 additions & 8 deletions packages/block-library/src/media-text/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { View } from 'react-native';
import { __, _x } from '@wordpress/i18n';
import {
BlockControls,
// BlockVerticalAlignmentToolbar,
BlockVerticalAlignmentToolbar,
InnerBlocks,
withColors,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -131,10 +131,10 @@ class MediaTextEdit extends Component {
attributes,
backgroundColor,
setAttributes,
// isMobile,
// isMobile,
} = this.props;
const {
// isStackedOnMobile,
// isStackedOnMobile,
mediaPosition,
mediaWidth,
verticalAlignment,
Expand All @@ -145,7 +145,7 @@ class MediaTextEdit extends Component {
const widthString = `${ temporaryMediaWidth }%`;
const containerStyles = {
...styles[ 'wp-block-media-text' ],
...styles[ `is-vertically-aligned-${ verticalAlignment }` ],
...styles[ `is-vertically-aligned-${ verticalAlignment || 'center' }` ],
...( mediaPosition === 'right' ? styles[ 'has-media-on-the-right' ] : {} ),
...( shouldStack ? styles[ 'is-stacked-on-mobile' ] : {} ),
...( shouldStack && mediaPosition === 'right' ? styles[ 'is-stacked-on-mobile.has-media-on-the-right' ] : {} ),
Expand All @@ -166,22 +166,21 @@ class MediaTextEdit extends Component {
onClick: () => setAttributes( { mediaPosition: 'right' } ),
} ];

/* const onVerticalAlignmentChange = ( alignment ) => {
const onVerticalAlignmentChange = ( alignment ) => {
setAttributes( { verticalAlignment: alignment } );
}; */
};

return (
<>
<BlockControls>
<Toolbar
controls={ toolbarControls }
/>
{ /* // Temporarily commenting out until alignment functionality is fixed
<BlockVerticalAlignmentToolbar
onChange={ onVerticalAlignmentChange }
value={ verticalAlignment }
isCollapsed={ false }
/> */ }
/>
</BlockControls>
<View style={ containerStyles }>
<View style={ { width: widthString } }>
Expand Down
44 changes: 23 additions & 21 deletions packages/block-library/src/media-text/media-container.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,32 +265,34 @@ class MediaContainer extends Component {

if ( mediaUrl ) {
return (
<View style={ { flex: 1 } }>
<View>
<MediaUpload
onSelect={ this.onSelectMediaUploadOption }
allowedTypes={ ALLOWED_MEDIA_TYPES }
value={ mediaId }
render={ ( { open, getMediaOptions } ) => {
return <>
{ getMediaOptions() }
{ this.renderToolbarEditButton( open ) }

<MediaUploadProgress
coverUrl={ coverUrl }
mediaId={ mediaId }
onUpdateMediaProgress={ this.updateMediaProgress }
onFinishMediaUploadWithSuccess={ this.finishMediaUploadWithSuccess }
onFinishMediaUploadWithFailure={ this.finishMediaUploadWithFailure }
onMediaUploadStateReset={ this.mediaUploadStateReset }
renderContent={ ( params ) => {
return (
<View style={ styles.content }>
{ this.renderContent( params, open ) }
</View>
);
} }
/>
</>;
return (
<View style={ { flex: 1 } }>
{ getMediaOptions() }
{ this.renderToolbarEditButton( open ) }

<MediaUploadProgress
coverUrl={ coverUrl }
mediaId={ mediaId }
onUpdateMediaProgress={ this.updateMediaProgress }
onFinishMediaUploadWithSuccess={ this.finishMediaUploadWithSuccess }
onFinishMediaUploadWithFailure={ this.finishMediaUploadWithFailure }
onMediaUploadStateReset={ this.mediaUploadStateReset }
renderContent={ ( params ) => {
return (
<View style={ styles.content }>
{ this.renderContent( params, open ) }
</View>
);
} }
/>
</View>
);
} }
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export const KeyboardAwareFlatList = ( {
shouldPreventAutomaticScroll,
innerRef,
autoScroll,
scrollViewStyle,
...listProps
} ) => (
<KeyboardAwareScrollView
style={ { flex: 1 } }
style={ [ { flex: 1 }, scrollViewStyle ] }
keyboardDismissMode="none"
enableResetScrollToCoords={ false }
keyboardShouldPersistTaps="handled"
Expand Down