From c25785ccf493e95977aa6e0d78a77587da4ec527 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Tue, 28 Aug 2018 11:59:14 +0100 Subject: [PATCH] Mobile rewards (#251) --- app/package-lock.json | 35 ++-- app/package.json | 2 +- app/src/component/AppNavigator.js | 21 ++- .../component/deviceIdRewardSubcard/index.js | 9 + .../component/deviceIdRewardSubcard/view.js | 48 +++++ app/src/component/emailRewardSubcard/index.js | 22 +++ app/src/component/emailRewardSubcard/view.js | 97 ++++++++++ app/src/component/fileItem/view.js | 2 +- app/src/component/link/view.js | 14 +- app/src/component/rewardCard/index.js | 29 +++ app/src/component/rewardCard/view.js | 95 ++++++++++ app/src/component/rewardSummary/index.js | 15 ++ app/src/component/rewardSummary/view.js | 55 ++++++ app/src/component/searchResultItem/view.js | 10 +- app/src/index.js | 14 +- app/src/page/discover/view.js | 4 +- .../firstRun/internal/email-collect-page.js | 19 +- app/src/page/firstRun/view.js | 30 ++- app/src/page/rewards/index.js | 28 +++ app/src/page/rewards/view.js | 172 ++++++++++++++++++ app/src/page/splash/index.js | 14 +- app/src/page/splash/view.js | 9 +- app/src/redux/actions/file.js | 13 +- app/src/styles/reward.js | 159 ++++++++++++++++ app/src/styles/wallet.js | 4 +- .../java/io/lbry/browser/MainActivity.java | 29 ++- .../browser/reactmodules/UtilityModule.java | 90 ++++++++- 27 files changed, 961 insertions(+), 78 deletions(-) create mode 100644 app/src/component/deviceIdRewardSubcard/index.js create mode 100644 app/src/component/deviceIdRewardSubcard/view.js create mode 100644 app/src/component/emailRewardSubcard/index.js create mode 100644 app/src/component/emailRewardSubcard/view.js create mode 100644 app/src/component/rewardCard/index.js create mode 100644 app/src/component/rewardCard/view.js create mode 100644 app/src/component/rewardSummary/index.js create mode 100644 app/src/component/rewardSummary/view.js create mode 100644 app/src/page/rewards/index.js create mode 100644 app/src/page/rewards/view.js create mode 100644 app/src/styles/reward.js diff --git a/app/package-lock.json b/app/package-lock.json index a59976e..680a806 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -3966,20 +3966,11 @@ } }, "lbryinc": { - "version": "github:lbryio/lbryinc#8e33473daa56ebe80b12509ac5374c5884efef90", - "from": "github:lbryio/lbryinc#authentication-flow", + "version": "github:lbryio/lbryinc#f5d23dc5ee80198bee8e859bb8487c1137f9fbef", + "from": "github:lbryio/lbryinc#rewards", "requires": { + "lbry-redux": "github:lbryio/lbry-redux#31f7afa8a37f5741dac01fc1ecdf153f3bed95dc", "reselect": "^3.0.0" - }, - "dependencies": { - "lbry-redux": { - "version": "github:lbryio/lbry-redux#467e48c77b8004cef738e950bdcc67654748ae9f", - "from": "github:lbryio/lbry-redux#467e48c77b8004cef738e950bdcc67654748ae9f", - "requires": { - "proxy-polyfill": "0.1.6", - "reselect": "^3.0.0" - } - } } }, "lcid": { @@ -5277,6 +5268,13 @@ "which-module": "^2.0.0", "y18n": "^3.2.1", "yargs-parser": "^7.0.0" + }, + "dependencies": { + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + } } } } @@ -6843,9 +6841,9 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" }, "yallist": { "version": "2.1.2", @@ -6870,6 +6868,13 @@ "which-module": "^2.0.0", "y18n": "^3.2.1", "yargs-parser": "^7.0.0" + }, + "dependencies": { + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + } } }, "yargs-parser": { diff --git a/app/package.json b/app/package.json index 4516970..73c4f22 100644 --- a/app/package.json +++ b/app/package.json @@ -8,7 +8,7 @@ "dependencies": { "base-64": "^0.1.0", "lbry-redux": "lbryio/lbry-redux", - "lbryinc": "lbryio/lbryinc#authentication-flow", + "lbryinc": "lbryio/lbryinc#rewards", "moment": "^2.22.1", "react": "16.2.0", "react-native": "0.55.3", diff --git a/app/src/component/AppNavigator.js b/app/src/component/AppNavigator.js index 1268d40..0619a65 100644 --- a/app/src/component/AppNavigator.js +++ b/app/src/component/AppNavigator.js @@ -3,8 +3,9 @@ import AboutPage from '../page/about'; import DiscoverPage from '../page/discover'; import FilePage from '../page/file'; import FirstRunScreen from '../page/firstRun'; -import SearchPage from '../page/search'; +import RewardsPage from '../page/rewards'; import TrendingPage from '../page/trending'; +import SearchPage from '../page/search'; import SettingsPage from '../page/settings'; import SplashScreen from '../page/splash'; import TransactionHistoryPage from '../page/transactionHistory'; @@ -99,10 +100,21 @@ const walletStack = StackNavigator({ headerMode: 'screen' }); +const rewardsStack = StackNavigator({ + Rewards: { + screen: RewardsPage, + navigationOptions: ({ navigation }) => ({ + title: 'Rewards', + headerLeft: navigation.navigate('DrawerOpen')} />, + }) + } +}); + const drawer = DrawerNavigator({ DiscoverStack: { screen: discoverStack }, TrendingStack: { screen: trendingStack }, WalletStack: { screen: walletStack }, + Rewards: { screen: rewardsStack }, Settings: { screen: SettingsPage, navigationOptions: { drawerLockMode: 'locked-closed' } }, About: { screen: AboutPage, navigationOptions: { drawerLockMode: 'locked-closed' } } }, { @@ -189,7 +201,7 @@ class AppWithNavigationState extends React.Component { if (notification) { const { displayType, message } = notification; let currentDisplayType; - if (displayType.length) { + if (displayType && displayType.length) { for (let i = 0; i < displayType.length; i++) { const type = displayType[i]; if (AppWithNavigationState.supportedDisplayTypes.indexOf(type) > -1) { @@ -201,6 +213,11 @@ class AppWithNavigationState extends React.Component { currentDisplayType = displayType; } + if (!currentDisplayType && message) { + // default to toast if no display type set and there is a message specified + currentDisplayType = 'toast'; + } + if ('toast' === currentDisplayType) { ToastAndroid.show(message, ToastAndroid.SHORT); } diff --git a/app/src/component/deviceIdRewardSubcard/index.js b/app/src/component/deviceIdRewardSubcard/index.js new file mode 100644 index 0000000..c79dc73 --- /dev/null +++ b/app/src/component/deviceIdRewardSubcard/index.js @@ -0,0 +1,9 @@ +import { connect } from 'react-redux'; +import { doNotify } from 'lbry-redux'; +import DeviceIdRewardSubcard from './view'; + +const perform = dispatch => ({ + notify: data => dispatch(doNotify(data)) +}); + +export default connect(null, perform)(DeviceIdRewardSubcard); \ No newline at end of file diff --git a/app/src/component/deviceIdRewardSubcard/view.js b/app/src/component/deviceIdRewardSubcard/view.js new file mode 100644 index 0000000..58ef455 --- /dev/null +++ b/app/src/component/deviceIdRewardSubcard/view.js @@ -0,0 +1,48 @@ +// @flow +import React from 'react'; +import { + ActivityIndicator, + AsyncStorage, + NativeModules, + Text, + TextInput, + TouchableOpacity, + View +} from 'react-native'; +import Icon from 'react-native-vector-icons/FontAwesome5'; +import Button from '../button'; +import Colors from '../../styles/colors'; +import Constants from '../../constants'; +import Link from '../link'; +import rewardStyle from '../../styles/reward'; + +class DeviceIdRewardSubcard extends React.PureComponent { + onAllowAccessPressed = () => { + if (!NativeModules.UtilityModule) { + return notify({ + message: 'The device ID could not be obtained due to a missing module.', + displayType: ['toast'] + }); + } + + NativeModules.UtilityModule.requestPhoneStatePermission(); + } + + render() { + return ( + + Pending action: Device ID + + The app requires the phone state permission in order to identify your device for reward eligibility. + +