Permalink
Browse files

Next up, camera

  • Loading branch information...
1 parent c34f633 commit 4ee2681c69198fa654c76d4bda076d3956c21967 Aaron Conran committed May 2, 2012
View
@@ -1,12 +1,12 @@
{
"name": "NativeContacts",
"settings": {
- "urlPrefix": "http://localhost/~lucacandela/contacts",
+ "urlPrefix": "http://localhost/NativeContacts/",
"directAPI": "",
"spacesToIndent": 4,
"codeGenFormat": "Class",
- "exportPath": "/Users/lucacandela/Sites/contacts",
- "extPath": "http://extjs.cachefly.net/touch/sencha-touch-2.0.0/",
+ "exportPath": "/Users/aconran/Sites/deploynative",
+ "extPath": "http://localhost/releases/sencha-touch-2.0.0-commercial/",
"senchaIoKey": "",
"senchaIoPath": "http://extjs.cachefly.net/designer/IO/",
"lineEnding": "LF",
@@ -22,58 +22,82 @@
"topInstanceFileMap": {
"ab0ebc18-fc5b-43b1-8958-7395bd191769": {
"paths": [
- "metadata/view/MainPanel",
- "app/view/override/MainPanel.js",
- "app/view/MainPanel.js"
+ "metadata/view/Main",
+ "app/view/override/Main.js",
+ "app/view/Main.js"
],
- "className": "MainPanel"
+ "className": "Main"
},
"266d5780-ee4a-4dca-a156-841cf77894ee": {
"paths": [
- "metadata/view/ContactInfo",
- "app/view/override/ContactInfo.js",
- "app/view/ContactInfo.js"
+ "metadata/view/Info",
+ "app/view/override/Info.js",
+ "app/view/Info.js"
],
- "className": "ContactInfo"
+ "className": "Info"
},
"7187cc37-7c2e-4f8a-a763-ba7d3f34a79c": {
"paths": [
- "metadata/view/ContactForm",
- "app/view/override/ContactForm.js",
- "app/view/ContactForm.js"
+ "metadata/view/Form",
+ "app/view/override/Form.js",
+ "app/view/Form.js"
],
- "className": "ContactForm"
+ "className": "Form"
},
"b037ea3a-5bcd-4f85-930a-abaa1bdc4dcd": {
"paths": [
- "metadata/view/ContactPicture",
- "app/view/override/ContactPicture.js",
- "app/view/ContactPicture.js"
+ "metadata/view/Picture",
+ "app/view/override/Picture.js",
+ "app/view/Picture.js"
],
- "className": "ContactPicture"
+ "className": "Picture"
},
"5b610c64-3053-4d2f-8bfb-77077b9b2217": {
"paths": [
- "metadata/view/ContactList",
- "app/view/override/ContactList.js",
- "app/view/ContactList.js"
+ "metadata/view/List",
+ "app/view/override/List.js",
+ "app/view/List.js"
],
- "className": "ContactList"
+ "className": "List"
},
"e83d8bd0-aa8b-4b79-bf87-9a8797bca19b": {
"paths": [
- "metadata/view/FavoriteList",
- "app/view/override/FavoriteList.js",
- "app/view/FavoriteList.js"
+ "metadata/view/FavoriteView",
+ "app/view/override/FavoriteView.js",
+ "app/view/FavoriteView.js"
],
- "className": "FavoriteList"
+ "className": "FavoriteView"
+ },
+ "8173b689-b7f9-4661-9bb0-6cba367d3d80": {
+ "paths": [
+ "metadata/store/ContactStore",
+ "app/store/override/ContactStore.js",
+ "app/store/ContactStore.js"
+ ],
+ "className": "ContactStore"
+ },
+ "218f2c46-69a4-44c6-8b9e-29b8e3d800dc": {
+ "paths": [
+ "metadata/model/Contact",
+ "app/model/override/Contact.js",
+ "app/model/Contact.js"
+ ],
+ "className": "Contact"
+ },
+ "12f4e105-fe10-4110-a7c7-4be456e0092e": {
+ "paths": [
+ "metadata/controller/Contacts",
+ "app/controller/override/Contacts.js",
+ "app/controller/Contacts.js"
+ ],
+ "className": "Contacts"
}
},
"expandedState": {
- "data": true,
- "model": true,
+ "data": false,
+ "model": false,
"component": true,
- "controller": true,
+ "controller": false,
"resource": true
}
}
View
@@ -6,8 +6,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NativeContacts</title>
- <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/resources/css/sencha-touch.css"/>
- <script type="text/javascript" src="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/sencha-touch-all-debug.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://localhost/releases/sencha-touch-2.0.0-commercial/resources/css/sencha-touch.css"/>
+ <script type="text/javascript" src="http://localhost/releases/sencha-touch-2.0.0-commercial/sencha-touch-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript">
if (!Ext.browser.is.WebKit) {
View
65 app.js
@@ -18,19 +18,66 @@ Ext.Loader.setConfig({
});
Ext.application({
+ models: [
+ 'Contact'
+ ],
+ stores: [
+ 'ContactStore'
+ ],
views: [
- 'MainPanel',
- 'ContactInfo',
- 'ContactForm',
- 'ContactPicture',
- 'ContactList',
- 'FavoriteList'
+ 'Main',
+ 'Info',
+ 'Form',
+ 'Picture',
+ 'List',
+ 'FavoriteView'
+ ],
+ name: 'Contact',
+ controllers: [
+ 'Contacts'
],
- name: 'MyApp',
launch: function() {
-
- Ext.create('MyApp.view.MainPanel', {fullscreen: true});
+ Ext.require('Ext.device.*');
+ Ext.util.Format.empty = function(value, defaultValue) {
+ return !Ext.isEmpty(value) ? value : defaultValue;
+ };
+ Ext.util.Format.undef = function(value, defaultValue) {
+ return Ext.isDefined(value) ? value : defaultValue;
+ };
+ var ds = Ext.StoreMgr.lookup('ContactStore');
+ if (!ds.getCount()) {
+ Ext.Msg.alert('Intro', 'Setting up default database.');
+ ds.add({
+ firstName: 'Aaron',
+ lastName: 'Conran',
+ emailAddress: 'aaron@sencha.com',
+ phoneNumber: '443-555-1234'
+ });
+ ds.add({
+ firstName: 'Aditya',
+ lastName: 'Bansod',
+ phoneNumber: '555-555-1234'
+ });
+ ds.add({
+ firstName: 'Luca',
+ lastName: 'Candela',
+ phoneNumber: '555-555-1234'
+ });
+ ds.add({
+ firstName: 'Tommy',
+ lastName: 'Maintz',
+ isFavorite: true,
+ phoneNumber: '717-555-1234'
+ });
+ ds.add({
+ firstName: 'Nige',
+ lastName: '(Animal) White',
+ isFavorite: true,
+ phoneNumber: '555-555-1234'
+ });
+ }
+ Ext.create('Contact.view.Main', {fullscreen: true});
}
});
View
@@ -0,0 +1,139 @@
+/*
+ * File: app/controller/Contacts.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/license or 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.controller.Contacts', {
+ extend: 'Ext.app.Controller',
+ config: {
+ stores: [
+ 'ContactStore'
+ ],
+
+ refs: {
+ contactinfo: {
+ selector: 'contactinfo',
+ xtype: 'contactinfo',
+ autoCreate: true
+ },
+ contactform: {
+ selector: 'contactform',
+ xtype: 'contactform',
+ autoCreate: true
+ },
+ contactlist: {
+ selector: 'contactlist',
+ xtype: 'contactlist',
+ autoCreate: true
+ }
+ },
+
+ control: {
+ "button#addContactBtn": {
+ tap: 'onAddContactBtnTap'
+ },
+ "button#saveContactBtn": {
+ tap: 'onSaveContactBtnTap'
+ },
+ "button#editContactBtn": {
+ tap: 'onEditContactBtnTap'
+ },
+ "button#cancelBtn": {
+ tap: 'onCancelBtnTap'
+ },
+ "dataview": {
+ itemtap: 'onContactItemTap'
+ },
+ "button#infoBackBtn": {
+ tap: 'onInfoBackBtnTap'
+ },
+ "favoriteview": {
+ activate: 'onFavoriteViewActivate'
+ },
+ "list": {
+ activate: 'onListActivate'
+ }
+ }
+ },
+
+ onAddContactBtnTap: function(button, e, options) {
+ var referrer = Ext.Viewport.getActiveItem();
+ var form = this.getContactform();
+ form.setRecord(null);
+ form.reset();
+ form.referrer = referrer;
+ Ext.Viewport.setActiveItem(form);
+ },
+
+ onSaveContactBtnTap: function(button, e, options) {
+ var form = this.getContactform();
+ var errors = form.getValidationErrors();
+
+ if (errors.length) {
+ Ext.Msg.alert('Error', errors.join('<br/>'));
+ } else {
+ var values = form.getValues();
+ var record = form.getRecord();
+ if (record) {
+ record.setData(values);
+ record.commit();
+ if (form.referrer.setInfo) {
+ form.referrer.setInfo(record);
+ }
+ } else {
+ Ext.StoreManager.lookup('ContactStore').add(values);
+ }
+ Ext.Viewport.setActiveItem(form.referrer);
+ delete form.referrer;
+ }
+
+ },
+
+ onEditContactBtnTap: function(button, e, options) {
+ var referrer = Ext.Viewport.getActiveItem();
+ var form = this.getContactform();
+ var info = this.getContactinfo();
+ form.referrer = referrer;
+ Ext.Viewport.setActiveItem(form);
+ form.setRecord(info.getRecord());
+ },
+
+ onCancelBtnTap: function(button, e, options) {
+ var form = this.getContactform();
+ Ext.Viewport.setActiveItem(form.referrer);
+ delete form.referrer;
+
+ },
+
+ onContactItemTap: function(dataview, index, target, record, e, options) {
+ var info = this.getContactinfo();
+ info.setInfo(record);
+ Ext.Viewport.setActiveItem(info);
+
+ },
+
+ onInfoBackBtnTap: function(button, e, options) {
+ Ext.Viewport.setActiveItem(0);
+ },
+
+ onFavoriteViewActivate: function(container, newActiveItem, oldActiveItem, options) {
+ var ds = Ext.StoreManager.lookup('ContactStore');
+ ds.filter('isFavorite', true);
+ },
+
+ onListActivate: function(container, newActiveItem, oldActiveItem, options) {
+ var ds = Ext.StoreManager.lookup('ContactStore');
+ ds.clearFilter();
+ }
+
+});
Oops, something went wrong.

0 comments on commit 4ee2681

Please sign in to comment.