From afade2530cb33208b314f6ec474f3a61689ed437 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 19 Jan 2016 15:10:06 -0800 Subject: [PATCH] Make ReactExample look decent on Android as well Mission (mostly) Accomplished! --- examples/ReactExample/components/styles.js | 44 ++++++++++++------- examples/ReactExample/components/todo-app.js | 40 ++++++++++------- examples/ReactExample/components/todo-item.js | 8 ++-- .../ReactExample/components/todo-list-item.js | 12 ++++- .../ReactExample/components/todo-listview.js | 8 ++-- 5 files changed, 74 insertions(+), 38 deletions(-) diff --git a/examples/ReactExample/components/styles.js b/examples/ReactExample/components/styles.js index e482e05c..9ab48593 100644 --- a/examples/ReactExample/components/styles.js +++ b/examples/ReactExample/components/styles.js @@ -6,16 +6,17 @@ const React = require('react-native'); -const { Navigator, StyleSheet } = React; +const { Navigator, Platform, StyleSheet } = React; +const { NavBarHeight, TotalNavHeight } = Navigator.NavigationBar.Styles.General; -const NAVBAR_HEIGHT = Navigator.NavigationBar.Styles.General.TotalNavHeight; +const iOS = (Platform.OS == 'ios'); module.exports = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'stretch', - backgroundColor: '#ffffff', + backgroundColor: '#fff', }, navigator: { flex: 1, @@ -23,11 +24,17 @@ module.exports = StyleSheet.create({ navBar: { backgroundColor: '#f0727d', }, + navBarView: { + alignItems: 'center', + flexDirection: 'row', + height: NavBarHeight, + }, navBarLeftArrow: { - fontSize: 36, + color: '#fff', + fontSize: 40, fontWeight: '200', - lineHeight: 26, letterSpacing: 2, + marginTop: -6, }, navBarLeftButton: { paddingLeft: 8, @@ -36,21 +43,21 @@ module.exports = StyleSheet.create({ paddingRight: 8, }, navBarText: { - color: '#ffffff', + color: '#fff', fontSize: 18, - marginVertical: 10, }, - navBarTitle: { + navBarTitleText: { fontWeight: '500', }, navScene: { - top: NAVBAR_HEIGHT, + top: TotalNavHeight, }, listItem: { borderColor: '#c8c7cc', borderBottomWidth: 0.5, alignItems: 'stretch', alignSelf: 'stretch', + justifyContent: 'center', flexDirection: 'row', flex: 1, height: 44, @@ -64,20 +71,26 @@ module.exports = StyleSheet.create({ listItemCheckbox: { borderColor: '#ccc', borderWidth: 1, - textAlign: 'center', width: 16, height: 16, - lineHeight: 14, + }, + listItemCheckboxText: { + width: 14, + height: 14, + fontSize: iOS ? 14 : 10, + textAlign: 'center', }, listItemCount: { borderColor: '#ccc', borderWidth: 1, borderRadius: 8, - textAlign: 'center', - fontSize: 12, width: 24, height: 18, - lineHeight: 16, + }, + listItemCountText: { + backgroundColor: 'transparent', + fontSize: iOS ? 12 : 11, + textAlign: 'center', }, listItemInput: { fontFamily: 'System', @@ -86,16 +99,17 @@ module.exports = StyleSheet.create({ flex: 1, }, listItemText: { + alignSelf: 'center', fontFamily: 'System', fontSize: 15, flexDirection: 'column', flex: 1, - lineHeight: 30, }, listItemTextSpecial: { fontStyle: 'italic', }, listItemDelete: { + backgroundColor: 'transparent', paddingLeft: 12, paddingRight: 12, flexDirection: 'column', diff --git a/examples/ReactExample/components/todo-app.js b/examples/ReactExample/components/todo-app.js index d7c97329..69936fdc 100644 --- a/examples/ReactExample/components/todo-app.js +++ b/examples/ReactExample/components/todo-app.js @@ -12,8 +12,10 @@ const styles = require('./styles'); const { Navigator, + StatusBarIOS, Text, TouchableOpacity, + View, } = React; class TodoApp extends React.Component { @@ -43,6 +45,12 @@ class TodoApp extends React.Component { return refs.listItemView || refs.listView; } + componentWillMount() { + if (StatusBarIOS) { + StatusBarIOS.setStyle('light-content'); + } + } + render() { let extraItems = [ {name: 'Complete', items: realm.objects('Todo', 'done = true')}, @@ -155,13 +163,13 @@ const RouteMapper = { let prevRoute = navState.routeStack[index - 1]; return ( - navigator.pop()} - style={styles.navBarLeftButton}> - + navigator.pop()}> + - {prevRoute.backButtonTitle || prevRoute.title || 'Back'} - + + {prevRoute.backButtonTitle || prevRoute.title || 'Back'} + + ); }, @@ -172,21 +180,23 @@ const RouteMapper = { } return ( - - - {route.rightButtonTitle} - + + + + {route.rightButtonTitle} + + ); }, Title(route) { return ( - - {route.title} - + + + {route.title} + + ); }, }; diff --git a/examples/ReactExample/components/todo-item.js b/examples/ReactExample/components/todo-item.js index 4b6d1623..b8306d73 100644 --- a/examples/ReactExample/components/todo-item.js +++ b/examples/ReactExample/components/todo-item.js @@ -38,9 +38,11 @@ class TodoItem extends TodoListItem { return ( - - {this.done ? '✓' : ''} - + + + {this.done ? '✓' : ''} + + ); diff --git a/examples/ReactExample/components/todo-list-item.js b/examples/ReactExample/components/todo-list-item.js index 6a01222c..ac82b878 100644 --- a/examples/ReactExample/components/todo-list-item.js +++ b/examples/ReactExample/components/todo-list-item.js @@ -8,7 +8,15 @@ const React = require('react-native'); const realm = require('./realm'); const styles = require('./styles'); -const { Text, TextInput, TouchableWithoutFeedback, View } = React; +const { + Platform, + Text, + TextInput, + TouchableWithoutFeedback, + View, +} = React; + +const iOS = (Platform.OS == 'ios'); class TodoListItem extends React.Component { constructor(props) { @@ -90,7 +98,7 @@ class TodoListItem extends React.Component { return ( - 𐄂 + {iOS ? '𐄂' : '×'} ); diff --git a/examples/ReactExample/components/todo-listview.js b/examples/ReactExample/components/todo-listview.js index ed483994..3e3ec407 100644 --- a/examples/ReactExample/components/todo-listview.js +++ b/examples/ReactExample/components/todo-listview.js @@ -142,9 +142,11 @@ class TodoListExtraItem extends TodoListItem { renderLeftSide() { return ( - - {this.props.item.items.length} - + + + {this.props.item.items.length} + + ); }