Skip to content

Commit

Permalink
[RNMobile] Media & Text - Media picker buttons functionality (#17537)
Browse files Browse the repository at this point in the history
* [RNMobile] Native mobile release v1.11.0 (#17181)

* [RNMobile] Fix crash when adding separator

* Build: remove global install of latest npm since we want to use the paired node/npm version (#17134)

* Build: remove global install of latest npm since we want to use the paired node/npm version
* Also update travis to remove --latest-npm flag

* [RNMobile] Try dark mode (iOS) (#17067)

* Adding dark mode component implemented on list and list block

* Adding DarkMode handling to RichText, ToolBar and SafeArea

* Mobile: Using DarkMode as HOC

* iOS DarkMode: Modified colors on block list and block container

* iOS DarkMode: Improved Header Toolbar colors

* iOS DarkMode: Removing background from buttons

* iOS DarkMode warning and unsupported

* iOS DarkMode: MediaPlaceholder

* iOS DarkMode: BottomSheets

* iOS DarkMode: Inserter

* iOS DarkMode: DefaultBlockAppender

* iOS DarkMode: PostTite

* Update hardcoded colors with variables

* iOS DarkMode: Fix bottom-sheet cell value color

* iOS DarkMode: More - PageBreak - Add Block Here

* iOS DarkMode: Better text color

* iOS Darkmode: Code block

* iOS DarkMode: HTML View

* iOS DarkMode: Improve colors on SafeArea

* Fix toolbar not avoiding keyboard regression

* Fix native unit tests

* Fix gutenberg-mobile unit tests

* Adding RNDarkMode mocks

* RNMobile: Fix crash when viewing HTML on iOS

* [RNMobile] Remove toolbar from html view

* [RNMobile] Fix MaxListenersExceededWarning caused by dark-mode event emitter (#17186)

* Fix MaxListenersExceededWarning caused by dark-mode event emitter

* Checking for setMaxListeners trying to avoid CI error

* Adding remove listener to DarkMode HOC

* DarkMode: Binding this.onModeChanged to `this`

* DarkMode: Adding conditional needed to pass UI Tests on CI

* Fix focus title on new posts regression (#17180)

* BottomSheet: Setting DashIcon color directly when theme is default (light) (#17193)

* [RNMobile] DarkMode improvements (#17309)

* Remove the need to import `useStyle` and pass the theme prop on every instance that `withStyle` is used

* Implement dark-mode refactor on all components

* Fix broken native tests

* Fix default block appender background color on DarkMode

* DarkMode: Make `useStyle` a class function

* WIP Media & Text video and image

* Media & text implementation

* Add label for media&text

* Media upload improvements

* [RNMobile] Refactor Dark Mode HOC (#17552)

* [RNMobile] Refactor the Dark Mode HOC to fix naming antipatterns

* Fix lint errors

* Add .native.js suffix to usePreferredColorScheme

* Update usage of theme props renamed to preferredColorScheme

* Update usage of theme props renamed to preferredColorScheme

* Mobile - Media & Text block video improvements

* Mobile - Platform mock

* Mobile - Move Platform mock

* Mobile - Media & text block media file type

* Remove unused var

* Mobile - Media & Text - Fix styles and allow both types of media upload for iOS and Android

* Mobile - Media & Text - Check for existing media in callback
  • Loading branch information
geriux authored and koke committed Oct 10, 2019
1 parent 1ebb697 commit a5be006
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 104 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export { default as URLInput } from './url-input';
export { default as BlockInvalidWarning } from './block-list/block-invalid-warning';
export { default as Caption } from './caption';
export { BottomSheetSettings, BlockSettingsButton } from './block-settings';
export { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';

// Content Related Components
export { default as BlockList } from './block-list';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function MediaPlaceholder( props ) {
instructions = __( 'ADD IMAGE' );
} else if ( isVideo ) {
instructions = __( 'ADD VIDEO' );
} else {
instructions = __( 'ADD IMAGE OR VIDEO' );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
background-color: $background-dark-secondary;
}

.emptyStateContainerDark {
background-color: $background-dark-secondary;
}

.emptyStateTitle {
text-align: center;
margin-top: 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export class MediaUploadProgress extends React.Component {

return (
<View style={ styles.mediaUploadProgress }>
{ showSpinner && <Spinner progress={ progress } /> }
{ showSpinner &&
<View style={ styles.progressBar }>
<Spinner progress={ progress } />
</View>
}
{ coverUrl &&
<ImageSize src={ coverUrl } >
{ ( sizes ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.mediaUploadProgress {
flex: 1;
}

.progressBar {
background-color: $gray-lighten-30;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class MediaUpload extends React.Component {
onPickerSelect( requestFunction ) {
const { allowedTypes = [], onSelect, multiple = false } = this.props;
requestFunction( allowedTypes, multiple, ( media ) => {
if ( ( multiple && media ) || media.id ) {
if ( ( multiple && media ) || ( media && media.id ) ) {
onSelect( media );
}
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import { default as VideoPlayer } from 'react-native-video';
/**
* Internal dependencies
*/
import styles from './video-player.scss';
import styles from './styles.scss';
import PlayIcon from './gridicon-play';

// Default Video ratio 16:9
export const VIDEO_ASPECT_RATIO = 16 / 9;

class Video extends Component {
constructor() {
super( ...arguments );
Expand Down
17 changes: 14 additions & 3 deletions packages/block-library/src/media-text/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MediaTextEdit extends Component {
super( ...arguments );

this.onSelectMedia = this.onSelectMedia.bind( this );
this.onMediaUpdate = this.onMediaUpdate.bind( this );
this.onWidthChange = this.onWidthChange.bind( this );
this.commitWidthChange = this.commitWidthChange.bind( this );
this.state = {
Expand All @@ -68,7 +69,7 @@ class MediaTextEdit extends Component {
mediaType = media.type;
}

if ( mediaType === 'image' ) {
if ( mediaType === 'image' && media.sizes ) {
// Try the "large" size URL, falling back to the "full" size URL below.
src = get( media, [ 'sizes', 'large', 'url' ] ) || get( media, [ 'media_details', 'sizes', 'large', 'source_url' ] );
}
Expand All @@ -83,6 +84,15 @@ class MediaTextEdit extends Component {
} );
}

onMediaUpdate( media ) {
const { setAttributes } = this.props;

setAttributes( {
mediaId: media.id,
mediaUrl: media.url,
} );
}

onWidthChange( width ) {
this.setState( {
mediaWidth: applyWidthConstraints( width ),
Expand All @@ -101,16 +111,17 @@ class MediaTextEdit extends Component {
}

renderMediaArea() {
const { attributes } = this.props;
const { attributes, isSelected } = this.props;
const { mediaAlt, mediaId, mediaPosition, mediaType, mediaUrl, mediaWidth, imageFill, focalPoint } = attributes;

return (
<MediaContainer
onSelectMedia={ this.onSelectMedia }
onMediaUpdate={ this.onMediaUpdate }
onWidthChange={ this.onWidthChange }
commitWidthChange={ this.commitWidthChange }
onFocus={ this.props.onFocus }
{ ...{ mediaAlt, mediaId, mediaType, mediaUrl, mediaPosition, mediaWidth, imageFill, focalPoint } }
{ ...{ mediaAlt, mediaId, mediaType, mediaUrl, mediaPosition, mediaWidth, imageFill, focalPoint, isSelected } }
/>
);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/media-text/icon-retry.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* WordPress dependencies
*/
import { Path, SVG } from '@wordpress/components';

export default <SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><Path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" /><Path d="M0 0h24v24H0z" fill={ 'none' } /></SVG>;
Loading

0 comments on commit a5be006

Please sign in to comment.