Skip to content

Commit

Permalink
Added pulldown refresher and event listeners for deviceready, pause, …
Browse files Browse the repository at this point in the history
…and resume
  • Loading branch information
Morabito committed Mar 4, 2016
1 parent b090dfa commit 762e904
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 95 deletions.
50 changes: 0 additions & 50 deletions npm-debug.log

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"description": "testTabs: An Ionic project",
"dependencies": {
"gulp": "^3.5.6",
"gulp-sass": "^2.0.4",
"gulp-concat": "^2.2.0",
"gulp-minify-css": "^0.3.0",
"gulp-rename": "^1.2.0"
"gulp-rename": "^1.2.0",
"gulp-sass": "^2.0.4",
"material-refresh": "^0.1.0"
},
"devDependencies": {
"bower": "^1.7.7",
Expand Down
27 changes: 22 additions & 5 deletions www/app/shell/tab.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
.module('shell')
.controller('TabController', TabController);

TabController.$inject = ['$scope', '$window', 'bluetoothService'];
function TabController($scope, $window, bluetoothService) {
TabController.$inject = ['$scope', '$window', '$document', 'bluetoothService'];
function TabController($scope, $window, $document, bluetoothService) {
var vm = this;

vm.selectedIndex = 0;
Expand All @@ -27,9 +27,9 @@
$scope.$broadcast('syncSettings', {});
};

/*
* Check status of bluetooth once plug-in is detected
*/
/****************** Cordova Events ******************/

// Check status of bluetooth once plug-in is detected
var unbindWatcher = $scope.$watch(function() {
return $window.bluetoothSerial;
},
Expand All @@ -39,5 +39,22 @@
unbindWatcher();
}
});

// Check status of bluetooth when app resumed
$document[0].addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$document[0].addEventListener("pause", onPause, false);
$document[0].addEventListener("resume", onResume, false);
}

// Handle the pause event
function onPause() {

}

// Handle the resume event
function onResume() {
$scope.$broadcast('checkConnectionStatus', {});
}
};
})(angular);
2 changes: 1 addition & 1 deletion www/app/shell/tabs.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<md-tabs md-stretch-tabs="always" layout-fill class="md-primary" md-selected="tabCtrl.selectedIndex" md-no-pagination="true">
<md-tabs md-stretch-tabs="always" layout-fill class="md-primary" md-selected="tabCtrl.selectedIndex" md-swipe-content="true" md-no-pagination="true">
<md-tab layout="column" label="Workout" md-on-select="tabCtrl.checkConnection()">
<md-tab-content ui-view="tab-workout" flex layout-fill></md-tab-content>
</md-tab>
Expand Down
66 changes: 36 additions & 30 deletions www/app/workout/tab-workout.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
<md-content layout="column" ng-class="workoutCtrl.waiting || !workoutCtrl.ready ? 'layout-align-center-center' : 'layout-align-start-center'" layout-fill>
<!-- Bluetooth Disabled Template -->
<!-- Contains button to direct to bluetooth settings -->
<div
layout="column" layout-align="center center"
ng-if="!workoutCtrl.waiting && !workoutCtrl.ready"
ng-include="'app/workout/templates/bluetooth-disabled.tmpl.html'">
</div>
<ion-content layout="column" ng-class="workoutCtrl.waiting || !workoutCtrl.ready ? 'layout-align-center-center' : 'layout-align-start-center'" layout-fill>

<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="workoutCtrl.doRefresh()">
</ion-refresher>

<!-- Bluetooth Disabled Template -->
<!-- Contains button to direct to bluetooth settings -->
<div
layout="column" layout-align="center center"
ng-if="!workoutCtrl.waiting && !workoutCtrl.ready"
ng-include="'app/workout/templates/bluetooth-disabled.tmpl.html'">
</div>

<!-- Bluetooth Device Disconnected Template -->
<!-- Contains button to direct to bluetooth settings -->
<div
layout="column" layout-align="center center"
ng-if="workoutCtrl.waiting && !workoutCtrl.ready"
ng-include="'app/workout/templates/bluetooth-disconnected.tmpl.html'">
</div>
<!-- Bluetooth Device Disconnected Template -->
<!-- Contains button to direct to bluetooth settings -->
<div
layout="column" layout-align="center center"
ng-if="workoutCtrl.waiting && !workoutCtrl.ready"
ng-include="'app/workout/templates/bluetooth-disconnected.tmpl.html'">
</div>

<!-- Bluetooth Device Ready & Waiting Template -->
<!-- Displays Open Barbell Icon and Greeting -->
<div
layout="column" layout-align="center center"
ng-if="workoutCtrl.waiting && workoutCtrl.ready"
ng-include="'app/workout/templates/waiting.tmpl.html'">
</div>
<!-- Bluetooth Device Ready & Waiting Template -->
<!-- Displays Open Barbell Icon and Greeting -->
<div
layout="column" layout-align="center center"
ng-if="workoutCtrl.waiting && workoutCtrl.ready"
ng-include="'app/workout/templates/waiting.tmpl.html'">
</div>

<!-- Workout Cards, once data starts being collected -->
<md-card
class="workout-set-card"
ng-if="!workoutCtrl.waiting && workoutCtrl.ready"
ng-repeat="set in workoutCtrl.getSets() | orderBy:$index:true"
ng-include="'app/workout/templates/workout-card.tmpl.html'">
</md-card>
</md-content>
<!-- Workout Cards, once data starts being collected -->
<md-card
class="workout-set-card"
ng-if="!workoutCtrl.waiting && workoutCtrl.ready"
ng-repeat="set in workoutCtrl.getSets() | orderBy:$index:true"
ng-include="'app/workout/templates/workout-card.tmpl.html'">
</md-card>
</ion-content>
20 changes: 13 additions & 7 deletions www/app/workout/workout.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

vm.enterSetInfo = enterSetInformation;

vm.doRefresh = function() {
console.log("Refreshing...");
// Stop the ion-refresher from spinning
$scope.$broadcast('scroll.refreshComplete');
};

/*
* Internal Methods
*/
Expand Down Expand Up @@ -61,13 +67,13 @@
function checkDeviceConnected() {
// vm.ready = false;

bluetoothService.isConnected()
.then(function(response) {
vm.ready = true;
},
function(reason) {
console.log(reason);
});
// bluetoothService.isConnected()
// .then(function(response) {
// vm.ready = true;
// },
// function(reason) {
// console.log(reason);
// });
}

function getUnits() {
Expand Down
12 changes: 12 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<!-- Angular Material -->
<link rel="stylesheet" href='lib/ionic/js/angular-material-1.0.0/angular-material.min.css' />

<!-- Material Refresh -->
<!-- <link rel='stylesheet' href='lib/ionic/js/material-refresh/material-refresh.min.css'/> -->

<link href="css/style.css" rel="stylesheet">
<link href="css/workout.css" rel="stylesheet">

Expand All @@ -30,6 +33,15 @@

<!-- Angular Material -->
<script src='lib/ionic/js/angular-material-1.0.0/angular-material.min.js' type="text/javascript"></script>

<!-- jQuery -->
<!-- <script src='lib/ionic/js/jQuery/jquery-1.12.1.min.js'></script> -->

<!-- Zepto -->
<!-- <script src='lib/ionic/js/Zepto/zepto.min.js'></script> -->

<!-- Material Refresh -->
<!-- <script src='lib/ionic/js/material-refresh/material-refresh.min.js'></script> -->

<!-- PouchDB -->
<script src='lib/ionic/js/pouchDB/pouchdb-5.2.1.min.js' type="text/javascript"></script>
Expand Down

0 comments on commit 762e904

Please sign in to comment.