Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Efect Swipe like android Call Phone

$
0
0

my app have a section inbox where the grid you can open like a android call phone, swipe left you open the message, swipe right you delete the message. My problem is when i make longclick in center of row that must show a background gradient, but it's not working so fine. what can i do? TableView

listMessages = Ti.UI.createTableView({
        top:'96dp',
        width:Ti.Platform.displayCaps.platformWidth,
        separatorColor:'#DAD6DA',
        backgroundColor:'#FFF',
        scrollabe:true,
        height:Ti.UI.SIZE,
        bubbleParent:true,
        allowsSelection:false
    }); 
    //Events Tableview
    listMessages.addEventListener('touchend',function(e){
        e.bubbles = true;
        setRowStyle(e.source,'N');
    });
    listMessages.addEventListener('touchcancel',function(e){
        e.bubbles = true;
        setRowStyle(e.source,'N');
    });
    listMessages.addEventListener('longclick',function(e){
        e.bubbles = true;
        e.source.backgroundGradient = {
            type: 'linear',
            startPoint: { x: '50%', y: '50%' },
            endPoint:   { x: '50%', y: '50%' },
            colors: [ 
                { color: '#974E9F', offset: 1 },
                { color: '#2988C0', offset: 1 }
             ]
        };
        setRowStyle(e.source,'S');
    });
    listMessages.addEventListener('swipe',function(e){
        var searchMsg = new searchs.Messages();
        e.bubbles = true;
        if(e.y > 0 && e.x > 0 ){
            if(e.direction == 'left'){
                setRowStyle(e.source,'S');
                e.source.backgroundColor = '#2988C0';
                openMessage(e.rowData.title,e.index,listMessages);
            }else if(e.direction == 'right'){
                setRowStyle(e.source,'S');
                e.source.backgroundColor = '#974E9F';
                searchMsg.delete(e.rowData.title);
                listMessages.deleteRow(e.index);
            }   
        }
        setRowStyle(e.source,'N');
    });
function setRowStyle
function setRowStyle(row,type){
    /*
        Change Style of a row depending parameter selected
        Parameters:
        *row -> row to change style
        *type -> 'N'-> normal  or 'S'->Selected
     * */
    if(type == 'N'){
        row.backgroundColor = '#FFF';
        row.children[0].show();
        row.children[1].show();
        row.children[2].show();
        row.children[3].show();
        row.children[4].hide();
        row.children[5].hide(); 
    }else{
        row.children[0].hide();
        row.children[1].hide();
        row.children[2].hide();
        row.children[3].hide();
        row.children[4].show();
        row.children[5].show();
    }
};

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>