Code Monkey home page Code Monkey logo

douglashennrich.dhennrich.alert's Introduction

Quick Start

Get it gitTio

Download this repository and consult the Alloy Documentation on how to install it, or simply use the gitTio CLI:

$ gittio install dhennrich.alert

Notes

This is a modified nl.fokkezb.loading widget. I took his structure as base for my widget, so all credits goes to him.

How it looks like

.AlertImage

XML

Add the widget below all your code.

<Alloy>
    <Window>
        <View>
            <Label id="Label">Something</Label>
        </View>

        <!-- Alert -->
        <Widget src="dhennrich.alert" id="DHalert"/>
    </Window>
</Alloy>

JS

When you want to display an alert

$.DHalert.show('Something you want to say', ['Option 1', 'Option 2'], function(event){
    // Hide and remove elements of alert
    $.DHalert.hide();

    switch(this.index){
        case 0:
            console.log('First button clicked');
            // Do something when press "Option 1"
            break;

        case 1:
            console.log('Second button clicked');
            // Do something when press "Option 2"
            break;
    }
});

IMPORTANT The callback should be handled as index as above example

TSS

You can customize your alert on app.tss file.

  • #DHalertMask is the role background of the view.
{
    backgroundColor: "#8000",
    visible: false
}
  • #DHalertOuter is the background of alert.
{
    width: Ti.UI.SIZE,
    height: Ti.UI.SIZE,

    borderRadius: 10,
    backgroundColor: "#F2248e21"
}
  • #DHalertMessage is the label that display our alert
{
    top: '0dp',
    width: Ti.UI.SIZE,
    height: Ti.UI.SIZE,

    color: '#fff',
    textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
    font: { fontSize: '20dp', fontFamily: 'Exo-Bold' }
}
  • #DHalertSeparator is the separator view between message and buttons
{
    top: '5dp',
    height: '2dp',
    width: '90%',
    backgroundColor: "#FFBC00"
}
  • #DHBtns is the options buttons style
{
    backgroundColor: 'transparent'
  , top: '20dp'
  , height: Ti.UI.SIZE
  , textAlign: 'center'
  , color: 'red'
  , font: { fontSize: 18, fontFamily: "Exo-Bold" }
}

Exposed Functions

  • show
  • hide

$.idWidget.show( alert message, [ array, buttons, names ], callback);

$.idWidget.hide();

Changelog

  • 0.0.2 - Add customization for Options Button

douglashennrich.dhennrich.alert's People

Contributors

douglashennrich avatar

Watchers

James Cloos avatar Brenton House avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.