Skip to content

Commit

Permalink
Use custom button instead of native provided by react-native
Browse files Browse the repository at this point in the history
  • Loading branch information
Tug committed Dec 19, 2018
1 parent a2f53fe commit c5eb770
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
24 changes: 24 additions & 0 deletions packages/format-library/src/link/button.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* External dependencies
*/
import { TouchableOpacity, View } from 'react-native';

export default function Button( props ) {
const {
children,
onClick,
disabled,
} = props;

return (
<TouchableOpacity
accessible={ true }
onPress={ onClick }
disabled={ disabled }
>
<View style={ { flexDirection: 'row' } }>
{ children }
</View>
</TouchableOpacity>
);
}
25 changes: 12 additions & 13 deletions packages/format-library/src/link/modal.native.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import React from 'react';
import { Button, Switch, Text, TextInput, View } from 'react-native';
import { Switch, Text, TextInput, View } from 'react-native';
import Modal from 'react-native-modal';
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
Expand All @@ -19,6 +19,7 @@ import {
} from '@wordpress/rich-text';

import { createLinkFormat, isValidHref } from './utils';
import Button from './button';

import styles from './modal.scss';

Expand Down Expand Up @@ -105,21 +106,19 @@ class ModalLinkUI extends Component {
<View style={ { ...styles.content, borderColor: 'rgba(0, 0, 0, 0.1)' } }>
<View style={ styles.dragIndicator } />
<View style={ styles.head }>
<Button
color="red"
title={ __( 'Remove' ) }
accessibilityLabel={ __( 'Remove the link' ) }
onPress={ this.removeLink }
/>
<Button onClick={ this.removeLink }>
<Text style={ { ...styles.buttonText, color: 'red' } }>
{ __( 'Remove' ) }
</Text>
</Button>
<Text style={ styles.title }>
{ __( 'Link Settings' ) }
</Text>
<Button
color="#0087be"
title={ __( 'Done' ) }
accessibilityLabel={ __( 'Finish editing the link' ) }
onPress={ this.submitLink }
/>
<Button onClick={ this.submitLink }>
<Text style={ { ...styles.buttonText, color: '#0087be' } } >
{ __( 'Done' ) }
</Text>
</Button>
</View>
<View style={ styles.separator } />
<View style={ styles.inlineInput }>
Expand Down
5 changes: 5 additions & 0 deletions packages/format-library/src/link/modal.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
text-align: center;
}

.buttonText {
font-size: 18px;
}

.inlineInput {
flex-direction: row;
width: 100%;
Expand All @@ -65,3 +69,4 @@
align-self: flex-end;
padding: 5px;
}

0 comments on commit c5eb770

Please sign in to comment.