diff --git a/android/app/build.gradle b/android/app/build.gradle index ea1b21a3f..8001a7184 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -152,6 +152,7 @@ dependencies { compile project(':react-native-vector-icons') compile project(':react-native-fetch-blob') compile project(':react-native-zeroconf') + compile project(':react-native-toast') compile project(':realm') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" diff --git a/android/app/src/main/java/com/rocketchatrn/MainApplication.java b/android/app/src/main/java/com/rocketchatrn/MainApplication.java index 1fdfe134a..72ed5b81b 100644 --- a/android/app/src/main/java/com/rocketchatrn/MainApplication.java +++ b/android/app/src/main/java/com/rocketchatrn/MainApplication.java @@ -15,6 +15,8 @@ import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage; import com.brentvatne.react.ReactVideoPackage; +import com.remobile.toast.RCTToastPackage; + import java.util.Arrays; import java.util.List; import org.devio.rn.splashscreen.SplashScreenReactPackage; @@ -31,15 +33,16 @@ public class MainApplication extends Application implements ReactApplication { protected List getPackages() { return Arrays.asList( new MainReactPackage(), - new SvgPackage(), - new ImagePickerPackage(), - new VectorIconsPackage(), - new RNFetchBlobPackage(), - new ZeroconfReactPackage(), - new RealmReactPackage(), - new ReactNativePushNotificationPackage(), - new ReactVideoPackage(), - new SplashScreenReactPackage() + new SvgPackage(), + new ImagePickerPackage(), + new VectorIconsPackage(), + new RNFetchBlobPackage(), + new ZeroconfReactPackage(), + new RealmReactPackage(), + new ReactNativePushNotificationPackage(), + new ReactVideoPackage(), + new SplashScreenReactPackage(), + new RCTToastPackage() ); } }; diff --git a/android/settings.gradle b/android/settings.gradle index 5472ba6d0..5455aadb5 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -17,4 +17,6 @@ include ':realm' project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android') include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android') +include ':react-native-toast' +project(':react-native-toast').projectDir = new File(settingsDir, '../node_modules/@remobile/react-native-toast/android') include ':app' diff --git a/app/containers/MessageActions.js b/app/containers/MessageActions.js index 7c645e231..c56adaf13 100644 --- a/app/containers/MessageActions.js +++ b/app/containers/MessageActions.js @@ -15,6 +15,7 @@ import { setInput, actionsHide } from '../actions/messages'; +import { showToast } from '../utils/info'; @connect( state => ({ @@ -127,7 +128,7 @@ export default class MessageActions extends React.Component { if (this.state.copyPermalink) { this.setState({ copyPermalink: false }); await Clipboard.setString(nextProps.permalink); - Alert.alert('Permalink copied to clipboard!'); + showToast('Permalink copied to clipboard!'); this.props.permalinkClear(); // quote } else if (this.state.quote) { @@ -235,7 +236,7 @@ export default class MessageActions extends React.Component { handleCopy = async() => { await Clipboard.setString(this.props.actionMessage.msg); - Alert.alert('Copied to clipboard!'); + showToast('Copied to clipboard!'); } handleStar() { diff --git a/app/utils/info.js b/app/utils/info.js new file mode 100644 index 000000000..e380ba8d8 --- /dev/null +++ b/app/utils/info.js @@ -0,0 +1,6 @@ +import { Alert } from 'react-native'; +import Toast from '@remobile/react-native-toast'; + +export const showToast = (message: string) => Toast.showLongCenter(message, Toast.SHORT); + +export const showErrorAlert = (message: string, title: string) => Alert.alert(title, message, [{ text: 'OK', onPress: () => {} }], { cancelable: true }); diff --git a/app/views/ForgotPasswordView.js b/app/views/ForgotPasswordView.js index 2f40ee9eb..d7af4ad7f 100644 --- a/app/views/ForgotPasswordView.js +++ b/app/views/ForgotPasswordView.js @@ -1,13 +1,14 @@ import React from 'react'; import Spinner from 'react-native-loading-spinner-overlay'; import PropTypes from 'prop-types'; -import { Text, TextInput, View, TouchableOpacity, Alert, SafeAreaView } from 'react-native'; +import { Text, TextInput, View, TouchableOpacity, SafeAreaView } from 'react-native'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as loginActions from '../actions/login'; import KeyboardView from '../presentation/KeyboardView'; import styles from './Styles'; +import { showErrorAlert } from '../utils/info'; class ForgotPasswordView extends React.Component { static propTypes = { @@ -35,11 +36,11 @@ class ForgotPasswordView extends React.Component { if (login.success) { this.props.navigation.goBack(); setTimeout(() => { - Alert.alert( - 'Alert', + showErrorAlert( 'If this email is registered, ' + 'we\'ll send instructions on how to reset your password. ' + - 'If you do not receive an email shortly, please come back and try again.' + 'If you do not receive an email shortly, please come back and try again.', + 'Alert' ); }); } diff --git a/app/views/LoginView.js b/app/views/LoginView.js index f7432ee8a..303aee5e4 100644 --- a/app/views/LoginView.js +++ b/app/views/LoginView.js @@ -8,6 +8,7 @@ import * as loginActions from '../actions/login'; import KeyboardView from '../presentation/KeyboardView'; import styles from './Styles'; +import { showToast } from '../utils/info'; class LoginView extends React.Component { static propTypes = { @@ -34,6 +35,7 @@ class LoginView extends React.Component { submit = () => { const { username, password, code } = this.state; if (username.trim() === '' || password.trim() === '') { + showToast('Email or password field is empty'); return; } diff --git a/app/views/RegisterView.js b/app/views/RegisterView.js index 7f97e48d7..766d60e0e 100644 --- a/app/views/RegisterView.js +++ b/app/views/RegisterView.js @@ -10,6 +10,7 @@ import * as loginActions from '../actions/login'; import KeyboardView from '../presentation/KeyboardView'; import styles from './Styles'; +import { showToast } from '../utils/info'; const placeholderTextColor = 'rgba(255,255,255,.2)'; @@ -51,6 +52,7 @@ class RegisterView extends React.Component { name, email, password, code } = this.state; if (!this._valid()) { + showToast('Some field is invalid or empty'); return; } diff --git a/package-lock.json b/package-lock.json index 6428a9be4..4c9d7d873 100644 --- a/package-lock.json +++ b/package-lock.json @@ -149,6 +149,11 @@ "resolved": "https://registry.npmjs.org/@hypnosphi/fuse.js/-/fuse.js-3.0.9.tgz", "integrity": "sha1-6pn2EhtKjwZbTHH4VZXbJxRJiAc=" }, + "@remobile/react-native-toast": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@remobile/react-native-toast/-/react-native-toast-1.0.7.tgz", + "integrity": "sha512-iOD1PRnTSVr9sDWQdesIpfRrwJhHfeEQe5BpalQxC5OhM9thpiE6cu2NlW1KBWl0RJG4ZiJaF1xLlCo9YxU6dA==" + }, "@storybook/addon-storyshots": { "version": "3.2.18", "resolved": "https://registry.npmjs.org/@storybook/addon-storyshots/-/addon-storyshots-3.2.18.tgz", diff --git a/package.json b/package.json index 7e4a7699c..f130d059c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ ] }, "dependencies": { + "@remobile/react-native-toast": "^1.0.7", "@storybook/addons": "^3.3.1", "@storybook/react-native": "^3.2.18", "babel-plugin-transform-decorators-legacy": "^1.3.4",