Commit 94491753 authored by Gijs Hendriksen's avatar Gijs Hendriksen Committed by Wietse Kuipers

Replace snackbar component with native solution

parent 34b4458b
......@@ -95,8 +95,8 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 25
buildToolsVersion "25.0.2"
lintOptions {
abortOnError false
......@@ -145,6 +145,7 @@ android {
}
dependencies {
compile project(':react-native-snackbar')
compile project(':react-native-fcm')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
......
......@@ -3,6 +3,7 @@ package com.thaliapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.azendoo.reactnativesnackbar.SnackbarPackage;
import com.evollu.react.fcm.FIRMessagingPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.oblador.vectoricons.VectorIconsPackage;
......@@ -26,6 +27,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SnackbarPackage(),
new FIRMessagingPackage(),
new LinearGradientPackage(),
new VectorIconsPackage()
......
rootProject.name = 'ThaliApp'
include ':react-native-snackbar'
project(':react-native-snackbar').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-snackbar/android')
include ':react-native-fcm'
project(':react-native-fcm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fcm/android')
include ':react-native-linear-gradient'
......
export const LOGIN = 'LOGIN_LOGIN';
export const FETCHING = 'LOGIN_FETCHING';
export const SUCCESS = 'LOGIN_SUCCESS';
export const FAILURE = 'LOGIN_FAILURE';
export const LOGOUT = 'LOGIN_LOGOUT';
export const RESET = 'LOGIN_RESET';
export function reset() {
return { type: RESET };
}
export function success(username, token, displayName, photo, loginState = 'success') {
return { type: SUCCESS, payload: { username, token, displayName, photo, loginState } };
}
export function fetching() {
return { type: FETCHING };
}
export function failure() {
return { type: FAILURE };
export function success(username, token, displayName, photo) {
return { type: SUCCESS, payload: { username, token, displayName, photo } };
}
export function login(user, pass) {
......
......@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { View, StatusBar, BackHandler } from 'react-native';
import { connect } from 'react-redux';
import Drawer from 'react-native-drawer';
import SnackBar from 'react-native-snackbar-component';
import Login from './Login';
import Welcome from './Welcome';
import Sidebar from './Sidebar';
......@@ -17,19 +16,6 @@ import * as actions from '../actions/navigation';
import styles from './style/navigator';
import { colors } from '../style';
const loginResult = (status) => {
switch (status) {
case 'progress':
return 'Logging in';
case 'failure':
return 'Login failed';
case 'logout':
return 'Logout successful';
default:
return '';
}
};
const sceneToComponent = (scene) => {
switch (scene) {
case 'welcome':
......@@ -48,7 +34,7 @@ const sceneToComponent = (scene) => {
};
const ReduxNavigator = (props) => {
const { currentScene, loggedIn, drawerOpen, updateDrawer, loginState,
const { currentScene, loggedIn, drawerOpen, updateDrawer,
isFirstScene, back, navigateToWelcome } = props;
BackHandler.addEventListener('hardwareBackPress', () => {
if (!isFirstScene) {
......@@ -84,7 +70,6 @@ const ReduxNavigator = (props) => {
>
{currentScene !== 'profile' && <StandardHeader />}
{sceneToComponent(currentScene)}
<SnackBar visible={loginState === 'success'} textMessage={'Login success'} />
</Drawer>);
}
return (
......@@ -100,7 +85,6 @@ const ReduxNavigator = (props) => {
/>
</View>
<Login />
<SnackBar visible={loginState !== ''} textMessage={loginResult(loginState)} />
</View>);
};
......@@ -112,7 +96,6 @@ ReduxNavigator.propTypes = {
updateDrawer: PropTypes.func.isRequired,
back: PropTypes.func.isRequired,
navigateToWelcome: PropTypes.func.isRequired,
loginState: PropTypes.string.isRequired,
};
const mapStateToProps = state => ({
......@@ -120,7 +103,6 @@ const mapStateToProps = state => ({
loggedIn: state.navigation.loggedIn,
drawerOpen: state.navigation.drawerOpen,
isFirstScene: state.navigation.previousScenes.length === 0,
loginState: state.session.loginState,
});
const mapDispatchToProps = dispatch => ({
......
import * as loginActions from '../actions/login';
const initialState = {
loginState: '',
token: '',
username: '',
displayName: '',
......@@ -13,20 +12,13 @@ export default function session(state = initialState, action = {}) {
case loginActions.SUCCESS:
return {
...state,
loginState: action.payload.loginState,
username: action.payload.username,
token: action.payload.token,
displayName: action.payload.displayName,
photo: action.payload.photo,
};
case loginActions.FAILURE:
return { ...state, loginState: 'failure' };
case loginActions.FETCHING:
return { ...state, loginState: 'progress' };
case loginActions.LOGOUT:
return { ...initialState, loginState: 'logout' };
case loginActions.RESET:
return { ...state, loginState: '' };
return initialState;
default:
return state;
}
......
import { delay } from 'redux-saga';
import { call, takeEvery, put } from 'redux-saga/effects';
import { AsyncStorage } from 'react-native';
import Snackbar from 'react-native-snackbar';
import { apiRequest, url } from '../url';
import * as loginActions from '../actions/login';
......@@ -15,7 +15,9 @@ const defaultAvatar = `${url}/static/members/images/default-avatar.jpg`;
const login = function* login(action) {
const { user, pass } = action.payload;
yield put(loginActions.fetching());
Snackbar.show({ title: 'Logging in', duration: Snackbar.LENGTH_INDEFINITE });
let data = {
method: 'POST',
headers: {
......@@ -51,20 +53,18 @@ const login = function* login(action) {
user, token, displayName, avatar,
));
yield put(pushNotificationsActions.register());
yield delay(2000);
yield put(loginActions.reset());
Snackbar.dismiss();
Snackbar.show({ title: 'Login successful' });
} catch (error) {
yield put(loginActions.failure());
yield delay(2000);
yield put(loginActions.reset());
Snackbar.dismiss();
Snackbar.show({ title: 'Login failed' });
}
};
const logout = function* logout() {
yield call(AsyncStorage.multiRemove, [USERNAMEKEY, TOKENKEY]);
yield delay(2000);
yield put(pushNotificationsActions.invalidate());
yield put(loginActions.reset());
Snackbar.show({ title: 'Logout successful' });
};
const loginSaga = function* loginSaga() {
......
......@@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
......@@ -52,6 +51,8 @@
E5F26864D8034A489C708F9E /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CF9FEDFD7450466781B02A2D /* Ionicons.ttf */; };
F4DAEE2B4E1B4763873408DA /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 93DB7BC111BA461BA87006BA /* MaterialCommunityIcons.ttf */; };
FC2516869BC4468581E4A667 /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9D762E1DAD73438C812C1461 /* Foundation.ttf */; };
E133E6C3EC124B32873102B8 /* libRNSnackbar.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 290659E890FD4B2CB58F9F15 /* libRNSnackbar.a */; };
23AADE2280934890A3D7391E /* Feather.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F80608CE5FD849848A5498D4 /* Feather.ttf */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -334,6 +335,9 @@
D43C2AB11CEE73A4F3E016EB /* Pods-ThaliApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ThaliApp.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ThaliApp/Pods-ThaliApp.debug.xcconfig"; sourceTree = "<group>"; };
F808FC5B0C6A43748E179BF6 /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Entypo.ttf"; sourceTree = "<group>"; };
FF381FFBF70744E6865413C2 /* SimpleLineIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = SimpleLineIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf"; sourceTree = "<group>"; };
8AB867AF03AC45AEB3C80BFA /* RNSnackbar.xcodeproj */ = {isa = PBXFileReference; name = "RNSnackbar.xcodeproj"; path = "../node_modules/react-native-snackbar/ios/RNSnackbar.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
290659E890FD4B2CB58F9F15 /* libRNSnackbar.a */ = {isa = PBXFileReference; name = "libRNSnackbar.a"; path = "libRNSnackbar.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
F80608CE5FD849848A5498D4 /* Feather.ttf */ = {isa = PBXFileReference; name = "Feather.ttf"; path = "../node_modules/react-native-vector-icons/Fonts/Feather.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -367,6 +371,7 @@
32D3E4CE1ED98F33004F54F8 /* libBVLinearGradient.a in Frameworks */,
150EE563EF1D49189E5DE953 /* libRNFIRMessaging.a in Frameworks */,
2D1FCA53D8DB5ADD28A3D2F3 /* libPods-ThaliApp.a in Frameworks */,
E133E6C3EC124B32873102B8 /* libRNSnackbar.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -573,6 +578,7 @@
A0A689B11A004758B19C64CE /* RNVectorIcons.xcodeproj */,
5A90BA3FF7F8422A9150FDAA /* BVLinearGradient.xcodeproj */,
8CED7FC8420844AF92491FE8 /* RNFIRMessaging.xcodeproj */,
8AB867AF03AC45AEB3C80BFA /* RNSnackbar.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
......@@ -644,6 +650,7 @@
0EBF699C4D43413C9CCE8127 /* Octicons.ttf */,
FF381FFBF70744E6865413C2 /* SimpleLineIcons.ttf */,
2A30344F7F0A4E50A76BDA3F /* Zocial.ttf */,
F80608CE5FD849848A5498D4 /* Feather.ttf */,
);
name = Resources;
sourceTree = "<group>";
......@@ -1086,6 +1093,7 @@
DD0BDA6EC5B84A00B22A1D59 /* Octicons.ttf in Resources */,
55F8857C1B5F455D81EBEF10 /* SimpleLineIcons.ttf in Resources */,
B4E7CD24D4FD4998A35D2106 /* Zocial.ttf in Resources */,
23AADE2280934890A3D7391E /* Feather.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1305,6 +1313,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-fcm/ios",
"$(SRCROOT)/../node_modules/react-native-snackbar/ios",
);
INFOPLIST_FILE = ThaliAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
......@@ -1314,6 +1323,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
......@@ -1337,6 +1347,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-fcm/ios",
"$(SRCROOT)/../node_modules/react-native-snackbar/ios",
);
INFOPLIST_FILE = ThaliAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
......@@ -1346,6 +1357,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
......@@ -1370,6 +1382,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-fcm/ios",
"$(SRCROOT)/../node_modules/react-native-snackbar/ios",
);
INFOPLIST_FILE = ThaliApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
......@@ -1396,6 +1409,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-fcm/ios",
"$(SRCROOT)/../node_modules/react-native-snackbar/ios",
);
INFOPLIST_FILE = ThaliApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
......@@ -1428,6 +1442,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-fcm/ios",
"$(SRCROOT)/../node_modules/react-native-snackbar/ios",
);
INFOPLIST_FILE = "ThaliApp-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
......@@ -1436,6 +1451,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
......@@ -1467,6 +1483,7 @@
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
"$(SRCROOT)/../node_modules/react-native-fcm/ios",
"$(SRCROOT)/../node_modules/react-native-snackbar/ios",
);
INFOPLIST_FILE = "ThaliApp-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
......@@ -1475,6 +1492,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
......@@ -1507,6 +1525,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.ThaliApp-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
......@@ -1535,6 +1554,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.ThaliApp-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
......
......@@ -49,6 +49,7 @@
<string>Octicons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Zocial.ttf</string>
<string>Feather.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
......
......@@ -14,7 +14,8 @@
"app/**/*.js"
],
"coverageReporters": [
"text", "text-summary"
"text",
"text-summary"
],
"modulePaths": [
".yarn/"
......@@ -28,7 +29,7 @@
"react-native-drawer": "^2.3.0",
"react-native-fcm": "^10.0.2",
"react-native-linear-gradient": "^2.0.0",
"react-native-snackbar-component": "https://github.com/WKuipers/React-Native-SnackBar-Component.git",
"react-native-snackbar": "^0.4.3",
"react-native-vector-icons": "^4.0.1",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
......
......@@ -3998,7 +3998,7 @@ prompt@^0.2.14:
utile "0.2.x"
winston "0.8.x"
prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.6.0:
prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.5.8:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
......@@ -4119,11 +4119,9 @@ react-native-linear-gradient@^2.0.0:
dependencies:
prop-types "^15.5.10"
"react-native-snackbar-component@https://github.com/WKuipers/React-Native-SnackBar-Component.git":
version "1.0.7"
resolved "https://github.com/WKuipers/React-Native-SnackBar-Component.git#8115a040f411b6ef57b22373bb407bc00c291c8f"
dependencies:
prop-types "^15.6.0"
react-native-snackbar@^0.4.3:
version "0.4.3"
resolved "https://registry.yarnpkg.com/react-native-snackbar/-/react-native-snackbar-0.4.3.tgz#b865bd50388c5776d13b2b4ef28052c493b5107c"
react-native-vector-icons@^4.0.1:
version "4.4.2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment