Skip to content

Commit 56cab56

Browse files
authored
Fix searchBar.hideOnScroll (wix#6849)
Fixes wrong `topBar.searchBar.hideOnScroll` parsing on iOS which broke this feature. Closes wix#6848
1 parent ddcf997 commit 56cab56

File tree

4 files changed

+72
-5
lines changed

4 files changed

+72
-5
lines changed

lib/ios/RNNBridgeManager.mm

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ - (void)onJavaScriptLoaded {
132132

133133
- (void)onBridgeWillReload {
134134
dispatch_async(dispatch_get_main_queue(), ^{
135-
[self->_overlayManager dismissAllOverlays];
136-
[self->_modalManager dismissAllModalsSynchronosly];
137-
[self->_componentRegistry clear];
138-
UIApplication.sharedApplication.delegate.window.rootViewController = nil;
135+
[self->_overlayManager dismissAllOverlays];
136+
[self->_modalManager dismissAllModalsSynchronosly];
137+
[self->_componentRegistry clear];
138+
UIApplication.sharedApplication.delegate.window.rootViewController = nil;
139139
});
140140
}
141141

lib/ios/RNNSearchBarOptions.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
66
self = [super initWithDict:dict];
77
self.visible = [BoolParser parse:dict key:@"visible"];
88
self.focus = [BoolParser parse:dict key:@"focus"];
9-
self.hideOnScroll = [BoolParser parse:dict key:@"hiddenWhenScrolling"];
9+
self.hideOnScroll = [BoolParser parse:dict key:@"hideOnScroll"];
1010
self.hideTopBarOnFocus = [BoolParser parse:dict key:@"hideTopBarOnFocus"];
1111
self.obscuresBackgroundDuringPresentation =
1212
[BoolParser parse:dict key:@"obscuresBackgroundDuringPresentation"];
@@ -19,6 +19,8 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
1919
- (void)mergeOptions:(RNNSearchBarOptions *)options {
2020
if (options.visible.hasValue)
2121
self.visible = options.visible;
22+
if (options.focus.hasValue)
23+
self.focus = options.focus;
2224
if (options.hideOnScroll.hasValue)
2325
self.hideOnScroll = options.hideOnScroll;
2426
if (options.hideTopBarOnFocus.hasValue)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#import <ReactNativeNavigation/RNNSearchBarOptions.h>
2+
#import <XCTest/XCTest.h>
3+
4+
@interface RNNSearchBarOptionsTest : XCTestCase
5+
6+
@end
7+
8+
@implementation RNNSearchBarOptionsTest
9+
10+
- (void)testInitWithDict {
11+
RNNSearchBarOptions *options = [[RNNSearchBarOptions alloc] initWithDict:@{
12+
@"visible" : @(1),
13+
@"focus" : @(1),
14+
@"hideOnScroll" : @(1),
15+
@"obscuresBackgroundDuringPresentation" : @(1),
16+
@"backgroundColor" : @(0xff0000ff),
17+
@"tintColor" : @(0xff0000ff),
18+
@"placeholder" : @"placeholder"
19+
}];
20+
21+
XCTAssertTrue(options.visible.get);
22+
XCTAssertTrue(options.focus.get);
23+
XCTAssertTrue(options.hideOnScroll.get);
24+
XCTAssertTrue(options.obscuresBackgroundDuringPresentation.get);
25+
XCTAssertTrue([options.backgroundColor.get isEqual:UIColor.blueColor]);
26+
XCTAssertTrue([options.tintColor.get isEqual:UIColor.blueColor]);
27+
XCTAssertTrue([options.placeholder.get isEqualToString:@"placeholder"]);
28+
}
29+
30+
- (void)testMergeOptions {
31+
RNNSearchBarOptions *options = [[RNNSearchBarOptions alloc] initWithDict:@{
32+
@"visible" : @(1),
33+
@"focus" : @(1),
34+
@"hideOnScroll" : @(1),
35+
@"obscuresBackgroundDuringPresentation" : @(1),
36+
@"backgroundColor" : @(0xff0000ff),
37+
@"tintColor" : @(0xff0000ff),
38+
@"placeholder" : @"placeholder"
39+
}];
40+
RNNSearchBarOptions *mergeOptions = [[RNNSearchBarOptions alloc] initWithDict:@{
41+
@"visible" : @(0),
42+
@"focus" : @(0),
43+
@"hideOnScroll" : @(0),
44+
@"obscuresBackgroundDuringPresentation" : @(0),
45+
@"backgroundColor" : @(0xff00ff00),
46+
@"tintColor" : @(0xff00ff00),
47+
@"placeholder" : @"mergedPlaceholder"
48+
}];
49+
50+
[options mergeOptions:mergeOptions];
51+
52+
XCTAssertFalse(options.visible.get);
53+
XCTAssertFalse(options.focus.get);
54+
XCTAssertFalse(options.hideOnScroll.get);
55+
XCTAssertFalse(options.obscuresBackgroundDuringPresentation.get);
56+
XCTAssertTrue([options.backgroundColor.get isEqual:UIColor.greenColor]);
57+
XCTAssertTrue([options.tintColor.get isEqual:UIColor.greenColor]);
58+
XCTAssertTrue([options.placeholder.get isEqualToString:@"mergedPlaceholder"]);
59+
}
60+
61+
@end

playground/ios/playground.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
50C9A8D1240EB95F00BD699F /* RNNBottomTabsController+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 50CF233C240695B10098042D /* RNNBottomTabsController+Helpers.m */; };
4444
50C9A8D4240FB9D000BD699F /* RNNComponentViewController+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 50C9A8D3240FB9D000BD699F /* RNNComponentViewController+Utils.m */; };
4545
50CF233D240695B10098042D /* RNNBottomTabsController+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 50CF233C240695B10098042D /* RNNBottomTabsController+Helpers.m */; };
46+
50FDEFBC258F5C5D008C9C3C /* RNNSearchBarOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50FDEFBB258F5C5D008C9C3C /* RNNSearchBarOptionsTest.m */; };
4647
6B102251DCC578519C2DC6A4 /* libPods-NavigationIOS12Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C10F72071A488F801E1F1116 /* libPods-NavigationIOS12Tests.a */; };
4748
8EB60A6CB93C527CC6A870A2 /* libPods-SnapshotTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8B4CFA18A5ACE953124E129 /* libPods-SnapshotTests.a */; };
4849
9F9A3A9625260DA900AAAF37 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9F9A3A9525260DA900AAAF37 /* LaunchScreen.storyboard */; };
@@ -156,6 +157,7 @@
156157
50CF233B240695B10098042D /* RNNBottomTabsController+Helpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNNBottomTabsController+Helpers.h"; sourceTree = "<group>"; };
157158
50CF233C240695B10098042D /* RNNBottomTabsController+Helpers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RNNBottomTabsController+Helpers.m"; sourceTree = "<group>"; };
158159
50E4888A2427DA4800B11A8E /* StackOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StackOptionsTest.m; sourceTree = "<group>"; };
160+
50FDEFBB258F5C5D008C9C3C /* RNNSearchBarOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSearchBarOptionsTest.m; sourceTree = "<group>"; };
159161
7F8E255E2E08F6ECE7DF6FE3 /* Pods-playground.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-playground.release.xcconfig"; path = "Target Support Files/Pods-playground/Pods-playground.release.xcconfig"; sourceTree = "<group>"; };
160162
9F9A3A9525260DA900AAAF37 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
161163
B484A10A046B0046B98A76B5 /* Pods-playground.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-playground.debug.xcconfig"; path = "Target Support Files/Pods-playground/Pods-playground.debug.xcconfig"; sourceTree = "<group>"; };
@@ -398,6 +400,7 @@
398400
E58D263F2385888C003F36BA /* RNNStackControllerTest.m */,
399401
E58D26322385888B003F36BA /* RNNNavigationOptionsTest.m */,
400402
E58D263C2385888C003F36BA /* RNNNavigationStackManagerTest.m */,
403+
50FDEFBB258F5C5D008C9C3C /* RNNSearchBarOptionsTest.m */,
401404
502734AE24F3E9110022163C /* ColorParserTest.m */,
402405
E58D262C2385888B003F36BA /* RNNOptionsTest.h */,
403406
E58D262D2385888B003F36BA /* RNNOverlayManagerTest.m */,
@@ -848,6 +851,7 @@
848851
50BCB27623F1A2B100D6C8E5 /* TopBarAppearancePresenterTest.m in Sources */,
849852
50C9A8D4240FB9D000BD699F /* RNNComponentViewController+Utils.m in Sources */,
850853
50647FE323E3196800B92025 /* RNNExternalViewControllerTests.m in Sources */,
854+
50FDEFBC258F5C5D008C9C3C /* RNNSearchBarOptionsTest.m in Sources */,
851855
E58D264D2385888C003F36BA /* RNNOverlayManagerTest.m in Sources */,
852856
501C86B9239FE9C400E0B631 /* UIImage+Utils.m in Sources */,
853857
E58D265F2385888C003F36BA /* RNNBasePresenterTest.m in Sources */,

0 commit comments

Comments
 (0)