From 2626e4a7bb64fed48331355e03f80dce3022b067 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Sat, 12 Aug 2017 17:52:55 -0300 Subject: [PATCH] Change the navigator by a better one --- .eslintrc | 1 + android/app/build.gradle | 5 +- .../java/com/rocketchatrn/MainActivity.java | 12 +- .../com/rocketchatrn/MainApplication.java | 26 ++-- android/settings.gradle | 2 + app/navigation.js | 68 ++-------- app/views/Main.js | 43 ------- app/views/login.js | 23 ++-- app/views/room.js | 23 ++-- app/views/roomsList.js | 69 ++++++++-- app/views/serverList.js | 59 ++++++--- app/views/serverNew.js | 34 ++++- index.android.js | 7 +- index.ios.js | 7 +- ios/RocketChatRN.xcodeproj/project.pbxproj | 119 +++++++++++++++++- ios/RocketChatRN/AppDelegate.m | 32 +++-- package.json | 1 + 17 files changed, 330 insertions(+), 201 deletions(-) delete mode 100644 app/views/Main.js diff --git a/.eslintrc b/.eslintrc index c8d864c5a..11327145f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -78,6 +78,7 @@ "vars": "all", "args": "after-used" }], + "max-len": 0, "react/jsx-uses-vars": 2, "no-void": 2, "no-var": 2, diff --git a/android/app/build.gradle b/android/app/build.gradle index cb1425889..704e8266f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -90,8 +90,8 @@ def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion 25 + buildToolsVersion "25.0.1" defaultConfig { applicationId "com.rocketchatrn" @@ -133,6 +133,7 @@ android { } dependencies { + compile project(':react-native-navigation') compile project(':react-native-svg') compile project(':react-native-image-picker') compile project(':react-native-vector-icons') diff --git a/android/app/src/main/java/com/rocketchatrn/MainActivity.java b/android/app/src/main/java/com/rocketchatrn/MainActivity.java index 460d2b783..57a754e0b 100644 --- a/android/app/src/main/java/com/rocketchatrn/MainActivity.java +++ b/android/app/src/main/java/com/rocketchatrn/MainActivity.java @@ -1,15 +1,7 @@ package com.rocketchatrn; -import com.facebook.react.ReactActivity; +import com.reactnativenavigation.controllers.SplashActivity; -public class MainActivity extends ReactActivity { +public class MainActivity extends SplashActivity { - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "RocketChatRN"; - } } diff --git a/android/app/src/main/java/com/rocketchatrn/MainApplication.java b/android/app/src/main/java/com/rocketchatrn/MainApplication.java index f55f4fcc1..277cfd500 100644 --- a/android/app/src/main/java/com/rocketchatrn/MainApplication.java +++ b/android/app/src/main/java/com/rocketchatrn/MainApplication.java @@ -3,6 +3,7 @@ package com.rocketchatrn; import android.app.Application; import com.facebook.react.ReactApplication; +// import com.reactnativenavigation.NavigationReactPackage; import com.horcrux.svg.SvgPackage; import com.imagepicker.ImagePickerPackage; import com.oblador.vectoricons.VectorIconsPackage; @@ -13,22 +14,20 @@ import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; +import com.reactnativenavigation.NavigationApplication; import java.util.Arrays; import java.util.List; -public class MainApplication extends Application implements ReactApplication { - - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { +public class MainApplication extends NavigationApplication { @Override - public boolean getUseDeveloperSupport() { + public boolean isDebug() { + // Make sure you are using BuildConfig from your own application return BuildConfig.DEBUG; } - @Override protected List getPackages() { return Arrays.asList( - new MainReactPackage(), new SvgPackage(), new ImagePickerPackage(), new VectorIconsPackage(), @@ -37,16 +36,9 @@ public class MainApplication extends Application implements ReactApplication { new RealmReactPackage() ); } - }; - @Override - public ReactNativeHost getReactNativeHost() { - return mReactNativeHost; - } - - @Override - public void onCreate() { - super.onCreate(); - SoLoader.init(this, /* native exopackage */ false); - } + @Override + public List createAdditionalReactPackages() { + return getPackages(); + } } diff --git a/android/settings.gradle b/android/settings.gradle index fcc9db102..aacf704b9 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'RocketChatRN' +include ':react-native-navigation' +project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app/') include ':react-native-svg' project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android') include ':react-native-image-picker' diff --git a/app/navigation.js b/app/navigation.js index 6733ca1a3..67ae8149d 100644 --- a/app/navigation.js +++ b/app/navigation.js @@ -1,68 +1,22 @@ -import React from 'react'; -import { Button, Platform } from 'react-native'; -import { StackNavigator } from 'react-navigation'; +import { Navigation } from 'react-native-navigation'; import LoginView from './views/login'; import NewServerView from './views/serverNew'; import ListServerView from './views/serverList'; -import Main from './views/Main'; import RoomsListView from './views/roomsList'; import RoomView from './views/room'; import CreateChannel from './views/CreateChannel'; -const MainCardNavigator = StackNavigator({ - Main: { - screen: Main - }, - Rooms: { - screen: RoomsListView - }, - Room: { - screen: RoomView - }, - ListServerModal: { - screen: ListServerView, - navigationOptions: ({ navigation }) => - (Platform.OS === 'ios' ? ({ - headerLeft: Platform.OS === 'ios' && (