Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] Add Celo Lite toggle (UI only, zeroSync on/off in other PR) #1369

Merged
merged 37 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1242a1f
Always write key to disk to allow to switch into zero sync mode
annakaz Oct 11, 2019
1e7fa99
Add celo lite settings component
annakaz Oct 11, 2019
1eaf14d
Add celo lite settings link
annakaz Oct 11, 2019
5f1443e
Update state to keep track of sync mode, account in web3 keystore
annakaz Oct 11, 2019
d170908
Make celo lite settings screen responsive
annakaz Oct 11, 2019
e49e37a
WIP switching
annakaz Oct 14, 2019
6e0f4bf
Merge branch 'master' into annakaz/zero-sync-option
annakaz Oct 14, 2019
304b8c2
Fixing redux saga logic
annakaz Oct 14, 2019
a017e5b
Get sagas working
annakaz Oct 14, 2019
b34d55d
Move zeroSync logic out, refactor assignAccountFromPrivateKey
annakaz Oct 14, 2019
b0dc9b3
Moving more logic to web3/zeroSync
annakaz Oct 14, 2019
2f9dc16
Merge branch 'master' into annakaz/zero-sync-option
annakaz Oct 14, 2019
d46e1cf
Yield select whenever zeroSync mode needed
annakaz Oct 14, 2019
8f7db2c
Switching between providers
annakaz Oct 14, 2019
eafce36
check sync mode via web3 provider
annakaz Oct 14, 2019
e12c0cf
switch web3 provider when necessary
annakaz Oct 14, 2019
dae95b3
Default to starting in full sync mode
annakaz Oct 14, 2019
a9a3dde
Revert changes to functions using sendTransaction
annakaz Oct 14, 2019
cfcd1fb
Handle isZeroSync mode using web3 object
annakaz Oct 15, 2019
15d7653
Ensure private key exists/web3 keystore exists for switch
annakaz Oct 15, 2019
b71ad0c
Switch to always reading zeroSync state from web3
annakaz Oct 15, 2019
efcfcee
Merge branch 'master' into annakaz/zero-sync-toggle
annakaz Oct 16, 2019
76abb84
Stop storing account in web3 keystore separately
annakaz Oct 16, 2019
9b44218
Remove zerosync logic
annakaz Oct 16, 2019
cfa940c
Remove zerosync file
annakaz Oct 16, 2019
bb210fa
Revert logic changes to save for diffrerent pr
annakaz Oct 16, 2019
8e5d46b
Remove some unused styles
annakaz Oct 16, 2019
d79988c
Comment out celoLite settings for now
annakaz Oct 16, 2019
8735f97
Add spanish translations, a couple comments
annakaz Oct 16, 2019
332e24e
Add jest tests
annakaz Oct 16, 2019
03cfa6f
Add Licenses test
annakaz Oct 16, 2019
1d33eb9
Update spanish translations
annakaz Oct 16, 2019
6843c4e
Fix linting error
annakaz Oct 16, 2019
e8a529d
Merge branch 'master' into annakaz/zero-sync-toggle
annakaz Oct 16, 2019
8a5a917
Merge branch 'master' into annakaz/zero-sync-toggle
annakaz Oct 16, 2019
456f72f
Merge branch 'master' into annakaz/zero-sync-toggle
annakaz Oct 17, 2019
060d0c5
Merge branch 'master' into annakaz/zero-sync-toggle
annakaz Oct 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/mobile/locales/en-US/accountScreen10.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"shareAnalytics": "Share Analytics",
"shareAnalytics_detail":
"We collect anonymized data about how you use Celo to help improve the application for everyone.",
"celoLite": "Celo Lite",
"enableCeloLite": "Enable Celo Lite",
"celoLiteDetail":
"Celo Lite mode allows you to communicate with the Celo Network through a trusted node. You can always change this mode in app settings.",
"testFaqHere": "<0>Test FAQ is </0><1>here</1>",
"termsOfServiceHere": "<0>Terms of service are </0><1>here</1>",
"editProfile": "Edit Profile",
Expand Down
4 changes: 4 additions & 0 deletions packages/mobile/locales/es-419/accountScreen10.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"shareAnalytics": "Compartir estadisticas de uso",
"shareAnalytics_detail":
"Recopilamos datos anónimos sobre cómo utiliza Celo para ayudar a mejorar la aplicación para todos.",
"celoLite": "Celo Lite",
"enableCeloLite": "Habilitar Celo Lite",
"celoLiteDetail":
"El modo Celo Lite te permite comunicarte con la Red Celo a través de un nodo confiable. Puedes cambiar este modo en la configuración de la aplicación.",
"testFaqHere": "<1>Aquí</1><0> están las preguntas frecuentes de la prueba. </0>",
"termsOfServiceHere": "<1>Aquí</1><0> están las Condiciones de servicio.</0>",
"editProfile": "Editar perfil",
Expand Down
7 changes: 7 additions & 0 deletions packages/mobile/src/account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export class Account extends React.Component<Props, State> {
navigate(Screens.Analytics, { nextScreen: Screens.Account })
}

goToCeloLite() {
navigate(Screens.CeloLite, { nextScreen: Screens.Account })
}

goToFAQ() {
navigateToURI(FAQ_LINK)
}
Expand Down Expand Up @@ -229,6 +233,9 @@ export class Account extends React.Component<Props, State> {
<SettingsItem title={t('celoRewards')} onPress={navigateToVerifierApp} />
)}
<SettingsItem title={t('analytics')} onPress={this.goToAnalytics} />
{/* // TODO(anna) Disabled until switch geth on/off is implemented
<SettingsItem title={t('celoLite')} onPress={this.goToCeloLite} />
*/}
<SettingsItem title={t('languageSettings')} onPress={this.goToLanguageSetting} />
<SettingsItem
title={t('localCurrencySetting')}
Expand Down
17 changes: 17 additions & 0 deletions packages/mobile/src/account/Analytics.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react'
import 'react-native'
import { Provider } from 'react-redux'
import * as renderer from 'react-test-renderer'
import Analytics from 'src/account/Analytics'
import { createMockStore } from 'test/utils'

describe('Analytics', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Provider store={createMockStore({})}>
<Analytics />
</Provider>
)
expect(tree).toMatchSnapshot()
})
})
18 changes: 0 additions & 18 deletions packages/mobile/src/account/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import SettingsSwitchItem from '@celo/react-components/components/SettingsSwitchItem'
import colors from '@celo/react-components/styles/colors'
import fontStyles from '@celo/react-components/styles/fonts'
import variables from '@celo/react-components/styles/variables'
import * as React from 'react'
import { WithNamespaces, withNamespaces } from 'react-i18next'
import { ScrollView, StyleSheet, Text } from 'react-native'
Expand Down Expand Up @@ -50,27 +49,10 @@ export class Analytics extends React.Component<Props> {
}

const style = StyleSheet.create({
accountHeader: {
paddingTop: 20,
},
input: {
borderWidth: 1,
borderRadius: 3,
borderColor: '#EEEEEE',
padding: 5,
height: 54,
margin: 20,
width: variables.width - 40,
fontSize: 16,
},
scrollView: {
flex: 1,
backgroundColor: colors.background,
},
container: {
flex: 1,
paddingLeft: 20,
},
})

export default connect<StateProps, DispatchProps, {}, RootState>(
Expand Down
17 changes: 17 additions & 0 deletions packages/mobile/src/account/CeloLite.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react'
import 'react-native'
import { Provider } from 'react-redux'
import * as renderer from 'react-test-renderer'
import CeloLite from 'src/account/CeloLite'
import { createMockStore } from 'test/utils'

describe('CeloLite', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Provider store={createMockStore({})}>
<CeloLite />
</Provider>
)
expect(tree).toMatchSnapshot()
})
})
65 changes: 65 additions & 0 deletions packages/mobile/src/account/CeloLite.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import SettingsSwitchItem from '@celo/react-components/components/SettingsSwitchItem'
import colors from '@celo/react-components/styles/colors'
import fontStyles from '@celo/react-components/styles/fonts'
import * as React from 'react'
import { WithNamespaces, withNamespaces } from 'react-i18next'
import { ScrollView, StyleSheet, Text } from 'react-native'
import { connect } from 'react-redux'
import i18n, { Namespaces } from 'src/i18n'
import { headerWithCancelButton } from 'src/navigator/Headers'
import { RootState } from 'src/redux/reducers'
import { setZeroSyncMode } from 'src/web3/actions'

interface StateProps {
zeroSyncEnabled: boolean
}

interface DispatchProps {
setZeroSyncMode: typeof setZeroSyncMode
}

type Props = StateProps & DispatchProps & WithNamespaces

const mapDispatchToProps = {
setZeroSyncMode,
}

const mapStateToProps = (state: RootState): StateProps => {
return {
zeroSyncEnabled: state.web3.zeroSyncMode,
}
}

export class CeloLite extends React.Component<Props> {
static navigationOptions = () => ({
...headerWithCancelButton,
headerTitle: i18n.t('accountScreen10:celoLite'),
})

render() {
const { zeroSyncEnabled, t } = this.props
return (
<ScrollView style={style.scrollView} keyboardShouldPersistTaps="handled">
<SettingsSwitchItem
switchValue={zeroSyncEnabled}
onSwitchChange={this.props.setZeroSyncMode}
details={t('celoLiteDetail')}
>
<Text style={fontStyles.body}>{t('enableCeloLite')}</Text>
</SettingsSwitchItem>
</ScrollView>
)
}
}

const style = StyleSheet.create({
scrollView: {
flex: 1,
backgroundColor: colors.background,
},
})

export default connect<StateProps, DispatchProps, {}, RootState>(
mapStateToProps,
mapDispatchToProps
)(withNamespaces(Namespaces.accountScreen10)(CeloLite))
7 changes: 0 additions & 7 deletions packages/mobile/src/account/EditProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ export class EditProfile extends React.Component<Props> {
}

const style = StyleSheet.create({
accountHeader: {
paddingTop: 20,
},
input: {
borderWidth: 1,
borderRadius: 3,
Expand All @@ -90,10 +87,6 @@ const style = StyleSheet.create({
flex: 1,
backgroundColor: colors.background,
},
container: {
flex: 1,
paddingLeft: 20,
},
})

export default connect<StateProps, DispatchProps, {}, RootState>(
Expand Down
14 changes: 0 additions & 14 deletions packages/mobile/src/account/Education.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,6 @@ const style = StyleSheet.create({
flex: 1,
paddingHorizontal: 20,
},
footerLink: {
color: colors.celoGreen,
textAlign: 'center',
marginTop: 10,
marginBottom: 25,
},
circleContainer: {
flex: 0,
width: PROGRESS_CIRCLE_PASSIVE_SIZE,
height: PROGRESS_CIRCLE_PASSIVE_SIZE,
alignItems: 'center',
justifyContent: 'center',
margin: 5,
},
circle: {
flex: 0,
backgroundColor: colors.inactive,
Expand Down
9 changes: 0 additions & 9 deletions packages/mobile/src/account/Invite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ const style = StyleSheet.create({
flex: 1,
backgroundColor: colors.background,
},
inviteHeadline: {
fontSize: 24,
lineHeight: 39,
color: colors.dark,
},
label: {
alignSelf: 'center',
textAlign: 'center',
},
})

export default componentWithAnalytics(
Expand Down
17 changes: 17 additions & 0 deletions packages/mobile/src/account/Licenses.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react'
import 'react-native'
import { Provider } from 'react-redux'
import * as renderer from 'react-test-renderer'
import Licenses from 'src/account/Licenses'
import { createMockStore } from 'test/utils'

describe('Licenses', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Provider store={createMockStore({})}>
<Licenses />
</Provider>
)
expect(tree).toMatchSnapshot()
})
})
23 changes: 0 additions & 23 deletions packages/mobile/src/account/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ export class Profile extends React.Component<Props> {
}

const style = StyleSheet.create({
accountHeader: {
paddingTop: 20,
},
accountProfile: {
paddingLeft: 10,
paddingTop: 30,
Expand All @@ -76,26 +73,6 @@ const style = StyleSheet.create({
flexDirection: 'column',
alignItems: 'center',
},
accountFooter: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: 50,
margin: 10,
},
accountFooterText: {
paddingBottom: 10,
},
editProfileButton: {
height: 28,
width: 110,
},
image: {
height: 55,
width: 55,
borderRadius: 50,
},
underlinedBox: {
borderTopWidth: 1,
borderColor: '#EEEEEE',
Expand Down
93 changes: 93 additions & 0 deletions packages/mobile/src/account/__snapshots__/Analytics.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Analytics renders correctly 1`] = `
<RCTScrollView
keyboardShouldPersistTaps="handled"
style={
Object {
"backgroundColor": "#FFFFFF",
"flex": 1,
}
}
>
<View>
<View
style={
Object {
"borderBottomWidth": 1,
"borderColor": "#EEEEEE",
"marginLeft": 15,
}
}
>
<View
style={
Object {
"flexDirection": "row",
"justifyContent": "space-between",
"padding": 20,
}
}
>
<View
style={
Array [
Object {
"justifyContent": "center",
},
]
}
>
<Text
style={
Object {
"color": "#2E3338",
"fontFamily": "Hind-Regular",
"fontSize": 16,
"lineHeight": 24,
}
}
>
shareAnalytics
</Text>
</View>
<View
style={
Array [
Object {
"justifyContent": "center",
},
]
}
>
<AndroidSwitch
accessibilityRole="button"
enabled={true}
on={true}
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
thumbTintColor="#FFFFFF"
trackColorForFalse="#E3E3E5"
trackColorForTrue="#42D689"
trackTintColor="#42D689"
/>
</View>
</View>
<View
style={
Object {
"paddingBottom": 20,
"paddingLeft": 20,
"paddingRight": 20,
}
}
>
<Text>
shareAnalytics_detail
</Text>
</View>
</View>
</View>
</RCTScrollView>
`;
Loading