From f3e96bd229892d2ce3479b149454db609db9a95d Mon Sep 17 00:00:00 2001 From: Bruno Lemos Date: Mon, 21 Nov 2016 03:50:13 -0200 Subject: [PATCH] Added react-native-navigation --- android/app/build.gradle | 1 + .../main/java/com/devhub/MainActivity.java | 5 +- .../main/java/com/devhub/MainApplication.java | 27 ++++++++- android/settings.gradle | 2 + index.android.js | 6 +- index.ios.js | 6 +- ios/devhub.xcodeproj/project.pbxproj | 37 ++++++++++++ ios/devhub/AppDelegate.m | 35 +++++++---- package.json | 1 + src/components/Columns.js | 6 +- src/components/Main.js | 1 - src/containers/App.js | 32 ++++++---- src/index.js | 60 +++++++++++++++++-- src/screens/index.js | 14 +++++ src/utils/helpers/icon-loader.js | 50 ++++++++++++++++ src/utils/{helpers.js => helpers/index.js} | 4 +- src/utils/types/navigator.js | 22 +++++++ yarn.lock | 12 +++- 18 files changed, 271 insertions(+), 50 deletions(-) create mode 100644 src/screens/index.js create mode 100644 src/utils/helpers/icon-loader.js rename src/utils/{helpers.js => helpers/index.js} (79%) create mode 100644 src/utils/types/navigator.js diff --git a/android/app/build.gradle b/android/app/build.gradle index 34d229e7..82a29748 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -126,6 +126,7 @@ android { } dependencies { + compile project(':react-native-navigation') compile project(':react-native-vector-icons') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" diff --git a/android/app/src/main/java/com/devhub/MainActivity.java b/android/app/src/main/java/com/devhub/MainActivity.java index c116e547..28bd7a39 100644 --- a/android/app/src/main/java/com/devhub/MainActivity.java +++ b/android/app/src/main/java/com/devhub/MainActivity.java @@ -1,9 +1,10 @@ package com.devhub; -import com.facebook.react.ReactActivity; +// import com.facebook.react.ReactActivity; +import com.reactnativenavigation.controllers.SplashActivity; import com.oblador.vectoricons.VectorIconsPackage; -public class MainActivity extends ReactActivity { +public class MainActivity extends SplashActivity { /** * Returns the name of the main component registered from JavaScript. diff --git a/android/app/src/main/java/com/devhub/MainApplication.java b/android/app/src/main/java/com/devhub/MainApplication.java index 84bb6094..8c41bc44 100644 --- a/android/app/src/main/java/com/devhub/MainApplication.java +++ b/android/app/src/main/java/com/devhub/MainApplication.java @@ -3,7 +3,9 @@ package com.devhub; import android.app.Application; import android.util.Log; -import com.facebook.react.ReactApplication; +// import com.facebook.react.ReactApplication; +import com.reactnativenavigation.NavigationApplication; +import com.reactnativenavigation.NavigationReactPackage; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; @@ -12,8 +14,9 @@ import com.facebook.react.shell.MainReactPackage; import java.util.Arrays; import java.util.List; -public class MainApplication extends Application implements ReactApplication { +public class MainApplication extends Application implements NavigationApplication { + /* private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override protected boolean getUseDeveloperSupport() { @@ -23,13 +26,31 @@ public class MainApplication extends Application implements ReactApplication { @Override protected List getPackages() { return Arrays.asList( - new MainReactPackage() + new MainReactPackage(), + new NavigationReactPackage() ); } }; + */ @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } + + @Override + public boolean isDebug() { + // Make sure you are using BuildConfig from your own application + return BuildConfig.DEBUG; + } + + @NonNull + @Override + public List createAdditionalReactPackages() { + // Add the packages you require here. + // No need to add RnnPackage and MainReactPackage + return Arrays.asList( + new NavigationReactPackage() + ); + } } diff --git a/android/settings.gradle b/android/settings.gradle index 0e7f5189..5dd543a8 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,5 +1,7 @@ rootProject.name = 'devhub' include ':app' +include ':react-native-navigation' +project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') diff --git a/index.android.js b/index.android.js index ff23e6ea..9c98b0d6 100644 --- a/index.android.js +++ b/index.android.js @@ -1,7 +1,7 @@ // @flow -import { AppRegistry } from 'react-native'; +// import { AppRegistry } from 'react-native'; -import App from './src/'; +import './src/'; -AppRegistry.registerComponent('devhub', () => App); +// AppRegistry.registerComponent('devhub', () => App); diff --git a/index.ios.js b/index.ios.js index ff23e6ea..9c98b0d6 100644 --- a/index.ios.js +++ b/index.ios.js @@ -1,7 +1,7 @@ // @flow -import { AppRegistry } from 'react-native'; +// import { AppRegistry } from 'react-native'; -import App from './src/'; +import './src/'; -AppRegistry.registerComponent('devhub', () => App); +// AppRegistry.registerComponent('devhub', () => App); diff --git a/ios/devhub.xcodeproj/project.pbxproj b/ios/devhub.xcodeproj/project.pbxproj index a55a6efd..189c843c 100644 --- a/ios/devhub.xcodeproj/project.pbxproj +++ b/ios/devhub.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; + 392F28C27C4346A29A767284 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2945A77FC1884935A327923C /* libReactNativeNavigation.a */; }; 58EE6352AADD42FB9A651625 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C5E41F4742B04791AEEE3757 /* EvilIcons.ttf */; }; 60A6A30424314974BFB37ED3 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D98EBE87E8DA4C4EB2D987AB /* libRNVectorIcons.a */; }; 6B74D2F529634189ACF1ED99 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CF10F6540C39491AA1EBE930 /* Ionicons.ttf */; }; @@ -106,6 +107,13 @@ remoteGlobalIDString = 5DBEB1501B18CEA900B34395; remoteInfo = RNVectorIcons; }; + 2E9237C31DE2AB6800AB29E9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1B5BCF017E9A46228778037F /* ReactNativeNavigation.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D8AFADBD1BEE6F3F00A4592D; + remoteInfo = ReactNativeNavigation; + }; 2EBC39771DDFF9CB0069A371 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; @@ -191,8 +199,10 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = devhub/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = devhub/main.m; sourceTree = ""; }; 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; + 1B5BCF017E9A46228778037F /* ReactNativeNavigation.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeNavigation.xcodeproj; path = "../node_modules/react-native-navigation/ios/ReactNativeNavigation.xcodeproj"; sourceTree = ""; }; 23A0EA464A944240ACD77912 /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = ""; }; 241679101CEA4099A8AD0C10 /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = "../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf"; sourceTree = ""; }; + 2945A77FC1884935A327923C /* libReactNativeNavigation.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libReactNativeNavigation.a; sourceTree = ""; }; 30E9E130484F498CACEDF9D6 /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = ""; }; 38E5F71976814E6193BF4FD1 /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Foundation.ttf"; sourceTree = ""; }; 4100AE658B094BB89ECEDB0C /* 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 = ""; }; @@ -230,6 +240,7 @@ 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 60A6A30424314974BFB37ED3 /* libRNVectorIcons.a in Frameworks */, + 392F28C27C4346A29A767284 /* libReactNativeNavigation.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -344,6 +355,14 @@ name = Products; sourceTree = ""; }; + 2E9237AF1DE2AB6800AB29E9 /* Products */ = { + isa = PBXGroup; + children = ( + 2E9237C41DE2AB6800AB29E9 /* libReactNativeNavigation.a */, + ); + name = Products; + sourceTree = ""; + }; 78C398B11ACF4ADC00677621 /* Products */ = { isa = PBXGroup; children = ( @@ -367,6 +386,7 @@ 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 23A0EA464A944240ACD77912 /* RNVectorIcons.xcodeproj */, + 1B5BCF017E9A46228778037F /* ReactNativeNavigation.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -528,6 +548,10 @@ ProductGroup = 146834001AC3E56700842450 /* Products */; ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, + { + ProductGroup = 2E9237AF1DE2AB6800AB29E9 /* Products */; + ProjectRef = 1B5BCF017E9A46228778037F /* ReactNativeNavigation.xcodeproj */; + }, { ProductGroup = 2E92378E1DE2A2A800AB29E9 /* Products */; ProjectRef = 23A0EA464A944240ACD77912 /* RNVectorIcons.xcodeproj */; @@ -605,6 +629,13 @@ remoteRef = 2E9237A21DE2A2A800AB29E9 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 2E9237C41DE2AB6800AB29E9 /* libReactNativeNavigation.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReactNativeNavigation.a; + remoteRef = 2E9237C31DE2AB6800AB29E9 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 2EBC39781DDFF9CB0069A371 /* libRCTImage-tvOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -771,6 +802,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -790,6 +822,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -809,6 +842,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", + "$(SRCROOT)/../node_modules/react-native-navigation/ios/**", ); INFOPLIST_FILE = devhub/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -834,6 +868,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", + "$(SRCROOT)/../node_modules/react-native-navigation/ios/**", ); INFOPLIST_FILE = devhub/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -891,6 +926,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", + "$(SRCROOT)/../node_modules/react-native-navigation/ios/**", ); IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; @@ -935,6 +971,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", + "$(SRCROOT)/../node_modules/react-native-navigation/ios/**", ); IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/ios/devhub/AppDelegate.m b/ios/devhub/AppDelegate.m index ace3295f..d1f5e362 100644 --- a/ios/devhub/AppDelegate.m +++ b/ios/devhub/AppDelegate.m @@ -1,19 +1,30 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - #import "AppDelegate.h" - -#import "RCTBundleURLProvider.h" +#import "RCCManager.h" #import "RCTRootView.h" +#import "RCTBundleURLProvider.h" +#import + +#define UIColorFromRGB(rgbValue) \ +[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ + green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \ + blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \ + alpha:1.0] @implementation AppDelegate +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + NSURL *jsCodeLocation; + jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; + + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + self.window.backgroundColor = UIColorFromRGB(0x111111); + [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation]; + + return YES; +} + +/* - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; @@ -32,6 +43,6 @@ self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; -} +*/ @end diff --git a/package.json b/package.json index 3cbb78c2..e893326a 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "react": "~15.3.1", "react-native": "0.37.0", + "react-native-navigation": "next", "react-native-vector-icons": "^3.0.0", "react-redux": "^4.4.6", "redux": "^3.6.0", diff --git a/src/components/Columns.js b/src/components/Columns.js index 40a12559..4d7910e9 100644 --- a/src/components/Columns.js +++ b/src/components/Columns.js @@ -10,11 +10,10 @@ import { contentPadding } from '../themes/variables'; const margin = 4; const getWidth = ({ first, last } = {}) => { - const onlyOne = first && last; const { width } = Dimensions.get('window'); - if (onlyOne) return width; - if (first || last) return width - contentPadding - margin; + // if (first && last) return width; + // if (first || last) return width - contentPadding - margin; return width - (2 * (contentPadding + margin)); }; @@ -39,6 +38,7 @@ export default props => ( width={getWidth()} loop={false} removeClippedSubviews={false} + contentContainerStyle={{ marginHorizontal: contentPadding + margin }} horizontal pagingEnabled {...props} diff --git a/src/components/Main.js b/src/components/Main.js index f84b0cb7..c3d9c249 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -7,7 +7,6 @@ import Columns from './Columns'; const Main = styled.View` flex: 1; - background-color: ${({ theme }) => theme.base00}; `; export default () => ( diff --git a/src/containers/App.js b/src/containers/App.js index 02624db4..bd033f02 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -13,6 +13,7 @@ import type { State } from '../utils/types'; const Root = styled(View)` flex: 1; + background-color: ${({ theme }) => theme.base00}; `; const StatusBarContainer = styled(View)` @@ -24,20 +25,25 @@ const StyledMain = styled(Main)` flex: 1; `; -const App = ({ theme }: State) => ( - - - - - +const App = ({ setTheme, theme }: State) => { + // TODO: Remove this + setTheme('dark'); - - - -); + return ( + + + + + + + + + + ); +}; const mapStateToProps = ({ config }: State) => ({ config, diff --git a/src/index.js b/src/index.js index dc2821e4..660f9542 100644 --- a/src/index.js +++ b/src/index.js @@ -2,20 +2,68 @@ import React from 'react'; import { AsyncStorage } from 'react-native'; +import { Navigation } from 'react-native-navigation'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; import { persistStore, autoRehydrate } from 'redux-persist'; import { composeWithDevTools } from 'remote-redux-devtools'; -import App from './containers/App'; import reducer from './reducers'; +import { registerScreens } from './screens'; +import { iconsMap, iconsLoaded } from './utils/helpers/icon-loader'; +import darkTheme from './themes/dark'; const composeEnhancers = composeWithDevTools({ realtime: true }); const store = createStore(reducer, composeEnhancers(autoRehydrate())); persistStore(store, { storage: AsyncStorage, blacklist: ['theme'] }); -export default () => ( - - - -); +const navigatorStyle = { + screenColor: darkTheme.base00, + navBarHidden: true, +}; + +function startApp() { + Navigation.startTabBasedApp({ + tabs: [ + { + screen: 'devhub.App', + label: 'Feed', + icon: iconsMap['mark-github'], + selectedIcon: iconsMap['mark-github__inverted'], + navigatorStyle, + }, + { + screen: 'devhub.View', + label: 'Discover', + icon: iconsMap.flame, + selectedIcon: iconsMap.flame__inverted, + navigatorStyle, + }, + { + screen: 'devhub.View', + label: 'Notifications', + icon: iconsMap.globe, + selectedIcon: iconsMap.globe__inverted, + navigatorStyle, + }, + { + screen: 'devhub.View', + label: 'More', + icon: iconsMap.gear, + selectedIcon: iconsMap.gear__inverted, + navigatorStyle, + }, + ], + tabsStyle: { + tabBarButtonColor: '#3f3f3f', // change the color of the tab icons and text (also unselected) + tabBarSelectedButtonColor: '#ffffff', // change the color of the selected tab icon and text (only selected) + tabBarBackgroundColor: '#111111', // change the background color of the tab bar + }, + }); +} + +registerScreens(store, Provider); + +iconsLoaded.then(() => { + startApp(); +}); diff --git a/src/screens/index.js b/src/screens/index.js new file mode 100644 index 00000000..c7e7149b --- /dev/null +++ b/src/screens/index.js @@ -0,0 +1,14 @@ +// @flow +/* eslint-disable import/prefer-default-export */ + +import React from 'react'; +import { View } from 'react-native'; +import { Navigation } from 'react-native-navigation'; + +// public screens +import App from '../containers/App'; + +export function registerScreens(store, provider) { + Navigation.registerComponent('devhub.App', () => App, store, provider); + Navigation.registerComponent('devhub.View', () => () => , store, provider); +} diff --git a/src/utils/helpers/icon-loader.js b/src/utils/helpers/icon-loader.js new file mode 100644 index 00000000..e7923bbc --- /dev/null +++ b/src/utils/helpers/icon-loader.js @@ -0,0 +1,50 @@ +// Define all your icons once, +// load them once, +// and use everywhere +// https://gist.github.com/dropfen/4a2209d7274788027f782e8655be198f + +import Octicons from 'react-native-vector-icons/Octicons'; + +const defaultIconProvider = Octicons; +const iconsMap = {}; + +const sizes = { + normal: 24, +}; + +// define your suffixes by yourself.. +// here we use active, big, small, very-big... +const replaceSuffixPattern = /__(inverted)/g; +const icons = { + 'mark-github': [sizes.normal, '#000000'], + 'mark-github__inverted': [sizes.normal, '#ffffff'], + flame: [sizes.normal, '#000000'], + flame__inverted: [sizes.normal, '#ffffff'], + globe: [sizes.normal, '#000000'], + globe__inverted: [sizes.normal, '#ffffff'], + gear: [sizes.normal, '#000000'], + gear__inverted: [sizes.normal, '#ffffff'], +}; + +const iconsLoaded = new Promise((resolve) => { + Promise.all( + Object.keys(icons).map((iconName) => { + const Provider = icons[iconName][2] || defaultIconProvider; // Octicons + return Provider.getImageSource( + iconName.replace(replaceSuffixPattern, ''), + icons[iconName][0], + icons[iconName][1], + ); + }) // eslint-disable-line comma-dangle + ).then((sources) => { + Object.keys(icons).forEach((iconName, idx) => { iconsMap[iconName] = sources[idx]; }); + + // Call resolve (and we are done) + resolve(true); + }); +}); + +export { + iconsMap, + iconsLoaded, +}; diff --git a/src/utils/helpers.js b/src/utils/helpers/index.js similarity index 79% rename from src/utils/helpers.js rename to src/utils/helpers/index.js index 261283da..5c2a9548 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers/index.js @@ -1,8 +1,8 @@ // @flow /* eslint-disable import/prefer-default-export */ -import { DARK_THEME, LIGHT_THEME } from '../themes'; -import type { Theme } from './types'; +import { DARK_THEME, LIGHT_THEME } from '../../themes'; +import type { Theme } from '../types'; export function isNight() { const hours = (new Date()).getHours(); diff --git a/src/utils/types/navigator.js b/src/utils/types/navigator.js new file mode 100644 index 00000000..8ef3140c --- /dev/null +++ b/src/utils/types/navigator.js @@ -0,0 +1,22 @@ +// @flow + +export type Navigator = { + push: Function, + pop: Function, + popToRoot: Function, + resetTo: Function, + showModal: Function, + dismissModal: Function, + dismissAllModals: Function, + showLightBox: Function, + dismissLightBox: Function, + handleDeepLink: Function, + setOnNavigatorEvent: Function, + setButtons: Function, + setTitle: Function, + toggleDrawer: Function, + toggleTabs: Function, + setTabBadge: Function, + switchToTab: Function, + toggleNavBar: Function, +}; diff --git a/yarn.lock b/yarn.lock index 839dc6fb..5b7284af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3535,7 +3535,7 @@ lodash@^3.1.0, lodash@^3.10.1, lodash@^3.2.0, lodash@^3.3.1, lodash@^3.5.0, loda version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.0.0, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: +lodash@^4.0.0, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.16.0, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: version "4.17.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42" @@ -4227,6 +4227,14 @@ react-deep-force-update@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.0.1.tgz#f911b5be1d2a6fe387507dd6e9a767aa2924b4c7" +react-native-navigation@next: + version "2.0.0-experimental.141" + resolved "https://registry.yarnpkg.com/react-native-navigation/-/react-native-navigation-2.0.0-experimental.141.tgz#180ec23f95bd7e74105769f30c16a0736e0f0465" + dependencies: + lodash "^4.16.0" + optionalDependencies: + react-redux "*" + react-native-vector-icons@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-3.0.0.tgz#a2f63757dee4fb89f67eef660e25e86926ae6827" @@ -4318,7 +4326,7 @@ react-proxy@^1.1.7: lodash "^4.6.1" react-deep-force-update "^1.0.0" -react-redux@^4.4.6: +react-redux@*, react-redux@^4.4.6: version "4.4.6" resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-4.4.6.tgz#4b9d32985307a11096a2dd61561980044fcc6209" dependencies: