From 3e72bfa56c860826429a842f6c128d78d4a930db Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 1 Jun 2017 19:47:08 -0400 Subject: react-native-web port of fmf app --- client/src/lib/views/home.js | 98 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 client/src/lib/views/home.js (limited to 'client/src/lib/views/home.js') diff --git a/client/src/lib/views/home.js b/client/src/lib/views/home.js new file mode 100644 index 0000000..618ce64 --- /dev/null +++ b/client/src/lib/views/home.js @@ -0,0 +1,98 @@ +import React, { Component } from 'react'; +import { + Image, + StyleSheet, + TouchableOpacity, + View, + Platform +} from 'react-native'; +import { Link } from 'react-router-dom' +import ClearText from '../components/text' +import FadeInView from 'react-native-fade-in-view' + +const sections = [ + '/timeline', + '/drones', + '/livestream', + '/information', + '/contact' +] +const labels = [ + 'SURVEILLANCE', + 'MILITARY DRONE STATISTICS', + 'LIVESTREAM', + 'ABOUT THIS WORK', + 'CONTACT', +] +const images = [ + require('../../img/nav/home/timeline.png'), + require('../../img/nav/home/drones.png'), + require('../../img/nav/home/livestream.png'), + require('../../img/nav/home/information.png'), + require('../../img/nav/home/contact.png'), +] + +export default class Home extends Component { + constructor() { + super() + } + render() { + const links = sections.map((path, i) => { + const image = images[i] + const label = labels[i] + return view(path, image, label) + }) + return ( + + {links} + + ) + } +} + +function view (path, image, label, isSelected) { + let key = ('home_' + path).replace('/','') + let imageKey = 'image_' + key + String(isSelected) + return ( + + + + {label} + + + ) +} + +const isIphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) +const isIpad = (navigator.userAgent.match(/iPad/i)) +const isAndroid = (navigator.userAgent.match(/Android/i)) +const isMobile = isIphone || isIpad || isAndroid +const isDesktop = ! isMobile + +const shortHeight = isIphone || window.innerHeight < 700 + +const buttonSide = shortHeight ? 50 : 70 +const buttonMargin = shortHeight ? 5 : 10 + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + marginTop: -80 + }, + navItem: { + justifyContent: 'center', + alignItems: 'center', + minHeight: shortHeight ? '10vh' : '13vh', + }, + text: { + lineHeight: 16, + marginBottom: shortHeight ? 5 : 10, + }, + image: { + width: buttonSide, + height: buttonSide, + margin: buttonMargin, + } +}) -- cgit v1.2.3-70-g09d2