From aa53d931d56f3c141de584820c194be061810cdf Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Fri, 19 Aug 2016 14:04:10 -0700 Subject: [PATCH] Add I18nManager example --- examples/apis/I18nManager/RTLExample.js | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 examples/apis/I18nManager/RTLExample.js diff --git a/examples/apis/I18nManager/RTLExample.js b/examples/apis/I18nManager/RTLExample.js new file mode 100644 index 00000000..e0fe0162 --- /dev/null +++ b/examples/apis/I18nManager/RTLExample.js @@ -0,0 +1,75 @@ +import { I18nManager, StyleSheet, TouchableHighlight, Text, View } from 'react-native' +import React, { Component } from 'react'; +import { storiesOf, action } from '@kadira/storybook'; + +class RTLExample extends Component { + render() { + return ( + + + LTR/RTL layout example! + + + This is sample text. The writing direction can be changed by pressing the button below. + + + This is text that will always display LTR. + + + This is text that will always display RTL. + + + Toggle LTR/RTL + + + ) + } + + _handleToggle = () => { + this._isRTL = !this._isRTL + I18nManager.setPreferredLanguageRTL(this._isRTL) + } +} + +const styles = StyleSheet.create({ + container: { + backgroundColor: '#F5FCFF', + flex: 1, + justifyContent: 'center', + padding: 10 + }, + welcome: { + fontSize: 28, + marginVertical: 10 + }, + text: { + color: '#333333', + fontSize: 18, + marginBottom: 5 + }, + ltrText: { + textAlign$noI18n: 'left', + writingDirection$noI18n: 'ltr' + }, + rtlText: { + textAlign$noI18n: 'right', + writingDirection$noI18n: 'rtl' + }, + toggle: { + alignSelf: 'center', + borderColor: 'black', + borderStyle: 'solid', + borderWidth: 1, + marginTop: 10, + padding: 10 + } +}) + +storiesOf('api: I18nManager', module) + .add('RTL layout', () => ( + + ))