mirror of https://github.com/BTCPrivate/copay.git
Scanner button at topbar only for mobile
This commit is contained in:
parent
05e4c2abb8
commit
d0f8583122
|
@ -84,8 +84,10 @@
|
|||
<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">
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue