├── platforms
└── ios
│ ├── build.xconfig
│ └── Podfile
├── .gitignore
├── ios.png
├── android.png
├── demo
├── app
│ ├── app.js
│ ├── App_Resources
│ │ ├── iOS
│ │ │ ├── icon.png
│ │ │ ├── Default.png
│ │ │ ├── icon-40.png
│ │ │ ├── icon-60.png
│ │ │ ├── icon-72.png
│ │ │ ├── icon-76.png
│ │ │ ├── icon@2x.png
│ │ │ ├── Default@2x.png
│ │ │ ├── Icon-Small.png
│ │ │ ├── icon-40@2x.png
│ │ │ ├── icon-60@2x.png
│ │ │ ├── icon-72@2x.png
│ │ │ ├── icon-76@2x.png
│ │ │ ├── Icon-Small-50.png
│ │ │ ├── Icon-Small@2x.png
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Default-667h@2x.png
│ │ │ ├── Default-736h@3x.png
│ │ │ ├── Default-Landscape.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Icon-Small-50@2x.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ ├── Default-Landscape@2x.png
│ │ │ ├── Default-Landscape@3x.png
│ │ │ ├── Default-Landscape-568h@2x.png
│ │ │ ├── Default-Landscape-667h@2x.png
│ │ │ ├── build.xcconfig
│ │ │ └── Info.plist
│ │ └── Android
│ │ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ │ ├── drawable-ldpi
│ │ │ └── icon.png
│ │ │ ├── drawable-mdpi
│ │ │ └── icon.png
│ │ │ ├── drawable-nodpi
│ │ │ └── splashscreen.9.png
│ │ │ ├── app.gradle
│ │ │ └── AndroidManifest.xml
│ ├── references.d.ts
│ ├── main-page.xml
│ ├── package.json
│ └── main-page.js
└── package.json
├── package.json
├── README.md
├── index.android.js
├── index.ios.js
└── LICENSE
/platforms/ios/build.xconfig:
--------------------------------------------------------------------------------
1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # generated files
2 | demo/node_modules/
3 | demo/platforms/
4 |
--------------------------------------------------------------------------------
/ios.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/ios.png
--------------------------------------------------------------------------------
/android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/android.png
--------------------------------------------------------------------------------
/demo/app/app.js:
--------------------------------------------------------------------------------
1 | var application = require("application");
2 | application.start({ moduleName: "main-page" });
3 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-40.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-60.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-72.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-76.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Icon-Small.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-40@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-60@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-72@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/icon-76@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Icon-Small-50.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Icon-Small@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-736h@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Landscape.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Portrait.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Icon-Small-50@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/Android/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/Android/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/Android/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Landscape-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/iOS/Default-Landscape-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/enchev/nativescript-dialog/HEAD/demo/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png
--------------------------------------------------------------------------------
/demo/app/references.d.ts:
--------------------------------------------------------------------------------
1 | /// Enable smart suggestions and completions in Visual Studio Code JavaScript projects.
2 |
--------------------------------------------------------------------------------
/platforms/ios/Podfile:
--------------------------------------------------------------------------------
1 | pod 'SDCAlertView', '~> 7.1'
2 |
3 | post_install do |installer|
4 | installer.pods_project.targets.each do |target|
5 | target.build_configurations.each do |config|
6 | config.build_settings['SWIFT_VERSION'] = '3.0'
7 | end
8 | end
9 | end
--------------------------------------------------------------------------------
/demo/app/main-page.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "nativescript": {
3 | "id": "org.nativescript.demo",
4 | "tns-android": {
5 | "version": "2.4.1"
6 | },
7 | "tns-ios": {
8 | "version": "2.4.0"
9 | }
10 | },
11 | "dependencies": {
12 | "nativescript-dialog": "0.1.0",
13 | "tns-core-modules": "2.4.3"
14 | }
15 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/build.xcconfig:
--------------------------------------------------------------------------------
1 | // You can add custom settings here
2 | // for example you can uncomment the following line to force distribution code signing
3 | // CODE_SIGN_IDENTITY = iPhone Distribution
4 | // ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
5 | // ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Brand Assets;
6 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
1 | // Add your native dependencies here:
2 |
3 | // Uncomment to add recyclerview-v7 dependency
4 | //dependencies {
5 | // compile 'com.android.support:recyclerview-v7:+'
6 | //}
7 |
8 | android {
9 | defaultConfig {
10 | generatedDensities = []
11 | }
12 | aaptOptions {
13 | additionalParameters "--no-version-vectors"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/demo/app/package.json:
--------------------------------------------------------------------------------
1 | {"name":"tns-template-hello-world","main":"app.js","version":"1.7.0","author":{"name":"Telerik","email":"support@telerik.com"},"description":"Nativescript hello-world project template","license":"Apache-2.0","keywords":["telerik","mobile","nativescript","{N}","tns","appbuilder","template"],"repository":{"type":"git","url":"git://github.com/NativeScript/template-hello-world.git"},"bugs":{"url":"https://github.com/NativeScript/template-hello-world/issues"},"homepage":"https://github.com/NativeScript/template-hello-world","android":{"v8Flags":"--expose_gc"},"readme":"ERROR: No README data found!","_id":"tns-template-hello-world@1.7.0","_from":"tns-template-hello-world@1.7.0"}
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-dialog",
3 | "version": "0.1.0",
4 | "description": "A NativeScript plugin for iOS and Android that allows you to create custom dialog.",
5 | "main": "index.js",
6 | "nativescript": {
7 | "id": "org.nativescript.dialog"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/enchev/nativescript-dialog"
12 | },
13 | "keywords": [
14 | "NativeScript",
15 | "native",
16 | "script",
17 | "dialog",
18 | "custom",
19 | "alert",
20 | "UIAlertView",
21 | "UIAlertController",
22 | "ios",
23 | "android"
24 | ],
25 | "author": "Vladimir Enchev (https://github.com/enchev)",
26 | "license": "Apache-2.0",
27 | "bugs": "https://github.com/enchev/nativescript-dialog/issues",
28 | "homepage": "https://github.com/enchev/nativescript-dialog"
29 | }
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NativeScript Dialog
2 |
3 | A NativeScript plugin for iOS and Android that allows you to create custom dialog.
4 |
5 | ## Installation
6 | `tns plugin add nativescript-dialog`
7 |
8 | ## Usage
9 |
10 | ###
11 | ```XML
12 |
13 |
14 |
15 |
16 |
17 | ```
18 |
19 | ```JavaScript
20 | var platform = require("platform");
21 | var application = require("application");
22 | var dialog = require("nativescript-dialog");
23 |
24 | exports.buttonTap = function(args){
25 | var nativeView;
26 |
27 | if(platform.device.os === platform.platformNames.ios){
28 | nativeView = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.UIActivityIndicatorViewStyleGray);
29 | nativeView.startAnimating();
30 | } else if(platform.device.os === platform.platformNames.android){
31 | nativeView = new android.widget.ProgressBar(application.android.currentContext);
32 | nativeView.setIndeterminate(true);
33 | }
34 |
35 | dialog.show({
36 | title: "Loading...",
37 | message: "Please wait!",
38 | cancelButtonText: "Cancel",
39 | nativeView: nativeView}
40 | ).then(function(r){ console.log("Result: " + r); },
41 | function(e){console.log("Error: " + e)});
42 | }
43 | ```
44 | iOS | Android
45 | ------------ | -------------
46 |  | 
47 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | icon.png
13 | CFBundleIcons
14 |
15 | CFBundlePrimaryIcon
16 |
17 | CFBundleIconFiles
18 |
19 | icon-40
20 | icon-60
21 | icon-72
22 | icon-76
23 | Icon-Small
24 | Icon-Small-50
25 |
26 | UIPrerenderedIcon
27 |
28 |
29 |
30 | CFBundleInfoDictionaryVersion
31 | 6.0
32 | CFBundleName
33 | ${PRODUCT_NAME}
34 | CFBundlePackageType
35 | APPL
36 | CFBundleShortVersionString
37 | 1.0
38 | CFBundleSignature
39 | ????
40 | CFBundleVersion
41 | 1.0
42 | LSRequiresIPhoneOS
43 |
44 | UILaunchStoryboardName
45 | LaunchScreen
46 | UIRequiresFullScreen
47 |
48 | UIRequiredDeviceCapabilities
49 |
50 | armv7
51 |
52 | UISupportedInterfaceOrientations
53 |
54 | UIInterfaceOrientationPortrait
55 | UIInterfaceOrientationLandscapeLeft
56 | UIInterfaceOrientationLandscapeRight
57 |
58 | UISupportedInterfaceOrientations~ipad
59 |
60 | UIInterfaceOrientationPortrait
61 | UIInterfaceOrientationPortraitUpsideDown
62 | UIInterfaceOrientationLandscapeLeft
63 | UIInterfaceOrientationLandscapeRight
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/index.android.js:
--------------------------------------------------------------------------------
1 | var application = require("application");
2 | var result;
3 |
4 | exports.show = function (options) {
5 | return new Promise(function (resolve, reject) {
6 | try {
7 | if (options) {
8 | var alert = new android.app.AlertDialog.Builder(application.android.currentContext);
9 |
10 | if (options.message) {
11 | alert.setMessage(options.message);
12 | }
13 |
14 | if (options.title) {
15 | alert.setTitle(options.title);
16 | }
17 |
18 | if (options.nativeView instanceof android.view.View) {
19 | alert.setView(options.nativeView);
20 | }
21 |
22 | if (options.cancelButtonText) {
23 | alert.setNegativeButton(options.cancelButtonText, new android.content.DialogInterface.OnClickListener({
24 | onClick: function (dialog, id) {
25 | dialog.cancel();
26 | resolve(false);
27 | }
28 | }));
29 | }
30 |
31 | if (options.neutralButtonText) {
32 | alert.setNeutralButton(options.neutralButtonText, new android.content.DialogInterface.OnClickListener({
33 | onClick: function (dialog, id) {
34 | dialog.cancel();
35 | resolve(undefined);
36 | }
37 | }));
38 | }
39 |
40 | if (options.okButtonText) {
41 | alert.setPositiveButton(options.okButtonText, new android.content.DialogInterface.OnClickListener({
42 | onClick: function (dialog, id) {
43 | dialog.cancel();
44 | resolve(true);
45 | }
46 | }));
47 | }
48 |
49 | result = {};
50 | result.resolve = resolve,
51 | result.dialog = alert.show();
52 | }
53 | } catch (ex) {
54 | reject(ex);
55 | }
56 | });
57 | }
58 |
59 | exports.close = function () {
60 | if(result){
61 |
62 | if(result.dialog instanceof android.app.AlertDialog){
63 | result.dialog.cancel();
64 | }
65 |
66 | if(result.resolve instanceof Function){
67 | result.resolve(true);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/demo/app/main-page.js:
--------------------------------------------------------------------------------
1 | var platform = require("platform");
2 | var application = require("application");
3 | var dialog = require("nativescript-dialog");
4 |
5 | function showLoadingDialog(){
6 | var nativeView;
7 |
8 | if(platform.device.os === platform.platformNames.ios){
9 | nativeView = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.UIActivityIndicatorViewStyleGray);
10 | nativeView.startAnimating();
11 | } else if(platform.device.os === platform.platformNames.android){
12 | nativeView = new android.widget.ProgressBar(application.android.currentContext);
13 | nativeView.setIndeterminate(true);
14 | }
15 |
16 | dialog.show({
17 | title: "Loading...",
18 | message: "Please wait!",
19 | cancelButtonText: "Cancel",
20 | nativeView: nativeView,
21 | }
22 | ).then(function(r){
23 | dialog.show({title: "Message", message: "Loading " + (r ? "finished!" : "aborted!"), okButtonText: "Close"});
24 | },
25 | function(e){
26 | dialog.show({title: "Error", message: "Error: " + e, okButtonText: "Close"});
27 | });
28 | }
29 |
30 | exports.showLoadingDialog = function(args){
31 | showLoadingDialog();
32 | }
33 |
34 | exports.closeLoadingDialog = function(args){
35 | showLoadingDialog();
36 |
37 | setTimeout(function(){
38 | dialog.close();
39 | }, 3000);
40 | }
41 |
42 | exports.showCustomSwitchDialog = function(args){
43 | var options = {
44 | title: "My Custom Dialog",
45 | message: "Please use the switch to turn something on/off",
46 | okButtonText: "Ok",
47 | cancelButtonText: "Cancel",
48 | nativeView: platform.device.os === platform.platformNames.ios ? new UISwitch() : new android.widget.Switch(application.android.currentContext)
49 | };
50 |
51 | dialog.show(options).then(
52 | function(r){
53 | if(r){
54 | dialog.show({
55 | title: "Result",
56 | message: "You've pressed OK button and the switch is " + (isChecked(options.nativeView) ? "checked" : "not checked"),
57 | okButtonText: "Close"
58 | });
59 | } else {
60 | dialog.show({title: "Result", message: "You've pressed Cancel button", okButtonText: "Close"});
61 | }
62 |
63 | },
64 | function(e){
65 | dialog.show({title: "Error", message: "Error: " + e, okButtonText: "Close"});
66 | }
67 | );
68 | }
69 |
70 | function isChecked(nativeView){
71 | if(platform.device.os === platform.platformNames.ios){
72 | return nativeView.on;
73 | } else if(platform.device.os === platform.platformNames.android) {
74 | return nativeView.isChecked();
75 | }
76 | return undefined;
77 | }
78 |
--------------------------------------------------------------------------------
/index.ios.js:
--------------------------------------------------------------------------------
1 | var dialogsCommon = require("ui/dialogs/dialogs-common");
2 |
3 | var result;
4 |
5 | exports.show = function (options) {
6 | return new Promise(function (resolve, reject) {
7 | try {
8 | if (options) {
9 | var alert = SDCAlertController.alloc().initWithTitleMessagePreferredStyle(options.title || "", options.message || "", SDCAlertControllerStyle.Alert);
10 |
11 | if (options.nativeView instanceof UIView) {
12 | alert.contentView.addSubview(options.nativeView);
13 |
14 | if(options.nativeView.centerXAnchor) {
15 | options.nativeView.translatesAutoresizingMaskIntoConstraints = false;
16 | options.nativeView.centerXAnchor.constraintEqualToAnchor(alert.contentView.centerXAnchor).active = true;
17 | options.nativeView.topAnchor.constraintEqualToAnchor(alert.contentView.topAnchor).active = true;
18 | options.nativeView.bottomAnchor.constraintEqualToAnchor(alert.contentView.bottomAnchor).active = true;
19 | } else {
20 | var xCenterConstraint = NSLayoutConstraint.constraintWithItemAttributeRelatedByToItemAttributeMultiplierConstant(options.nativeView, NSLayoutAttributeCenterX, NSLayoutRelationEqual, alert.contentView, NSLayoutAttributeCenterX, 1.0, 0);
21 | alert.contentView.addConstraint(xCenterConstraint);
22 |
23 | var yCenterConstraint = NSLayoutConstraint.constraintWithItemAttributeRelatedByToItemAttributeMultiplierConstant(options.nativeView, NSLayoutAttributeCenterY, NSLayoutRelationEqual, alert.contentView, NSLayoutAttributeCenterY, 1.0, 0);
24 | alert.contentView.addConstraint(yCenterConstraint);
25 |
26 | var views = {"newView": options.nativeView};
27 |
28 | var widthConstraints = NSLayoutConstraint.constraintsWithVisualFormatOptionsMetricsViews("H:[newView(100)]", 0, null, views);
29 | alert.contentView.addConstraints(widthConstraints);
30 |
31 | var heightConstraints = NSLayoutConstraint.constraintsWithVisualFormatOptionsMetricsViews("V:[newView(100)]", 0, null, views);
32 | alert.contentView.addConstraints(heightConstraints);
33 | }
34 | }
35 |
36 | if (options.cancelButtonText) {
37 | alert.add(SDCAlertAction.alloc().initWithTitleStyleHandler(options.cancelButtonText,
38 | SDCAlertActionStyle.Default, function (args) {
39 | resolve(false);
40 | }));
41 | }
42 |
43 | if (options.neutralButtonText) {
44 | alert.add(SDCAlertAction.alloc().initWithTitleStyleHandler(options.neutralButtonText,
45 | SDCAlertActionStyle.Default, function (args) {
46 | resolve(undefined);
47 | }));
48 | }
49 |
50 | if (options.okButtonText) {
51 | alert.add(SDCAlertAction.alloc().initWithTitleStyleHandler(options.okButtonText,
52 | SDCAlertActionStyle.Default, function (args) {
53 | resolve(true);
54 | }));
55 | }
56 |
57 |
58 | result = {};
59 | result.resolve = resolve,
60 | result.dialog = alert;
61 |
62 | if (alert) {
63 | var currentPage = dialogsCommon.getCurrentPage();
64 | if (currentPage) {
65 | var viewController = currentPage.ios;
66 | if (viewController) {
67 | viewController.presentViewControllerAnimatedCompletion(alert, true, null);
68 | }
69 | }
70 | }
71 | }
72 | } catch (ex) {
73 | reject(ex);
74 | }
75 | });
76 | }
77 |
78 | exports.close = function () {
79 | if(result){
80 |
81 | if(result.dialog instanceof SDCAlertController){
82 | result.dialog.dismissAnimatedCompletion(true, null);
83 | }
84 |
85 | if(result.resolve instanceof Function){
86 | result.resolve(true);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------