Skip to content

Commit

Permalink
Remove manually dismissing all modals on setRoot (#7340)
Browse files Browse the repository at this point in the history
Currently we manually dismiss all modals on `setRoot`, we should instead clear it from the modal manager so that those controllers will be automatically released by the reference count system.
  • Loading branch information
yogevbd committed Nov 7, 2021
1 parent 0352baa commit ba3ee16
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 26 deletions.
4 changes: 2 additions & 2 deletions lib/ios/RNNAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ extern BOOL RNNIsMainQueue(void);
if ((condition) == 0) { \
if (RNN_NSASSERT) { \
[[NSAssertionHandler currentHandler] \
handleFailureInFunction:(NSString * _Nonnull) @(__func__) \
file:(NSString * _Nonnull) @(__FILE__) \
handleFailureInFunction:(NSString *_Nonnull)@(__func__) \
file:(NSString *_Nonnull)@(__FILE__) \
lineNumber:__LINE__ \
description:__VA_ARGS__]; \
} \
Expand Down
3 changes: 2 additions & 1 deletion lib/ios/RNNBottomTabOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ - (BOOL)hasValue {
self.testID.hasValue || self.icon.hasValue || self.selectedIcon.hasValue ||
self.iconColor.hasValue || self.selectedIconColor.hasValue ||
self.selectedTextColor.hasValue || self.iconInsets.hasValue || self.textColor.hasValue ||
self.visible.hasValue || self.selectTabOnPress.hasValue || self.sfSymbol.hasValue || self.sfSelectedSymbol.hasValue;
self.visible.hasValue || self.selectTabOnPress.hasValue || self.sfSymbol.hasValue ||
self.sfSelectedSymbol.hasValue;
}

@end
6 changes: 3 additions & 3 deletions lib/ios/RNNButtonBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ - (RNNUIBarButtonItem *)build:(RNNButtonOptions *)button
return [[RNNUIBarButtonItem alloc] initCustomIcon:button
iconCreator:_iconCreator
onPress:onPress];
} else if (button.sfSymbol.hasValue) {
return [[RNNUIBarButtonItem alloc] initWithSFSymbol:button onPress:onPress];
} else if (button.icon.hasValue) {
} else if (button.sfSymbol.hasValue) {
return [[RNNUIBarButtonItem alloc] initWithSFSymbol:button onPress:onPress];
} else if (button.icon.hasValue) {
return [[RNNUIBarButtonItem alloc] initWithIcon:button onPress:onPress];
} else if (button.text.hasValue) {
return [[RNNUIBarButtonItem alloc] initWithTitle:button onPress:onPress];
Expand Down
8 changes: 4 additions & 4 deletions lib/ios/RNNButtonOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
self.fontWeight = [TextParser parse:dict key:@"fontWeight"];
self.fontSize = [NumberParser parse:dict key:@"fontSize"];
self.text = [TextParser parse:dict key:@"text"];
self.sfSymbol = [TextParser parse:dict key:@"sfSymbol"];
self.sfSymbol = [TextParser parse:dict key:@"sfSymbol"];
self.testID = [TextParser parse:dict key:@"testID"];
self.accessibilityLabel = [TextParser parse:dict key:@"accessibilityLabel"];
self.color = [ColorParser parse:dict key:@"color"];
Expand Down Expand Up @@ -40,7 +40,7 @@ - (RNNButtonOptions *)copy {
newOptions.color = self.color.copy;
newOptions.disabledColor = self.disabledColor.copy;
newOptions.icon = self.icon.copy;
newOptions.sfSymbol = self.sfSymbol.copy;
newOptions.sfSymbol = self.sfSymbol.copy;
newOptions.iconInsets = self.iconInsets.copy;
newOptions.enabled = self.enabled.copy;
newOptions.selectTabOnPress = self.selectTabOnPress.copy;
Expand Down Expand Up @@ -73,8 +73,8 @@ - (void)mergeOptions:(RNNButtonOptions *)options {
self.disabledColor = options.disabledColor;
if (options.icon.hasValue)
self.icon = options.icon;
if (options.sfSymbol.hasValue)
self.sfSymbol = options.sfSymbol;
if (options.sfSymbol.hasValue)
self.sfSymbol = options.sfSymbol;
if (options.enabled.hasValue) {
self.enabled = options.enabled;
[self.iconBackground setEnabled:self.enabled];
Expand Down
5 changes: 1 addition & 4 deletions lib/ios/RNNCommandsHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ - (void)setRoot:(NSDictionary *)layout
}
}

[_modalManager dismissAllModalsAnimated:NO
completion:^{

}];
[_modalManager reset];

UIViewController *vc = [_controllerFactory createLayout:layout[@"root"]];
[_layoutManager addPendingViewController:vc];
Expand Down
3 changes: 2 additions & 1 deletion lib/ios/RNNDotIndicatorPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ - (BOOL)currentIndicatorEquals:(UIViewController *)child options:(DotIndicatorOp
return NO;
UIView *currentIndicator = [self getCurrentIndicator:child];

return [[currentIndicator backgroundColor] isEqual:[options.color withDefault:[UIColor redColor]]];
return
[[currentIndicator backgroundColor] isEqual:[options.color withDefault:[UIColor redColor]]];
}

- (UIView *)getCurrentIndicator:(UIViewController *)child {
Expand Down
2 changes: 2 additions & 0 deletions lib/ios/RNNModalManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ typedef void (^RNNTransitionRejectionBlock)(NSString *_Nonnull code, NSString *_
- (void)dismissAllModalsAnimated:(BOOL)animated completion:(void (^__nullable)(void))completion;
- (void)dismissAllModalsSynchronosly;

- (void)reset;

@end
5 changes: 5 additions & 0 deletions lib/ios/RNNModalManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ - (void)dismissAllModalsSynchronosly {
}
}

- (void)reset {
[_presentedModals removeAllObjects];
[_pendingModalIdsToDismiss removeAllObjects];
}

#pragma mark - private

- (void)removePendingNextModalIfOnTop:(RNNTransitionCompletionBlock)completion
Expand Down
2 changes: 1 addition & 1 deletion lib/ios/RNNSegmentedControl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <HMSegmentedControl/HMSegmentedControl.h>
#import <Foundation/Foundation.h>
#import <HMSegmentedControl/HMSegmentedControl.h>

@interface RNNSegmentedControl : HMSegmentedControl

Expand Down
5 changes: 3 additions & 2 deletions lib/ios/RNNTabBarItemCreator.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ - (UITabBarItem *)createTabBarItem:(RNNBottomTabOptions *)bottomTabOptions

if (@available(iOS 13.0, *)) {
if (bottomTabOptions.sfSymbol.hasValue) {
icon = [UIImage systemImageNamed: [bottomTabOptions.sfSymbol withDefault:nil]];
icon = [UIImage systemImageNamed:[bottomTabOptions.sfSymbol withDefault:nil]];
}

if (bottomTabOptions.sfSelectedSymbol.hasValue) {
selectedIcon = [UIImage systemImageNamed: [bottomTabOptions.sfSelectedSymbol withDefault:nil]];
selectedIcon =
[UIImage systemImageNamed:[bottomTabOptions.sfSelectedSymbol withDefault:nil]];
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ios/RNNUIBarButtonItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ typedef void (^RNNButtonPressCallback)(NSString *buttonId);
iconCreator:(RNNIconCreator *)iconCreator
onPress:(RNNButtonPressCallback)onPress;
- (instancetype)initWithSFSymbol:(RNNButtonOptions *)buttonOptions
onPress:(RNNButtonPressCallback)onPress;
onPress:(RNNButtonPressCallback)onPress;
- (instancetype)initWithIcon:(RNNButtonOptions *)buttonOptions
onPress:(RNNButtonPressCallback)onPress;
- (instancetype)initWithTitle:(RNNButtonOptions *)buttonOptions
Expand Down
6 changes: 3 additions & 3 deletions lib/ios/RNNUIBarButtonItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ - (instancetype)init {
}

- (instancetype)initWithSFSymbol:(RNNButtonOptions *)buttonOptions
onPress:(RNNButtonPressCallback)onPress {
onPress:(RNNButtonPressCallback)onPress {
UIImage *iconImage = [UIImage alloc];

if (@available(iOS 13.0, *)) {
if (@available(iOS 13.0, *)) {
iconImage = [UIImage systemImageNamed:[buttonOptions.sfSymbol withDefault:nil]];
}
}

self = [super initWithImage:iconImage
style:UIBarButtonItemStylePlain
Expand Down
12 changes: 8 additions & 4 deletions lib/ios/TopBarPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,21 @@ - (void)setBackButtonOptions:(RNNBackButtonOptions *)backButtonOptions {
UIBarButtonItem *backItem = [[RNNUIBarBackButtonItem alloc] initWithOptions:backButtonOptions];
UINavigationItem *previousNavigationItem = previousViewControllerInStack.navigationItem;


if (@available(iOS 13.0, *)) {
UIImage *sfSymbol = [UIImage systemImageNamed:[backButtonOptions.sfSymbol withDefault:nil]];
if (backButtonOptions.sfSymbol.hasValue) {
icon = color ? [sfSymbol imageWithTintColor:color renderingMode:UIImageRenderingModeAlwaysOriginal]
icon = color ? [sfSymbol imageWithTintColor:color
renderingMode:UIImageRenderingModeAlwaysOriginal]
: [sfSymbol imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
} else {
icon = color ? [[icon withTintColor:color] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] : icon;
icon = color ? [[icon withTintColor:color]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
: icon;
}
} else {
icon = color ? [[icon withTintColor:color] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] : icon;
icon = color ? [[icon withTintColor:color]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
: icon;
}

[self setBackIndicatorImage:icon withColor:color];
Expand Down

0 comments on commit ba3ee16

Please sign in to comment.