summaryrefslogtreecommitdiff
path: root/src/Components/PortalPanel.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Components/PortalPanel.tsx')
-rw-r--r--src/Components/PortalPanel.tsx25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/Components/PortalPanel.tsx b/src/Components/PortalPanel.tsx
index d49d88a..e372259 100644
--- a/src/Components/PortalPanel.tsx
+++ b/src/Components/PortalPanel.tsx
@@ -1,18 +1,20 @@
import React, { Component, PureComponent } from 'react';
-import { StyleSheet, View, Text, GestureResponderEvent, ActivityIndicator, Image } from 'react-native';
+import { StyleSheet, View, Text, GestureResponderEvent, ActivityIndicator, Image, Dimensions, Button, Linking } from 'react-native';
// import { Button } from 'react-native-vector-icons/FontAwesome';
import { getStatusBarHeight } from '../helper';
import { connect } from 'react-redux';
import actions from '../Actions/actions';
import { Portal } from '../Api/types';
import { bindActionCreators } from 'redux';
-import { COLORS_FRACTION } from '../colors';
+import { COLORS_FRACTION, RESO_NRG, COLORS_LVL, COLORS_MOD, MOD_TYPE, NavTo } from '../constants';
type Props = {
guid: string
portal?: Portal
}
+const { width, height } = Dimensions.get("screen")
+
class PortalPanel extends PureComponent<Props> {
static navigationOptions = ({ navigation }) => {
return {
@@ -41,21 +43,33 @@ class PortalPanel extends PureComponent<Props> {
<Text style={styles.subtitle}>Уровeнь: {portal.level}, здоровье: {portal.power}</Text>
<Text style={styles.subtitle}>Владелец: <Text style={[styles.user, { color: COLORS_FRACTION[portal.fraction] }]}>{portal.owner || 'нет'}</Text></Text>
<Text style={styles.subtitle}>Дата: {portal.timestamp && (new Date(portal.timestamp)).toLocaleString()}</Text>
+ <Text style={styles.subtitle}>Адрес: {portal.address || 'загрузка...'}</Text>
</View>
</View>
<Text style={styles.title}>Резонаторы</Text>
<View>
{portal.resonators && portal.resonators.map((r, idx) =>
- r ? (<Text style={styles.subtitle}>{idx + 1}: {r[1]} [{r[2]}] - {r[0]}</Text>) : (<Text style={styles.subtitle}>{idx + 1}: нет</Text>)
+ r ?
+ (<Text key={idx} style={[styles.subtitle, { color: COLORS_LVL[r[1]] }]}>{idx + 1}: {r[1]} [{r[2]}/{RESO_NRG[r[1]]}] - {r[0]}</Text>) :
+ (<Text key={idx} style={styles.subtitle}>{idx + 1}: нет</Text>)
)}
{(!portal.resonators || portal.resonators.length == 0) && (<Text style={styles.subtitle}>нет</Text>)}
</View>
<Text style={styles.title}>Моды</Text>
<View>
{portal.mods && portal.mods.map((r, idx) =>
- r ? (<Text style={styles.subtitle}>{idx + 1}: {r[1]} [{r[2]}] - {r[0]}</Text>) : (<Text style={styles.subtitle}>{idx + 1}: нет</Text>)
+ r ?
+ (<Text key={idx} style={[styles.subtitle, { color: COLORS_MOD[r[2]] }]}>{idx + 1}: {MOD_TYPE[r[1]] || r[1]} [{r[2]}] - {r[0]}</Text>) :
+ (<Text key={idx} style={styles.subtitle}>{idx + 1}: нет</Text>)
)}
</View>
+ <Text style={styles.title}>Навигация к порталу</Text>
+ <View>
+ <Button onPress={() => Linking.openURL(NavTo(portal.coords.latitude, portal.coords.longitude, portal.name, 'ymaps'))} title={'Яндекс Навигатор'} />
+ <Button onPress={() => Linking.openURL(NavTo(portal.coords.latitude, portal.coords.longitude, portal.name, 'maps.me'))} title={'Maps.me'} />
+ <Button onPress={() => Linking.openURL(NavTo(portal.coords.latitude, portal.coords.longitude, portal.name, '2gis'))} title={'2ГИС'} />
+ <Button onPress={() => Linking.openURL(NavTo(portal.coords.latitude, portal.coords.longitude, portal.name, 'default'))} title={'Другие карты/навигаторы'} />
+ </View>
</View>
);
}
@@ -78,7 +92,8 @@ const styles = StyleSheet.create({
flexDirection: 'row',
},
panelRight: {
- paddingLeft: 8
+ paddingLeft: 8,
+ width: width - 116
},
title: {
fontWeight: 'bold',