use snackbars instead of toasts #101

Merged
akinwale merged 1 commit from snackbars into master 2019-12-18 16:49:19 +01:00
3 changed files with 17 additions and 3 deletions

5
package-lock.json generated
View file

@ -8186,6 +8186,11 @@
"debounce": "^1.2.0" "debounce": "^1.2.0"
} }
}, },
"react-native-snackbar": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/react-native-snackbar/-/react-native-snackbar-1.0.2.tgz",
"integrity": "sha512-VOpF7/fUdv32zVH+CW542wpFYGtvAw+nFVloJu0HJWGeClB6V/GcxgAADQOEReOw91RnQkr+bZk0aEf4UXZ64w=="
},
"react-native-speedometer": { "react-native-speedometer": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/react-native-speedometer/-/react-native-speedometer-1.0.3.tgz", "resolved": "https://registry.npmjs.org/react-native-speedometer/-/react-native-speedometer-1.0.3.tgz",

View file

@ -30,6 +30,7 @@
"react-native-password-strength-meter": "^0.0.2", "react-native-password-strength-meter": "^0.0.2",
"react-native-phone-input": "lbryio/react-native-phone-input", "react-native-phone-input": "lbryio/react-native-phone-input",
"react-native-reanimated": "1.2.0", "react-native-reanimated": "1.2.0",
"react-native-snackbar": "1.0.2",
"react-native-super-grid": "^3.0.4", "react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0", "react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android", "react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",

View file

@ -62,6 +62,7 @@ import NavigationButton from 'component/navigationButton';
import discoverStyle from 'styles/discover'; import discoverStyle from 'styles/discover';
import searchStyle from 'styles/search'; import searchStyle from 'styles/search';
import SearchRightHeaderIcon from 'component/searchRightHeaderIcon'; import SearchRightHeaderIcon from 'component/searchRightHeaderIcon';
import Snackbar from 'react-native-snackbar';
const SYNC_GET_INTERVAL = 1000 * 60 * 5; // every 5 minutes const SYNC_GET_INTERVAL = 1000 * 60 * 5; // every 5 minutes
@ -364,7 +365,7 @@ class AppWithNavigationState extends React.Component {
this.setState({ verifyPending: false }); this.setState({ verifyPending: false });
NativeModules.Firebase.track('email_verified', { email: user.primary_email }); NativeModules.Firebase.track('email_verified', { email: user.primary_email });
ToastAndroid.show(__('Your email address was successfully verified.'), ToastAndroid.LONG); Snackbar.show({ title: __('Your email address was successfully verified.'), duration: Snackbar.LENGTH_LONG });
// get user settings after email verification // get user settings after email verification
this.getUserSettings(); this.getUserSettings();
@ -381,7 +382,7 @@ class AppWithNavigationState extends React.Component {
const { toast, emailToVerify, emailVerifyPending, emailVerifyErrorMessage, user } = nextProps; const { toast, emailToVerify, emailVerifyPending, emailVerifyErrorMessage, user } = nextProps;
if (toast) { if (toast) {
const { message } = toast; const { message, isError } = toast;
let currentDisplayType; let currentDisplayType;
if (!currentDisplayType && message) { if (!currentDisplayType && message) {
// default to toast if no display type set and there is a message specified // default to toast if no display type set and there is a message specified
@ -389,7 +390,14 @@ class AppWithNavigationState extends React.Component {
} }
if (currentDisplayType === 'toast') { if (currentDisplayType === 'toast') {
ToastAndroid.show(message, ToastAndroid.LONG); const props = {
title: message,
duration: Snackbar.LENGTH_LONG,
};
if (isError) {
props.backgroundColor = Colors.Red;
}
Snackbar.show(props);
} }
dispatch(doDismissToast()); dispatch(doDismissToast());