1
- import React from 'react' ;
1
+ import React , { Component } from 'react' ;
2
2
import { StyleSheet , View } from 'react-native' ;
3
3
import { observer } from 'mobx-react' ;
4
4
import PropTypes from 'prop-types' ;
5
5
import Background from '../component/background' ;
6
6
import MainContent from '../component/main-content' ;
7
7
import { Header , Title } from '../component/header' ;
8
- import { color } from '../component/style' ;
8
+ import { createStyles , maxWidth } from '../component/media-query' ;
9
+ import { color , breakWidth , smallBreakWidth } from '../component/style' ;
9
10
import { H4Text } from '../component/text' ;
10
11
import Icon from '../component/icon' ;
11
12
import ChannelIcon from '../asset/icon/channel' ;
@@ -17,6 +18,7 @@ import {
17
18
SmallBalanceLabel ,
18
19
} from '../component/label' ;
19
20
import { Button , QrButton , GlasButton , DownButton } from '../component/button' ;
21
+ import { calculateTopPadding } from '../helper' ;
20
22
21
23
//
22
24
// Home View
@@ -83,7 +85,7 @@ HomeView.propTypes = {
83
85
// Balance Display
84
86
//
85
87
86
- const balanceStyles = StyleSheet . create ( {
88
+ const baseBalanceStyles = {
87
89
wrapper : {
88
90
flex : 1 ,
89
91
justifyContent : 'center' ,
@@ -92,26 +94,61 @@ const balanceStyles = StyleSheet.create({
92
94
marginTop : 30 ,
93
95
marginBottom : 5 ,
94
96
} ,
95
- } ) ;
97
+ } ;
96
98
97
- const BalanceDisplay = ( {
98
- depositLabel,
99
- channelBalanceLabel,
100
- unitLabel,
101
- toggleDisplayFiat,
102
- } ) => (
103
- < View style = { balanceStyles . wrapper } >
104
- < Button onPress = { toggleDisplayFiat } >
105
- < BalanceLabel >
106
- < BalanceLabelNumeral > { channelBalanceLabel } </ BalanceLabelNumeral >
107
- < BalanceLabelUnit > { unitLabel } </ BalanceLabelUnit >
108
- </ BalanceLabel >
109
- < H4Text style = { balanceStyles . smallLabel } > Chain Deposit</ H4Text >
110
- < SmallBalanceLabel unit = { unitLabel } > { depositLabel } </ SmallBalanceLabel >
111
- </ Button >
112
- </ View >
99
+ const balanceStyles = createStyles (
100
+ baseBalanceStyles ,
101
+
102
+ maxWidth ( breakWidth , {
103
+ wrapper : {
104
+ width : 350 ,
105
+ } ,
106
+ } ) ,
107
+
108
+ maxWidth ( smallBreakWidth , {
109
+ wrapper : {
110
+ width : 250 ,
111
+ } ,
112
+ } )
113
113
) ;
114
114
115
+ class BalanceDisplay extends Component {
116
+ constructor ( props ) {
117
+ super ( props ) ;
118
+ this . state = {
119
+ height : 80 ,
120
+ } ;
121
+ }
122
+
123
+ render ( ) {
124
+ const {
125
+ depositLabel,
126
+ channelBalanceLabel,
127
+ unitLabel,
128
+ toggleDisplayFiat,
129
+ } = this . props ;
130
+ return (
131
+ < View style = { balanceStyles . wrapper } >
132
+ < Button onPress = { toggleDisplayFiat } >
133
+ < BalanceLabel >
134
+ < BalanceLabelNumeral > { channelBalanceLabel } </ BalanceLabelNumeral >
135
+ < BalanceLabelUnit
136
+ onLayout = { event => {
137
+ this . setState ( { height : event . nativeEvent . layout . height } ) ;
138
+ } }
139
+ style = { { paddingTop : calculateTopPadding ( this . state . height ) } }
140
+ >
141
+ { unitLabel }
142
+ </ BalanceLabelUnit >
143
+ </ BalanceLabel >
144
+ < H4Text style = { balanceStyles . smallLabel } > Chain Deposit</ H4Text >
145
+ < SmallBalanceLabel unit = { unitLabel } > { depositLabel } </ SmallBalanceLabel >
146
+ </ Button >
147
+ </ View >
148
+ ) ;
149
+ }
150
+ }
151
+
115
152
BalanceDisplay . propTypes = {
116
153
depositLabel : PropTypes . string . isRequired ,
117
154
channelBalanceLabel : PropTypes . string . isRequired ,
0 commit comments