diff --git a/package.json b/package.json index 9e92728f52fc374d21f4e8a18f4553898367d55a..82c6818a320afb7c5c87b522769e8f232643ee0d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,10 @@ "cordova-plugin-whitelist", "cordova-plugin-splashscreen", "cordova-plugin-statusbar", - "ionic-plugin-keyboard" + "ionic-plugin-keyboard", + "cordova-plugin-barcodescanner" ], - "cordovaPlatforms": [] -} \ No newline at end of file + "cordovaPlatforms": [ + "android" + ] +} diff --git a/www/index.html b/www/index.html index e817c4356941e6b475f5614f4b3cacf9f61ee85a..9af5b469b06dc68a296bd1c98281370fa086f183 100644 --- a/www/index.html +++ b/www/index.html @@ -21,7 +21,7 @@ <script src="js/services.js"></script> <script src="js/directives.js"></script> - <!-- Only required for Tab projects w/ pages in multiple tabs + <!-- Only required for Tab projects w/ pages in multiple tabs <script src="lib/ionicuirouter/ionicUIRouter.js"></script> --> diff --git a/www/js/controllers.js b/www/js/controllers.js index 8d53c9c84c35b5411869092002104c56fb58b0f8..ae2aeabc42b988dac0a195ca3f12c8acb814f218 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -1,14 +1,32 @@ angular.module('app.controllers', []) - -.controller('ceitificatorCtrl', function($scope) { +.controller('ceitificatorCtrl', function($scope, events) { + $scope.events = events; }) - -.controller('novoEventoCtrl', function($scope) { +.controller('novoEventoCtrl', function($scope, events) { + $scope.formData = {}; + $scope.addNewEvent = function (){ + if ((!$scope.formData.newEvent || $scope.formData.newEvent.length === 0 || !$scope.formData.newEvent.trim()) || + (!$scope.formData.speaker || $scope.formData.speaker.length === 0 || !$scope.formData.speaker.trim())) + alert("WTF?"); + else + events.push({id: 3, name: $scope.formData.newEvent, speaker: $scope.formData.speaker}); + }; }) - -.controller('listaDePresenAEventoXCtrl', function($scope) { -}) - \ No newline at end of file +.controller('listaDePresenAEventoXCtrl', function($scope, people) { + $scope.people = people; + $scope.scan = function(){ + cordova.plugins.barcodeScanner.scan( + function (result) { + $scope.$apply(function(){ + people.push({id: '5', data: result.text}); + }); + }, + function (error) { + alert("Scanning failed: " + error); + } + ); + }; +}); diff --git a/www/js/routes.js b/www/js/routes.js index 5a18251dad28f2265fe28df711c580fb91e506c9..ded662c5537a032b50650071a4c3d22cb282649b 100644 --- a/www/js/routes.js +++ b/www/js/routes.js @@ -7,29 +7,44 @@ angular.module('app.routes', []) // Set up the various states which the app can be in. // Each state's controller can be found in controllers.js $stateProvider - - - .state('ceitificator', { + + + .state('ceitificator', { url: '/home', templateUrl: 'templates/ceitificator.html', - controller: 'ceitificatorCtrl' + controller: 'ceitificatorCtrl', + resolve: { + events: function(EventsService) { + return EventsService.getEvents(); + } + } }) .state('novoEvento', { url: '/novo-evento', templateUrl: 'templates/novoEvento.html', - controller: 'novoEventoCtrl' + controller: 'novoEventoCtrl', + resolve: { + events: function(EventsService) { + return EventsService.getEvents(); + } + } }) .state('listaDePresenAEventoX', { url: '/presenca', templateUrl: 'templates/listaDePresenAEventoX.html', - controller: 'listaDePresenAEventoXCtrl' + controller: 'listaDePresenAEventoXCtrl', + resolve: { + people: function(PeopleService) { + return PeopleService.getPeople(); + } + } }) -$urlRouterProvider.otherwise('/home') +$urlRouterProvider.otherwise('/home'); + - -}); \ No newline at end of file +}); diff --git a/www/js/services.js b/www/js/services.js index 8ce60391e5e0a2f8454585063b778801cbafc4b0..c38daf168062606ade23569b2eaa54a61bf92977 100644 --- a/www/js/services.js +++ b/www/js/services.js @@ -6,5 +6,48 @@ angular.module('app.services', []) .service('BlankService', [function(){ -}]); +}]) + +.service('EventsService', function($q) { + return { + events: [ + { + id: '1', + name: 'Pick up apples', + speaker: 'hue' + }, + { + id: '2', + name: 'Mow the lawn', + speaker: 'lol' + } + ], + getEvents: function() { + return this.events; + }, + addEvent: function(event){ + this.events.push(event); + } + }; +}) +.service('PeopleService', function($q) { + return { + people: [ + { + id: '1', + data: 'Lol' + }, + { + id: '2', + data: 'hue' + } + ], + getPeople: function() { + return this.people; + }, + addPerson: function(person){ + this.people.push(person); + } + } +}); diff --git a/www/templates/ceitificator.html b/www/templates/ceitificator.html index d9cbc41e87331e93bdfc6af67be696208b1d7bb1..22af4ca9b2472cfe9172f6f4edd043ca24259ae7 100644 --- a/www/templates/ceitificator.html +++ b/www/templates/ceitificator.html @@ -5,11 +5,9 @@ <div class="item item-body"> <a ui-sref="novoEvento" id="ceitificator-button2" class="button button-positive button-block icon-right ion-android-add-circle">Criar Novo</a> <ion-list> - <ion-item ui-sref="listaDePresenAEventoX">Item 1</ion-item> - <ion-item ui-sref="listaDePresenAEventoX">Item 2</ion-item> - <ion-item ui-sref="listaDePresenAEventoX">Item 3</ion-item> + <ion-item ui-sref="listaDePresenAEventoX" ng-repeat="event in events">{{event.name}} - {{event.speaker}}</ion-item> </ion-list> </div> </div> </ion-content> -</ion-view> \ No newline at end of file +</ion-view> diff --git a/www/templates/listaDePresenAEventoX.html b/www/templates/listaDePresenAEventoX.html index 8347eaa23c9ba0c06042cc88bddf5d0d348a3693..0722ce351ad421e2c86e2de167dc0aad7e3a13a7 100644 --- a/www/templates/listaDePresenAEventoX.html +++ b/www/templates/listaDePresenAEventoX.html @@ -2,13 +2,11 @@ <ion-content overflow-scroll="true" padding="true" class="has-header"> <div class="list card"> <div class="item item-body"> - <button id="listaDePresenAEventoX-button9" class="button button-positive button-block icon-right ion-qr-scanner">Adicionar</button> + <button id="listaDePresenAEventoX-button9" class="button button-positive button-block icon-right ion-qr-scanner" ng-click="scan()">Adicionar</button> <ion-list> - <ion-item>Item 1</ion-item> - <ion-item>Item 2</ion-item> - <ion-item>Item 3</ion-item> + <ion-item ng-repeat="person in people">{{person.data}}</ion-item> </ion-list> </div> </div> </ion-content> -</ion-view> \ No newline at end of file +</ion-view> diff --git a/www/templates/novoEvento.html b/www/templates/novoEvento.html index 9c8cbf81a69ae59a5cad8d4a4e25defecfa7a811..bf6903920d79580388b06b017566b2e36dd77144 100644 --- a/www/templates/novoEvento.html +++ b/www/templates/novoEvento.html @@ -5,20 +5,20 @@ <form class="list"> <label class="item item-input"> <span class="input-label">Palestra</span> - <input type="text" placeholder=""> + <input type="text" placeholder="" ng-model="formData.newEvent"/> </label> <label class="item item-input"> <span class="input-label">Palestrante</span> - <input type="text" placeholder=""> + <input type="text" placeholder="" ng-model="formData.speaker"/> </label> <div class="spacer" style="width: 255px; height: 32px;"></div> </form> <div class="button-bar"> - <a ui-sref="ceitificator" id="novoEvento-button6" class="button button-positive button-block button-outline icon-left ion-checkmark">Salvar</a> + <a ui-sref="ceitificator" id="novoEvento-button6" class="button button-positive button-block button-outline icon-left ion-checkmark" ng-click="addNewEvent()">Salvar</a> <a ui-sref="ceitificator" id="novoEvento-button8" class="button button-assertive button-block button-outline icon-left ion-android-cancel">Cancelar</a> </div> </div> </div> <form class="list"></form> </ion-content> -</ion-view> \ No newline at end of file +</ion-view>