Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 80bb26f

Browse files
authored
Merge pull request #1258 from lightninglabs/dev/atpl-choice-setup
Select autopilot during wallet setup.
2 parents 2fec786 + 95e022a commit 80bb26f

File tree

6 files changed

+185
-26
lines changed

6 files changed

+185
-26
lines changed

src/action/nav-mobile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ class NavAction {
9797
this._navigate('NewAddress');
9898
}
9999

100+
goSelectAutopilot() {
101+
this._navigate('SelectAutopilot');
102+
}
103+
100104
goLoaderSyncing() {
101105
this._navigate('LoaderSyncing');
102106
this._reset('Main', 'LoaderSyncing');

src/component/setting.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,50 @@ SettingItem.propTypes = {
121121
children: PropTypes.node,
122122
};
123123

124+
//
125+
// Setting Copy Item
126+
//
127+
128+
const iCopyStyles = StyleSheet.create({
129+
item: {
130+
height: null,
131+
paddingTop: 20,
132+
paddingBottom: 20,
133+
},
134+
left: {
135+
flex: 1,
136+
},
137+
name: {
138+
color: color.grey,
139+
fontSize: font.sizeSub,
140+
},
141+
copy: {
142+
fontSize: font.sizeS,
143+
lineHeight: font.lineHeightS,
144+
color: color.greyListLabel,
145+
opacity: 0.74,
146+
paddingRight: 50,
147+
marginTop: 5,
148+
},
149+
});
150+
151+
export const SettingCopyItem = ({ name, onSelect, copy, children }) => (
152+
<ListItem style={iCopyStyles.item} onSelect={onSelect}>
153+
<View style={iCopyStyles.left}>
154+
<Text style={iCopyStyles.name}>{name}</Text>
155+
<Text style={iCopyStyles.copy}>{copy}</Text>
156+
</View>
157+
{children}
158+
</ListItem>
159+
);
160+
161+
SettingCopyItem.propTypes = {
162+
name: PropTypes.string.isRequired,
163+
onSelect: PropTypes.func,
164+
copy: PropTypes.string,
165+
children: PropTypes.node,
166+
};
167+
124168
//
125169
// Setting Header
126170
//

src/view/main-mobile.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import SetPinConfirmView from './set-pin-confirm-mobile';
1818
import SeedSuccessView from './seed-success-mobile';
1919
import RestoreSeedView from './restore-seed-mobile';
2020
import NewAddressView from './new-address-mobile';
21+
import SelectAutopilotView from './select-atpl-mobile';
2122

2223
import PinView from './pin-mobile';
2324
import ResetPinCurrentView from './reset-pin-current-mobile';
@@ -93,7 +94,11 @@ const SeedSuccess = () => <SeedSuccessView wallet={wallet} />;
9394
const RestoreSeed = () => <RestoreSeedView store={store} wallet={wallet} />;
9495

9596
const NewAddress = () => (
96-
<NewAddressView store={store} invoice={invoice} info={info} />
97+
<NewAddressView store={store} invoice={invoice} nav={nav} />
98+
);
99+
100+
const SelectAutopilot = () => (
101+
<SelectAutopilotView store={store} autopilot={autopilot} info={info} />
97102
);
98103

99104
const Password = () => <PinView store={store} auth={auth} />;
@@ -212,6 +217,7 @@ const MainStack = createStackNavigator(
212217
SeedSuccess,
213218
RestoreSeed,
214219
NewAddress,
220+
SelectAutopilot,
215221
Password,
216222
LoaderSyncing,
217223
Home,

src/view/new-address-mobile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const styles = createStyles(
5959
})
6060
);
6161

62-
const NewAddressView = ({ store, invoice, info }) => (
62+
const NewAddressView = ({ store, invoice, nav }) => (
6363
<SplitBackground image="purple-gradient-bg" bottom={color.blackDark}>
6464
<MainContent style={styles.content}>
6565
<View style={styles.copyWrapper}>
@@ -80,7 +80,7 @@ const NewAddressView = ({ store, invoice, info }) => (
8080
>
8181
{store.walletAddress}
8282
</CopyButton>
83-
<SmallGlasButton onPress={() => info.initLoaderSyncing()}>
83+
<SmallGlasButton onPress={() => nav.goSelectAutopilot()}>
8484
Done
8585
</SmallGlasButton>
8686
</View>
@@ -96,7 +96,7 @@ const NewAddressView = ({ store, invoice, info }) => (
9696
NewAddressView.propTypes = {
9797
store: PropTypes.object.isRequired,
9898
invoice: PropTypes.object.isRequired,
99-
info: PropTypes.object.isRequired,
99+
nav: PropTypes.object.isRequired,
100100
};
101101

102102
export default observer(NewAddressView);

src/view/select-atpl-mobile.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import React from 'react';
2+
import { View } from 'react-native';
3+
import { createStyles, maxWidth } from '../component/media-query';
4+
import { observer } from 'mobx-react';
5+
import PropTypes from 'prop-types';
6+
import Background from '../component/background';
7+
import MainContent from '../component/main-content';
8+
import { CopyOnboardText, Text } from '../component/text';
9+
import { RadioButton, GlasButton } from '../component/button';
10+
import { SettingCopyItem } from '../component/setting';
11+
import { color, font, smallBreakWidth } from '../component/style';
12+
13+
//
14+
// Select Autopilot View
15+
//
16+
17+
const baseStyles = {
18+
content: {
19+
paddingLeft: 20,
20+
paddingRight: 20,
21+
},
22+
title: {
23+
marginTop: 80,
24+
textAlign: 'center',
25+
},
26+
copyTxt: {
27+
textAlign: 'center',
28+
marginTop: 20,
29+
maxWidth: 260,
30+
},
31+
list: {
32+
marginTop: 40,
33+
width: undefined,
34+
alignSelf: 'stretch',
35+
},
36+
};
37+
38+
const styles = createStyles(
39+
baseStyles,
40+
41+
maxWidth(smallBreakWidth, {
42+
title: {
43+
fontSize: font.sizeL + 10,
44+
lineHeight: font.sizeL + 10,
45+
marginTop: 40,
46+
},
47+
list: {
48+
marginTop: 50,
49+
},
50+
})
51+
);
52+
53+
const SelectAutopilotView = ({ store, autopilot, info }) => (
54+
<Background color={color.blackDark}>
55+
<MainContent style={styles.content}>
56+
<CopyOnboardText style={styles.title}>
57+
Automatically set up channels?
58+
</CopyOnboardText>
59+
<Text style={styles.copyTxt}>
60+
{
61+
"If you want to avoid manual channel creation, the app can allocate funds to channels for you. It's called autopilot."
62+
}
63+
</Text>
64+
<View style={styles.list}>
65+
<SettingCopyItem
66+
name="Use autopilot (recommended)"
67+
copy="I want the app to create channels and move my funds into those channels automatically."
68+
onSelect={() => !store.settings.autopilot && autopilot.toggle()}
69+
>
70+
<RadioButton selected={store.settings.autopilot === true} />
71+
</SettingCopyItem>
72+
<SettingCopyItem
73+
name="Create channels manually"
74+
copy="I don't want the app to automatically create channels for me. I can do this all myself."
75+
onSelect={() => store.settings.autopilot && autopilot.toggle()}
76+
>
77+
<RadioButton selected={store.settings.autopilot === false} />
78+
</SettingCopyItem>
79+
</View>
80+
</MainContent>
81+
<GlasButton onPress={() => info.initLoaderSyncing()}>Save</GlasButton>
82+
</Background>
83+
);
84+
85+
SelectAutopilotView.propTypes = {
86+
store: PropTypes.object.isRequired,
87+
autopilot: PropTypes.object.isRequired,
88+
info: PropTypes.object.isRequired,
89+
};
90+
91+
export default observer(SelectAutopilotView);

0 commit comments

Comments
 (0)