Skip to content

Commit

Permalink
chore(ios): update minimum target to iOS 11 and cleaned the code
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysingh-axway authored and sgtcoolguy committed Feb 18, 2021
1 parent cf8e368 commit d01cb0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 36 deletions.
43 changes: 12 additions & 31 deletions ios/Classes/TiWebdialogModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (void)teardown
[self fireEvent:@"close"
withObject:@{
@"success" : NUMINT(YES),
@"url" : [_url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
@"url" : [_url stringByRemovingPercentEncoding]
}];
}
}
Expand All @@ -62,19 +62,13 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller
- (SFSafariViewController *)safariController:(NSString *)url withEntersReaderIfAvailable:(BOOL)entersReaderIfAvailable andBarCollapsingEnabled:(BOOL)barCollapsingEnabled
{
if (_safariController == nil) {
NSURL *safariURL = [NSURL URLWithString:[url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if (@available(iOS 11.0, *)) {
SFSafariViewControllerConfiguration *config = [[SFSafariViewControllerConfiguration alloc] init];
config.entersReaderIfAvailable = entersReaderIfAvailable;
config.barCollapsingEnabled = barCollapsingEnabled;

_safariController = [[SFSafariViewController alloc] initWithURL:safariURL
configuration:config];
} else {
_safariController = [[SFSafariViewController alloc] initWithURL:safariURL
entersReaderIfAvailable:entersReaderIfAvailable];
}
NSURL *safariURL = [NSURL URLWithString:[url stringByRemovingPercentEncoding]];
SFSafariViewControllerConfiguration *config = [[SFSafariViewControllerConfiguration alloc] init];
config.entersReaderIfAvailable = entersReaderIfAvailable;
config.barCollapsingEnabled = barCollapsingEnabled;

_safariController = [[SFSafariViewController alloc] initWithURL:safariURL
configuration:config];
[_safariController setDelegate:self];
}

Expand All @@ -86,7 +80,7 @@ - (void)safariViewController:(SFSafariViewController *)controller didCompleteIni
if ([self _hasListeners:@"load"]) {
[self fireEvent:@"load"
withObject:@{
@"url" : [_url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
@"url" : [_url stringByRemovingPercentEncoding],
@"success" : NUMBOOL(didLoadSuccessfully)
}];
}
Expand All @@ -97,7 +91,7 @@ - (void)safariViewController:(SFSafariViewController *)controller initialLoadDid
if ([self _hasListeners:@"redirect"]) {
[self fireEvent:@"redirect"
withObject:@{
@"url" : [_url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
@"url" : [_url stringByRemovingPercentEncoding]
}];
}
}
Expand Down Expand Up @@ -150,28 +144,15 @@ - (void)open:(id)args

if ([args objectForKey:@"tintColor"]) {
TiColor *newColor = [TiUtils colorValue:@"tintColor" properties:args];

if ([TiUtils isIOSVersionOrGreater:@"10.0"]) {
[safari setPreferredControlTintColor:[newColor _color]];
} else {
[[safari view] setTintColor:[newColor _color]];
}
[safari setPreferredControlTintColor:[newColor _color]];
}

if ([args objectForKey:@"barColor"]) {
if ([TiUtils isIOSVersionOrGreater:@"10.0"]) {
[safari setPreferredBarTintColor:[[TiUtils colorValue:@"barColor" properties:args] _color]];
} else {
NSLog(@"[ERROR] Ti.WebDialog: The barColor property is only available in iOS 10 and later");
}
[safari setPreferredBarTintColor:[[TiUtils colorValue:@"barColor" properties:args] _color]];
}

if ([args objectForKey:@"dismissButtonStyle"]) {
if (@available(iOS 11.0, *)) {
[safari setDismissButtonStyle:[TiUtils intValue:@"dismissButtonStyle" properties:args def:SFSafariViewControllerDismissButtonStyleDone]];
} else {
NSLog(@"[ERROR] Ti.WebDialog: The dismissButtonStyle property is only available in iOS 11 and later");
}
[safari setDismissButtonStyle:[TiUtils intValue:@"dismissButtonStyle" properties:args def:SFSafariViewControllerDismissButtonStyleDone]];
}

[[TiApp app] showModalController:safari
Expand Down
4 changes: 2 additions & 2 deletions ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.0.0
version: 3.0.0
apiversion: 2
architectures: armv7 arm64 i386 x86_64
architectures: arm64 x86_64
description: titanium-web-dialog
author: Hans Knoechel
license: Apache 2.0
Expand Down
7 changes: 4 additions & 3 deletions ios/titanium-web-dialog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LIBRARY_SEARCH_PATHS = "";
OTHER_CFLAGS = (
"-DDEBUG",
Expand Down Expand Up @@ -289,7 +289,7 @@
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LIBRARY_SEARCH_PATHS = "";
OTHER_CFLAGS = "-DTI_POST_1_2";
OTHER_LDFLAGS = "-ObjC";
Expand Down Expand Up @@ -325,6 +325,7 @@
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-DDEBUG",
Expand Down Expand Up @@ -363,7 +364,7 @@
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
OTHER_CFLAGS = "-DTI_POST_1_2";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = ti.webdialog;
Expand Down

0 comments on commit d01cb0a

Please sign in to comment.