-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
592247a
commit d67187c
Showing
13 changed files
with
372 additions
and
321 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var React = require("react-native"); | ||
|
||
// Utilities | ||
var _ = require("lodash"); | ||
|
||
var { | ||
SegmentedControlIOS | ||
} = React; | ||
|
||
module.exports = React.createClass({ | ||
render: function() { | ||
var navBarStyle = { | ||
justifyContent: "center", | ||
alignItems: "center", | ||
width: this.props.width * 6/10, | ||
}; | ||
|
||
return ( | ||
<SegmentedControlIOS | ||
enabled={true} | ||
onChange={this.props.changeScene} | ||
selectedIndex={this.props.sceneIndex} | ||
style={navBarStyle} | ||
tintColor="orange" | ||
values={["Details", "Map"]} /> | ||
) | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
'use strict'; | ||
|
||
// REACT PARTS | ||
var React = require("react-native"); | ||
var Reflux = require("reflux"); | ||
var NavBar = require("react-native-navbar"); | ||
|
||
// COMPONENTS | ||
var NavBarTitle = require("../Comps/NavBarTitle"); | ||
var NavItem = require("../Comps/NavItem"); | ||
|
||
// ACTIONS && STORES | ||
var ItemActions = require("../Actions/ItemActions"); | ||
var ItemStore = require("../Stores/ItemStore"); | ||
var HostActions = require("../Actions/HostActions"); | ||
var HostStore = require("../Stores/HostStore"); | ||
var UserActions = require("../Actions/UserActions"); | ||
var UserStore = require("../Stores/UserStore"); | ||
|
||
// SCENES | ||
var MapScene = require("../Scenes/MapScene"); | ||
var ItemDetailScene = require("../Scenes/ItemDetailScene"); | ||
|
||
// Utilities | ||
var _ = require("lodash"); | ||
|
||
var { | ||
Navigator, | ||
StyleSheet, | ||
View, | ||
} = React; | ||
|
||
var styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
}, | ||
main: { | ||
flex: 1, | ||
}, | ||
}) | ||
|
||
module.exports = React.createClass({ | ||
mixins: [Reflux.connect(HostStore), Reflux.connect(ItemStore), Reflux.connect(UserStore)], | ||
getInitialState: function() { | ||
return { | ||
author: this.props.route.passProps.author, | ||
context: this.props.route.passProps.context, | ||
dims: this.props.route.passProps.dims, | ||
imageDims: null, | ||
item: this.props.route.passProps.item, | ||
scenes: [ | ||
<ItemDetailScene | ||
currentUser={this.state.authenticatedUser} | ||
db={this.state.db} | ||
dims={this.state.dims} | ||
item={this.state.item} | ||
author={this.state.author} />, | ||
<MapScene | ||
authors={[this.state.author]} | ||
context="all" | ||
dims={this.state.dims} | ||
items={[this.state.item]} /> | ||
], | ||
sceneIndex: 0, | ||
}; | ||
}, | ||
|
||
_changeScene: function(e) { | ||
var nextIndex = e.nativeEvent.selectedSegmentedIndex; | ||
this.setState({ | ||
sceneIndex: 1 - nextIndex, | ||
}); | ||
}, | ||
|
||
_setDims: function(e) { | ||
if (this.state.dims == null) { | ||
var layout = e.nativeEvent.layout; | ||
|
||
this.setState({ | ||
dims: { | ||
height: layout.height, | ||
width: layout.width, | ||
} | ||
}); | ||
} else | ||
return; | ||
}, | ||
|
||
_renderScene: function(route, navigator) { | ||
var navBar = null; | ||
|
||
if (route.navigationBar) { | ||
navBar = React.addons.cloneWithProps(route.navigationBar, { | ||
navigator: navigator, | ||
route: route | ||
}); | ||
|
||
navBar._store.props.onPrev = function() { | ||
this.props.navigator.pop(); | ||
}.bind(this); | ||
} | ||
|
||
var Scene = this.state.scenes[this.state.sceneIndex]; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
{navBar} | ||
|
||
<View style={styles.main} onLayout={this._setDims}> | ||
{Scene} | ||
</View> | ||
</View> | ||
); | ||
}, | ||
|
||
render: function() { | ||
var navBarTitle = | ||
<NavBarTitle | ||
changeScene={this._changeScene} | ||
sceneIndex={this.state.sceneIndex} | ||
width={this.state.dims.width} />; | ||
|
||
var navBar = | ||
<NavBar | ||
title="Detail" | ||
backgroundColor="#A4A4A4" | ||
buttonsColor="#FFFFFF" | ||
titleColor="#FFFFFF" | ||
prevTitle="Back" | ||
customTitle={navBarTitle} /> | ||
|
||
return ( | ||
<Navigator | ||
renderScene={this._renderScene} | ||
initialRoute={{ | ||
component: (this.state.sceneIndex == 0) ? ItemDetailScene : MapScene, | ||
navigationBar: navBar, | ||
}} /> | ||
) | ||
} | ||
}); |
Oops, something went wrong.