-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ android.useDeprecatedNdk=true | |
|
||
org.gradle.daemon=true | ||
org.gradle.parallel=true | ||
org.gradle.jvmargs=-Xmx1536M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/pages/rightButton.js → src/components/common/rightButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {ActionConst, Reducer} from 'react-native-router-flux'; | ||
|
||
export const reducerCreate = params => { | ||
//https://github.com/aksonov/react-native-router-flux/blob/master/Example/Example.js#L43 | ||
const defaultReducer = Reducer(params); | ||
let logData = { | ||
key: null, | ||
timeStamp: null | ||
}; | ||
return (state, action) => { | ||
if (__DEV__) { | ||
console.debug('ACTION:', action); | ||
} | ||
switch (action.type) { | ||
case ActionConst.FOCUS: | ||
logData = { | ||
key: action.scene.name, | ||
timeStamp: +new Date() | ||
}; | ||
break; | ||
case ActionConst.BACK_ACTION: | ||
case ActionConst.PUSH: | ||
logData = { | ||
key: action.key, | ||
timeStamp: +new Date() | ||
}; | ||
if (__DEV__) { | ||
console.debug('logData', logData); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
return defaultReducer(state, action); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 全局场景标题样式 | ||
export const getSceneStyle = (props, computedProps) => { | ||
const style = { | ||
flex: 1, | ||
backgroundColor: '#FFF', | ||
shadowColor: null, | ||
shadowOffset: null, | ||
shadowOpacity: null, | ||
shadowRadius: null | ||
}; | ||
if (computedProps.isActive) { | ||
style.marginTop = computedProps.hideNavBar ? 0 : 64; | ||
style.marginBottom = computedProps.hideTabBar ? 0 : 50; | ||
} | ||
return style; | ||
}; | ||
|
||
// 全局导航标题样式 | ||
export const getNavigationStyle = { | ||
title: { | ||
color: '#333333', | ||
fontSize: 17, | ||
fontWeight: 'normal', | ||
}, | ||
}; | ||
|
||
export const backButtonImage = require("./../../images/icon_back.png"); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,45 @@ | ||
import React, {Component} from 'react'; | ||
import { | ||
Text, | ||
View | ||
Text, | ||
View | ||
} from 'react-native'; | ||
import {ActionConst, Router, Scene, Modal, Reducer} from 'react-native-router-flux'; | ||
|
||
// components | ||
import navBarIcon from '../components/navTabIcon'; | ||
import {getSceneStyle, getNavigationStyle, backButtonImage} from '../components/styles/routerBase'; | ||
import {reducerCreate} from '../components/common/routerBase'; | ||
import {rightButton} from '../components/common/rightButton' | ||
|
||
// pages | ||
import HomeIndex from './home/index'; | ||
import MessageIndex from './message/index'; | ||
import MessageDetail from './message/detail'; | ||
import Page3 from './page3'; | ||
import MyIndex from './my/index'; | ||
import {rightButton} from './rightButton' | ||
|
||
const reducerCreate = params => { | ||
//https://github.com/aksonov/react-native-router-flux/blob/master/Example/Example.js#L43 | ||
const defaultReducer = Reducer(params); | ||
let logData = { | ||
key: null, | ||
timeStamp: null | ||
}; | ||
return (state, action) => { | ||
if (__DEV__) { | ||
console.debug('ACTION:', action); | ||
} | ||
switch (action.type) { | ||
case ActionConst.FOCUS: | ||
logData = { | ||
key: action.scene.name, | ||
timeStamp: +new Date() | ||
}; | ||
break; | ||
case ActionConst.BACK_ACTION: | ||
case ActionConst.PUSH: | ||
//viewStayLogger(logData, action.key); | ||
logData = { | ||
key: action.key, | ||
timeStamp: +new Date() | ||
}; | ||
if (__DEV__) { | ||
console.debug('logData', logData); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
return defaultReducer(state, action); | ||
}; | ||
}; | ||
|
||
|
||
export default class RootRouter extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
} | ||
|
||
render() { | ||
let rightButtonInner = () => { | ||
return ( | ||
<View style={{flexDirection: 'row'}}> | ||
<Text style={{marginRight: 10}}>收藏</Text> | ||
<Text>分享</Text> | ||
</View> | ||
); | ||
} | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
//code getSceneStyle https://github.com/aksonov/react-native-router-flux/blob/master/Example/Example.js#L52 | ||
//api getSceneStyle https://github.com/aksonov/react-native-router-flux/blob/master/docs/API_CONFIGURATION.md#router | ||
//api getSceneStyle https://github.com/aksonov/react-native-router-flux/blob/master/docs/API_CONFIGURATION.md#scene-styles | ||
return ( | ||
<Router createReducer={reducerCreate} key='modal'> | ||
<Scene key='root' hideNavBar={false}> | ||
<Scene key='tabbar' tabs={true}> | ||
<Scene key='tab1' component={HomeIndex} title='首页' icon={navBarIcon} idx={0} initial={true}/> | ||
<Scene key='tab2' component={MessageIndex} title='消息' icon={navBarIcon} idx={1} | ||
navigationBarStyle={{}} titleStyle={{color: 'white'}}/> | ||
<Scene key='tab3' component={Page3} title='发现' icon={navBarIcon} idx={2} | ||
titleStyle={{color: 'blue'}} renderRightButton={ rightButtonInner }/> | ||
<Scene key='tab4' component={MyIndex} title='我的' icon={navBarIcon} idx={3} | ||
onLeft={() => alert("Left button!")} leftTitle="Left" | ||
onRight={() => alert("Right button")} | ||
rightTitle="Right"/> | ||
</Scene> | ||
</Scene> | ||
<Scene key='messageDetail' component={MessageDetail} title='消息详情' hideNavBar={false}/> | ||
</Router> | ||
); | ||
} | ||
render() { | ||
//code getSceneStyle https://github.com/aksonov/react-native-router-flux/blob/master/Example/Example.js#L52 | ||
//api getSceneStyle https://github.com/aksonov/react-native-router-flux/blob/master/docs/API_CONFIGURATION.md#router | ||
//api getSceneStyle https://github.com/aksonov/react-native-router-flux/blob/master/docs/API_CONFIGURATION.md#scene-styles | ||
return ( | ||
//<Router createReducer={reducerCreate} getSceneStyle={getSceneStyle} titleStyle={getNavigationStyle.title} titleOpacity={0.95} backButtonImage={backButtonImage} key='modal'> | ||
<Router key='modal'> | ||
<Scene key='root' hideNavBar={false}> | ||
<Scene key='tabbar' tabs={true}> | ||
<Scene key='tab1' component={HomeIndex} title='首页' icon={navBarIcon} idx={0} initial={true}/> | ||
<Scene key='tab2' component={MessageIndex} title='消息' icon={navBarIcon} idx={1} navigationBarStyle={{}}/> | ||
<Scene key='tab3' component={Page3} title='发现' icon={navBarIcon} idx={2} renderRightButton={ rightButton }/> | ||
<Scene key='tab4' component={MyIndex} title='我的' icon={navBarIcon} idx={3} onLeft={() => alert("Left button!")} leftTitle="Left" onRight={() => alert("Right button")} rightTitle="Right"/> | ||
</Scene> | ||
</Scene> | ||
<Scene key='messageDetail' component={MessageDetail} title='消息详情' hideNavBar={false}/> | ||
</Router> | ||
); | ||
} | ||
} |