Jump to content

Camera with Touch - revisted


stiaan

Recommended Posts

Hi Farshad

 

I have been looking at the Sencha forums regarding the camera feature. Have have seen some code on how to use the camera. Can you maybe give an idea on how one would go about to integrate the following code: https://github.com/CaliLuke/NativeContacts/blob/master/app/view/Picture.js

 

It looks like (See code in bold below):

/*
 * File: app/view/Picture.js
 *
 * This file was generated by Sencha Architect version 2.0.0.
 * http://www.sencha.com/products/architect/
 *
 * This file requires use of the Sencha Touch 2.0.x library, under independent license.
 * License of Sencha Architect does not include license for Sencha Touch 2.0.x. For more
 * details see http://www.sencha.com/licenseor contact license@sencha.com.
 *
 * This file will be auto-generated each and everytime you save your project.
 *
 * Do NOT hand edit this file.
 */

Ext.define('Contact.view.Picture', {
    extend: 'Ext.Container',
    alias: 'widget.contactpic',

    config: {
        height: 120,
        minHeight: 100,
        style: 'overflow: hidden',
        ui: '',
        layout: {
            align: 'center',
            type: 'vbox'
        },
        overflow: 'hidden',
        tpl: [
            '<img src="{picture}" width="160" />'
        ],
        items: [
            {
                xtype: 'component',
                html: ''
            },
            {
                xtype: 'button',
                bottom: 5,
                itemId: 'mybutton',
                right: 5,
                iconCls: 'add',
                iconMask: true
            }
        ],
        listeners: [
            {
                fn: 'onMybuttonTap',
                event: 'tap',
                delegate: '#mybutton'
            }
        ]
    },

    onMybuttonTap: function(button, e, options) {
        Ext.device.Camera.capture({
            source: 'camera',
            destination: 'file',

            success: function(url) {
                this.fireEvent('change', this, url);
            },
            failure: function() {
                Ext.Msg.alert('Error', 'There was an error when acquiring the picture.');
            },
            scope: this
        });
    }


});

Link to comment
Share on other sites

×
×
  • Create New...