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: Fix links ui on landscape iOS #14047

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f5852b9
Bump plugin version to 5.1.0-rc.1
noisysocks Feb 18, 2019
81e13d6
RichText: only ignore input types that insert HTML (#13914)
ellatrix Feb 20, 2019
bfe46d6
Bump plugin version to 5.1.0
noisysocks Feb 20, 2019
bb39e9a
Merge branch 'master' into rnmobile/release-v1.0
hypest Feb 20, 2019
2240dcf
Deprecate RichTextInputEvent on mobile too (#13975)
hypest Feb 20, 2019
ece3caf
The undelying RichText component implementation has changed the param…
daniloercoli Feb 20, 2019
d2e2a18
Fixes wrong state comparison (#13987)
marecar3 Feb 20, 2019
811fbe0
Re-add rootTagsToEliminate prop (#14006)
pinarol Feb 21, 2019
762f769
[Mobile]Update PostTitle to apply borders when it is focused (#13970)
pinarol Feb 21, 2019
7c32d3a
Mobile: Rename ref to innerRef on PostTitle (#14024)
etoledom Feb 21, 2019
258a10b
Fixes a red screen in mobile. (#14011)
diegoreymendez Feb 22, 2019
36b7447
Change background color on image placeholder block (#14033)
marecar3 Feb 22, 2019
1171ec5
Fix post title native syntax (#14041)
Tug Feb 22, 2019
d5de5f5
Mobile: Links UI using BottomSheet component (#13972)
etoledom Feb 22, 2019
3aed0f0
Mobile BottomSheet: Replacing keyboard-avoiding-view with custom vers…
etoledom Feb 22, 2019
2c11274
Adding .native to keyboard-avoiding.view.js file name.
etoledom Feb 22, 2019
170fc9d
Modify syntax to pass tests
etoledom Feb 22, 2019
a751b7b
Merge branch 'master' into rnmobile/links-ui-landscape-ios
etoledom Mar 5, 2019
2294a13
Commit original keyboard-avoiding-view code.
etoledom Mar 5, 2019
f226625
Commit modified version of keybaord-avoiding-view for diff
etoledom Mar 5, 2019
8e200f4
Revert "Modify syntax to pass tests"
etoledom Mar 5, 2019
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cache:
branches:
only:
- master
- rnmobile/release-v1.0

before_install:
- nvm install
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/primitives/svg/style.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
color: #87a6bc;
fill: currentColor;
}

.dashicons-format-image {
color: #2e4453;
fill: currentColor;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function MediaPlaceholder( props ) {
return (
<TouchableWithoutFeedback onPress={ props.onMediaOptionsPressed }>
<View style={ styles.emptyStateContainer }>
<Dashicon icon={ 'format-image' } />
<Dashicon ariaPressed={ 'dashicons-format-image' } icon={ 'format-image' } />
<Text style={ styles.emptyStateTitle }>
{ __( 'Image' ) }
</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { Text, View, KeyboardAvoidingView, Platform, PanResponder, Dimensions } from 'react-native';
import { Text, View, Platform, PanResponder, Dimensions } from 'react-native';
import Modal from 'react-native-modal';
import SafeArea from 'react-native-safe-area';

Expand All @@ -17,6 +17,7 @@ import styles from './styles.scss';
import Button from './button';
import Cell from './cell';
import PickerCell from './picker-cell';
import KeyboardAvoidingView from './keyboard-avoiding-view';

class BottomSheet extends Component {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

/**
* External dependencies
*/
import React from 'react';
import {
    Keyboard,
    LayoutAnimation,
    Platform,
    StyleSheet,
    View,
    Dimensions,
} from 'react-native';

/**
* This is a simplified version of Facebook's KeyboardAvoidingView.
* It's meant to work specifically with BottomSheets.
* This fixes an issue in the bottom padding calculation, when the
* BottomSheet was presented on Landscape, with the keyboard already present,
* and a TextField on Autofocus (situation present on Links UI)
*/
class KeyboardAvoidingView extends React.Component {
static defaultProps = {
enabled: true,
keyboardVerticalOffset: 0,
};

_subscriptions = [];

state = {
bottom: 0,
};

_relativeKeyboardHeight( keyboardFrame ) {
if ( ! keyboardFrame ) {
return 0;
}

const windowHeight = Dimensions.get( 'window' ).height;
const keyboardY = keyboardFrame.screenY - this.props.keyboardVerticalOffset;

const final = Math.max( windowHeight - keyboardY, 0 );
return final;
}

/**
* @param {Object} event Keyboard event.
*/
_onKeyboardChange = ( event ) => {
if ( event === null ) {
this.setState( { bottom: 0 } );
return;
}

const { duration, easing, endCoordinates } = event;
const height = this._relativeKeyboardHeight( endCoordinates );

if ( this.state.bottom === height ) {
return;
}

if ( duration && easing ) {
LayoutAnimation.configureNext( {
duration,
update: {
duration,
type: LayoutAnimation.Types[ easing ] || 'keyboard',
},
} );
}
this.setState( { bottom: height } );
};

componentDidMount() {
if ( Platform.OS === 'ios' ) {
this._subscriptions = [
Keyboard.addListener( 'keyboardWillChangeFrame', this._onKeyboardChange ),
];
}
}

componentWillUnmount() {
this._subscriptions.forEach( ( subscription ) => {
subscription.remove();
} );
}

render() {
const {
children,
enabled,
keyboardVerticalOffset, // eslint-disable-line no-unused-vars
style,
...props
} = this.props;

let finalStyle = style;
if ( Platform.OS === 'ios' ) {
const bottomHeight = enabled ? this.state.bottom : 0;
finalStyle = StyleSheet.compose( style, { paddingBottom: bottomHeight } );
}

return (
<View
style={ finalStyle }
{ ...props }
>
{ children }
</View>
);
}
}

export default KeyboardAvoidingView;