[RN] Extract header components for reuse
This commit is contained in:
parent
c13424f7c0
commit
d7475a44e4
|
@ -3,8 +3,9 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { TouchableOpacity } from 'react-native';
|
import { TouchableOpacity } from 'react-native';
|
||||||
|
|
||||||
import { Icon } from '../../../base/font-icons';
|
import { Icon } from '../../../font-icons';
|
||||||
import { Header } from '../../../base/react';
|
|
||||||
|
import styles from './styles';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the React {@code Component} props of {@link BackButton}
|
* The type of the React {@code Component} props of {@link BackButton}
|
||||||
|
@ -40,7 +41,7 @@ export default class BackButton extends Component<Props> {
|
||||||
<Icon
|
<Icon
|
||||||
name = { 'arrow_back' }
|
name = { 'arrow_back' }
|
||||||
style = { [
|
style = { [
|
||||||
Header.buttonStyle,
|
styles.headerButton,
|
||||||
this.props.style
|
this.props.style
|
||||||
] } />
|
] } />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
|
@ -0,0 +1,48 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { Text } from 'react-native';
|
||||||
|
|
||||||
|
import { translate } from '../../../i18n';
|
||||||
|
|
||||||
|
import styles from './styles';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the React {@code Component} props of {@link HeaderLabel}
|
||||||
|
*/
|
||||||
|
type Props = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The i18n key of the label to be rendered.
|
||||||
|
*/
|
||||||
|
labelKey: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The i18n translate function.
|
||||||
|
*/
|
||||||
|
t: Function
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A component rendering a standard label in the header.
|
||||||
|
*/
|
||||||
|
class HeaderLabel extends Component<Props> {
|
||||||
|
/**
|
||||||
|
* Implements React's {@link Component#render()}.
|
||||||
|
*
|
||||||
|
* @inheritdoc
|
||||||
|
* @returns {ReactElement}
|
||||||
|
*/
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Text
|
||||||
|
style = { [
|
||||||
|
styles.headerText
|
||||||
|
] }>
|
||||||
|
{ this.props.t(this.props.labelKey) }
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate(HeaderLabel);
|
|
@ -1,5 +1,7 @@
|
||||||
|
export { default as BackButton } from './BackButton';
|
||||||
export { default as Container } from './Container';
|
export { default as Container } from './Container';
|
||||||
export { default as Header } from './Header';
|
export { default as Header } from './Header';
|
||||||
|
export { default as HeaderLabel } from './HeaderLabel';
|
||||||
export { default as Link } from './Link';
|
export { default as Link } from './Link';
|
||||||
export { default as LoadingIndicator } from './LoadingIndicator';
|
export { default as LoadingIndicator } from './LoadingIndicator';
|
||||||
export { default as NavigateSectionListEmptyComponent } from
|
export { default as NavigateSectionListEmptyComponent } from
|
||||||
|
|
|
@ -7,25 +7,24 @@ import {
|
||||||
SafeAreaView,
|
SafeAreaView,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Switch,
|
Switch,
|
||||||
Text,
|
|
||||||
TextInput,
|
TextInput,
|
||||||
View
|
View
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { translate } from '../../../base/i18n';
|
import { translate } from '../../../base/i18n';
|
||||||
import { Header } from '../../../base/react';
|
import { BackButton, Header } from '../../../base/react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AbstractSettingsView,
|
AbstractSettingsView,
|
||||||
_mapStateToProps
|
_mapStateToProps
|
||||||
} from '../AbstractSettingsView';
|
} from '../AbstractSettingsView';
|
||||||
import { setSettingsViewVisible } from '../../actions';
|
import { setSettingsViewVisible } from '../../actions';
|
||||||
import BackButton from './BackButton';
|
|
||||||
import FormRow from './FormRow';
|
import FormRow from './FormRow';
|
||||||
import FormSectionHeader from './FormSectionHeader';
|
import FormSectionHeader from './FormSectionHeader';
|
||||||
import { normalizeUserInputURL } from '../../functions';
|
import { normalizeUserInputURL } from '../../functions';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
import { HeaderLabel } from '../../../base/react/components/native';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The native container rendering the app settings page.
|
* The native container rendering the app settings page.
|
||||||
|
@ -205,13 +204,7 @@ class SettingsView extends AbstractSettingsView {
|
||||||
return (
|
return (
|
||||||
<Header>
|
<Header>
|
||||||
<BackButton onPress = { this._onRequestClose } />
|
<BackButton onPress = { this._onRequestClose } />
|
||||||
<Text
|
<HeaderLabel labelKey = 'settingsView.header' />
|
||||||
style = { [
|
|
||||||
styles.text,
|
|
||||||
Header.textStyle
|
|
||||||
] }>
|
|
||||||
{ this.props.t('settingsView.header') }
|
|
||||||
</Text>
|
|
||||||
</Header>
|
</Header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue