diff options
Diffstat (limited to 'src/Components/PortalPanel.tsx')
-rw-r--r-- | src/Components/PortalPanel.tsx | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/Components/PortalPanel.tsx b/src/Components/PortalPanel.tsx new file mode 100644 index 0000000..6cf19c2 --- /dev/null +++ b/src/Components/PortalPanel.tsx @@ -0,0 +1,70 @@ +import React, { Component, PureComponent } from 'react'; +import { StyleSheet, View, Text, GestureResponderEvent, ActivityIndicator } from 'react-native'; +// import { Button } from 'react-native-vector-icons/FontAwesome'; +import Reactotron from 'reactotron-react-native' +import { getStatusBarHeight } from '../helper'; +import { connect } from 'react-redux'; +import actions from '../Actions/actions'; +import { Portal } from '../Api/types'; +import { bindActionCreators } from 'redux'; + +type Props = { + guid: string + portal?: Portal +} + +class PortalPanel extends PureComponent<Props> { + static navigationOptions = ({ navigation }) => { + return { + title: navigation.getParam('title', 'Загрузка...'), + }; + }; + componentWillMount() { + this.props.navigation.setParams({title: this.props.portal.name}) + } + componentDidMount() { + this.props.getPortalDetails(this.props.guid) + } + componentWillReceiveProps(next: Props) { + if (next.guid != this.props.guid) { + this.props.navigation.setParams({title: this.props.portal.name}) + this.props.getPortalDetails(next.guid) + } + } + render() { + const { portal } = this.props + if (!portal) { + return <ActivityIndicator /> + } + return ( + <View style={styles.overlay}> + <Text style={styles.title}>{portal.name}</Text> + <Text style={styles.subtitle}>Уровeнь: {portal.level}, здоровье: {portal.power}</Text> + <Text>{JSON.stringify(this.props)}</Text> + </View> + ); + } +} + +export default connect((store, props: Props) => { + const guid = props.navigation.getParam('guid') + return { + portal: store.entities.portals[guid], + guid + } +}, (dispatch) => bindActionCreators(actions, dispatch))(PortalPanel) + +const styles = StyleSheet.create({ + overlay: { + flex: 1, + padding: 8, + }, + title: { + fontWeight: 'bold', + fontSize: 22, + }, + subtitle: { + fontWeight: 'normal', + fontSize: 18, + } +});
\ No newline at end of file |