Adds scan tab. Fix grunt ios

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-17 15:23:17 -03:00
commit 70ba150e60
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
14 changed files with 141 additions and 132 deletions

View file

@ -2,8 +2,7 @@
angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $rootScope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, go, storageService, gettext, platformInfo, ongoingProcess) {
var self = this;
self.tries = 0;
var tries = 0;
var isCordova = platformInfo.isCordova;
ongoingProcess.set('creatingWallet', true);
@ -20,13 +19,13 @@ angular.module('copayApp.controllers').controller('disclaimerController',
return $timeout(function() {
$log.warn('Retrying to create profile......');
if (self.tries == 3) {
self.tries == 0;
if (tries == 3) {
tries == 0;
return create({
noWallet: true
});
} else {
self.tries += 1;
tries += 1;
return create();
}
}, 3000);
@ -36,9 +35,9 @@ angular.module('copayApp.controllers').controller('disclaimerController',
});
};
this.init = function(opts) {
$scope.init = function(opts) {
$ionicSideMenuDelegate.canDragContent(false);
self.lang = uxLanguage.currentLanguage;
$scope.lang = uxLanguage.currentLanguage;
storageService.getProfile(function(err, profile) {
if (!profile) {
@ -57,7 +56,7 @@ angular.module('copayApp.controllers').controller('disclaimerController',
});
};
this.accept = function() {
$scope.accept = function() {
profileService.setDisclaimerAccepted(function(err) {
if (err) $log.error(err);
else {

View file

@ -19,7 +19,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
self.setWallets();
});
self.setWallets = function() {
self.setWallets = function() {
$scope.wallets = profileService.getWallets();
};
@ -36,5 +36,5 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.bitpayCardEnabled = true; // TODO
$state.transitionTo('confirm', {toAmount:555500, toAddress: 'mvfAwUJohJWibGzBZgAUGsDarsr4Z4NovU', toName: 'bla bla'});
// $state.transitionTo('confirm', {toAmount:555500, toAddress: 'mvfAwUJohJWibGzBZgAUGsDarsr4Z4NovU', toName: 'bla bla'});
});

View file

@ -1,6 +1,63 @@
'use strict';
angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout) {
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, gettextCatalog, platformInfo) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
var onSuccess = function(result) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
if (isWP && result.cancelled) return;
$timeout(function() {
var data = isIOS ? result : result.text;
$scope.onScan({
data: data
});
}, 1000);
};
var onError = function(error) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
};
$scope.cordovaOpenScanner = function() {
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true);
$timeout(function() {
if (isIOS) {
cloudSky.zBar.scan({}, onSuccess, onError);
} else {
cordova.plugins.barcodeScanner.scan(onSuccess, onError);
}
if ($scope.beforeScan) {
$scope.beforeScan();
}
}, 100);
};
$scope.modalOpenScanner = function() {
$ionicModal.fromTemplateUrl('views/modals/scanner.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.scannerModal = modal;
$scope.scannerModal.show();
});
};
$scope.openScanner = function() {
if (isCordova) {
$scope.cordovaOpenScanner();
} else {
$scope.modalOpenScanner();
}
};
// QR code Scanner
var video;
@ -73,6 +130,10 @@ angular.module('copayApp.controllers').controller('scannerController', function(
};
$scope.init = function() {
if (isCordova) {
$scope.cordovaOpenScanner();
return;
}
setScanner();
$timeout(function() {
if ($scope.beforeScan) {
@ -99,4 +160,8 @@ angular.module('copayApp.controllers').controller('scannerController', function(
$scope.scannerModal.remove();
};
$scope.$on("$destroy", function(){
_scanStop();
});
});

View file

@ -1,66 +1,7 @@
'use strict';
angular.module('copayApp.directives')
.directive('qrScanner', function($rootScope, $timeout, $ionicModal, gettextCatalog, platformInfo) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
var controller = function($scope) {
var onSuccess = function(result) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
if (isWP && result.cancelled) return;
$timeout(function() {
var data = isIOS ? result : result.text;
$scope.onScan({
data: data
});
}, 1000);
};
var onError = function(error) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
};
$scope.cordovaOpenScanner = function() {
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true);
$timeout(function() {
if (isIOS) {
cloudSky.zBar.scan({}, onSuccess, onError);
} else {
cordova.plugins.barcodeScanner.scan(onSuccess, onError);
}
if ($scope.beforeScan) {
$scope.beforeScan();
}
}, 100);
};
$scope.modalOpenScanner = function() {
$ionicModal.fromTemplateUrl('views/modals/scanner.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.scannerModal = modal;
$scope.scannerModal.show();
});
};
$scope.openScanner = function() {
if (isCordova) {
$scope.cordovaOpenScanner();
} else {
$scope.modalOpenScanner();
}
};
};
.directive('qrScanner', function() {
return {
restrict: 'E',
@ -68,7 +9,7 @@ angular.module('copayApp.directives')
onScan: "&",
beforeScan: "&"
},
controller: controller,
controller: 'tabScanController',
replace: true,
template: '<a ng-click="openScanner()"><i class="icon ion-qr-scanner"></i></a>'
}

View file

@ -161,6 +161,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
},
}
})
.state('tabs.scan', {
url: '/scan',
needProfile: true,
views: {
'tab-scan': {
templateUrl: 'views/tab-scan.html',
},
}
})
.state('tabs.send', {
url: '/send',
cache: false,
@ -200,7 +209,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
},
},
})
.state('unsupported', {
url: '/unsupported',
needProfile: false,
@ -652,9 +661,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}, 300);
});
if (window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
cordova.plugins.Keyboard.disableScroll(false);
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleLightContent();
}
$ionicPlatform.registerBackButtonAction(function(event) {

View file

@ -35,16 +35,12 @@ angular.module('copayApp.services').factory('go', function($window, $ionicSideMe
$log.debug("Wallet not complete at startup... redirecting")
root.path('copayers');
} else {
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'walletHome', true);
});
root.path('tabs.home');
}
};
root.send = function() {
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'send');
});
root.path('tabs.send');
};
root.addWallet = function() {