Skip to content

Commit

Permalink
RNN 2422
Browse files Browse the repository at this point in the history
  • Loading branch information
birkir committed Jul 23, 2018
1 parent 3920f47 commit 42423b9
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 219 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Expand Up @@ -111,7 +111,7 @@ android {
ndk {
abiFilters "armeabi-v7a", "x86"
}
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative55"
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative56"
multiDexEnabled true
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
@@ -1,6 +1,6 @@
platform :ios, '9.0'

# Force build 0
# Force build 1

target 'Hekla' do

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -19,6 +19,7 @@
]
},
"dependencies": {
"color": "3.0.0",
"core-decorators": "0.20.0",
"date-fns": "1.29.0",
"html-entities": "1.2.1",
Expand All @@ -42,7 +43,7 @@
"react-native-iap": "1.2.5",
"react-native-interactable": "0.1.10",
"react-native-keychain": "3.0.0-rc.3",
"react-native-navigation": "2.0.2394",
"react-native-navigation": "2.0.2422",
"react-native-progress": "3.5.0",
"react-native-rate": "1.0.9",
"react-native-sentry": "0.38.2",
Expand Down
@@ -1,18 +1,15 @@
patch-package
--- a/node_modules/react-native-navigation/lib/ios/RNNBackgroundOptions.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNBackgroundOptions.m
@@ -3,9 +3,9 @@
@@ -3,7 +3,7 @@
@implementation RNNBackgroundOptions

- (void)applyOn:(UIViewController *)viewController {
- if (self.color) {
+ if (self.color && [self.color doubleValue] > 0) {
UIColor* backgroundColor = [RCTConvert UIColor:self.color];
- viewController.navigationController.navigationBar.barTintColor = backgroundColor;
+ viewController.navigationController.navigationBar.barTintColor = backgroundColor;
viewController.navigationController.navigationBar.barTintColor = backgroundColor;
} else {
viewController.navigationController.navigationBar.barTintColor = nil;
}
--- a/node_modules/react-native-navigation/lib/ios/RNNBottomTabsOptions.h
+++ b/node_modules/react-native-navigation/lib/ios/RNNBottomTabsOptions.h
@@ -11,6 +11,7 @@
Expand Down Expand Up @@ -43,36 +40,9 @@ patch-package

if (self.translucent) {
viewController.tabBarController.tabBar.translucent = [self.translucent boolValue];
--- a/node_modules/react-native-navigation/lib/ios/RNNBridgeManager.h
+++ b/node_modules/react-native-navigation/lib/ios/RNNBridgeManager.h
@@ -1,6 +1,7 @@
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>
#import "RNNBridgeManagerDelegate.h"
+#import "RNNStore.h"

typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);

@@ -11,5 +12,6 @@ typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBri
- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;

@property (readonly, nonatomic, strong) RCTBridge *bridge;
+@property (readonly, nonatomic, strong) RNNStore *store;

@end
--- a/node_modules/react-native-navigation/lib/ios/RNNBridgeManager.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNBridgeManager.m
@@ -12,6 +12,7 @@
@interface RNNBridgeManager() <RCTBridgeDelegate>

@property (nonatomic, strong, readwrite) RCTBridge *bridge;
+@property (nonatomic, strong, readwrite) RNNStore *store;

@end

--- a/node_modules/react-native-navigation/lib/ios/RNNCommandsHandler.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNCommandsHandler.m
@@ -101,16 +101,28 @@ -(void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNT
@@ -98,16 +98,28 @@ -(void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNT
RNNRootViewController *newVc = (RNNRootViewController *)[_controllerFactory createLayoutAndSaveToStore:layout];
UIViewController *fromVC = [_store findComponentForId:componentId];

Expand All @@ -91,7 +61,7 @@ patch-package
+ RNNRootViewController* rvc = (RNNRootViewController*)vcc;
+ NSDictionary * params = @{ @"previewComponentId": newVc.componentId, @"componentId": rvc.componentId };
+ if (newVc.options.preview.commit) {
+ [self->_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
+// [self->_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
+ [CATransaction begin];
+ [CATransaction setCompletionBlock:^{
+ [self->_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
Expand All @@ -100,13 +70,13 @@ patch-package
+ [rvc.navigationController pushViewController:newVc animated:YES];
+ [CATransaction commit];
+ } else {
+ [self->_eventEmitter sendOnNavigationEvent:@"previewDismissed" params:params];
+// [self->_eventEmitter sendOnNavigationEvent:@"previewDismissed" params:params];
+ }
+ };
CGSize size = CGSizeMake(rootVc.view.frame.size.width, rootVc.view.frame.size.height);

if (newVc.options.preview.width) {
@@ -125,7 +137,10 @@ -(void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNT
@@ -122,7 +134,10 @@ -(void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNT
newVc.preferredContentSize = size;
}

Expand All @@ -117,7 +87,7 @@ patch-package
+ });
}
} else {
[newVc onReactViewReady:^{
id animationDelegate = (newVc.options.animations.push.hasCustomAnimation || newVc.isCustomTransitioned) ? newVc : nil;
--- a/node_modules/react-native-navigation/lib/ios/RNNPreviewOptions.h
+++ b/node_modules/react-native-navigation/lib/ios/RNNPreviewOptions.h
@@ -2,7 +2,7 @@
Expand All @@ -131,22 +101,22 @@ patch-package
@property (nonatomic, strong) NSNumber* commit;
--- a/node_modules/react-native-navigation/lib/ios/RNNRootViewController.h
+++ b/node_modules/react-native-navigation/lib/ios/RNNRootViewController.h
@@ -12,6 +12,7 @@
@class RNNRootViewController;
@@ -7,6 +7,7 @@
#import "RNNAnimator.h"

typedef void (^RNNReactViewReadyCompletionBlock)(void);
+typedef void(^PreviewCallback)(UIViewController *vc);

@interface RNNRootViewController : UIViewController <RNNRootViewProtocol, UIViewControllerPreviewingDelegate, UISearchResultsUpdating, UISearchBarDelegate>
@interface RNNRootViewController : UIViewController <UIViewControllerPreviewingDelegate, UISearchResultsUpdating, UISearchBarDelegate, UINavigationControllerDelegate, UISplitViewControllerDelegate>

@@ -22,6 +23,7 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
@@ -16,6 +17,7 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
@property (nonatomic) id<RNNRootViewCreator> creator;
@property (nonatomic, strong) RNNAnimator* animator;
@property (nonatomic, strong) UIViewController* previewController;
+@property (nonatomic, copy) PreviewCallback previewCallback;


-(instancetype)initWithName:(NSString*)name
- (instancetype)initWithName:(NSString*)name
--- a/node_modules/react-native-navigation/lib/ios/RNNRootViewController.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNRootViewController.m
@@ -22,6 +22,8 @@ @interface RNNRootViewController() {
Expand All @@ -158,48 +128,46 @@ patch-package
-(instancetype)initWithName:(NSString*)name
withOptions:(RNNNavigationOptions*)options
withComponentId:(NSString*)componentId
@@ -281,28 +283,22 @@ - (void)orientationDidChange:(NSNotification*)notification {
@@ -292,27 +294,21 @@ - (void)orientationDidChange:(NSNotification*)notification {

- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location{
if (self.previewController) {
- RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
- [_eventEmitter sendOnNavigationEvent:@"previewContext" params:@{
- @"previewComponentId": vc.componentId,
- @"componentId": self.componentId
- }];
+ if ([self.previewController isKindOfClass:[RNNRootViewController class]]) {
+ RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
+ [_eventEmitter sendOnNavigationEvent:@"previewContext" params:@{
+ @"previewComponentId": vc.componentId,
+ @"componentId": self.componentId
+ }];
+ }
-// RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
-// [_eventEmitter sendOnNavigationEvent:@"previewContext" params:@{
-// @"previewComponentId": vc.componentId,
-// @"componentId": self.componentId
-// }];
+ if ([self.previewController isKindOfClass:[RNNRootViewController class]]) {
+// RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
+// [_eventEmitter sendOnNavigationEvent:@"previewContext" params:@{
+// @"previewComponentId": vc.componentId,
+// @"componentId": self.componentId
+// }];
+ }
}
return self.previewController;
}


- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
- RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
- NSDictionary * params = @{
- @"previewComponentId": vc.componentId,
- @"componentId": self.componentId
- };
-// NSDictionary * params = @{
-// @"previewComponentId": vc.componentId,
-// @"componentId": self.componentId
-// };
- if (vc.options.preview.commit) {
- [_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
-// [_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
- [self.navigationController pushViewController:vc animated:false];
- } else {
- [_eventEmitter sendOnNavigationEvent:@"previewDismissed" params:params];
- }
+ if (self.previewCallback) {
-// [_eventEmitter sendOnNavigationEvent:@"previewDismissed" params:params];
+ if (self.previewCallback) {
+ self.previewCallback(self);
+ }
}
}

- (void)onActionPress:(NSString *)id {
--- a/node_modules/react-native-navigation/lib/ios/RNNTopBarOptions.h
+++ b/node_modules/react-native-navigation/lib/ios/RNNTopBarOptions.h
@@ -13,6 +13,7 @@
@@ -14,6 +14,7 @@
@property (nonatomic, strong) NSNumber* visible;
@property (nonatomic, strong) NSNumber* hideOnScroll;
@property (nonatomic, strong) NSNumber* buttonColor;
Expand All @@ -209,7 +177,7 @@ patch-package
@property (nonatomic, strong) NSNumber* drawBehind;
--- a/node_modules/react-native-navigation/lib/ios/RNNTopBarOptions.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNTopBarOptions.m
@@ -116,6 +116,11 @@ - (void)applyOn:(UIViewController*)viewController {
@@ -119,6 +119,11 @@ - (void)applyOn:(UIViewController*)viewController {
} else {
disableTopBarTransparent();
}
Expand All @@ -223,23 +191,11 @@ patch-package
viewController.navigationController.navigationBar.translucent = [self.translucent boolValue];
--- a/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.h
+++ b/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.h
@@ -15,4 +15,6 @@ typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBri

+ (RCTBridge *)getBridge;

++ (UIViewController *)findViewController:(NSString *)componentId;
+
@end
--- a/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.m
+++ b/node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.m
@@ -31,6 +31,10 @@ + (RCTBridge *)getBridge {
return [[ReactNativeNavigation sharedInstance].bridgeManager bridge];
}

++ (UIViewController *)findViewController:(NSString *)componentId {
+ RNNStore *store = [[ReactNativeNavigation sharedInstance].bridgeManager store];
+ return [store findComponentForId:componentId];
+}

# pragma mark - instance
@@ -1,6 +1,7 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <React/RCTBridge.h>
+#import <React/RCTUIManager.h>
#import "RNNBridgeManagerDelegate.h"

typedef UIViewController * (^RNNExternalViewCreator)(NSDictionary* props, RCTBridge* bridge);
6 changes: 6 additions & 0 deletions src/components/comment/Comment.styl
Expand Up @@ -91,6 +91,12 @@ for color, i in $colors {
tint-color: var(--content-fg);
opacity: 0.7;
}

&__arrow {
margin-top: 1px;
margin-left: 2px;
tint-color: var(--primary-color);
}
}

.parent {
Expand Down
2 changes: 1 addition & 1 deletion src/components/story-row/StoryRow.tsx
Expand Up @@ -37,7 +37,7 @@ export default class StoryRow extends React.Component<Props> {
@autobind
async onDownloadPress() {
await this.props.item.refetch();
await this.props.item.fetchComments({ offset: 0, all: true, force: true });
await this.props.item.fetchComments({ offset: 0, all: true });
this.isDownloaded = true;
setTimeout(() => { this.isDownloaded = false; }, 1750);
}
Expand Down
63 changes: 33 additions & 30 deletions src/index.ts
Expand Up @@ -6,6 +6,7 @@ import { db } from 'utils/firebase';
import { onSnapshot } from 'mobx-state-tree';
import { connectToDevTools } from 'mobx-devtools/lib/mobxDevtoolsBackend';
import makeInspectable from 'mobx-devtools-mst';
import debounce from 'lodash/debounce';
import UI from 'stores/UI';
import Stories from 'stores/Stories';
import Items from 'stores/Items';
Expand Down Expand Up @@ -39,9 +40,9 @@ Screens.forEach((ScreenComponent, key) =>
Navigation.registerComponent(key, () => ScreenComponent));

// Set current componentId
Navigation.events().registerComponentDidAppearListener((componentId, componentName) => {
UI.setComponentId(componentId);
});
// Navigation.events().registerComponentDidAppearListener(({ componentId, componentName }) => {
// UI.setComponentId(componentId);
// });

// Start application
Navigation.events().registerAppLaunchedListener(() => {
Expand All @@ -55,30 +56,32 @@ Navigation.events().registerAppLaunchedListener(() => {
UI.hydrate().then(startApp);
});

// Listen for Navigation events
Navigation.events().registerNativeEventListener((name, params) => {
if (name === 'previewContext') {
UI.setPreview({
srcComponentId: params.componentId,
dstComponentId: params.previewComponentId,
active: true,
});
}
console.log(Navigation);

if (name === 'previewCommit') {
UI.setPreview({
active: false,
});
}
});
// Listen for Navigation events
// Navigation.events().registerNativeEventListener((name, params) => {
// if (name === 'previewContext') {
// UI.setPreview({
// srcComponentId: params.componentId,
// dstComponentId: params.previewComponentId,
// active: true,
// });
// }

// if (name === 'previewCommit') {
// UI.setPreview({
// active: false,
// });
// }
// });

// Listen for componentDidAppear screen events
Navigation.events().registerComponentDidAppearListener((componentId, componentName) => {
Navigation.events().registerComponentDidAppearListener(({ componentId, componentName }) => {
UI.setComponentId(componentId, componentName);
});

// Listen for componentDidDisappear screen events
Navigation.events().registerComponentDidDisappearListener((componentId, componentName) => {
Navigation.events().registerComponentDidDisappearListener(({ componentId, componentName }) => {
if (UI.preview.dstComponentId === componentId) {
UI.setComponentId(UI.preview.srcComponentId);
UI.setPreview({
Expand All @@ -87,7 +90,7 @@ Navigation.events().registerComponentDidDisappearListener((componentId, componen
}
});

// Update insets on device rotation
// Calculate layout on device rotation (and initially)
Dimensions.addEventListener('change', UI.updateLayout);
UI.updateLayout();

Expand All @@ -106,13 +109,13 @@ NetInfo.getConnectionInfo().then(({ type }) => {
UI.setIsConnected(type !== 'none');
});

// Persist Settings!
onSnapshot(UI.settings, (snapshot) => {
AsyncStorage.setItem('UI.settings', JSON.stringify(snapshot));
});

onSnapshot(Account.read, (snapshot) => {
AsyncStorage.setItem('Account.read', JSON.stringify(snapshot));
});
// Persist some stuff (debounced to 1s)
onSnapshot(UI.settings, debounce(
snapshot => AsyncStorage.setItem('UI.settings', JSON.stringify(snapshot)),
1000,
));

console.log(Navigation);
onSnapshot(Account, debounce(
snapshot => AsyncStorage.setItem('Account', JSON.stringify(snapshot)),
1000,
));

0 comments on commit 42423b9

Please sign in to comment.