Skip to content

Commit d4d4c41

Browse files
authored
Merge pull request #7 from ava-labs/wallet_basic_functionalities
Wallet basic functionalities
2 parents cc1835d + 63290b1 commit d4d4c41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2502
-940
lines changed

App.tsx

Lines changed: 59 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -5,170 +5,88 @@
55
* @flow strict-local
66
*/
77

8-
import React, {Component} from "react";
9-
import {
10-
Appearance,
11-
Button,
12-
SafeAreaView,
13-
SectionList,
14-
StatusBar,
15-
StyleSheet,
16-
Text,
17-
} from "react-native";
18-
import Header from "./src/mainView/Header";
19-
import AppViewModel from "./src/AppViewModel";
20-
import Clock from "./src/mainView/Clock";
21-
import {Colors} from "react-native/Libraries/NewAppScreen";
8+
import React, {Component} from 'react'
9+
import {Appearance, SafeAreaView, StatusBar,} from 'react-native'
10+
import AppViewModel, {SelectedView} from './src/AppViewModel'
11+
import CommonViewModel from './src/CommonViewModel'
12+
import Login from './src/login/Login'
13+
import MainView from './src/mainView/MainView'
14+
import Onboard from './src/onboarding/Onboard'
15+
import CreateWallet from './src/onboarding/CreateWallet'
2216

23-
type AppProps = {
24-
viewModel: AppViewModel
25-
};
26-
type AppState = {
27-
avaxPrice: number
17+
type AppProps = {}
18+
type AppState = {
2819
backgroundStyle: any
29-
mnemonic: string
30-
walletCAddress: string
31-
walletEvmAddress: string
3220
isDarkMode: boolean
33-
externalAddressesX: string[]
34-
externalAddressesP: string[]
35-
addressC: string
36-
availableX: string
37-
};
21+
selectedView: SelectedView
22+
}
3823

3924
class App extends Component<AppProps, AppState> {
40-
viewModel: AppViewModel = new AppViewModel(Appearance.getColorScheme() as string);
25+
viewModel: AppViewModel = new AppViewModel()
26+
commonViewModel: CommonViewModel = new CommonViewModel(Appearance.getColorScheme() as string)
4127

4228
constructor(props: AppProps | Readonly<AppProps>) {
43-
super(props);
29+
super(props)
4430
this.state = {
45-
avaxPrice: 0,
4631
backgroundStyle: {},
47-
mnemonic: "",
48-
walletCAddress: "",
49-
walletEvmAddress: "",
5032
isDarkMode: false,
51-
externalAddressesX: [],
52-
externalAddressesP: [],
53-
addressC: "",
54-
availableX: "",
55-
};
33+
selectedView: SelectedView.Login,
34+
}
5635
}
5736

5837
componentWillUnmount() {
59-
console.log("componentWillUnmount");
6038
}
39+
6140
componentDidMount() {
62-
console.log("componentDidMount");
63-
this.viewModel.onComponentMount();
41+
this.commonViewModel.isDarkMode.subscribe(value => {
42+
this.setState({isDarkMode: value})
43+
})
44+
this.commonViewModel.backgroundStyle.subscribe(value => {
45+
this.setState({backgroundStyle: value})
46+
})
47+
48+
this.viewModel.onComponentMount()
49+
50+
this.viewModel.selectedView.subscribe(value => {
51+
this.setState({selectedView: value})
52+
})
6453

65-
this.viewModel.avaxPrice.subscribe(value => {
66-
this.setState({avaxPrice: value});
67-
});
68-
this.setState({mnemonic: this.viewModel.mnemonic});
69-
this.viewModel.walletCAddress.subscribe(value => {
70-
this.setState({walletCAddress: value});
71-
});
72-
this.viewModel.walletEvmAddrBech.subscribe(value => {
73-
this.setState({walletEvmAddress: value});
74-
});
75-
this.viewModel.isDarkMode.subscribe(value => {
76-
this.setState({isDarkMode: value});
77-
});
78-
this.viewModel.backgroundStyle.subscribe(value => {
79-
this.setState({backgroundStyle: value});
80-
});
81-
this.viewModel.externalAddressesX.subscribe(value => {
82-
this.setState({externalAddressesX: value});
83-
});
84-
this.viewModel.externalAddressesP.subscribe(value => {
85-
this.setState({externalAddressesP: value});
86-
});
87-
this.viewModel.addressC.subscribe(value => {
88-
this.setState({addressC: value});
89-
});
90-
this.viewModel.availableX.subscribe(value => {
91-
this.setState({availableX: value});
92-
});
9354
}
94-
render() {
95-
console.log("render");
9655

97-
const sectionListData = [
98-
{
99-
title: "Avax Price",
100-
data: ["$" + this.state.avaxPrice],
101-
},
102-
{
103-
title: "Mnemonic",
104-
data: [this.state.mnemonic],
105-
},
106-
{
107-
title: "External addresses X",
108-
data: [this.state.externalAddressesX],
109-
},
110-
{
111-
title: "External addresses P",
112-
data: [this.state.externalAddressesP],
113-
},
114-
{
115-
title: "External addresses C",
116-
data: [this.state.addressC],
117-
},
118-
{
119-
title: "Available (X)",
120-
data: [this.state.availableX],
121-
},
122-
];
56+
onEnterWallet(mnemonic: string): void {
57+
this.viewModel.onEnterWallet(mnemonic)
58+
}
59+
60+
getSelectedView(): Element {
61+
switch (this.state.selectedView) {
62+
case SelectedView.CreateWallet:
63+
return <CreateWallet
64+
onSavedMyPhrase={mnemonic => this.onEnterWallet(mnemonic)}
65+
onClose={() => this.viewModel.setSelectedView(SelectedView.Onboard)}/>
66+
case SelectedView.Onboard:
67+
return <Onboard
68+
onAlreadyHaveWallet={() => this.viewModel.setSelectedView(SelectedView.Login)}
69+
onCreateWallet={() => this.viewModel.setSelectedView(SelectedView.CreateWallet)}/>
70+
case SelectedView.Login:
71+
return <Login
72+
onEnterWallet={mnemonic => this.onEnterWallet(mnemonic)}
73+
onClose={() => this.viewModel.setSelectedView(SelectedView.Onboard)}/>
74+
case SelectedView.Main:
75+
if (this.viewModel.wallet === null) throw Error("Wallet not defined")
76+
return <MainView wallet={this.viewModel.wallet} onLogout={() => this.viewModel.onLogout()}/>
77+
}
78+
}
79+
80+
render() {
12381
return (
12482
<SafeAreaView style={this.state.backgroundStyle}>
12583
<StatusBar
12684
barStyle={this.state.isDarkMode ? "light-content" : "dark-content"}
12785
/>
128-
<Clock />
129-
<Header />
130-
<SectionList
131-
sections={sectionListData}
132-
renderItem={({item}) => (
133-
<Text
134-
style={[
135-
styles.item,
136-
{color: this.state.isDarkMode ? Colors.light : Colors.dark},
137-
]}>
138-
{item}
139-
</Text>
140-
)}
141-
renderSectionHeader={({section}) => (
142-
<Text style={styles.sectionHeader}>{section.title}</Text>
143-
)}
144-
keyExtractor={(item, index) => index}
145-
/>
146-
<Button
147-
title={"Reset Hd indices"}
148-
onPress={() => this.viewModel.onResetHdIndices()}
149-
/>
86+
{this.getSelectedView()}
15087
</SafeAreaView>
151-
);
88+
)
15289
}
15390
}
154-
const styles = StyleSheet.create({
155-
container: {
156-
flex: 1,
157-
paddingTop: 22,
158-
},
159-
sectionHeader: {
160-
paddingTop: 2,
161-
paddingLeft: 10,
162-
paddingRight: 10,
163-
paddingBottom: 2,
164-
fontSize: 14,
165-
fontWeight: "bold",
166-
backgroundColor: "rgba(247,247,247,1.0)",
167-
},
168-
item: {
169-
padding: 10,
170-
fontSize: 18,
171-
height: 44,
172-
},
173-
});
174-
export default App;
91+
92+
export default App

ios/AvaxWallet.xcodeproj/project.pbxproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
49D759DDE6DA7811CD099B69 /* Pods-AvaxWallet-AvaxWalletTests.debug.xcconfig */,
146146
768AB2F6A941B6D6A6F508D4 /* Pods-AvaxWallet-AvaxWalletTests.release.xcconfig */,
147147
);
148-
name = Pods;
149148
path = Pods;
150149
sourceTree = "<group>";
151150
};
@@ -448,7 +447,10 @@
448447
buildSettings = {
449448
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
450449
CLANG_ENABLE_MODULES = YES;
450+
CODE_SIGN_IDENTITY = "Apple Development";
451+
CODE_SIGN_STYLE = Automatic;
451452
CURRENT_PROJECT_VERSION = 1;
453+
DEVELOPMENT_TEAM = U57DXD258P;
452454
ENABLE_BITCODE = NO;
453455
INFOPLIST_FILE = AvaxWallet/Info.plist;
454456
LD_RUNPATH_SEARCH_PATHS = (
@@ -460,8 +462,9 @@
460462
"-ObjC",
461463
"-lc++",
462464
);
463-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
465+
PRODUCT_BUNDLE_IDENTIFIER = org.avalabs.avaxwallet;
464466
PRODUCT_NAME = AvaxWallet;
467+
PROVISIONING_PROFILE_SPECIFIER = "";
465468
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
466469
SWIFT_VERSION = 5.0;
467470
VERSIONING_SYSTEM = "apple-generic";
@@ -474,7 +477,9 @@
474477
buildSettings = {
475478
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
476479
CLANG_ENABLE_MODULES = YES;
480+
CODE_SIGN_STYLE = Manual;
477481
CURRENT_PROJECT_VERSION = 1;
482+
DEVELOPMENT_TEAM = U57DXD258P;
478483
INFOPLIST_FILE = AvaxWallet/Info.plist;
479484
LD_RUNPATH_SEARCH_PATHS = (
480485
"$(inherited)",
@@ -485,8 +490,9 @@
485490
"-ObjC",
486491
"-lc++",
487492
);
488-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
493+
PRODUCT_BUNDLE_IDENTIFIER = org.avalabs.avaxwallet;
489494
PRODUCT_NAME = AvaxWallet;
495+
PROVISIONING_PROFILE_SPECIFIER = "App distribution provisioning profile";
490496
SWIFT_VERSION = 5.0;
491497
VERSIONING_SYSTEM = "apple-generic";
492498
};
@@ -586,7 +592,7 @@
586592
CLANG_WARN_SUSPICIOUS_MOVE = YES;
587593
CLANG_WARN_UNREACHABLE_CODE = YES;
588594
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
589-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
595+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
590596
COPY_PHASE_STRIP = YES;
591597
ENABLE_NS_ASSERTIONS = NO;
592598
ENABLE_STRICT_OBJC_MSGSEND = YES;

ios/AvaxWallet.xcodeproj/xcshareddata/xcschemes/AvaxWallet.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</Testables>
4242
</TestAction>
4343
<LaunchAction
44-
buildConfiguration = "Debug"
44+
buildConfiguration = "Release"
4545
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4646
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4747
launchStyle = "0"
Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,62 @@
11
{
22
"images" : [
33
{
4+
"filename" : "ic_logo_dark_40.png",
45
"idiom" : "iphone",
5-
"size" : "29x29",
6-
"scale" : "2x"
6+
"scale" : "2x",
7+
"size" : "20x20"
78
},
89
{
10+
"filename" : "ic_logo_dark_60.png",
911
"idiom" : "iphone",
10-
"size" : "29x29",
11-
"scale" : "3x"
12+
"scale" : "3x",
13+
"size" : "20x20"
1214
},
1315
{
16+
"filename" : "ic_logo_dark_58.png",
1417
"idiom" : "iphone",
15-
"size" : "40x40",
16-
"scale" : "2x"
18+
"scale" : "2x",
19+
"size" : "29x29"
1720
},
1821
{
22+
"filename" : "ic_logo_dark_87.png",
1923
"idiom" : "iphone",
20-
"size" : "40x40",
21-
"scale" : "3x"
24+
"scale" : "3x",
25+
"size" : "29x29"
2226
},
2327
{
28+
"filename" : "ic_logo_dark_80.png",
2429
"idiom" : "iphone",
25-
"size" : "60x60",
26-
"scale" : "2x"
30+
"scale" : "2x",
31+
"size" : "40x40"
2732
},
2833
{
34+
"filename" : "ic_logo_dark.png",
2935
"idiom" : "iphone",
30-
"size" : "60x60",
31-
"scale" : "3x"
36+
"scale" : "3x",
37+
"size" : "40x40"
38+
},
39+
{
40+
"filename" : "ic_logo_dark-1.png",
41+
"idiom" : "iphone",
42+
"scale" : "2x",
43+
"size" : "60x60"
44+
},
45+
{
46+
"filename" : "ic_logo_dark_180.png",
47+
"idiom" : "iphone",
48+
"scale" : "3x",
49+
"size" : "60x60"
50+
},
51+
{
52+
"filename" : "ic_logo_dark_1024.png",
53+
"idiom" : "ios-marketing",
54+
"scale" : "1x",
55+
"size" : "1024x1024"
3256
}
3357
],
3458
"info" : {
35-
"version" : 1,
36-
"author" : "xcode"
59+
"author" : "xcode",
60+
"version" : 1
3761
}
38-
}
62+
}
2.88 KB
Loading
2.88 KB
Loading
126 KB
Loading
13.9 KB
Loading
2.81 KB
Loading
4.18 KB
Loading

0 commit comments

Comments
 (0)