Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// angular
import {Injectable, NgZone} from '@angular/core';
// libs
import {Store} from '@ngrx/store';
// nativescript
import {Color} from 'color';
import {isIOS} from 'platform';
import * as dialogs from 'ui/dialogs';
var TNSFancyAlert, TNSFancyAlertButton;
if (isIOS) {
var fAlerts = require('nativescript-fancyalert');
TNSFancyAlert = fAlerts.TNSFancyAlert;
TNSFancyAlertButton = fAlerts.TNSFancyAlertButton;
} else {
// android
TNSFancyAlertButton = (function () {
function TNSFancyAlertButton(model) {
if (model) {
this.label = model.label;
this.action = model.action;
}
}
return TNSFancyAlertButton;
}());
}
// app
import {ColorService} from './color.service';
public showCustomButtons() {
let buttons = [
new TNSFancyAlertButton({
label: "One",
action: () => {
console.log("One");
}
}),
new TNSFancyAlertButton({
label: "Two",
action: () => {
console.log("Two");
}
}),
new TNSFancyAlertButton({
label: "Three",
action: () => {
console.log("Three");
}
}),
new TNSFancyAlertButton({
label: "Four",
action: () => {
console.log("Four");
}
let underline = nsString.rangeOfStringOptions(
"too!",
NSCaseInsensitiveSearch
);
subTitle.addAttributeValueRange(
NSUnderlineStyleAttributeName,
NSUnderlineStyleSingle,
underline
);
return subTitle;
};
TNSFancyAlert.showCustomTextAttributes(
textAttribution,
new TNSFancyAlertButton({
label: "Wow, ok.",
action: (value: any) => {
console.log(`Clicked ok.`);
}
}),
undefined,
undefined,
"Custom text color?",
`Yep, that can be done too!`,
null
);
}
showSwitch(): void {
TNSFancyAlert.showSwitch("Don't ask me again", '#58B136', new TNSFancyAlertButton({
label: "Save",
action: (isSelected: boolean) => {
console.log(`Don't ask again was selected? ${isSelected}`);
}
}), 'switch.png', '#B3714F', 'Need a switch?', `It can be useful.`, 'Got it.');
}
}
public showTextField() {
TNSFancyAlert.showTextField(
"Enter your name",
"",
new TNSFancyAlertButton({
label: "Save",
action: (value: any) => {
console.log(`User entered ${value}`);
}
}),
undefined,
undefined,
"User Input?",
`Yeah, sure we can.`,
"Ok, lots of options."
);
}
public showSwitch() {
TNSFancyAlert.showSwitch(
`Don't show again`,
"#58B136",
new TNSFancyAlertButton({
label: "Save",
action: (isSelected: boolean) => {
console.log(`Don't show again was selected: ${isSelected}`);
}
}),
"switch.png",
"#B3714F",
"Need a switch?",
`It can be useful.`,
"Got it."
);
}
public showSwitch() {
TNSFancyAlert.showSwitch(
`Don't show again`,
"#58B136",
new TNSFancyAlertButton({
label: "Save",
action: (isSelected: boolean) => {
console.log(`Don't show again was selected: ${isSelected}`);
}
}),
"switch.png",
"#B3714F",
"Need a switch?",
`It can be useful.`,
"Got it."
);
}
public showTextField() {
TNSFancyAlert.showTextField(
"Enter your name",
"",
new TNSFancyAlertButton({
label: "Save",
action: (value: any) => {
console.log(`User entered ${value}`);
}
}),
undefined,
undefined,
"User Input?",
`Yeah, sure we can.`,
"Ok, lots of options."
);
}
}
}),
new TNSFancyAlertButton({
label: "Four",
action: () => {
console.log("Four");
}
}),
new TNSFancyAlertButton({
label: "Really? More?",
action: () => {
console.log("more");
}
})
];
TNSFancyAlert.showCustomButtons(
buttons,
undefined,
undefined,
"Got Buttons?",
`Add as many as you'd like.`,
"Ok"
);
}
greenRange
);
let underline = nsString.rangeOfStringOptions(
"too!",
NSCaseInsensitiveSearch
);
subTitle.addAttributeValueRange(
NSUnderlineStyleAttributeName,
NSUnderlineStyleSingle,
underline
);
return subTitle;
};
TNSFancyAlert.showCustomTextAttributes(
textAttribution,
new TNSFancyAlertButton({
label: "Wow, ok.",
action: (value: any) => {
console.log(`Clicked ok.`);
}
}),
undefined,
undefined,
"Custom text color?",
`Yep, that can be done too!`,
null
);
}