Commit 701fd579 authored by shiyunjie's avatar shiyunjie

props push

parent fe40ad0f
...@@ -7,9 +7,10 @@ export const PUSH = 'push'; ...@@ -7,9 +7,10 @@ export const PUSH = 'push';
export const POP = 'pop'; export const POP = 'pop';
export const TAB = 'tab'; export const TAB = 'tab';
// action creator // action creator
export const push = (pageName: String = '') => ({ export const push = (pageName: String = '', extProps) => ({
type: PUSH, type: PUSH,
pageName, pageName,
extProps,
}); });
export const pop = (pageName: String = '') => ({ export const pop = (pageName: String = '') => ({
type: POP, type: POP,
......
...@@ -84,6 +84,12 @@ const navigator = createStackNavigator({ ...@@ -84,6 +84,12 @@ const navigator = createStackNavigator({
}, { }, {
initialRouteName, initialRouteName,
headerMode: 'none', headerMode: 'none',
defaultNavigationOptions: {
gesturesEnabled: false,
},
disableKeyboardHandling: false,
cardShadowEnabled: true,
cardOverlayEnabled: true,
}); });
//export default navigator; //export default navigator;
......
...@@ -10,17 +10,18 @@ import { PUSH, POP, TAB } from './actions'; ...@@ -10,17 +10,18 @@ import { PUSH, POP, TAB } from './actions';
const ActionForTab = NavigationStack.router.getActionForPathAndParams(initialRouteName); const ActionForTab = NavigationStack.router.getActionForPathAndParams(initialRouteName);
const ActionForNativePage = pageName => NavigationStack.router.getActionForPathAndParams(pageName); const ActionForNativePage = action => NavigationStack.router
.getActionForPathAndParams(action.pageName, action.extProps);
const initialState = NavigationStack.router.getStateForAction(ActionForTab); const initialState = NavigationStack.router.getStateForAction(ActionForTab);
const nav = (state = initialState, action) => { const nav = (state = initialState, action) => {
switch (action.type) { switch (action.type) {
case PUSH: case PUSH:
return NavigationStack.router.getStateForAction(ActionForNativePage(action.pageName), state); return NavigationStack.router.getStateForAction(ActionForNativePage(action), state);
case POP: case POP:
if (action.pageName) { if (action.pageName) {
return NavigationStack.router.getStateForAction(ActionForNativePage(action.pageName), state); return NavigationStack.router.getStateForAction(ActionForNativePage(action), state);
} }
return NavigationStack.router.getStateForAction(NavigationActions.back(), state); return NavigationStack.router.getStateForAction(NavigationActions.back(), state);
case TAB: case TAB:
......
...@@ -38,6 +38,7 @@ class MainApp extends Component { ...@@ -38,6 +38,7 @@ class MainApp extends Component {
//console.log('handleAppChange:') //console.log('handleAppChange:')
if (currentAppState === 'active') { if (currentAppState === 'active') {
//checkForUpdate(true) //checkForUpdate(true)
console.log('handleAppChange','active');
} }
} }
......
...@@ -21,6 +21,7 @@ import themeAction from '../theme/action'; ...@@ -21,6 +21,7 @@ import themeAction from '../theme/action';
import NavigationBar from '../components/NavigationBar'; import NavigationBar from '../components/NavigationBar';
import BackButton from '../components/BackButton'; import BackButton from '../components/BackButton';
import Button from '../components/ThemeButton'; import Button from '../components/ThemeButton';
import { NavigationEvents } from "react-navigation";
type Props = {}; type Props = {};
const styles = StyleSheet.create({ const styles = StyleSheet.create({
...@@ -37,8 +38,11 @@ const styles = StyleSheet.create({ ...@@ -37,8 +38,11 @@ const styles = StyleSheet.create({
class ThemePage extends Component<Props> { class ThemePage extends Component<Props> {
render() { render() {
const { theme, setCurrentTheme } = this.props; const { theme, setCurrentTheme } = this.props;
console.log('ThemePage:', this.props)
this.props.navigation.isFirstRouteInParent()
return ( return (
<View style={styles.container}> <View style={styles.container}>
<NavigationBar <NavigationBar
...@@ -66,6 +70,12 @@ class ThemePage extends Component<Props> { ...@@ -66,6 +70,12 @@ class ThemePage extends Component<Props> {
}} }}
title="切换红色主题" title="切换红色主题"
/> />
<NavigationEvents
onWillFocus={payload => console.log('onWillFocus',payload)}
onDidFocus={() => console.log('onDidFocus')}
onWillBlur={payload => console.log('onWillBlur',payload)}
onDidBlur={payload => console.log('onDidBlur',payload)}
/>
</View> </View>
); );
} }
......
...@@ -36,8 +36,6 @@ const styles = StyleSheet.create({ ...@@ -36,8 +36,6 @@ const styles = StyleSheet.create({
androidPad: { androidPad: {
height: 88, height: 88,
}, },
backgroundColor: '#0074E1',
// backgroundColor: 'rgb(42,85,161)',
flexDirection: 'row', flexDirection: 'row',
}, },
left: { left: {
......
...@@ -81,6 +81,7 @@ Row ...@@ -81,6 +81,7 @@ Row
); );
render() { render() {
const { theme } = this.props
const data = []; const data = [];
for (let section = 1; section <= 10; section += 1) { for (let section = 1; section <= 10; section += 1) {
const sContent = { items: [] }; const sContent = { items: [] };
...@@ -90,7 +91,7 @@ Row ...@@ -90,7 +91,7 @@ Row
data.push(sContent); data.push(sContent);
} }
return ( return (
<View style={styles.container}> <View style={theme.container}>
<NavigationBar <NavigationBar
title="Frame" title="Frame"
/> />
...@@ -100,7 +101,7 @@ Row ...@@ -100,7 +101,7 @@ Row
title="Frame" title="Frame"
/> />
<LargeList <LargeList
style={styles.container} style={{height:SCREEN_HEIGHT,backgroundColor:'yellow'}}
data={data} data={data}
heightForSection={() => 50} heightForSection={() => 50}
renderSection={this._renderSection} renderSection={this._renderSection}
......
...@@ -38,7 +38,7 @@ class JSComponentList extends Component<Props> { ...@@ -38,7 +38,7 @@ class JSComponentList extends Component<Props> {
console.log('MainPage', this.props); console.log('MainPage', this.props);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<TouchableOpacity onPress={() => { this.props.push('JSPage'); }}> <TouchableOpacity onPress={() => { this.props.push('JSPage', {test:1}); }}>
<Text style={styles.instructions}>JSComponentList</Text> <Text style={styles.instructions}>JSComponentList</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
......
...@@ -10,35 +10,42 @@ import React, { Component } from 'react'; ...@@ -10,35 +10,42 @@ import React, { Component } from 'react';
import { import {
Platform, StyleSheet, Text, View, TouchableOpacity, Platform, StyleSheet, Text, View, TouchableOpacity,
} from 'react-native'; } from 'react-native';
import { NavigationEvents, withNavigationFocus } from 'react-navigation';
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { push,tab } from '../BasicNavigator/actions'; import { push,tab } from '../BasicNavigator/actions';
import NavigationBar from '../components/NavigationBar';
import BackButton from '../components/BackButton';
type Props = {}; type Props = {};
class JSPage extends Component<Props> { function JSPage(props) {
render() { console.log('JSPage_props:', props)
console.log('JSPage', this.props); //console.log('JSPage props from lastPage', this.props.navigation.state);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<TouchableOpacity onPress={() => { this.props.push('NativePage'); }}> <NavigationBar
left={<BackButton />}
title="ThemeDemo"
/>
<TouchableOpacity onPress={() => { props.push('NativePage',{may: '22'}); }}>
<Text style={styles.instructions}>JSPage</Text> <Text style={styles.instructions}>JSPage</Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity onPress={() => { this.props.tab('ServicePage'); }}> <TouchableOpacity onPress={() => { props.tab('ServicePage'); }}>
<Text style={styles.instructions}>Tab切换</Text> <Text style={styles.instructions}>Tab切换</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
); );
}
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF', backgroundColor: '#F5FCFF',
}, },
welcome: { welcome: {
...@@ -52,8 +59,8 @@ const styles = StyleSheet.create({ ...@@ -52,8 +59,8 @@ const styles = StyleSheet.create({
marginBottom: 5, marginBottom: 5,
}, },
}); });
function propsMapping(props, extProps) { function propsMapping(props) {
const { nav } = props const { nav } = props;
return { return {
nav, nav,
}; };
......
...@@ -13,6 +13,8 @@ import { ...@@ -13,6 +13,8 @@ import {
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { pop } from '../BasicNavigator/actions'; import { pop } from '../BasicNavigator/actions';
import NavigationBar from '../components/NavigationBar';
import BackButton from '../components/BackButton';
type Props = { type Props = {
routes: Array, routes: Array,
...@@ -20,10 +22,13 @@ type Props = { ...@@ -20,10 +22,13 @@ type Props = {
}; };
class NativePage extends Component<Props> { class NativePage extends Component<Props> {
render() { render() {
console.log('NativePage', this.props); //console.log('NativePage props from lastPage', this.props.navigation.state);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<NavigationBar
left={<BackButton />}
title="ThemeDemo"
/>
<Text style={styles.instructions}>NativePage</Text> <Text style={styles.instructions}>NativePage</Text>
<TouchableOpacity onPress={() => { <TouchableOpacity onPress={() => {
...@@ -43,8 +48,6 @@ class NativePage extends Component<Props> { ...@@ -43,8 +48,6 @@ class NativePage extends Component<Props> {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF', backgroundColor: '#F5FCFF',
}, },
welcome: { welcome: {
...@@ -58,8 +61,7 @@ const styles = StyleSheet.create({ ...@@ -58,8 +61,7 @@ const styles = StyleSheet.create({
marginBottom: 5, marginBottom: 5,
}, },
}); });
function propsMapping(props, extProps) { function propsMapping(props) {
console.log(extProps);
const { nav } = props; const { nav } = props;
return { return {
routes: nav ? nav.routes : [], routes: nav ? nav.routes : [],
......
...@@ -20,8 +20,8 @@ const ApplicationStyles = { ...@@ -20,8 +20,8 @@ const ApplicationStyles = {
}, },
container: { container: {
flex: 1, flex: 1,
paddingTop: Metrics.baseMargin, //paddingTop: Metrics.baseMargin,
backgroundColor: Colors.transparent, backgroundColor: Colors.background,
}, },
section: { section: {
margin: Metrics.section, margin: Metrics.section,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* charcoal : string, text : string, eggplant : string, ricePaper : string}} * charcoal : string, text : string, eggplant : string, ricePaper : string}}
*/ */
const colors = { const colors = {
background: '#1F0808', background: '#F4F5F5',
clear: 'rgba(0,0,0,0)', clear: 'rgba(0,0,0,0)',
facebook: '#3b5998', facebook: '#3b5998',
transparent: 'rgba(0,0,0,0)', transparent: 'rgba(0,0,0,0)',
......
/**
* @flow
*
*/
type Result = "GREATER_THEN" | "EQUAL" | "LESS_THEN"
export const GREATER_THEN = 'GREATER_THEN'
export const EQUAL = 'EQUAL'
export const LESS_THEN = 'LESS_THEN'
export function versionCheck(currentVersionString: string, targetVersionString: string): Result {
function numberialVersion(versionText) {
return versionText.split('.').map((i) => parseInt(i, 10))
}
function compare(currentVersion, targetVersion) {
const [current, ...restCurrent] = currentVersion
const [target, ...restTarget] = targetVersion
if (current == null && target == null) {
return EQUAL
}
if (current === target) {
return compare(restCurrent, restTarget)
}
if (current > target) return GREATER_THEN
return LESS_THEN
}
return compare(
numberialVersion(currentVersionString),
numberialVersion(targetVersionString),
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment