Skip to content

Commit

Permalink
refactoring and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZlotin committed Jan 5, 2017
1 parent 1e3cd7c commit 106c303
Show file tree
Hide file tree
Showing 17 changed files with 274 additions and 93 deletions.
20 changes: 20 additions & 0 deletions integration/SingleScreen.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('single screen integration', () => {
let Navigation;
let mockNativeNavigation;

beforeEach(() => {
mockNativeNavigation = {};
require('react-native').NativeModules.NativeNavigation = mockNativeNavigation;
Navigation = require('../../src/index').default;
});

xit('startApp directs to native with constructed hirarchy for single screens', () => {
mockNativeNavigation.startApp = jest.fn();
Navigation.startApp({
container: {
key: 'com.integration.MyFirstScreen'
}
});
expect(mockNativeNavigation.startApp).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('remx support', () => {
let store;

beforeEach(() => {
MyConnectedContainer = require('./remx-support-component').default;
store = require('./remx-support-store');
MyConnectedContainer = require('./remxComponent').default;
store = require('./remxStore');
});

it('renders normally', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {Component} from 'react';

import {connect} from 'remx/react-native';

import {selectors} from './remx-support-store';
import {selectors} from './remxStore';

class MyContainer extends Component {
constructor(props) {
Expand Down
File renamed without changes.
177 changes: 177 additions & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,174 @@
############
# Node
############
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

################
# JetBrains
################
.idea

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties


############
# iOS
############
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
ios/build/
ios/DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
ios/xcuserdata/

## Other
*.moved-aside
*.xcuserstate

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
ios/Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/screenshots


############
# Android
############
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
android/bin/
android/gen/
android/out/

# Gradle files
android/.gradle/
android/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
android/proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
android/.navigation/

# Android Studio captures folder
android/captures/

# Intellij
*.iml

# Keystore files
*.jks

##################
# React-Native
##################
# OSX
#
.DS_Store
Expand Down Expand Up @@ -32,3 +203,9 @@ local.properties
#
node_modules/
npm-debug.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
6 changes: 3 additions & 3 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"postinstall": "rm -rf node_modules/react-native-navigation/node_modules && rm -rf node_modules/react-native-navigation/playground",
"start": "watchman watch-del-all && (adb reverse tcp:8081 tcp:8081 || true) && node node_modules/react-native/local-cli/cli.js start --reset-cache",
"xcode": "open ios/example.xcodeproj",
"xcode": "open ios/playground.xcodeproj",
"android": "cd android && ./gradlew installDebug",
"e2e": "node ./scripts/e2e.ios.js"
},
Expand All @@ -21,10 +21,10 @@
"detox": {
"session": {
"server": "ws://localhost:8099",
"sessionId": "example"
"sessionId": "playground"
},
"ios-simulator": {
"app": "ios/DerivedData/example/Build/Products/Debug_Detox-iphonesimulator/example.app",
"app": "ios/DerivedData/playground/Build/Products/Debug_Detox-iphonesimulator/playground.app",
"device": "iPhone 7, iOS 10.1"
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/Navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import _ from 'lodash';

describe('Navigation', () => {
let Navigation;
let Commands;
let ContainerRegistry;

beforeEach(() => {
jest.mock('./containers/ContainerRegistry');
Navigation = require('./Navigation');
Commands = require('./commands/Commands');
ContainerRegistry = require('./containers/ContainerRegistry');
Navigation = require('./Navigation');
});

it('exposes static commands', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
export const singleContainerApp = {
describe('valid commands', () => {
it('just works', () => {
//
});
});

const singleContainerApp = {
container: {
key: 'com.example.FirstTabContainer'
}
};

export const tabBasedApp = {
const tabBasedApp = {
tabs: [
{
container: {
Expand All @@ -24,7 +30,7 @@ export const tabBasedApp = {
]
};

export const singleWithSideMenu = {
const singleWithSideMenu = {
container: {
key: 'com.example.MyContainer'
},
Expand All @@ -35,7 +41,7 @@ export const singleWithSideMenu = {
}
};

export const singleWithRightSideMenu = {
const singleWithRightSideMenu = {
container: {
key: 'com.example.MyContainer'
},
Expand All @@ -46,7 +52,7 @@ export const singleWithRightSideMenu = {
}
};

export const singleWithBothMenus = {
const singleWithBothMenus = {
container: {
key: 'com.example.MyContainer'
},
Expand All @@ -60,7 +66,7 @@ export const singleWithBothMenus = {
}
};

export const tabBasedWithSideMenu = {
const tabBasedWithSideMenu = {
tabs: [
{
container: {
Expand Down
12 changes: 4 additions & 8 deletions src/containers/ContainerRegistry.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React, {Component} from 'react';
import {AppRegistry} from 'react-native';
import * as PropsStore from './PropsStore';
import * as ContainerStore from './ContainerStore';
import * as Store from './Store';

export function registerContainer(containerKey, getContainerFunc) {
const OriginalContainer = getContainerFunc();
const NavigationContainer = wrapContainer(containerKey, OriginalContainer);
ContainerStore.setContainerClass(containerKey, NavigationContainer);
Store.setContainerClass(containerKey, NavigationContainer);
AppRegistry.registerComponent(containerKey, () => NavigationContainer);
}

export const bla = {};

function wrapContainer(containerKey, OriginalContainer) {
return class extends Component {
constructor(props) {
Expand All @@ -21,20 +18,19 @@ function wrapContainer(containerKey, OriginalContainer) {
}
this.state = {
containerId: props.containerId,
allProps: {...props, ...PropsStore.getPropsForContainerId(props.containerId)}
allProps: {...props, ...Store.getPropsForContainerId(props.containerId)}
};
}

componentWillReceiveProps(nextProps) {
this.setState({
allProps: {...nextProps, ...PropsStore.getPropsForContainerId(this.state.containerId)}
allProps: {...nextProps, ...Store.getPropsForContainerId(this.state.containerId)}
});
}

render() {
return (
<OriginalContainer
ref={(r) => bla.ref = r}
{...this.state.allProps}
containerId={this.state.containerId}
/>
Expand Down
Loading

0 comments on commit 106c303

Please sign in to comment.