-
Notifications
You must be signed in to change notification settings - Fork 255
/
Main.ui.js
806 lines (746 loc) · 34.1 KB
/
Main.ui.js
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
// @flow
import React, { Component, Fragment } from 'react'
import { Image, Linking, TouchableWithoutFeedback, View, YellowBox } from 'react-native'
import { Actions, Drawer, Router, Scene, Stack, Tabs } from 'react-native-router-flux'
import slowlog from 'react-native-slowlog'
import { connect } from 'react-redux'
import * as URI from 'uri-js'
import ENV from '../../env.json'
import MenuIcon from '../assets/images/MenuButton/menu.png'
import exchangeIconSelected from '../assets/images/tabbar/exchange_selected.png'
import exchangeIcon from '../assets/images/tabbar/exchange.png'
import receiveIconSelected from '../assets/images/tabbar/receive_selected.png'
import receiveIcon from '../assets/images/tabbar/receive.png'
import scanIconSelected from '../assets/images/tabbar/scan_selected.png'
import scanIcon from '../assets/images/tabbar/scan.png'
import walletIconSelected from '../assets/images/tabbar/wallets_selected.png'
import walletIcon from '../assets/images/tabbar/wallets.png'
import { CreateWalletChoiceComponent } from '../components/scenes/CreateWalletChoiceScene.js'
import ExchangeDropMenu from '../connectors/components/HeaderMenuExchangeConnector'
import RequestDropMenu from '../connectors/components/HeaderMenuRequestConnector'
import CurrencySettingsTitleConnector from '../connectors/CurrencySettingsTitleConnector.js'
import { ExchangeSettingsConnector } from '../connectors/ExchangeSettingsConnector.js'
import AddToken from '../connectors/scenes/AddTokenConnector.js'
import ChangePasswordConnector from '../connectors/scenes/ChangePasswordConnector.ui'
import ChangePinConnector from '../connectors/scenes/ChangePinConnector.ui'
import { CreateWalletAccountSelectConnector } from '../connectors/scenes/CreateWalletAccountSelectConnector.js'
import { CreateWalletAccountSetupConnector } from '../connectors/scenes/CreateWalletAccountSetupConnector.js'
import { CreateWalletImportConnector } from '../connectors/scenes/CreateWalletImportConnector.js'
import { CreateWalletReview } from '../connectors/scenes/CreateWalletReviewConnector'
import { CreateWalletSelectCrypto } from '../connectors/scenes/CreateWalletSelectCryptoConnector'
import { CreateWalletSelectFiat } from '../connectors/scenes/CreateWalletSelectFiatConnector'
import { CryptoExchangeQuoteConnector } from '../connectors/scenes/CryptoExchangeQuoteConnector.js'
import { CryptoExchangeSceneConnector as ExchangeConnector } from '../connectors/scenes/CryptoExchangeSceneConnector'
import CurrencySettings from '../connectors/scenes/CurrencySettingsConnector'
import DefaultFiatSettingConnector from '../connectors/scenes/DefaultFiatSettingConnector'
import EdgeLoginSceneConnector from '../connectors/scenes/EdgeLoginSceneConnector'
import EditToken from '../connectors/scenes/EditTokenConnector.js'
import LoginConnector from '../connectors/scenes/LoginConnector'
import ManageTokens from '../connectors/scenes/ManageTokensConnector.js'
import OtpSettingsSceneConnector from '../connectors/scenes/OtpSettingsSceneConnector.js'
import PasswordRecoveryConnector from '../connectors/scenes/PasswordRecoveryConnector.js'
import Request from '../connectors/scenes/RequestConnector.js'
import Scan from '../connectors/scenes/ScanConnector'
import SendConfirmation from '../connectors/scenes/SendConfirmationConnector.js'
import SettingsOverview from '../connectors/scenes/SettingsOverviewConnector'
import TransactionDetails from '../connectors/scenes/TransactionDetailsConnector.js'
import TransactionListConnector from '../connectors/scenes/TransactionListConnector'
import TransactionsExportSceneConnector from '../connectors/scenes/TransactionsExportSceneConnector'
import WalletList from '../connectors/scenes/WalletListConnector'
import SendConfirmationOptions from '../connectors/SendConfirmationOptionsConnector.js'
import SpendingLimitsConnector from '../connectors/SpendingLimitsConnector.js'
import * as Constants from '../constants/indexConstants'
import s from '../locales/strings.js'
import DeepLinkingManager from '../modules/DeepLinkingManager.js'
import PermissionsManager, { type Permission, PermissionStrings } from '../modules/PermissionsManager.js'
import ControlPanel from '../modules/UI/components/ControlPanel/ControlPanelConnector'
import T from '../modules/UI/components/FormattedText/index'
import BackButton from '../modules/UI/components/Header/Component/BackButton.ui'
import { ExitButton } from '../modules/UI/components/Header/Component/ExitButton.js'
import HelpButton from '../modules/UI/components/Header/Component/HelpButton.ui.js'
import Header from '../modules/UI/components/Header/Header.ui'
import WalletName from '../modules/UI/components/Header/WalletName/WalletNameConnector.js'
import { ifLoggedIn } from '../modules/UI/components/LoginStatus/LoginStatus.js'
import { PasswordRecoveryReminderModalConnector } from '../modules/UI/components/PasswordRecoveryReminderModal/PasswordRecoveryReminderModalConnector.js'
import { passwordReminderModalConnector as PasswordReminderModal } from '../modules/UI/components/PasswordReminderModal/indexPasswordReminderModal.js'
import { handlePluginBack, renderPluginBackButton } from '../modules/UI/scenes/Plugins/BackButton.js'
import { styles } from '../styles/MainStyle.js'
import { scale } from '../util/scaling.js'
import { trackEvent } from '../util/tracking.js'
import { ChangeMiningFeeScene } from './scenes/ChangeMiningFeeScene.js'
import { CreateWalletName } from './scenes/CreateWalletNameScene.js'
import { CryptoExchangeQuoteProcessingScreenComponent } from './scenes/CryptoExchangeQuoteProcessingScene.js'
import { LoadingScene } from './scenes/LoadingScene.js'
import { OnBoardingComponent } from './scenes/OnBoardingScene.js'
import { LegacyPluginViewConnect, renderLegacyPluginBackButton } from './scenes/PluginViewLegacyScene.js'
import { PluginListScene } from './scenes/PluginViewListScene.js'
import { PluginViewConnect } from './scenes/PluginViewScene.js'
import { SwapActivateShapeshiftScene } from './scenes/SwapActivateShapeshiftScene.js'
import { TermsOfServiceComponent } from './scenes/TermsOfServiceScene.js'
import { showError, showToast } from './services/AirshipInstance.js'
const RouterWithRedux = connect()(Router)
const tabBarIconFiles: { [tabName: string]: string } = {}
tabBarIconFiles[Constants.WALLET_LIST] = walletIcon
tabBarIconFiles[Constants.REQUEST] = receiveIcon
tabBarIconFiles[Constants.SCAN] = scanIcon
tabBarIconFiles[Constants.TRANSACTION_LIST] = exchangeIcon
tabBarIconFiles[Constants.EXCHANGE] = exchangeIcon
const tabBarIconFilesSelected: { [tabName: string]: string } = {}
tabBarIconFilesSelected[Constants.WALLET_LIST] = walletIconSelected
tabBarIconFilesSelected[Constants.REQUEST] = receiveIconSelected
tabBarIconFilesSelected[Constants.SCAN] = scanIconSelected
tabBarIconFilesSelected[Constants.TRANSACTION_LIST] = exchangeIconSelected
tabBarIconFilesSelected[Constants.EXCHANGE] = exchangeIconSelected
const TRANSACTION_DETAILS = s.strings.title_transaction_details
const WALLETS = s.strings.title_wallets
const CREATE_WALLET_IMPORT = s.strings.create_wallet_import_title
const CREATE_WALLET_SELECT_CRYPTO = s.strings.title_create_wallet_select_crypto
const CREATE_WALLET_SELECT_FIAT = s.strings.title_create_wallet_select_fiat
const CREATE_WALLET = s.strings.title_create_wallet
const CREATE_WALLET_ACCOUNT_SETUP = s.strings.create_wallet_create_account
const CREATE_WALLET_ACCOUNT_ACTIVATE = s.strings.create_wallet_account_activate
const TRANSACTIONS_EXPORT = s.strings.title_export_transactions
const REQUEST = s.strings.title_request
const SCAN = s.strings.title_scan
const EDGE_LOGIN = s.strings.title_edge_login
const EXCHANGE = s.strings.title_exchange
const CHANGE_MINING_FEE = s.strings.title_change_mining_fee
const BACK = s.strings.title_back
const MANAGE_TOKENS = s.strings.title_manage_tokens
const ADD_TOKEN = s.strings.title_add_token
const EDIT_TOKEN = s.strings.title_edit_token
const SETTINGS = s.strings.title_settings
const EXCHANGE_SETTINGS = s.strings.settings_exchange_settings
const CHANGE_PASSWORD = s.strings.title_change_password
const CHANGE_PIN = s.strings.title_change_pin
const SPENDING_LIMITS = s.strings.spending_limits
const PASSWORD_RECOVERY = s.strings.title_password_recovery
const OTP = s.strings.title_otp
const DEFAULT_FIAT = s.strings.title_default_fiat
const TERMS_OF_SERVICE = s.strings.title_terms_of_service
type Props = {
hideWalletListModal: () => mixed,
requestPermission: (permission: Permission) => void,
username?: string,
dispatchEnableScan: () => void,
dispatchDisableScan: () => void,
urlReceived: string => void,
showReEnableOtpModal: () => void,
checkEnabledExchanges: () => void,
openDrawer: () => void,
dispatchAddressDeepLinkReceived: (addressDeepLinkData: Object) => any,
deepLinkPending: boolean,
checkAndShowGetCryptoModal: (?string) => void,
logout(): () => mixed
}
export default class Main extends Component<Props> {
backPressedOnce: boolean
constructor (props: Props) {
super(props)
slowlog(this, /.*/, global.slowlogOptions)
if (ENV.HIDE_IS_MOUNTED) {
YellowBox.ignoreWarnings([
'Warning: isMounted(...) is deprecated',
'Module RCTImageLoader',
'The scalesPageToFit property is not supported when useWebKit = true'
])
}
}
componentDidMount () {
trackEvent('AppStart')
Linking.getInitialURL()
.then(url => {
if (url) {
this.doDeepLink(url)
}
// this.navigate(url);
})
.catch(showError)
Linking.addEventListener('url', this.handleOpenURL)
}
handleOpenURL = (event: Object) => {
this.doDeepLink(event.url)
}
doDeepLink (url: string) {
const parsedUri = URI.parse(url)
switch (parsedUri.scheme) {
case 'edge':
case 'airbitz':
case 'edge-ret':
case 'airbitz-ret':
case 'https':
if (parsedUri.host === 'recovery' || parsedUri.host === 'recovery.edgesecure.co') {
this.handleRecoveryToken(parsedUri)
} else {
this.handleAddress(parsedUri, url)
}
break
case 'bitcoin':
case 'bitcoincash':
case 'ethereum':
case 'rsk':
case 'dash':
case 'litecoin':
this.handleAddress(parsedUri, url)
break
}
}
handleRecoveryToken (parsedUri: URI) {
const query = parsedUri.query
if (!query || !query.includes('token=')) {
return
}
const splitArray = query.split('token=')
const nextString = splitArray[1]
const finalArray = nextString.split('&')
const token = finalArray[0]
this.props.urlReceived(token)
}
handleAddress (parsedUri: URI, url: string) {
const addressDeepLinkData = {}
const currencyCode = this.convertCurrencyCodeFromScheme(parsedUri.scheme)
addressDeepLinkData.currencyCode = currencyCode
addressDeepLinkData.uri = url
this.props.dispatchAddressDeepLinkReceived(addressDeepLinkData)
}
convertCurrencyCodeFromScheme (scheme: string) {
switch (scheme) {
case 'bitcoin':
return 'BTC'
case 'bitcoincash':
return 'BCH'
case 'ethereum':
return 'ETH'
case 'litecoin':
return 'LTC'
case 'dash':
return 'DASH'
case 'rsk':
return 'RBTC'
default:
console.log('Unrecognized currency URI scheme')
return null
}
}
render () {
return (
<Fragment>
<RouterWithRedux backAndroidHandler={this.handleBack}>
<Stack key={Constants.ROOT} hideNavBar panHandlers={null}>
<Scene key={Constants.LOGIN} initial component={LoginConnector} username={this.props.username} />
<Scene key={Constants.ONBOARDING} navTransparent={true} component={OnBoardingComponent} />
<Scene
key={Constants.TRANSACTION_DETAILS}
navTransparent={true}
onEnter={() => this.props.requestPermission(PermissionStrings.CONTACTS)}
clone
component={TransactionDetails}
renderTitle={this.renderTitle(TRANSACTION_DETAILS)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderMenuButton()}
/>
<Drawer key={Constants.EDGE} hideNavBar contentComponent={ControlPanel} hideDrawerButton={true} drawerPosition="right" drawerWidth={scale(280)}>
{/* Wrapper Scene needed to fix a bug where the tabs would reload as a modal ontop of itself */}
<Scene key={'AllMyTabs'} hideNavBar>
<Tabs
key={Constants.EDGE}
swipeEnabled={false}
navTransparent={true}
tabBarPosition={'bottom'}
showLabel={true}
tabBarStyle={styles.footerTabStyles}
>
<Stack key={Constants.WALLET_LIST} icon={this.icon(Constants.WALLET_LIST)} tabBarLabel={WALLETS}>
<Scene
key={Constants.WALLET_LIST_SCENE}
navTransparent={true}
component={WalletList}
renderTitle={this.renderTitle(WALLETS)}
renderLeftButton={this.renderHelpButton()}
renderRightButton={this.renderMenuButton()}
/>
<Scene
key={Constants.CREATE_WALLET_CHOICE}
navTransparent={true}
component={CreateWalletChoiceComponent}
renderTitle={this.renderTitle(CREATE_WALLET)}
renderLeftButton={this.renderBackButton(WALLETS)}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CREATE_WALLET_IMPORT}
navTransparent={true}
component={CreateWalletImportConnector}
renderTitle={this.renderTitle(CREATE_WALLET_IMPORT)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CREATE_WALLET_SELECT_CRYPTO}
navTransparent={true}
component={CreateWalletSelectCrypto}
renderTitle={this.renderTitle(CREATE_WALLET_SELECT_CRYPTO)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CREATE_WALLET_NAME}
navTransparent={true}
component={CreateWalletName}
renderTitle={this.renderTitle(CREATE_WALLET)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CREATE_WALLET_SELECT_FIAT}
navTransparent={true}
component={CreateWalletSelectFiat}
renderTitle={this.renderTitle(CREATE_WALLET_SELECT_FIAT)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CREATE_WALLET_REVIEW}
navTransparent={true}
component={CreateWalletReview}
renderTitle={this.renderTitle(CREATE_WALLET)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CREATE_WALLET_ACCOUNT_SETUP}
navTransparent={true}
component={CreateWalletAccountSetupConnector}
renderTitle={this.renderTitle(CREATE_WALLET_ACCOUNT_SETUP)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderHelpButton()}
/>
<Scene
key={Constants.CREATE_WALLET_ACCOUNT_SELECT}
navTransparent={true}
component={CreateWalletAccountSelectConnector}
renderTitle={this.renderTitle(CREATE_WALLET_ACCOUNT_ACTIVATE)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderHelpButton()}
/>
<Scene
key={Constants.TRANSACTION_LIST}
onEnter={() => {
this.props.requestPermission(PermissionStrings.CONTACTS)
this.props.hideWalletListModal()
}}
navTransparent={true}
component={TransactionListConnector}
renderTitle={this.renderWalletListNavBar()}
renderLeftButton={this.renderBackButton(WALLETS)}
renderRightButton={this.renderMenuButton()}
/>
<Scene
key={Constants.MANAGE_TOKENS}
renderLeftButton={this.renderBackButton()}
navTransparent={true}
component={ManageTokens}
renderTitle={this.renderTitle(MANAGE_TOKENS)}
renderRightButton={this.renderEmptyButton()}
animation={'fade'}
duration={600}
/>
<Scene
key={Constants.ADD_TOKEN}
component={AddToken}
navTransparent={true}
onLeft={Actions.pop}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
renderTitle={this.renderTitle(ADD_TOKEN)}
/>
<Scene
key={Constants.EDIT_TOKEN}
component={EditToken}
navTransparent={true}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
renderTitle={this.renderTitle(EDIT_TOKEN)}
/>
<Scene
key={Constants.TRANSACTIONS_EXPORT}
navTransparent={true}
component={ifLoggedIn(TransactionsExportSceneConnector, LoadingScene)}
renderTitle={this.renderTitle(TRANSACTIONS_EXPORT)}
renderLeftButton={this.renderBackButton(WALLETS)}
renderRightButton={this.renderEmptyButton()}
/>
</Stack>
<Scene
key={Constants.REQUEST}
navTransparent={true}
onEnter={this.props.hideWalletListModal}
icon={this.icon(Constants.REQUEST)}
tabBarLabel={REQUEST}
component={Request}
renderTitle={this.renderWalletListNavBar()}
renderLeftButton={this.renderRequestMenuButton()}
renderRightButton={this.renderMenuButton()}
/>
<Stack key={Constants.SCAN} icon={this.icon(Constants.SCAN)} tabBarLabel={SCAN}>
<Scene
key={Constants.SCAN_NOT_USED}
navTransparent={true}
onEnter={props => {
this.props.requestPermission(PermissionStrings.CAMERA)
this.props.dispatchEnableScan()
this.props.hideWalletListModal()
this.props.checkAndShowGetCryptoModal(props.data)
}}
onExit={this.props.dispatchDisableScan}
component={Scan}
renderTitle={this.renderWalletListNavBar()}
renderLeftButton={this.renderHelpButton()}
renderRightButton={this.renderMenuButton()}
/>
<Scene
key={Constants.EDGE_LOGIN}
navTransparent={true}
component={EdgeLoginSceneConnector}
renderTitle={this.renderTitle(EDGE_LOGIN)}
renderLeftButton={this.renderHelpButton()}
renderRightButton={this.renderEmptyButton()}
/>
</Stack>
<Stack key={Constants.EXCHANGE} icon={this.icon(Constants.EXCHANGE)} tabBarLabel={EXCHANGE}>
<Scene
key={Constants.EXCHANGE_SCENE}
navTransparent={true}
component={ExchangeConnector}
renderTitle={this.renderTitle(EXCHANGE)}
renderLeftButton={this.renderExchangeButton()}
renderRightButton={this.renderMenuButton()}
onEnter={() => this.props.checkEnabledExchanges()}
/>
<Scene
key={Constants.EXCHANGE_QUOTE_PROCESSING_SCENE}
navTransparent={true}
hideTabBar
component={CryptoExchangeQuoteProcessingScreenComponent}
renderTitle={this.renderTitle(EXCHANGE)}
renderLeftButton={this.renderEmptyButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.EXCHANGE_QUOTE_SCENE}
navTransparent={true}
component={CryptoExchangeQuoteConnector}
renderTitle={this.renderTitle(EXCHANGE)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderMenuButton()}
/>
<Scene
key={Constants.SWAP_ACTIVATE_SHAPESHIFT}
navTransparent={true}
component={SwapActivateShapeshiftScene}
renderTitle={this.renderTitle(s.strings.title_activate_shapeshift)}
renderLeftButton={this.renderBackButton(BACK)}
renderRightButton={this.renderEmptyButton()}
onLeft={Actions.pop}
/>
</Stack>
</Tabs>
<Stack key={Constants.SEND_CONFIRMATION} hideTabBar>
<Scene
key={Constants.SEND_CONFIRMATION_NOT_USED}
navTransparent={true}
hideTabBar
panHandlers={null}
component={SendConfirmation}
renderTitle={this.renderWalletName()}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderSendConfirmationButton()}
/>
<Scene
key={Constants.CHANGE_MINING_FEE_SEND_CONFIRMATION}
navTransparent={true}
component={ChangeMiningFeeScene}
renderTitle={this.renderTitle(CHANGE_MINING_FEE)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderHelpButton()}
/>
</Stack>
<Stack key={Constants.MANAGE_TOKENS} hideTabBar>
<Scene
key={Constants.MANAGE_TOKENS_NOT_USED}
navTransparent={true}
component={ManageTokens}
renderTitle={this.renderTitle(MANAGE_TOKENS)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.ADD_TOKEN}
navTransparent={true}
component={AddToken}
renderTitle={this.renderTitle(ADD_TOKEN)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
</Stack>
<Stack key={Constants.SETTINGS_OVERVIEW_TAB} hideDrawerButton={true}>
<Scene
key={Constants.SETTINGS_OVERVIEW}
navTransparent={true}
onEnter={() => this.props.showReEnableOtpModal()}
component={SettingsOverview}
renderTitle={this.renderTitle(SETTINGS)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CHANGE_PASSWORD}
navTransparent={true}
component={ChangePasswordConnector}
renderTitle={this.renderTitle(CHANGE_PASSWORD)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.CHANGE_PIN}
navTransparent={true}
component={ChangePinConnector}
renderTitle={this.renderTitle(CHANGE_PIN)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.OTP_SETUP}
navTransparent={true}
component={OtpSettingsSceneConnector}
renderTitle={this.renderTitle(OTP)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.RECOVER_PASSWORD}
navTransparent={true}
component={PasswordRecoveryConnector}
renderTitle={this.renderTitle(PASSWORD_RECOVERY)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.SPENDING_LIMITS}
navTransparent={true}
component={SpendingLimitsConnector}
renderTitle={this.renderTitle(SPENDING_LIMITS)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.EXCHANGE_SETTINGS}
navTransparent={true}
component={ExchangeSettingsConnector}
renderTitle={this.renderTitle(EXCHANGE_SETTINGS)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
{this.renderCurrencySettings()}
<Scene
key={Constants.DEFAULT_FIAT_SETTING}
navTransparent={true}
component={DefaultFiatSettingConnector}
renderTitle={this.renderTitle(DEFAULT_FIAT)}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
<Scene
key={Constants.SWAP_ACTIVATE_SHAPESHIFT}
navTransparent={true}
component={SwapActivateShapeshiftScene}
renderTitle={this.renderTitle(s.strings.title_activate_shapeshift)}
renderLeftButton={this.renderBackButton(BACK)}
renderRightButton={this.renderEmptyButton()}
onLeft={Actions.pop}
/>
</Stack>
<Stack key={Constants.PLUGIN_LIST} hideDrawerButton={true}>
<Scene
key={Constants.PLUGIN_LIST}
navTransparent={true}
component={PluginListScene}
renderTitle={props =>
this.renderTitle(
props.direction === 'buy'
? s.strings.title_plugin_buy
: props.direction === 'sell'
? s.strings.title_plugin_sell
: s.strings.title_plugin_buysell
)
}
renderLeftButton={this.renderBackButton(BACK)}
renderRightButton={this.renderEmptyButton()}
onLeft={Actions.pop}
/>
<Scene
key={Constants.PLUGIN_VIEW}
navTransparent={true}
component={ifLoggedIn(PluginViewConnect, LoadingScene)}
renderTitle={props => this.renderTitle(props.plugin.name)}
renderLeftButton={renderPluginBackButton(BACK)}
renderRightButton={this.renderExitButton()}
/>
<Scene
key={Constants.PLUGIN_VIEW_LEGACY}
navTransparent={true}
component={ifLoggedIn(LegacyPluginViewConnect, LoadingScene)}
renderTitle={props => this.renderTitle(props.plugin.name)}
renderLeftButton={renderLegacyPluginBackButton(BACK)}
renderRightButton={this.renderExitButton()}
/>
</Stack>
<Stack key={Constants.PLUGIN_VIEW_DEEP} hideDrawerButton={true}>
<Scene
key={Constants.PLUGIN_VIEW}
navTransparent={true}
component={ifLoggedIn(PluginViewConnect, LoadingScene)}
renderTitle={props => this.renderTitle(props.plugin.name)}
renderLeftButton={renderPluginBackButton(BACK)}
renderRightButton={this.renderExitButton()}
/>
</Stack>
<Stack key={Constants.TERMS_OF_SERVICE}>
<Scene
key={Constants.TERMS_OF_SERVICE}
navTransparent={true}
component={TermsOfServiceComponent}
renderTitle={this.renderTitle(TERMS_OF_SERVICE)}
renderLeftButton={this.renderBackButton(BACK)}
renderRightButton={this.renderEmptyButton()}
onLeft={Actions.pop}
/>
</Stack>
</Scene>
</Drawer>
</Stack>
</RouterWithRedux>
<PasswordReminderModal />
<PasswordRecoveryReminderModalConnector />
<PermissionsManager />
<DeepLinkingManager />
</Fragment>
)
}
renderCurrencySettings = () => {
const settings = []
for (const key in Constants.CURRENCY_SETTINGS) {
const { pluginName, currencyCode } = Constants.CURRENCY_SETTINGS[key]
settings.push(
<Scene
key={key}
pluginName={pluginName}
currencyCode={currencyCode}
navTransparent={true}
component={CurrencySettings}
renderTitle={
<View style={styles.titleWrapper}>
<CurrencySettingsTitleConnector key={key} cryptoKey={key} pluginName={pluginName} currencyCode={currencyCode} />
</View>
}
renderLeftButton={this.renderBackButton()}
renderRightButton={this.renderEmptyButton()}
/>
)
}
return settings
}
renderWalletListNavBar = () => {
return <Header />
}
renderWalletName = () => {
return (
<View style={styles.titleWrapper}>
<WalletName />
</View>
)
}
renderExitButton = () => {
return <ExitButton />
}
renderEmptyButton = () => {
return <BackButton />
}
renderHelpButton = () => {
return <HelpButton />
}
renderBackButton = (label: string = BACK) => {
return <BackButton withArrow onPress={this.handleBack} label={label} />
}
renderTitle = (title: string) => {
return (
<View style={styles.titleWrapper}>
<T style={styles.titleStyle}>{title}</T>
</View>
)
}
renderSpendTitle = (title: string) => {
return (
<View style={styles.titleWrapper}>
<T style={styles.titleStyle}>{'title'}</T>
</View>
)
}
renderMenuButton = () => {
return (
<TouchableWithoutFeedback onPress={this.props.openDrawer}>
<Image source={MenuIcon} />
</TouchableWithoutFeedback>
)
}
renderExchangeButton = () => {
return <ExchangeDropMenu />
}
renderRequestMenuButton = () => {
return <RequestDropMenu />
}
renderSendConfirmationButton = () => {
return <SendConfirmationOptions />
}
icon = (tabName: string) => (props: { focused: boolean }) => {
if (typeof tabBarIconFiles[tabName] === 'undefined' || typeof tabBarIconFilesSelected[tabName] === 'undefined') {
throw new Error('Invalid tabbar name')
}
let imageFile
if (props.focused) {
imageFile = tabBarIconFilesSelected[tabName]
} else {
imageFile = tabBarIconFiles[tabName]
}
return <Image source={imageFile} />
}
isCurrentScene = (sceneKey: string) => {
return Actions.currentScene === sceneKey
}
handleBack = () => {
if (this.isCurrentScene(Constants.LOGIN)) {
return false
}
if (this.isCurrentScene(Constants.WALLET_LIST_SCENE)) {
if (this.backPressedOnce) {
this.props.logout()
} else {
this.backPressedOnce = true
showToast(s.strings.back_button_tap_again_to_exit).then(() => {
this.backPressedOnce = false
})
}
return true
}
if (this.isCurrentScene(Constants.EXCHANGE_QUOTE_SCENE)) {
Actions.popTo(Constants.EXCHANGE_SCENE)
return true
}
if (this.isCurrentScene(Constants.PLUGIN_VIEW)) {
handlePluginBack()
return true
}
Actions.pop()
return true
}
}