aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/main-container.js
blob: 4fea3a6d1379376c071613035ec00b2a28f7a7e9 (plain) (blame)
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
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const AccountAndTransactionDetails = require('./account-and-transaction-details')
const Settings = require('./components/pages/settings')
const UnlockScreen = require('./components/pages/unlock')

module.exports = MainContainer

inherits(MainContainer, Component)
function MainContainer () {
  Component.call(this)
}

MainContainer.prototype.render = function () {
  // 3. summarize:
  //  switch statement goes inside MainContainer,
  //  or a method in renderPrimary
  //    - pass resulting h() to MainContainer
  //  - error checking in separate func
  //  - router in separate func
  let contents = {
    component: AccountAndTransactionDetails,
    key: 'account-detail',
    style: {},
  }

  if (this.props.isUnlocked === false) {
    switch (this.props.currentViewName) {
      case 'config':
        log.debug('rendering config screen from unlock screen.')
        return h(Settings, {key: 'config'})
      default:
        log.debug('rendering locked screen')
        contents = {
          component: UnlockScreen,
          style: {
            boxShadow: 'none',
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            background: '#F7F7F7',
            // must force 100%, because lock screen is full-width
            width: '100%',
          },
          key: 'locked',
        }
    }
  }

  return h('div.main-container', {
    style: contents.style,
  }, [
    h(contents.component, {
      key: contents.key,
    }, []),
  ])
}