How to use the @nativescript/core/color.Color function in @nativescript/core

To help you get started, we’ve selected a few @nativescript/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Akylas / nativescript-material-components / src / core / core.android.ts View on Github external
export function getRippleColor(color: string | Color) {
    if (color) {
        const temp = typeof color === 'string' ? new Color(color) : color;
        // return android.graphics.Color.argb(temp.a !== 255 ? temp.a / 255 : 0.14, temp.r / 255, temp.g / 255, temp.b); // default alpha is 0.14
        return new Color(temp.a !== 255 ? temp.a : 61.5, temp.r, temp.g, temp.b).android; // default alpha is 0.24
    }
    return null;
}
github Akylas / nativescript-material-components / src / snackbar / snackbar.android.ts View on Github external
public initSnack(options: SnackBarOptions, resolve?: Function) {
        if (this._snackbar) {
            return;
        }
        // options.actionText = options.actionText ? options.actionText : 'Close';
        options.hideDelay = options.hideDelay ? options.hideDelay : 3000;

        const attachToView = (options.view && options.view.android) || topmost().currentPage.android;
        this._snackbar = com.google.android.material.snackbar.Snackbar.make(attachToView, options.message, options.hideDelay);

        this._snackbar.setText(options.message);
        this._snackbar.setDuration(options.hideDelay);

        // set text color of the TextView in the Android SnackBar
        if (options.textColor && Color.isValid(options.textColor)) {
            const color = (options.textColor instanceof Color ? options.textColor : new Color(options.textColor)).android;

            if ((this._snackbar as any).setTextColor) {
                (this._snackbar as any).setTextColor(color);
            } else {
                const mainTextView = this._snackbar.getView().findViewById(SnackBar.SNACKBAR_TEXT_ID) as android.widget.TextView;
                if (mainTextView) {
                    mainTextView.setTextColor(color);
                }
            }
            // this._snackbar.setTextColor(color);
        }

        if (options.actionTextColor && Color.isValid(options.actionTextColor)) {
            const color = (options.actionTextColor instanceof Color ? options.actionTextColor : new Color(options.actionTextColor)).android;
            this._snackbar.setActionTextColor(color);
        }
github Akylas / nativescript-material-components / src / core / core.android.ts View on Github external
export function getRippleColor(color: string | Color) {
    if (color) {
        const temp = typeof color === 'string' ? new Color(color) : color;
        // return android.graphics.Color.argb(temp.a !== 255 ? temp.a / 255 : 0.14, temp.r / 255, temp.g / 255, temp.b); // default alpha is 0.14
        return new Color(temp.a !== 255 ? temp.a : 61.5, temp.r, temp.g, temp.b).android; // default alpha is 0.24
    }
    return null;
}
github Akylas / nativescript-material-components / src / core / core.ios.ts View on Github external
export function getRippleColor(color: string | Color): UIColor {
    if (color) {
        const temp = typeof color === 'string' ? new Color(color) : color;
        // return UIColor.colorWithRedGreenBlueAlpha(temp.r / 255, temp.g / 255, temp.b, temp.a !== 255 ? temp.a / 255 : 0.14);
        return new Color(temp.a !== 255 ? temp.a : 61.5, temp.r, temp.g, temp.b).ios; // default alpha is 0.24
    }
    return null;
}
github NativeScript / NativeScript / tests / app / ui-helper.ts View on Github external
span = new Span();
    span.fontFamily = "serif";
    span.fontSize = 10;
    span.fontWeight = "bold";
    span.color = new Color("red");
    span.backgroundColor = new Color("blue");
    span.textDecoration = "line-through";
    span.text = "Formatted";
    formattedString.spans.push(span);

    span = new Span();
    span.fontFamily = "sans-serif";
    span.fontSize = 20;
    span.fontStyle = "italic";
    span.color = new Color("green");
    span.backgroundColor = new Color("yellow");
    span.textDecoration = "underline";
    span.text = "Text";
    formattedString.spans.push(span);

    return formattedString;
}
github NativeScript / NativeScript / tests / app / ui-helper.ts View on Github external
span = new Span();
    span.fontFamily = "serif";
    span.fontSize = 10;
    span.fontWeight = "bold";
    span.color = new Color("red");
    span.backgroundColor = new Color("blue");
    span.textDecoration = "line-through";
    span.text = "Formatted";
    formattedString.spans.push(span);

    span = new Span();
    span.fontFamily = "sans-serif";
    span.fontSize = 20;
    span.fontStyle = "italic";
    span.color = new Color("green");
    span.backgroundColor = new Color("yellow");
    span.textDecoration = "underline";
    span.text = "Text";
    formattedString.spans.push(span);

    return formattedString;
}
github Akylas / nativescript-material-components / src / core / core.ios.ts View on Github external
setOnSurfaceColor(value: string | Color) {
        this.onSurfaceColor = value;
        const colorTheme = this.getOrcreateAppColorScheme();
        const color = value instanceof Color ? value : new Color(value);
        colorTheme.onSurfaceColor = color.ios;
    }
    getOnSurfaceColor(): string | Color {