Skip to content

Commit

Permalink
Merge pull request #9431 from hansemannn/TIMOB-24805-6_3_X
Browse files Browse the repository at this point in the history
[TIMOB-24805] (6_3_X) iOS11: Support large window titles
  • Loading branch information
ssjsamir committed Oct 11, 2017
2 parents f13d1b1 + a3fadc5 commit 4dc9f7b
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 1 deletion.
28 changes: 28 additions & 0 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,34 @@ properties:
osver: {ios: {min: "8.0"}}
availability: creation

- name: largeTitleEnabled
summary: A Boolean value indicating whether the title should be displayed in a large format.
description: |
When set to `true`, the navigation bar will use a larger out-of-line
title view when requested by the current navigation item. To specify when
the large out-of-line title view appears, see <Titanium.UI.Window.largeTitleDisplayMode>.
default: false
type: String
since: "6.3.0"
platforms: [iphone, ipad]
osver: {ios: {min: "11.0"}}

- name: largeTitleDisplayMode
summary: The mode to use when displaying the title of the navigation bar.
description: |
Automatically use the large out-of-line title based on the state of the
previous item in the navigation bar. An item with
`largeTitleDisplayMode = Ti.UI.iOS.LARGE_TITLE_DISPLAY_MODE_AUTOMATIC`
will show or hide the large title based on the request of the previous
navigation item. If the first item pushed is set to Automatic, then it
will show the large title if the navigation bar has `largeTitleEnabled = true`.
type: Number
constants: [Titanium.UI.iOS.LARGE_TITLE_DISPLAY_MODE_*]
default: Titanium.UI.iOS.LARGE_TITLE_DISPLAY_MODE_AUTOMATIC
since: "6.3.0"
platforms: [iphone, ipad]
osver: {ios: {min: "11.0"}}

- name: left
summary: Window's left position, in platform-specific units.
description: |
Expand Down
31 changes: 31 additions & 0 deletions apidoc/Titanium/UI/iOS/iOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ methods:
osver: {ios: {min: "9.1"}}

properties:
- name: LARGE_TITLE_DISPLAY_MODE_AUTOMATIC
summary: |
Automatically use the large out-of-line title based on the state of the p
revious item in the navigation bar.
description: |
Use with <Titanium.UI.Window.largeTitleDisplayMode>. An item with this
constant will show or hide the large title based on the request of the
previous navigation item. If the first item pushed is set to Automatic,
then it will show the large title if the navigation bar has the property
<Titanium.UI.Window.largeTitleEnabled> set to `true`.
type: Number
since: "6.3.0"
osver: {ios: {min: "11.0"}}
permission: read-only

- name: LARGE_TITLE_DISPLAY_MODE_ALWAYS
summary: Always use a larger title when this item is top most.
description: Use with <Titanium.UI.Window.largeTitleDisplayMode>.
type: Number
since: "6.3.0"
osver: {ios: {min: "11.0"}}
permission: read-only

- name: LARGE_TITLE_DISPLAY_MODE_NEVER
summary: Never use a larger title when this item is top most.
description: Use with <Titanium.UI.Window.largeTitleDisplayMode>.
type: Number
since: "6.3.0"
osver: {ios: {min: "11.0"}}
permission: read-only

- name: LIVEPHOTO_BADGE_OPTIONS_OVER_CONTENT
summary: |
Include treatments so this image can be shown directly over the content
Expand Down
35 changes: 34 additions & 1 deletion iphone/Classes/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ -(void)setTitleAttributes:(id)args
}

if (shouldUpdateNavBar && ([controller navigationController] != nil)) {
#if IS_XCODE_9
if ([TiUtils isIOS11OrGreater] && [TiUtils boolValue:[self valueForKey:@"largeTitleEnabled"] def:NO]) {
[[[controller navigationController] navigationBar] setLargeTitleTextAttributes:theAttributes];
}
#endif
[[[controller navigationController] navigationBar] setTitleTextAttributes:theAttributes];
}
}
Expand Down Expand Up @@ -818,6 +823,32 @@ -(void)setTitle:(NSString*)title_
}, [NSThread isMainThread]);
}

#if IS_XCODE_9
- (void)setLargeTitleEnabled:(id)value
{
ENSURE_UI_THREAD(setLargeTitleEnabled, value);
ENSURE_TYPE(value, NSNumber);

[self replaceValue:value forKey:@"largeTitleEnabled" notification:NO];

if (@available(iOS 11.0, *) && shouldUpdateNavBar && controller != nil && [controller navigationController] != nil) {
[[[controller navigationController] navigationBar] setPrefersLargeTitles:[TiUtils boolValue:value def:NO]];
}
}

- (void)setLargeTitleDisplayMode:(id)value
{
ENSURE_UI_THREAD(setLargeTitleDisplayMode, value);
ENSURE_TYPE(value, NSNumber);

[self replaceValue:value forKey:@"largeTitleDisplayMode" notification:NO];

if (@available(iOS 11.0, *) && shouldUpdateNavBar && controller != nil && [controller navigationController] != nil) {
[[controller navigationItem] setLargeTitleDisplayMode:[TiUtils intValue:value def:UINavigationItemLargeTitleDisplayModeAutomatic]];
}
}
#endif

-(void)setTitlePrompt:(NSString*)title_
{
ENSURE_UI_THREAD(setTitlePrompt,title_);
Expand Down Expand Up @@ -938,13 +969,15 @@ -(void)setupWindowDecorations
if ((controller == nil) || ([controller navigationController] == nil)) {
return;
}

[[controller navigationController] setToolbarHidden:!hasToolbar animated:YES];
//Need to clear title for titleAttributes to apply correctly on iOS6.
[[controller navigationItem] setTitle:nil];
SETPROP(@"titleAttributes",setTitleAttributes);
SETPROP(@"title",setTitle);
SETPROP(@"titlePrompt",setTitlePrompt);
SETPROP(@"largeTitleEnabled", setLargeTitleEnabled);
SETPROP(@"largeTitleDisplayMode", setLargeTitleDisplayMode);
[self updateTitleView];
SETPROP(@"barColor",setBarColor);
SETPROP(@"navTintColor",setNavTintColor);
Expand Down
5 changes: 5 additions & 0 deletions iphone/Classes/TiUIiOSProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
@property(nonatomic,readonly) NSNumber* BLUR_EFFECT_STYLE_DARK;
#endif

#if IS_XCODE_9
@property(nonatomic,readonly) NSNumber* LARGE_TITLE_DISPLAY_MODE_AUTOMATIC;
@property(nonatomic,readonly) NSNumber* LARGE_TITLE_DISPLAY_MODE_ALWAYS;
@property(nonatomic,readonly) NSNumber* LARGE_TITLE_DISPLAY_MODE_NEVER;
#endif

/**
Checks the force touch capibility of the current device.
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/TiUIiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -823,5 +823,11 @@ -(id)createFeedbackGenerator:(id)args
#endif
#endif

#if IS_XCODE_9
MAKE_SYSTEM_PROP(LARGE_TITLE_DISPLAY_MODE_AUTOMATIC, UINavigationItemLargeTitleDisplayModeAutomatic);
MAKE_SYSTEM_PROP(LARGE_TITLE_DISPLAY_MODE_ALWAYS, UINavigationItemLargeTitleDisplayModeAlways);
MAKE_SYSTEM_PROP(LARGE_TITLE_DISPLAY_MODE_NEVER, UINavigationItemLargeTitleDisplayModeNever);
#endif

@end
#endif
2 changes: 2 additions & 0 deletions iphone/iphone/Titanium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_WARN_UNGUARDED_AVAILABILITY = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -3007,6 +3008,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_WARN_UNGUARDED_AVAILABILITY = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEVELOPMENT_TEAM = "";
Expand Down

0 comments on commit 4dc9f7b

Please sign in to comment.