mirror of
https://github.com/zhigang1992/devhub.git
synced 2026-06-18 03:58:44 +08:00
Added react-native-navigation
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>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<ReactPackage> createAdditionalReactPackages() {
|
||||
// Add the packages you require here.
|
||||
// No need to add RnnPackage and MainReactPackage
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new NavigationReactPackage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 = "<group>"; };
|
||||
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = devhub/main.m; sourceTree = "<group>"; };
|
||||
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
2945A77FC1884935A327923C /* libReactNativeNavigation.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libReactNativeNavigation.a; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
@@ -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 = "<group>";
|
||||
};
|
||||
2E9237AF1DE2AB6800AB29E9 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2E9237C41DE2AB6800AB29E9 /* libReactNativeNavigation.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
78C398B11ACF4ADC00677621 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -367,6 +386,7 @@
|
||||
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
|
||||
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
|
||||
23A0EA464A944240ACD77912 /* RNVectorIcons.xcodeproj */,
|
||||
1B5BCF017E9A46228778037F /* ReactNativeNavigation.xcodeproj */,
|
||||
);
|
||||
name = Libraries;
|
||||
sourceTree = "<group>";
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <AVFoundation/AVFoundation.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -7,7 +7,6 @@ import Columns from './Columns';
|
||||
|
||||
const Main = styled.View`
|
||||
flex: 1;
|
||||
background-color: ${({ theme }) => theme.base00};
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
|
||||
@@ -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) => (
|
||||
<ThemeProvider theme={theme}>
|
||||
<Root>
|
||||
<StatusBarContainer>
|
||||
<StatusBar
|
||||
backgroundColor={theme.base01}
|
||||
barStyle={theme.isDark ? 'light-content' : 'dark-content'}
|
||||
/>
|
||||
</StatusBarContainer>
|
||||
const App = ({ setTheme, theme }: State) => {
|
||||
// TODO: Remove this
|
||||
setTheme('dark');
|
||||
|
||||
<StyledMain />
|
||||
</Root>
|
||||
</ThemeProvider>
|
||||
);
|
||||
return (
|
||||
<ThemeProvider theme={theme}>
|
||||
<Root>
|
||||
<StatusBarContainer>
|
||||
<StatusBar
|
||||
backgroundColor={theme.base01}
|
||||
barStyle={theme.isDark ? 'light-content' : 'dark-content'}
|
||||
/>
|
||||
</StatusBarContainer>
|
||||
|
||||
<StyledMain />
|
||||
</Root>
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = ({ config }: State) => ({
|
||||
config,
|
||||
|
||||
60
src/index.js
60
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 () => (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
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();
|
||||
});
|
||||
|
||||
14
src/screens/index.js
Normal file
14
src/screens/index.js
Normal file
@@ -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', () => () => <View />, store, provider);
|
||||
}
|
||||
50
src/utils/helpers/icon-loader.js
Normal file
50
src/utils/helpers/icon-loader.js
Normal file
@@ -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,
|
||||
};
|
||||
@@ -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();
|
||||
22
src/utils/types/navigator.js
Normal file
22
src/utils/types/navigator.js
Normal file
@@ -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,
|
||||
};
|
||||
12
yarn.lock
12
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:
|
||||
|
||||
Reference in New Issue
Block a user