Skip to content
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

feat(ios): expose Ti.UI.Window.largeTitleAttributes #13896

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,14 @@ public void open(String method, String url)

setReadyState(READY_STATE_OPENED);
setRequestHeader("User-Agent", TITANIUM_USER_AGENT);
// Causes Auth to Fail with twitter and other size apparently block X- as well
// Ticket #729, ignore twitter for now
// if (!hostString.contains("twitter.com")) {
// setRequestHeader("X-Requested-With", "XMLHttpRequest");

// } else {
// Log.d(TAG, "Twitter: not sending X-Requested-With header", Log.DEBUG_MODE);
// }
hansemannn marked this conversation as resolved.
Show resolved Hide resolved
}

public void setRawData(Object data)
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/TiNetworkHTTPClientProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ - (void)open:(id)args
[httpRequest setMethod:method];
[httpRequest setUrl:url];

// twitter specifically disallows X-Requested-With so we only add this normal
// XHR header if not going to twitter. however, other services generally expect
// this header to indicate an XHR request (such as RoR)
// if ([[url absoluteString] rangeOfString:@"twitter.com"].location == NSNotFound) {
// [httpRequest addRequestHeader:@"X-Requested-With" value:@"XMLHttpRequest"];
// }
hansemannn marked this conversation as resolved.
Show resolved Hide resolved
if ((apsConnectionManager != nil) && ([apsConnectionManager willHandleURL:url])) {
apsConnectionDelegate = [[apsConnectionManager connectionDelegateForUrl:url] retain];
}
Expand Down
33 changes: 33 additions & 0 deletions iphone/Classes/TiUITabGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,39 @@ - (void)setTitleAttributes_:(id)args
}
[self updateMoreBar:[controller moreNavigationController]];
}
- (void)setLargeTitleAttributes_:(id)args
{
ENSURE_SINGLE_ARG_OR_NIL(args, NSDictionary);
[self.proxy replaceValue:args forKey:@"largeTitleAttributes" notification:NO];
RELEASE_TO_NIL(theAttributes)
if (args != nil) {
theAttributes = [[NSMutableDictionary dictionary] retain];
if ([args objectForKey:@"color"] != nil) {
UIColor *theColor = [[TiUtils colorValue:@"color" properties:args] _color];
if (theColor != nil) {
[theAttributes setObject:theColor forKey:NSForegroundColorAttributeName];
}
}
if ([args objectForKey:@"shadow"] != nil) {
NSShadow *shadow = [TiUtils shadowValue:[args objectForKey:@"shadow"]];
if (shadow != nil) {
[theAttributes setObject:shadow forKey:NSShadowAttributeName];
}
}

if ([args objectForKey:@"font"] != nil) {
UIFont *theFont = [[TiUtils fontValue:[args objectForKey:@"font"] def:nil] font];
if (theFont != nil) {
[theAttributes setObject:theFont forKey:NSFontAttributeName];
}
}

if ([theAttributes count] == 0) {
RELEASE_TO_NIL(theAttributes)
}
}
[self updateMoreBar:[controller moreNavigationController]];
}

- (void)setNavTintColor_:(id)value
{
Expand Down
59 changes: 55 additions & 4 deletions iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ - (void)_configure
[self replaceValue:nil forKey:@"barImage" notification:NO];
[self replaceValue:nil forKey:@"translucent" notification:NO];
[self replaceValue:nil forKey:@"titleAttributes" notification:NO];
[self replaceValue:nil forKey:@"largeTitleAttributes" notification:NO];
[self replaceValue:NUMBOOL(NO) forKey:@"tabBarHidden" notification:NO];
[self replaceValue:NUMBOOL(NO) forKey:@"navBarHidden" notification:NO];
[self replaceValue:NUMBOOL(NO) forKey:@"hidesBarsOnSwipe" notification:NO];
Expand Down Expand Up @@ -404,10 +405,10 @@ - (void)setTitleAttributes:(id)args
if (shouldUpdateNavBar && ([controller navigationController] != nil)) {
UINavigationBar *navigationBar = controller.navigationController.navigationBar;
if ([TiUtils boolValue:[self valueForKey:@"largeTitleEnabled"] def:NO]) {
if ([self shouldUseNavBarApperance]) {
navigationBar.standardAppearance.largeTitleTextAttributes = theAttributes;
navigationBar.scrollEdgeAppearance.largeTitleTextAttributes = theAttributes;
}
// if ([self shouldUseNavBarApperance]) {
// navigationBar.standardAppearance.largeTitleTextAttributes = theAttributes;
// navigationBar.scrollEdgeAppearance.largeTitleTextAttributes = theAttributes;
// }
hansemannn marked this conversation as resolved.
Show resolved Hide resolved
navigationBar.largeTitleTextAttributes = theAttributes;
}
if ([self shouldUseNavBarApperance]) {
Expand All @@ -417,6 +418,55 @@ - (void)setTitleAttributes:(id)args
navigationBar.titleTextAttributes = theAttributes;
}
}
- (void)setLargeTitleAttributes:(id)args
{
ENSURE_UI_THREAD(setLargeTitleAttributes, args);
ENSURE_SINGLE_ARG_OR_NIL(args, NSDictionary);
[self replaceValue:args forKey:@"largeTitleAttributes" notification:NO];

if (args == nil) {
args = [[self tabGroup] valueForUndefinedKey:@"largeTitleAttributes"];
}

NSMutableDictionary *theAttributes = nil;
if (args != nil) {
theAttributes = [NSMutableDictionary dictionary];
if ([args objectForKey:@"color"] != nil) {
UIColor *theColor = [[TiUtils colorValue:@"color" properties:args] _color];
if (theColor != nil) {
[theAttributes setObject:theColor forKey:NSForegroundColorAttributeName];
}
}
if ([args objectForKey:@"shadow"] != nil) {
NSShadow *shadow = [TiUtils shadowValue:[args objectForKey:@"shadow"]];
if (shadow != nil) {
[theAttributes setObject:shadow forKey:NSShadowAttributeName];
}
}

if ([args objectForKey:@"font"] != nil) {
UIFont *theFont = [[TiUtils fontValue:[args objectForKey:@"font"] def:nil] font];
if (theFont != nil) {
[theAttributes setObject:theFont forKey:NSFontAttributeName];
}
}

if ([theAttributes count] == 0) {
theAttributes = nil;
}
}

if (shouldUpdateNavBar && ([controller navigationController] != nil)) {
UINavigationBar *navigationBar = controller.navigationController.navigationBar;
if ([TiUtils boolValue:[self valueForKey:@"largeTitleEnabled"] def:NO]) {
if ([self shouldUseNavBarApperance]) {
navigationBar.standardAppearance.largeTitleTextAttributes = theAttributes;
navigationBar.scrollEdgeAppearance.largeTitleTextAttributes = theAttributes;
}
navigationBar.largeTitleTextAttributes = theAttributes;
}
}
}

- (BOOL)shouldUseNavBarApperance
{
Expand Down Expand Up @@ -1016,6 +1066,7 @@ - (void)setupWindowDecorations
//Need to clear title for titleAttributes to apply correctly on iOS6.
[[controller navigationItem] setTitle:nil];
SETPROP(@"titleAttributes", setTitleAttributes);
SETPROP(@"largeTitleAttributes", setLargeTitleAttributes);
SETPROP(@"title", setTitle);
SETPROP(@"titlePrompt", setTitlePrompt);
SETPROP(@"largeTitleEnabled", setLargeTitleEnabled);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "titanium-mobile",
"description": "TiDev Titanium Mobile",
"version": "12.2.0",
"version": "12.2.2",
hansemannn marked this conversation as resolved.
Show resolved Hide resolved
"moduleApiVersion": {
"iphone": "2",
"android": "4"
Expand Down