Skip to content

Commit

Permalink
fix(ios) : build issue for XCode < 11
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysingh-axway committed May 18, 2020
1 parent 122e496 commit 35b5a9f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 36 deletions.
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

0 comments on commit 35b5a9f

Please sign in to comment.