diff --git a/app/src/component/fileRewardsDriver/view.js b/app/src/component/fileRewardsDriver/view.js index 4bd82972..5e96a8a3 100644 --- a/app/src/component/fileRewardsDriver/view.js +++ b/app/src/component/fileRewardsDriver/view.js @@ -1,6 +1,5 @@ import React from 'react'; import { Text, TouchableOpacity } from 'react-native'; -import Colors from 'styles/colors'; import Icon from 'react-native-vector-icons/FontAwesome5'; import filePageStyle from 'styles/filePage'; diff --git a/app/src/component/walletRewardsDriver/view.js b/app/src/component/walletRewardsDriver/view.js index 7463fce3..ea8184f2 100644 --- a/app/src/component/walletRewardsDriver/view.js +++ b/app/src/component/walletRewardsDriver/view.js @@ -1,5 +1,6 @@ import React from 'react'; import { Text, TouchableOpacity } from 'react-native'; +import Icon from 'react-native-vector-icons/FontAwesome5'; import walletStyle from 'styles/wallet'; class WalletRewardsDriver extends React.PureComponent { @@ -8,7 +9,8 @@ class WalletRewardsDriver extends React.PureComponent { return ( navigation.navigate('Rewards')}> - Earn credits while using the LBRY app. Tap to get started. + + Earn credits while using the LBRY app. ); } diff --git a/app/src/component/walletSyncDriver/index.js b/app/src/component/walletSyncDriver/index.js index 77845744..10651586 100644 --- a/app/src/component/walletSyncDriver/index.js +++ b/app/src/component/walletSyncDriver/index.js @@ -1,13 +1,22 @@ import { connect } from 'react-redux'; +import { doSetClientSetting } from 'redux/actions/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { doToast } from 'lbry-redux'; +import { selectUserEmail } from 'lbryinc'; import Constants from 'constants'; import WalletSyncDriver from './view'; const select = state => ({ deviceWalletSynced: makeSelectClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED)(state), + userEmail: selectUserEmail(state), +}); + +const perform = dispatch => ({ + notify: data => dispatch(doToast(data)), + setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), }); export default connect( select, - null + perform )(WalletSyncDriver); diff --git a/app/src/component/walletSyncDriver/view.js b/app/src/component/walletSyncDriver/view.js index be3da11d..799612c6 100644 --- a/app/src/component/walletSyncDriver/view.js +++ b/app/src/component/walletSyncDriver/view.js @@ -1,45 +1,89 @@ import React from 'react'; -import { Text, View } from 'react-native'; +import { Alert, NativeModules, Switch, Text, View } from 'react-native'; import Button from 'component/button'; +import Constants from 'constants'; import Link from 'component/link'; import walletStyle from 'styles/wallet'; class WalletSyncDriver extends React.PureComponent { - onEnableSyncPressed = () => { - const { navigation } = this.props; - navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: true } }); + handleSyncStatusChange = value => { + const { navigation, notify, setClientSetting } = this.props; + if (value) { + // enabling + navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: true } }); + } else { + // turning off + // set deviceWalletSynced to false (if confirmed) + Alert.alert( + 'Disable wallet sync', + 'Are you sure you want to turn off wallet sync?', + [ + { text: 'No' }, + { + text: 'Yes', + onPress: () => { + setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, false); + notify({ message: 'Wallet sync was successfully disabled.' }); + }, + }, + ], + { cancelable: true } + ); + } }; render() { - const { deviceWalletSynced } = this.props; + const { deviceWalletSynced, userEmail } = this.props; return ( - - Wallet sync is {deviceWalletSynced ? 'on' : 'off'}. - {!deviceWalletSynced && ( - Wallet Sync + + + Sync status + + + + {deviceWalletSynced ? 'On' : 'Off'} + + - )} + - {!deviceWalletSynced && ( - -