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

fix(ios) : build issue for XCode < 11 #11711

Merged
merged 5 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apidoc/Titanium/UI/UI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ events:
type: Number
constants: Titanium.UI.USER_INTERFACE_STYLE_*
platforms: [android, iphone, ipad]
osver: {ios: {min: "13.0"}}

methods:
- name: create2DMatrix
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/UIModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
TiProxy *clipboard;
#endif
NSNumber *lastEmittedMode;
NSDictionary *systemColors;
NSMutableDictionary *systemColors;
}

//TODO: review these, maybe they need to go on iPhone Animation Style - however, they are platform generic
Expand Down
84 changes: 49 additions & 35 deletions iphone/Classes/UIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ - (void)dealloc
[self forgetProxy:clipboard];
RELEASE_TO_NIL(clipboard);
#endif
RELEASE_TO_NIL(systemColors);
[super dealloc];
}

- (void)_listenerAdded:(NSString *)type count:(int)count
{
if ((count == 1) && [type isEqual:@"userinterfacestyle"]) {
lastEmittedMode = self.userInterfaceStyle;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
lastEmittedMode = self.userInterfaceStyle;
}
#endif
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didChangeTraitCollection:)
name:kTiTraitCollectionChanged
Expand All @@ -85,12 +88,16 @@ - (void)_listenerRemoved:(NSString *)type count:(int)count

- (void)didChangeTraitCollection:(NSNotification *)info
{
NSNumber *currentMode = self.userInterfaceStyle;
if (currentMode == lastEmittedMode) {
return;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
NSNumber *currentMode = self.userInterfaceStyle;
if (currentMode == lastEmittedMode) {
return;
}
lastEmittedMode = currentMode;
[self fireEvent:@"userinterfacestyle" withObject:@{ @"value" : currentMode }];
}
lastEmittedMode = currentMode;
[self fireEvent:@"userinterfacestyle" withObject:@{ @"value" : currentMode }];
#endif
}

- (NSString *)apiName
Expand Down Expand Up @@ -401,7 +408,10 @@ - (NSNumber *)USER_INTERFACE_STYLE_DARK
- (UIColor *)getSystemColor:(NSString *)color
{
if (systemColors == nil) {
systemColors = @{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
systemColors = [NSMutableDictionary dictionary];

[systemColors addEntriesFromDictionary:@{
@"systemRedColor" : UIColor.systemRedColor,
@"systemGreenColor" : UIColor.systemGreenColor,
@"systemBlueColor" : UIColor.systemBlueColor,
Expand All @@ -410,34 +420,38 @@ - (UIColor *)getSystemColor:(NSString *)color
@"systemPinkColor" : UIColor.systemPinkColor,
@"systemPurpleColor" : UIColor.systemPurpleColor,
@"systemTealColor" : UIColor.systemTealColor,
@"systemIndigoColor" : UIColor.systemIndigoColor,
@"systemGrayColor" : UIColor.systemGrayColor,
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
@"systemGray2Color" : UIColor.systemGray2Color,
@"systemGray3Color" : UIColor.systemGray3Color,
@"systemGray4Color" : UIColor.systemGray4Color,
@"systemGray5Color" : UIColor.systemGray5Color,
@"systemGray6Color" : UIColor.systemGray6Color,
@"labelColor" : UIColor.labelColor,
@"secondaryLabelColor" : UIColor.secondaryLabelColor,
@"tertiaryLabelColor" : UIColor.tertiaryLabelColor,
@"quaternaryLabelColor" : UIColor.quaternaryLabelColor,
@"linkColor" : UIColor.linkColor,
@"placeholderTextColor" : UIColor.placeholderTextColor,
@"separatorColor" : UIColor.separatorColor,
@"opaqueSeparatorColor" : UIColor.opaqueSeparatorColor,
@"systemBackgroundColor" : UIColor.systemBackgroundColor,
@"secondarySystemBackgroundColor" : UIColor.secondarySystemBackgroundColor,
@"tertiarySystemBackgroundColor" : UIColor.tertiarySystemBackgroundColor,
@"systemGroupedBackgroundColor" : UIColor.systemGroupedBackgroundColor,
@"secondarySystemGroupedBackgroundColor" : UIColor.secondarySystemGroupedBackgroundColor,
@"tertiarySystemGroupedBackgroundColor" : UIColor.tertiarySystemGroupedBackgroundColor,
@"systemFillColor" : UIColor.systemFillColor,
@"secondarySystemFillColor" : UIColor.secondarySystemFillColor,
@"tertiarySystemFillColor" : UIColor.tertiarySystemFillColor,
@"quaternarySystemFillColor" : UIColor.quaternarySystemFillColor
@"systemGrayColor" : UIColor.systemGrayColor
}];

if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
[systemColors addEntriesFromDictionary:@{
@"systemIndigoColor" : UIColor.systemIndigoColor,
@"systemGray2Color" : UIColor.systemGray2Color,
@"systemGray3Color" : UIColor.systemGray3Color,
@"systemGray4Color" : UIColor.systemGray4Color,
@"systemGray5Color" : UIColor.systemGray5Color,
@"systemGray6Color" : UIColor.systemGray6Color,
@"labelColor" : UIColor.labelColor,
@"secondaryLabelColor" : UIColor.secondaryLabelColor,
@"tertiaryLabelColor" : UIColor.tertiaryLabelColor,
@"quaternaryLabelColor" : UIColor.quaternaryLabelColor,
@"linkColor" : UIColor.linkColor,
@"placeholderTextColor" : UIColor.placeholderTextColor,
@"separatorColor" : UIColor.separatorColor,
@"opaqueSeparatorColor" : UIColor.opaqueSeparatorColor,
@"systemBackgroundColor" : UIColor.systemBackgroundColor,
@"secondarySystemBackgroundColor" : UIColor.secondarySystemBackgroundColor,
@"tertiarySystemBackgroundColor" : UIColor.tertiarySystemBackgroundColor,
@"systemGroupedBackgroundColor" : UIColor.systemGroupedBackgroundColor,
@"secondarySystemGroupedBackgroundColor" : UIColor.secondarySystemGroupedBackgroundColor,
@"tertiarySystemGroupedBackgroundColor" : UIColor.tertiarySystemGroupedBackgroundColor,
@"systemFillColor" : UIColor.systemFillColor,
@"secondarySystemFillColor" : UIColor.secondarySystemFillColor,
@"tertiarySystemFillColor" : UIColor.tertiarySystemFillColor,
@"quaternarySystemFillColor" : UIColor.quaternarySystemFillColor
}];
}
#endif
};
}
return [systemColors objectForKey:color];
}
Expand Down