Merge pull request #6107 from cmgustavo/ref/tab-receive-01

Ref/tab receive 01
This commit is contained in:
Gabriel Edgardo Bazán 2017-05-24 16:29:56 -03:00 committed by GitHub
commit b61944a510
11 changed files with 171 additions and 53 deletions

View File

@ -1,8 +1,9 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, bwcError, platformInfo, gettextCatalog, ongoingProcess) {
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, bwcError, platformInfo, gettextCatalog, ongoingProcess, pushNotificationsService) {
var listener;
var appName = appConfigService.userVisibleName;
var appUrl = appConfigService.url;
@ -10,13 +11,15 @@ angular.module('copayApp.controllers').controller('copayersController',
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.wallet = profileService.getWallet(data.stateParams.walletId);
updateWallet();
});
$scope.shareIcon = platformInfo.isIOS ? 'iOS' : 'Android';
listener = $rootScope.$on('bwsEvent', function(e, walletId, type, n) {
if ($scope.wallet && walletId == $scope.wallet.id && type == ('NewCopayer' || 'WalletComplete'))
updateWalletDebounced();
});
});
var listener = $rootScope.$on('bwsEvent', function() {
updateWallet();
});
$scope.$on('$destroy', function() {
$scope.$on("$ionicView.leave", function(event, data) {
listener();
});
@ -35,12 +38,19 @@ angular.module('copayApp.controllers').controller('copayersController',
if (status.wallet.status == 'complete') {
$scope.wallet.openWallet(function(err, status) {
if (err) $log.error(err);
$scope.goHome();
$scope.clearNextView();
$state.go('tabs.home').then(function() {
$state.transitionTo('tabs.wallet', {
walletId: $scope.wallet.credentials.walletId
});
});
});
}
});
};
var updateWalletDebounced = lodash.debounce(updateWallet, 5000, true);
$scope.showDeletePopup = function() {
var title = gettextCatalog.getString('Confirm');
var msg = gettextCatalog.getString('Are you sure you want to cancel and delete this wallet?');
@ -56,7 +66,9 @@ angular.module('copayApp.controllers').controller('copayersController',
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else {
$scope.goHome();
pushNotificationsService.unsubscribe($scope.wallet);
$scope.clearNextView();
$state.go('tabs.home');
}
});
};
@ -81,9 +93,13 @@ angular.module('copayApp.controllers').controller('copayersController',
}
};
$scope.goHome = function() {
$state.go('tabs.home');
$ionicHistory.clearHistory();
$scope.clearNextView = function() {
listener(); // remove listener
$ionicHistory.nextViewOptions({
disableAnimate: true,
historyRoot: true
});
$ionicHistory.clearHistory();
};
});

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('customAmountController', function($rootScope, $scope, $stateParams, $ionicHistory, txFormatService, platformInfo, configService, profileService, walletService, popupService) {
angular.module('copayApp.controllers').controller('customAmountController', function($scope, $ionicHistory, txFormatService, platformInfo, configService, profileService, walletService, popupService) {
var showErrorAndBack = function(title, msg) {
popupService.showAlert(title, msg, function() {
@ -15,6 +15,8 @@ angular.module('copayApp.controllers').controller('customAmountController', func
showErrorAndBack('Error', 'No wallet selected');
return;
}
$scope.showShareButton = platformInfo.isCordova ? (platformInfo.isIOS ? 'iOS' : 'Android') : null;
$scope.wallet = profileService.getWallet(walletId);
@ -57,6 +59,12 @@ angular.module('copayApp.controllers').controller('customAmountController', func
$ionicHistory.goBack(-2);
};
$scope.shareAddress = function() {
if (!platformInfo.isCordova) return;
var data = 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc;
window.plugins.socialsharing.share(data, null, null, null);
}
$scope.copyToClipboard = function() {
return 'bitcoin:' + $scope.address + '?amount=' + $scope.amountBtc;
};

View File

@ -98,6 +98,8 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
var selectedWallet = checkSelectedWallet($scope.wallet, $scope.wallets);
$scope.onWalletSelect(selectedWallet);
$scope.showShareButton = platformInfo.isCordova ? (platformInfo.isIOS ? 'iOS' : 'Android') : null;
listeners = [
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
// Update current address
@ -132,8 +134,8 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.showWallets = true;
};
$scope.copyToClipboard = function() {
if ($scope.isCordova) return 'bitcoin:' + $scope.addr;
else return $scope.addr;
$scope.shareAddress = function() {
if (!$scope.isCordova) return;
window.plugins.socialsharing.share('bitcoin:' + $scope.addr, null, null, null);
}
});

View File

@ -21,18 +21,18 @@ angular.module('copayApp.directives')
if (!data) return;
if (isCordova) {
window.plugins.socialsharing.share(data, null, null, null);
cordova.plugins.clipboard.copy(data);
} else if (isNW) {
nodeWebkitService.writeToClipboard(data);
scope.$apply(function() {
ionicToast.show(msg, 'bottom', false, 1000);
});
} else if (clipboard.supported) {
clipboard.copyText(data);
scope.$apply(function() {
ionicToast.show(msg, 'bottom', false, 1000);
});
} else {
// No supported
return;
}
scope.$apply(function() {
ionicToast.show(msg, 'bottom', false, 1000);
});
});
}
}

View File

@ -24,6 +24,7 @@ $v-text-accent-color: #647ce8 !default;
$v-success-color: #13e5b6 !default;
$v-warning-color: #ffa500 !default;
$v-error-color: #ef473a !default;
$v-wallet-color-map: (
0: (color: #dd4b39, name: 'Cinnabar'),

View File

@ -1,13 +1,37 @@
.copayers-secret {
text-align: center;
font-size: 12px;
margin: 10px;
white-space: -moz-pre-wrap !important;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
white-space: -webkit-pre-wrap;
word-break: break-all;
white-space: normal;
#copayers-invitation {
@extend .deflash-blue;
.button-share {
color: #fff;
box-shadow: none;
border-color: transparent;
background: transparent;
padding: 0 10px;
.icon:before {
font-size: 26px;
}
}
.button-cancel {
margin-top: 15px;
background: transparent;
border: none;
font-size: 12px;
color: $v-error-color;
i.icon {
vertical-align: middle;
padding-left: 5px;
}
}
.copayers-secret {
text-align: center;
font-size: 12px;
margin: 10px;
white-space: -moz-pre-wrap !important;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
white-space: -webkit-pre-wrap;
word-break: break-all;
white-space: normal;
}
}

View File

@ -3,6 +3,16 @@
$item-lateral-padding: 20px;
$item-vertical-padding: 10px;
$item-label-color: #6C6C6E;
.button-share {
color: #fff;
box-shadow: none;
border-color: transparent;
background: transparent;
padding: 0 10px;
.icon:before {
font-size: 26px;
}
}
.address {
background: #fff;
overflow: auto;
@ -39,6 +49,11 @@
padding-right: $item-lateral-padding;
}
.item-note {
width: 75%;
text-align: right;
}
.label {
font-size: 14px;
color: $item-label-color;

View File

@ -1,5 +1,33 @@
#tab-receive {
@extend .deflash-blue;
.button-share {
color: #fff;
box-shadow: none;
border-color: transparent;
background: transparent;
padding: 0 10px;
.icon:before {
font-size: 26px;
}
}
.button-request {
margin-top: 10px;
background: transparent;
border: none;
font-size: 12px;
color: $v-text-accent-color;
i.icon {
vertical-align: middle;
padding-left: 5px;
}
}
.button-address {
margin-top: 10px;
background: transparent;
border: none;
font-size: 12px;
color: $v-text-accent-color;
}
.address {
background: #fff;
overflow: auto;
@ -21,9 +49,6 @@
margin-top: 5%;
font-size: 13px;
}
.request-button {
padding-top: 20px;
}
}
.incomplete {
.title {

View File

@ -1,19 +1,23 @@
<ion-view>
<ion-view id="copayers-invitation">
<ion-nav-bar class="bar-royal">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-title>{{wallet.name}}</ion-nav-title>
<ion-nav-buttons side="secondary">
<button class="button button-clear" ng-click="showDeletePopup()">
Cancel
<button class="button-share ng-hide" ng-show="isCordova && secret" ng-click="shareSecret()">
<i class="icon"
ng-class="{
'ion-ios-upload-outline': shareIcon == 'iOS',
'ion-android-share-alt': shareIcon != 'iOS'
}"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content>
<div ng-show="!wallet.notAuthorized">
<div class="list card text-center">
<div class="list text-center">
<div class="item item-heading item-text-wrap" translate>
Share this invitation with your copayers
</div>
@ -29,11 +33,8 @@
{{secret || ('Loading...'|translate)}}
</div>
</div>
<button ng-if="isCordova && secret"
class="button button-primary button-outline button-small"
ng-click="shareSecret()">
<i class="icon ion-ios-upload-outline"></i>
<span translate>Share invitation</span>
<button ng-if="secret" class="button-cancel" ng-click="showDeletePopup()">
<span translate>Cancel invitation</span>
</button>
</div>
</div>

View File

@ -1,11 +1,20 @@
<ion-view id="custom-amount" hide-tabs>
<ion-nav-bar class="bar-royal">
<ion-nav-buttons side="primary">
<button class="button back-button button-clear" ng-click="close()" translate>
Close
</button>
</ion-nav-buttons>
<ion-nav-title>
{{'Custom Amount' | translate}}
</ion-nav-title>
<ion-nav-buttons side="secondary">
<button class="button no-border" ng-click="close()" translate>
Close
<button class="button-share ng-hide" ng-show="showShareButton" ng-click="shareAddress()">
<i class="icon"
ng-class="{
'ion-ios-upload-outline': showShareButton == 'iOS',
'ion-android-share-alt': showShareButton != 'iOS'
}"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar>
@ -15,7 +24,7 @@
<qrcode size="220" data="bitcoin:{{address + '?amount=' + amountBtc}}" color="#334"></qrcode>
</div>
<div class="info">
<div class="item single-line">
<div class="item single-line" copy-to-clipboard="address">
<span class="label" translate>Address</span>
<span class="item-note ellipsis">
{{address}}

View File

@ -1,6 +1,15 @@
<ion-view id="tab-receive">
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Receive' | translate}}</ion-nav-title>
<ion-nav-buttons side="secondary">
<button class="button-share ng-hide" ng-show="showShareButton" ng-click="shareAddress()">
<i class="icon"
ng-class="{
'ion-ios-upload-outline': showShareButton == 'iOS',
'ion-android-share-alt': showShareButton != 'iOS'
}"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content scroll="false">
<article class="list card padding text-center" ng-if="!wallets[0]">
@ -19,7 +28,7 @@
</div>
</div>
<div class="address-info" ng-if="wallet && wallet.isComplete()">
<div copy-to-clipboard="copyToClipboard()">
<div copy-to-clipboard="addr">
<span ng-show="shouldShowReceiveAddressFromHardware()">
<button class="button button-standard button-primary" ng-click="showReceiveAddressFromHardware()">
<span translate>Show address</span>
@ -31,8 +40,16 @@
<ion-spinner ng-show="!addr" class="spinner-dark" icon="crescent"></ion-spinner>
</div>
</div>
<div ng-show="addr" class="request-button">
<button class="button button-standard button-primary button-outline button-small" ng-click="requestSpecificAmount()" translate>Request Specific amount</button>
<div>
<button ng-show="addr" class="button-request" ng-click="requestSpecificAmount()">
<span translate>Request Specific amount</span>
<i class="icon ion-ios-arrow-right"></i>
</button>
</div>
<div>
<button ng-show="addr" class="button-address" ng-click="setAddress(true)">
<span translate>Generate new address</span>
</button>
</div>
</div>
</article>