-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iOS): Refactoring configuration (#3759)
- Loading branch information
Showing
25 changed files
with
759 additions
and
206 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef CAPInstanceConfiguration_h | ||
#define CAPInstanceConfiguration_h | ||
|
||
@import UIKit; | ||
|
||
@class CAPInstanceDescriptor; | ||
|
||
NS_SWIFT_NAME(InstanceConfiguration) | ||
@interface CAPInstanceConfiguration: NSObject | ||
@property (nonatomic, readonly, nullable) NSString *appendedUserAgentString; | ||
@property (nonatomic, readonly, nullable) NSString *overridenUserAgentString; | ||
@property (nonatomic, readonly, nullable) UIColor *backgroundColor; | ||
@property (nonatomic, readonly, nonnull) NSArray<NSString*> *allowedNavigationHostnames; | ||
@property (nonatomic, readonly, nonnull) NSURL *localURL; | ||
@property (nonatomic, readonly, nonnull) NSURL *serverURL; | ||
@property (nonatomic, readonly, nonnull) NSDictionary *pluginConfigurations; | ||
@property (nonatomic, readonly) BOOL enableLogging; | ||
@property (nonatomic, readonly) BOOL enableScrolling; | ||
@property (nonatomic, readonly) BOOL allowLinkPreviews; | ||
@property (nonatomic, readonly) BOOL cordovaDeployDisabled; | ||
@property (nonatomic, readonly) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior; | ||
@property (nonatomic, readonly, nonnull) NSURL *appLocation; | ||
|
||
@property (nonatomic, readonly, nonnull) NSDictionary *legacyConfig DEPRECATED_MSG_ATTRIBUTE("Use direct properties instead"); | ||
|
||
- (instancetype _Nonnull)initWithDescriptor:(CAPInstanceDescriptor* _Nonnull)descriptor NS_SWIFT_NAME(init(with:)); | ||
@end | ||
|
||
#endif /* CAPInstanceConfiguration_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#import "CAPInstanceConfiguration.h" | ||
#import <Capacitor/Capacitor-Swift.h> | ||
|
||
@implementation CAPInstanceConfiguration | ||
|
||
- (instancetype)initWithDescriptor:(CAPInstanceDescriptor *)descriptor { | ||
if (self = [super init]) { | ||
// first, give the descriptor a chance to make itself internally consistent | ||
[descriptor normalize]; | ||
// now copy the simple properties | ||
_appendedUserAgentString = descriptor.appendedUserAgentString; | ||
_overridenUserAgentString = descriptor.overridenUserAgentString; | ||
_backgroundColor = descriptor.backgroundColor; | ||
_allowedNavigationHostnames = descriptor.allowedNavigationHostnames; | ||
_enableLogging = descriptor.enableLogging; | ||
_enableScrolling = descriptor.enableScrolling; | ||
_allowLinkPreviews = descriptor.allowLinkPreviews; | ||
_contentInsetAdjustmentBehavior = descriptor.contentInsetAdjustmentBehavior; | ||
_appLocation = descriptor.appLocation; | ||
_pluginConfigurations = descriptor.pluginConfigurations; | ||
_legacyConfig = descriptor.legacyConfig; | ||
// construct the necessary URLs | ||
_localURL = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@://%@", descriptor.urlScheme, descriptor.urlHostname]]; | ||
if (descriptor.serverURL != nil) { | ||
_serverURL = [[NSURL alloc] initWithString:(descriptor.serverURL)]; | ||
} | ||
else { | ||
_serverURL = _localURL; | ||
} | ||
// extract the one value we care about from the cordova configuration | ||
id value = [descriptor.cordovaConfiguration.settings objectForKey:[@"DisableDeploy" lowercaseString]]; | ||
if (value != nil && [value isKindOfClass:[NSString class]]) { | ||
_cordovaDeployDisabled = [(NSString*)value boolValue]; | ||
} | ||
else { | ||
_cordovaDeployDisabled = false; | ||
} | ||
} | ||
return self; | ||
} | ||
|
||
@end |
Oops, something went wrong.