Skip to content

Commit

Permalink
fix(ios): add missing notification and remove unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Jan 12, 2024
1 parent 62fff3f commit 9c5d0fc
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 30 deletions.
5 changes: 1 addition & 4 deletions renderer/native/ios/renderer/HippyUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,7 @@ - (void)updateView:(nonnull NSNumber *)componentTag
return;
}
HippyComponentData *componentData = [self componentDataForViewName:renderObject.viewName];
NSDictionary *newProps = props;
NSDictionary *virtualProps = props;
newProps = [renderObject mergeProps:props];
virtualProps = renderObject.props;
NSDictionary *newProps = [renderObject mergeProps:props];
[componentData setProps:newProps forShadowView:renderObject];
[renderObject dirtyPropagation:NativeRenderUpdateLifecyclePropsDirtied];
[self addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#import "HippyViewManager.h"
#import "HippyModalHostView.h"

HIPPY_EXTERN NSString * const HippyModalHostViewDismissNotification;

@protocol HippyModalHostViewInteractor;

typedef void (^NativeRenderModalViewInteractionBlock)(
typedef void (^HippyModalViewInteractionBlock)(
UIViewController *reactViewController, UIViewController *viewController, BOOL animated, dispatch_block_t completionBlock);

@interface HippyModalHostViewManager : HippyViewManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#import "HippyShadowView+Internal.h"
#import "NativeRenderUtils.h"


NSString * const HippyModalHostViewDismissNotification = @"HippyModalHostViewDismissNotification";


@interface HippyModalHostShadowView : HippyShadowView

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@class HippyModalHostViewController;

@protocol HippyModalHostViewInteractor;
typedef void (^NativeRenderModalViewInteractionBlock)(
typedef void (^HippyModalViewInteractionBlock)(
UIViewController *hippyViewController, UIViewController *viewController, BOOL animated, dispatch_block_t completionBlock);

@interface HippyModalTransitioningDelegate : NSObject <HippyModalHostViewInteractor, UIViewControllerTransitioningDelegate>
Expand All @@ -36,8 +36,8 @@ typedef void (^NativeRenderModalViewInteractionBlock)(
* e.g. in case you have a native navigator that has its own way to display a modal.
* If these are not specified, it falls back to the UIViewController standard way of presenting.
*/
@property (nonatomic, strong) NativeRenderModalViewInteractionBlock presentationBlock;
@property (nonatomic, strong) NativeRenderModalViewInteractionBlock dismissalBlock;
@property (nonatomic, strong) HippyModalViewInteractionBlock presentationBlock;
@property (nonatomic, strong) HippyModalViewInteractionBlock dismissalBlock;

- (void)presentModalHostView:(HippyModalHostView *)modalHostView
withViewController:(HippyModalHostViewController *)viewController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
#import "HippyModalCustomPresentationController.h"
#import "HippyModalCustomAnimationTransition.h"
#import "UIView+Hippy.h"
#import "HippyModalHostViewManager.h"


@implementation HippyModalTransitioningDelegate

- (nullable UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented
presentingViewController:(__unused UIViewController *)presenting
sourceViewController:(__unused UIViewController *)source NS_AVAILABLE_IOS(8_0) {
sourceViewController:(__unused UIViewController *)source {
HippyModalCustomPresentationController *controller = [[HippyModalCustomPresentationController alloc] initWithPresentedViewController:presented
presentingViewController:presenting];
return controller;
Expand Down Expand Up @@ -76,6 +78,7 @@ - (void)dismissModalHostView:(HippyModalHostView *)modalHostView
if (modalHostView.primaryKey.length != 0) {
userInfo = @{ @"primaryKey": modalHostView.primaryKey };
}
[[NSNotificationCenter defaultCenter] postNotificationName:HippyModalHostViewDismissNotification object:self userInfo:userInfo];
if (modalHostView.onRequestClose) {
modalHostView.onRequestClose(nil);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ enum class Direction;
BOOL _recomputeMargin;
BOOL _recomputeBorder;
BOOL _didUpdateSubviews;
//TODO remove it
NSInteger _isDecendantOfLazilyRenderObject;

std::vector<std::string> _eventNames;
}

Expand Down
6 changes: 0 additions & 6 deletions renderer/native/ios/renderer/component/view/HippyShadowView.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ typedef void (^NativeRenderApplierBlock)(NSDictionary<NSNumber *, UIView *> *vie
typedef UIView *_Nullable(^HippyViewCreationBlock)(HippyShadowView *renderObject);
typedef void (^HippyViewInsertionBlock)(UIView *container, NSArray<UIView *> *children);

//TODO remove unused string
extern NSString *const NativeRenderShadowViewDiffInsertion;
extern NSString *const NativeRenderShadowViewDiffRemove;
extern NSString *const NativeRenderShadowViewDiffUpdate;
extern NSString *const NativeRenderShadowViewDiffTag;

/**
* ShadowView tree mirrors Hippy view tree. Every node is highly stateful.
* 1. A node is in one of three lifecycles: uninitialized, computed, dirtied.
Expand Down
14 changes: 4 additions & 10 deletions renderer/native/ios/renderer/component/view/HippyShadowView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@
#import "UIView+Hippy.h"
#import "HippyShadowView+Internal.h"

static NSString *const NativeRenderBackgroundColorProp = @"backgroundColor";

NSString *const NativeRenderShadowViewDiffInsertion = @"NativeRenderShadowViewDiffInsertion";
NSString *const NativeRenderShadowViewDiffRemove = @"NativeRenderShadowViewDiffRemove";
NSString *const NativeRenderShadowViewDiffUpdate = @"NativeRenderShadowViewDiffUpdate";
NSString *const NativeRenderShadowViewDiffTag = @"NativeRenderShadowViewDiffTag";

static NSString *const HippyBackgroundColorPropKey = @"backgroundColor";

@implementation HippyShadowView

Expand Down Expand Up @@ -74,7 +69,7 @@ - (void)amendLayoutBeforeMount:(NSMutableSet<NativeRenderApplierBlock> *)blocks
_confirmedLayoutDirectionDidUpdated = NO;
}
if (!_backgroundColor) {
UIColor *parentBackgroundColor = parentProperties[NativeRenderBackgroundColorProp];
UIColor *parentBackgroundColor = parentProperties[HippyBackgroundColorPropKey];
if (parentBackgroundColor) {
[applierBlocks addObject:^(NSDictionary<NSNumber *, UIView *> *viewRegistry, UIView * _Nullable lazyCreatedView) {
UIView *view = lazyCreatedView ?: viewRegistry[self->_hippyTag];
Expand All @@ -87,9 +82,9 @@ - (void)amendLayoutBeforeMount:(NSMutableSet<NativeRenderApplierBlock> *)blocks
CGFloat alpha = CGColorGetAlpha(_backgroundColor.CGColor);
if (alpha < 1.0) {
// If bg is non-opaque, don't propagate further
properties[NativeRenderBackgroundColorProp] = [UIColor clearColor];
properties[HippyBackgroundColorPropKey] = [UIColor clearColor];
} else {
properties[NativeRenderBackgroundColorProp] = _backgroundColor;
properties[HippyBackgroundColorPropKey] = _backgroundColor;
}
return properties;
}
Expand All @@ -103,7 +98,6 @@ - (instancetype)init {
if ((self = [super init])) {
_propagationLifecycle = NativeRenderUpdateLifecycleUninitialized;
_frame = CGRectMake(0, 0, NAN, NAN);
_isDecendantOfLazilyRenderObject = -1;
_objectSubviews = [NSMutableArray arrayWithCapacity:8];
_confirmedLayoutDirection = hippy::Direction::Inherit;
_layoutDirection = hippy::Direction::Inherit;
Expand Down
5 changes: 2 additions & 3 deletions renderer/native/ios/utils/NativeRenderGradientObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,14 @@ - (instancetype)initWithGradientObject:(NSDictionary *)object {
}

- (LinearGradientPoints)linearGradientPointsFromSize:(CGSize)size {
LinearGradientPoints points = {CGPointZero, CGPointZero};
LinearGradientPoints points;
if (self.drawnByDegree) {
self.degree %= 360;
if (self.degree < 0) {
self.degree += 360;
}
points = gradientPointsWithSizeAndDegree(size, self.degree);
}
else {
} else {
points = pointsFromDirection(self, size);
}
return points;
Expand Down

0 comments on commit 9c5d0fc

Please sign in to comment.