Files
NativeScript/ui/dialogs/dialogs-common.ts
Vladimir Enchev c3d3326cb2 alert fixed
2015-11-27 14:56:11 +02:00

86 lines
1.9 KiB
TypeScript

import color = require("color");
import frame = require("ui/frame");
import page = require("ui/page");
import button = require("ui/button");
import textField = require("ui/text-field");
import label = require("ui/label");
import types = require("utils/types");
export var STRING = "string",
PROMPT = "Prompt",
CONFIRM = "Confirm",
ALERT = "Alert",
LOGIN = "Login",
OK = "OK",
CANCEL = "Cancel";
/**
* Defines the input type for prompt dialog.
*/
export module inputType {
/**
* Plain text input type.
*/
export var text: string = "text";
/**
* Password input type.
*/
export var password: string = "password";
}
export function getCurrentPage(): page.Page {
var topMostFrame = frame.topmost();
if (topMostFrame) {
return topMostFrame.currentPage;
}
return undefined;
}
function applySelectors(view) {
var currentPage = getCurrentPage();
if (currentPage) {
var styleScope = currentPage._getStyleScope();
if (styleScope) {
styleScope.applySelectors(view);
}
}
}
var buttonColor: color.Color;
export function getButtonColor(): color.Color {
if (!buttonColor) {
var btn = new button.Button();
applySelectors(btn);
buttonColor = btn.color;
}
return buttonColor;
}
var textFieldColor: color.Color;
export function getTextFieldColor(): color.Color {
if (!textFieldColor) {
var tf = new textField.TextField();
applySelectors(tf);
textFieldColor = tf.color;
}
return textFieldColor;
}
var labelColor: color.Color;
export function getLabelColor(): color.Color {
if (!labelColor) {
var lbl = new label.Label();
applySelectors(lbl);
labelColor = lbl.color;
}
return labelColor;
}
export function isDialogOptions(arg): boolean {
return !types.isNullOrUndefined(arg) && (arg.message || arg.title);
}