<commit_before>declare var NSBundle, SSSnackbar: any;

export class SnackBar {
    private _snackbar = null;
    private _isDismissedManual: boolean = false;


    public simple(snackText: string) {
        return new Promise((resolve, reject) => {
            let timeout = 3;

            try {
                this._snackbar = SSSnackbar.snackbarWithMessageActionTextDurationActionBlockDismissalBlock(
                    snackText,
                    this._getActionText(),
                    timeout,
                    (args) => {
                        //Action, Do Nothing, just close it
                        this._snackbar.dismiss(); //Force close
                        resolve({
                            command: "Dismiss",
                            reason: "Manual",
                            event: args
                        });
                    },
                    (args) => {
                        //Dismissal, Do Nothing
                        resolve({
                            command: "Dismiss",
                            reason: "Timeout",
                            event: args
                        });
                    }
                );

                this._snackbar.show();

            } catch (ex) {
                reject(ex);
            }

        });

    }


    public action(options) {
        return new Promise((resolve, reject) => {

            try {

                if (!options.hideDelay)
                    options.hideDelay = 3000;

                this._snackbar = SSSnackbar.snackbarWithMessageActionTextDurationActionBlockDismissalBlock(
                    options.snackText,
                    options.actionText,
                    options.hideDelay / 1000,
                    (args) => {
                        resolve({
                            command: "Action",
                            event: args
                        });
                    },
                    (args) => {
                        let reason = (this._isDismissedManual) ? "Manual" : "Timeout";
                        this._isDismissedManual = false; //reset
                        resolve({
                            command: "Dismiss",
                            reason: reason,
                            event: args
                        });
                    }
                );

                this._snackbar.show();

            } catch (ex) {
                reject(ex);
            }

        });
    }


    public dismiss(options) {
        return new Promise((resolve, reject) => {
            if (this._snackbar !== null && this._snackbar != "undefined") {
                try {
                    this._isDismissedManual = true;
                    this._snackbar.dismiss();

                    //Return AFTER the item is dismissed, 200ms delay
                    setTimeout(() => {
                        resolve({
                            action: "Dismiss",
                            reason: "Manual"
                        });
                    }, 200);

                } catch (ex) {
                    reject(ex);
                }

            } else {
                resolve({
                    action: "None",
                    message: "No actionbar to dismiss"
                });
            }
        });
    }


    public getSnackbar() {
        return this._snackbar;
    }


    private _getActionText() {
        var actionText = NSBundle.mainBundle().objectForInfoDictionaryKey("NSSnackBarActionText");
        if (actionText != "" && actionText != null) {
            return actionText;
        } else {<commit_msg>Add support for ios10/xcode8 class properties<commit_after>declare var NSBundle, SSSnackbar: any;

export class SnackBar {
    private _snackbar = null;
    private _isDismissedManual: boolean = false;


    public simple(snackText: string) {
        return new Promise((resolve, reject) => {
            let timeout = 3;

            try {
                this._snackbar = SSSnackbar.snackbarWithMessageActionTextDurationActionBlockDismissalBlock(
                    snackText,
                    this._getActionText(),
                    timeout,
                    (args) => {
                        //Action, Do Nothing, just close it
                        this._snackbar.dismiss(); //Force close
                        resolve({
                            command: "Dismiss",
                            reason: "Manual",
                            event: args
                        });
                    },
                    (args) => {
                        //Dismissal, Do Nothing
                        resolve({
                            command: "Dismiss",
                            reason: "Timeout",
                            event: args
                        });
                    }
                );

                this._snackbar.show();

            } catch (ex) {
                reject(ex);
            }

        });

    }


    public action(options) {
        return new Promise((resolve, reject) => {

            try {

                if (!options.hideDelay)
                    options.hideDelay = 3000;

                this._snackbar = SSSnackbar.snackbarWithMessageActionTextDurationActionBlockDismissalBlock(
                    options.snackText,
                    options.actionText,
                    options.hideDelay / 1000,
                    (args) => {
                        resolve({
                            command: "Action",
                            event: args
                        });
                    },
                    (args) => {
                        let reason = (this._isDismissedManual) ? "Manual" : "Timeout";
                        this._isDismissedManual = false; //reset
                        resolve({
                            command: "Dismiss",
                            reason: reason,
                            event: args
                        });
                    }
                );

                this._snackbar.show();

            } catch (ex) {
                reject(ex);
            }

        });
    }


    public dismiss(options) {
        return new Promise((resolve, reject) => {
            if (this._snackbar !== null && this._snackbar != "undefined") {
                try {
                    this._isDismissedManual = true;
                    this._snackbar.dismiss();

                    //Return AFTER the item is dismissed, 200ms delay
                    setTimeout(() => {
                        resolve({
                            action: "Dismiss",
                            reason: "Manual"
                        });
                    }, 200);

                } catch (ex) {
                    reject(ex);
                }

            } else {
                resolve({
                    action: "None",
                    message: "No actionbar to dismiss"
                });
            }
        });
    }


    public getSnackbar() {
        return this._snackbar;
    }


    private _getActionText() {
        var actionText = NSBundle.mainBundle.objectForInfoDictionaryKey("NSSnackBarActionText");
        if (actionText != "" && actionText != null) {
            return actionText;
        } else {
{'fraction_non_alphanumeric': 0.08886771910724006, 'fraction_numerical': 0.004491017964071856, 'mean_word_length': 0.8619204459082848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '298017', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1577, 'n_words': 333}