-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-23684] iOS: Expose properties to hide the navbar #8160
Changes from 1 commit
e88eb02
5e7c827
6a9eaf6
1f91020
2c29ee6
0a35071
272d318
b36132c
d39fded
bd69f67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,6 +304,7 @@ - (void)viewWillAppear:(BOOL)animated; // Called when the view is about to ma | |
- (void)viewDidAppear:(BOOL)animated; // Called when the view has been fully transitioned onto the screen. Default does nothing | ||
{ | ||
[self updateTitleView]; | ||
[self updateHidesBars]; | ||
[super viewDidAppear:animated]; | ||
} | ||
|
||
|
@@ -920,6 +921,45 @@ -(void)setToolbar:(id)items withObject:(id)properties | |
|
||
} | ||
|
||
-(void)setHidesBarsOnSwipe:(id)value | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need validation, please add
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhm, it's a bool! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They come to the proxies as NSNumbers (because of the JavaScriptCore below it). So usually this is what you do in boolean-setters: - (void)setHidesBarsOnSwipe:(id)value
{
ENSURE_TYPE(value, NSNumber);
[myView setWhatever:[TiUtils boolValue:value def:YES]];
[self replaceValue:value forKey:@"hidesBarsOnSwipe" notification:NO];
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! Thank you! |
||
[self replaceValue:value forKey:@"hidesBarsOnSwipe" notification:NO]; | ||
[self updateHidesBars]; | ||
} | ||
|
||
-(void)setHidesBarsOnTap:(id)value | ||
{ | ||
[self replaceValue:value forKey:@"hidesBarsOnTap" notification:NO]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, add it for all please |
||
[self updateHidesBars]; | ||
} | ||
|
||
-(void)setHidesBarsWhenVerticallyCompact:(id)value | ||
{ | ||
[self replaceValue:value forKey:@"hidesBarsWhenVerticallyCompact" notification:NO]; | ||
[self updateHidesBars]; | ||
} | ||
|
||
-(void)setHidesBarsWhenKeyboardAppears:(id)value | ||
{ | ||
[self replaceValue:value forKey:@"hidesBarsWhenKeyboardAppears" notification:NO]; | ||
[self updateHidesBars]; | ||
} | ||
|
||
-(void)updateHidesBars | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we call all of them together as oppose as each to their own setter ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a better code organization, nope? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's more about performance. Imagine, you use all provided properties. Then 4 setters will be called and 16 native calls will be made, since it calls the If they require main-thread, use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I keep |
||
{ | ||
if ([TiUtils isIOS8OrGreater]) { | ||
TiThreadPerformOnMainThread(^{ | ||
if ((controller != nil) && ([controller navigationController] != nil)) { | ||
UINavigationController *ourNC = [controller navigationController]; | ||
ourNC.hidesBarsOnSwipe = [TiUtils boolValue:[self valueForUndefinedKey:@"hidesBarsOnSwipe"] def:NO]; | ||
ourNC.hidesBarsOnTap = [TiUtils boolValue:[self valueForUndefinedKey:@"hidesBarsOnTap"] def:NO]; | ||
ourNC.hidesBarsWhenVerticallyCompact = [TiUtils boolValue:[self valueForUndefinedKey:@"hidesBarsWhenVerticallyCompact"] def:NO]; | ||
ourNC.hidesBarsWhenKeyboardAppears = [TiUtils boolValue:[self valueForUndefinedKey:@"hidesBarsWhenKeyboardAppears"] def:NO]; | ||
} | ||
}, NO); | ||
} | ||
} | ||
|
||
|
||
#define SETPROP(m,x) \ | ||
{\ | ||
|
@@ -970,6 +1010,10 @@ -(void)setupWindowDecorations | |
SETPROP(@"navTintColor",setNavTintColor); | ||
SETPROP(@"translucent",setTranslucent); | ||
SETPROP(@"tabBarHidden",setTabBarHidden); | ||
SETPROP(@"hidesBarsOnSwipe",setHidesBarsOnSwipe); | ||
SETPROP(@"hidesBarsOnTap", setHidesBarsOnTap); | ||
SETPROP(@"hidesBarsWhenVerticallyCompact",setHidesBarsWhenVerticallyCompact); | ||
SETPROP(@"hidesBarsWhenKeyboardAppears", setHidesBarsWhenKeyboardAppears); | ||
SETPROPOBJ(@"toolbar",setToolbar); | ||
[self updateBarImage]; | ||
[self updateNavButtons]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think someone broke the indentation with tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr:
It's a legacy part of the code, where tabs have been used.
The way to go here is to use the pattern that is already there. All new sources have spaces by default, but some old one have tabs. The only reason we don't run a script to fix it to spaces everywhere is, to not loose the ability to git-blame the source, because it sometimes can be very important to see why a certain change was made back in the days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so tab ;)