summaryrefslogtreecommitdiffhomepage
path: root/app/components/NavigationBar.js
blob: c1a5daab1e97f8ff11323d67e002817d19f944f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// @flow

import * as React from 'react';
import { Button, Component, Text, View, Styles } from 'reactxp';
import Img from './Img';
import { colors } from '../config';

const styles = {
  navigationBar: {
    default: Styles.createViewStyle({
      flex: 0,
      alignItems: 'flex-start',
      marginLeft: 12,
    }),
    darwin: Styles.createViewStyle({
      marginTop: 24,
    }),
    windows: Styles.createViewStyle({
      marginTop: 24,
    }),
    linux: Styles.createViewStyle({
      marginTop: 12,
    }),
  },
  closeBarItem: {
    default: Styles.createViewStyle({
      cursor: 'default',
    }),
    icon: Styles.createViewStyle({
      flex: 0,
      opacity: 0.6,
    }),
  },
  backBarButton: {
    default: Styles.createViewStyle({
      borderWidth: 0,
      padding: 0,
      margin: 0,
      cursor: 'default',
    }),
    content: Styles.createViewStyle({
      flexDirection: 'row',
      alignItems: 'center',
    }),
    label: Styles.createTextStyle({
      fontFamily: 'Open Sans',
      fontSize: 13,
      fontWeight: '600',
      color: colors.white60,
    }),
    icon: Styles.createViewStyle({
      opacity: 0.6,
      marginRight: 8,
    }),
  },
};

export default class NavigationBar extends Component {
  render() {
    return (
      <View style={[styles.navigationBar.default, styles.navigationBar[process.platform]]}>
        {this.props.children}
      </View>
    );
  }
}

export class CloseBarItem extends Component {
  props: {
    action: () => void,
  };
  render() {
    return (
      <Button style={[styles.closeBarItem.default]} onPress={this.props.action}>
        <Img height={24} width={24} style={[styles.closeBarItem.icon]} source="icon-close" />
      </Button>
    );
  }
}

export class BackBarItem extends Component {
  props: {
    title: string,
    action: () => void,
  };
  render() {
    return (
      <Button style={styles.backBarButton.default} onPress={this.props.action}>
        <View style={styles.backBarButton.content}>
          <Img style={styles.backBarButton.icon} source="icon-back" />
          <Text style={styles.backBarButton.label}>{this.props.title}</Text>
        </View>
      </Button>
    );
  }
}