Scanner button at topbar only for mobile

This commit is contained in:
Gustavo Maximiliano Cortez 2015-01-15 12:57:18 -03:00 committed by bechi
parent 05e4c2abb8
commit d0f8583122
8 changed files with 76 additions and 70 deletions

View File

@ -84,13 +84,15 @@
<a class="left-off-canvas-toggle menu-icon" ><span></span></a>
</section>
<section class="right-small" ng-show="$root.iden && $root.wallet.isComplete() && !$root.hideWalletNavigation">
<a class="p10" ng-click="$root.go('more')"><i class="fi-widget size-24"></i></a>
<section class="right-small"
ng-show="$root.iden && $root.wallet.isComplete() && !$root.hideWalletNavigation && isCordova">
<a class="p10"
ng-click="openScanner()"><i class="fi-camera size-24"></i></a>
</section>
<section class="middle tab-bar-section">
<h1 class="title ellipsis" ng-show="$root.iden && $root.wallet && !$root.hideWalletNavigation">
{{$root.wallet.getName()}}
{{$root.wallet.getName()}}
</h1>
</section>
</nav>

View File

@ -72,7 +72,7 @@ angular.module('copayApp.controllers').controller('CreateController',
});
};
$scope.$on("$destroy", function () {
$rootScope.hideWalletNavigation = false;
$scope.$on("$destroy", function () {
$rootScope.hideWalletNavigation = false;
});
});

View File

@ -100,8 +100,8 @@ angular.module('copayApp.controllers').controller('ImportController',
};
$scope.$on("$destroy", function () {
$rootScope.hideWalletNavigation = false;
$scope.$on("$destroy", function () {
$rootScope.hideWalletNavigation = false;
});
});

View File

@ -154,7 +154,7 @@ angular.module('copayApp.controllers').controller('JoinController',
}
$scope.$on("$destroy", function () {
$rootScope.hideWalletNavigation = false;
$scope.$on("$destroy", function () {
$rootScope.hideWalletNavigation = false;
});
});

View File

@ -50,6 +50,17 @@ angular.module('copayApp.controllers').controller('SendController',
});
};
if (isCordova) {
var openScannerCordova = $rootScope.$on('dataScanned', function(event, data) {
$scope.sendForm.address.$setViewValue(data);
$scope.sendForm.address.$render();
});
$scope.$on('$destroy', function() {
openScannerCordova();
});
}
$scope.formFocus = function(what) {
if (!$scope.isWindowsPhoneApp) return
@ -183,17 +194,17 @@ angular.module('copayApp.controllers').controller('SendController',
var comment = form.comment.$modelValue;
var merchantData = $scope._merchantData;
var address, amount;
if (!merchantData) {
if (!merchantData) {
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
}
w.spend({
w.spend({
merchantData: merchantData,
toAddress: address,
amountSat: amount,
comment: comment,
}, function (err, txid, status) {
comment: comment,
}, function (err, txid, status) {
$scope.loading = false;
$scope.creatingTX = false;
if ($scope.isWindowsPhoneApp)
@ -202,8 +213,8 @@ angular.module('copayApp.controllers').controller('SendController',
if (err)
return $scope.setError(err);
txStatus.notify(status);
$scope.resetForm();
});
$scope.resetForm();
});
}, 1);
};
@ -299,7 +310,6 @@ angular.module('copayApp.controllers').controller('SendController',
};
$scope.openScanner = function() {
if (window.cordova) return $scope.scannerIntent();
$scope.showScanner = true;
// Wait a moment until the canvas shows
@ -324,31 +334,6 @@ angular.module('copayApp.controllers').controller('SendController',
}, 500);
};
$scope.scannerIntent = function() {
window.ignoreMobilePause = true;
cordova.plugins.barcodeScanner.scan(
function onSuccess(result) {
$timeout(function() {
window.ignoreMobilePause = false;
}, 100);
if (result.cancelled) return;
$timeout(function() {
var data = result.text;
$scope.$apply(function() {
$scope.sendForm.address.$setViewValue(result.text);
$scope.sendForm.address.$render();
});
}, 1000);
},
function onError(error) {
$timeout(function() {
window.ignoreMobilePause = false;
}, 100);
alert('Scanning error');
});
}
$scope.setTopAmount = function() {
var w = $rootScope.wallet;
var form = $scope.sendForm;

View File

@ -1,8 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService, isMobile, go) {
angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService, isMobile, isCordova, go) {
$scope.isMobile = isMobile.any()
$scope.isMobile = isMobile.any();
$scope.isCordova = isCordova;
$scope.menu = [{
'title': 'Home',
@ -46,6 +47,32 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
$scope.setWallets();
};
$scope.openScanner = function() {
window.ignoreMobilePause = true;
cordova.plugins.barcodeScanner.scan(
function onSuccess(result) {
$timeout(function() {
window.ignoreMobilePause = false;
}, 100);
if (result.cancelled) return;
$timeout(function() {
var data = result.text;
$scope.$apply(function() {
$rootScope.$emit('dataScanned', data);
});
}, 1000);
},
function onError(error) {
$timeout(function() {
window.ignoreMobilePause = false;
}, 100);
alert('Scanning error');
}
);
go.send();
};
$scope.init = function() {
// This should be called only once.

View File

@ -12,7 +12,10 @@
<div class="large-8 medium-6 small-12 columns">
<div class="ellipsis oh">
<div class="avatar-wallet left">{{$root.wallet.getName() | limitTo: 1}}</div>
<h2 class="m10t left">{{$root.wallet.getName()}}</h2>
<h2 class="m10t left">
{{$root.wallet.getName()}}
<a ng-click="$root.go('more')"><i class="fi-widget size-24"></i></a>
</h2>
</div>
</div>
<div class="large-4 medium-6 small-12 columns">

View File

@ -1,19 +1,8 @@
<div class="send" ng-controller="SendController" ng-init="init()">
<div class="row">
<h1 class="large-8 large-centered columns show-for-large-up">{{$root.title}}</h1>
</div>
<div class="row hide-for-medium-up" ng-hide="$root.wpInputFocused" >
<div class="large-10 medium-10 small-9 columns">
<div class="row show-for-large-up">
<div class="large-8 large-centered columns">
<h1>{{$root.title}}</h1>
</div>
<div class="large-2 medium-2 small-3 columns" ng-show="!lockAddress && !_merchantData">
<div ng-hide="showScanner || disableScanner">
<a class="button right m10b radius tiny black" ng-click="openScanner()"><i class="fi-camera size-18"></i></a>
</div>
<div ng-show="showScanner">
<a translate class="button right radius tiny m10b warning" ng-click="cancelScanner()"><i class="fi-x size-18"></i></a>
</div>
</div>
</div>
<div class="row" ng-show="fetchingURL">
@ -31,24 +20,24 @@
</div>
</div>
<div class="row" ng-show="creatingTX">
<div class="large-12 columns">
<div class="panel">
<div class="box-notification">
<div class="box-icon secondary">
<i class="fi-bitcoin-circle icon-rotate spinner size-24"></i>
</div>
<span class="text-secondary size-14">
Creating Transaction...
</span>
</div>
</div>
<div class="row" ng-show="creatingTX">
<div class="large-12 columns">
<div class="panel">
<div class="box-notification">
<div class="box-icon secondary">
<i class="fi-bitcoin-circle icon-rotate spinner size-24"></i>
</div>
<span class="text-secondary size-14">
Creating Transaction...
</span>
</div>
</div>
</div>
</div>
<div class="row" ng-show="!fetchingURL && !creatingTX">
<div class="large-8 large-centered columns">
<div class="large-8 large-centered columns">
<form name="sendForm" ng-submit="submitForm(sendForm)" novalidate>
<div class="panel">
<div class="box-notification" ng-show="error && !hideForWP ">