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

[Mobile] - Refactor gallery - Cleanup #32382

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
2 changes: 1 addition & 1 deletion lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function gutenberg_initialize_experiments_settings() {
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable the refactored gallery block', 'gutenberg' ),
'label' => __( 'Enable the refactored gallery block (Warning: The refactored gallery is not compatible with WordPress mobile apps prior to version 17.8. If you use the mobile app, please update to the latest version to avoid content loss.)', 'gutenberg' ),
'id' => 'gutenberg-gallery-refactor',
)
);
Expand Down
14 changes: 7 additions & 7 deletions packages/block-editor/src/components/block-list/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ export class BlockList extends Component {
isStackedHorizontally,
horizontalAlignment,
contentResizeMode,
// eslint-disable-next-line no-unused-vars
blockWidth,
} = this.props;
const { parentScrollRef } = extraProps;
Expand All @@ -229,11 +228,8 @@ export class BlockList extends Component {
marginHorizontal: isRootList ? 0 : -marginHorizontal,
};

// eslint-disable-next-line no-unused-vars
const isContentStretch = contentResizeMode === 'stretch';
// eslint-disable-next-line no-unused-vars
const isMultiBlocks = blockClientIds.length > 1;
// eslint-disable-next-line no-unused-vars
const { isWider } = alignmentHelpers;

return (
Expand Down Expand Up @@ -269,9 +265,13 @@ export class BlockList extends Component {
horizontal={ horizontal }
extraData={ this.getExtraData() }
scrollEnabled={ isRootList }
contentContainerStyle={
horizontal && styles.horizontalContentContainer
}
contentContainerStyle={ [
horizontal && styles.horizontalContentContainer,
isWider( blockWidth, 'medium' ) &&
( isContentStretch && isMultiBlocks
? styles.horizontalContentContainerStretch
: styles.horizontalContentContainerCenter ),
] }
style={ getStyles(
isRootList,
isStackedHorizontally,
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/store/defaults.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {

const SETTINGS_DEFAULTS = {
...SETTINGS,
// FOR TESTING ONLY - Later, this will come from a REST API
// eslint-disable-next-line no-undef
__experimentalGalleryRefactor: __DEV__,
alignWide: true,
Expand Down
22 changes: 8 additions & 14 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import { concat, find } from 'lodash';
*/
import { compose } from '@wordpress/compose';
import {
// eslint-disable-next-line no-unused-vars
BaseControl,
PanelBody,
SelectControl,
ToggleControl,
withNotices,
RangeControl,
// eslint-disable-next-line no-unused-vars
Spinner,
} from '@wordpress/components';
import {
Expand Down Expand Up @@ -63,17 +61,13 @@ const linkOptions = [
];
const ALLOWED_MEDIA_TYPES = [ 'image' ];

const PLACEHOLDER_TEXT = Platform.select( {
web: __(
'Drag images, upload new ones or select files from your library.'
),
native: __( 'ADD MEDIA' ),
} );
const PLACEHOLDER_TEXT = Platform.isNative
? __( 'ADD MEDIA' )
: __( 'Drag images, upload new ones or select files from your library.' );

const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.select( {
web: {},
native: { type: 'stepper' },
} );
const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
? { type: 'stepper' }
: {};

function GalleryEdit( props ) {
const {
Expand Down Expand Up @@ -501,7 +495,7 @@ function GalleryEdit( props ) {
hideCancelButton={ true }
/>
) }
{ /* { ! imageSizeOptions && (
{ Platform.isWeb && ! imageSizeOptions && (
<BaseControl className={ 'gallery-image-sizes' }>
<BaseControl.VisualLabel>
{ __( 'Image size' ) }
Expand All @@ -511,7 +505,7 @@ function GalleryEdit( props ) {
{ __( 'Loading options…' ) }
</View>
</BaseControl>
) } */ }
) }
</PanelBody>
</InspectorControls>
{ noticeUI }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class ImageEdit extends Component {
image,
clientId,
imageDefaultSize,
context: { isGrouped = false, imageCrop = false },
context: { isGrouped = false, imageCrop = false } = {},
featuredImageId,
wasBlockJustInserted,
} = this.props;
Expand Down
2 changes: 2 additions & 0 deletions packages/element/src/platform.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const Platform = {
}
return spec.default;
},
isNative: true,
isAndroid: true,
};

export default Platform;
2 changes: 2 additions & 0 deletions packages/element/src/platform.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const Platform = {
}
return spec.default;
},
isNative: true,
isIOS: true,
};

export default Platform;
1 change: 1 addition & 0 deletions packages/element/src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
const Platform = {
OS: 'web',
select: ( spec ) => ( 'web' in spec ? spec.web : spec.default ),
isWeb: true,
};
/**
* Component used to detect the current Platform being used.
Expand Down