88import React , { Component } from 'react' ;
99import {
1010 Appearance ,
11+ Button ,
1112 SafeAreaView ,
12- ScrollView ,
13+ SectionList ,
1314 StatusBar ,
14- View ,
15+ StyleSheet ,
16+ Text ,
1517} from 'react-native' ;
16-
17- import { Colors } from 'react-native/Libraries/NewAppScreen' ;
18- import Section from './src/mainView/Section' ;
1918import Header from './src/mainView/Header' ;
2019import AppViewModel from './src/AppViewModel' ;
20+ import Clock from './src/mainView/Clock' ;
21+ import { Colors } from 'react-native/Libraries/NewAppScreen' ;
2122
2223class App extends Component {
2324 viewModel : AppViewModel = new AppViewModel ( Appearance . getColorScheme ( ) ) ;
@@ -31,6 +32,10 @@ class App extends Component {
3132 walletCAddress : '' ,
3233 walletEvmAddress : '' ,
3334 isDarkMode : false ,
35+ externalAddressesX : [ ] ,
36+ externalAddressesP : [ ] ,
37+ addressC : '' ,
38+ availableX : '' ,
3439 } ;
3540 }
3641
@@ -44,9 +49,7 @@ class App extends Component {
4449 this . viewModel . avaxPrice . subscribe ( value => {
4550 this . setState ( { avaxPrice : value } ) ;
4651 } ) ;
47- this . viewModel . mnemonic . subscribe ( value => {
48- this . setState ( { mnemonic : value } ) ;
49- } ) ;
52+ this . setState ( { mnemonic : this . viewModel . mnemonic } ) ;
5053 this . viewModel . walletCAddress . subscribe ( value => {
5154 this . setState ( { walletCAddress : value } ) ;
5255 } ) ;
@@ -59,36 +62,97 @@ class App extends Component {
5962 this . viewModel . backgroundStyle . subscribe ( value => {
6063 this . setState ( { backgroundStyle : value } ) ;
6164 } ) ;
65+ this . viewModel . externalAddressesX . subscribe ( value => {
66+ this . setState ( { externalAddressesX : value } ) ;
67+ } ) ;
68+ this . viewModel . externalAddressesP . subscribe ( value => {
69+ this . setState ( { externalAddressesP : value } ) ;
70+ } ) ;
71+ this . viewModel . addressC . subscribe ( value => {
72+ this . setState ( { addressC : value } ) ;
73+ } ) ;
74+ this . viewModel . availableX . subscribe ( value => {
75+ this . setState ( { availableX : value } ) ;
76+ } ) ;
6277 }
63-
6478 render ( ) {
6579 console . log ( 'render' ) ;
80+
81+ const sectionListData = [
82+ {
83+ title : 'Avax Price' ,
84+ data : [ '$' + this . state . avaxPrice ] ,
85+ } ,
86+ {
87+ title : 'Mnemonic' ,
88+ data : [ this . state . mnemonic ] ,
89+ } ,
90+ {
91+ title : 'External addresses X' ,
92+ data : [ this . state . externalAddressesX ] ,
93+ } ,
94+ {
95+ title : 'External addresses P' ,
96+ data : [ this . state . externalAddressesP ] ,
97+ } ,
98+ {
99+ title : 'External addresses C' ,
100+ data : [ this . state . addressC ] ,
101+ } ,
102+ {
103+ title : 'Available (X)' ,
104+ data : [ this . state . availableX ] ,
105+ } ,
106+ ] ;
66107 return (
67108 < SafeAreaView style = { this . state . backgroundStyle } >
68109 < StatusBar
69110 barStyle = { this . state . isDarkMode ? 'light-content' : 'dark-content' }
70111 />
71- < ScrollView
72- contentInsetAdjustmentBehavior = "always"
73- style = { this . state . backgroundStyle } >
74- < Header />
75- < View
76- style = { {
77- backgroundColor : this . state . isDarkMode
78- ? Colors . black
79- : Colors . white ,
80- } } >
81- < Section title = "Avax price" > ${ this . state . avaxPrice } </ Section >
82- < Section title = "Mnemonic" > { this . state . mnemonic } </ Section >
83- < Section title = "C addr" > { this . state . walletCAddress } </ Section >
84- < Section title = "Evm addr bech" >
85- { this . state . walletEvmAddress }
86- </ Section >
87- </ View >
88- </ ScrollView >
112+ < Clock />
113+ < Header />
114+ < SectionList
115+ sections = { sectionListData }
116+ renderItem = { ( { item} ) => (
117+ < Text
118+ style = { [
119+ styles . item ,
120+ { color : this . state . isDarkMode ? Colors . light : Colors . dark } ,
121+ ] } >
122+ { item }
123+ </ Text >
124+ ) }
125+ renderSectionHeader = { ( { section} ) => (
126+ < Text style = { styles . sectionHeader } > { section . title } </ Text >
127+ ) }
128+ keyExtractor = { ( item , index ) => index }
129+ />
130+ < Button
131+ title = { 'Reset Hd indices' }
132+ onPress = { ( ) => this . viewModel . onResetHdIndices ( ) }
133+ />
89134 </ SafeAreaView >
90135 ) ;
91136 }
92137}
93-
138+ const styles = StyleSheet . create ( {
139+ container : {
140+ flex : 1 ,
141+ paddingTop : 22 ,
142+ } ,
143+ sectionHeader : {
144+ paddingTop : 2 ,
145+ paddingLeft : 10 ,
146+ paddingRight : 10 ,
147+ paddingBottom : 2 ,
148+ fontSize : 14 ,
149+ fontWeight : 'bold' ,
150+ backgroundColor : 'rgba(247,247,247,1.0)' ,
151+ } ,
152+ item : {
153+ padding : 10 ,
154+ fontSize : 18 ,
155+ height : 44 ,
156+ } ,
157+ } ) ;
94158export default App ;
0 commit comments