Merge pull request #133 from cmgustavo/ref/design-36

Ref/design 36
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-19 09:30:24 -03:00 committed by GitHub
commit 041052d440
18 changed files with 177 additions and 173 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService) {
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService, $ionicHistory) {
var address = $stateParams.address;
@ -26,10 +26,13 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
});
$scope.sendTo = function() {
$ionicHistory.clearHistory();
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('send.amount', {
$state.transitionTo('tabs.send.amount', {
toAddress: $scope.addressbookEntry.address,
toName: $scope.addressbookEntry.name
toName: $scope.addressbookEntry.name,
toEmail: $scope.addressbookEntry.email
});
}, 100);
};

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Enter Amount'));
var unitToSatoshi;
@ -188,7 +188,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
var _amount = evaluate(format($scope.amount));
var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals);
$state.transitionTo('send.confirm', {
$state.transitionTo('tabs.send.confirm', {
toAmount: amount * unitToSatoshi,
toAddress: $scope.toAddress,
toName: $scope.toName,

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) {
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, $ionicHistory, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Confirm'));
var cachedTxp = {};
var isChromeApp = platformInfo.isChromeApp;
@ -17,24 +17,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.showDescriptionPopup = function() {
$scope.data = {
comment: null
var title = gettextCatalog.getString('Add description');
var opts = {
defaultText: $scope.description
};
var commentPopup = $ionicPopup.show({
templateUrl: "views/includes/note.html",
title: gettextCatalog.getString('Set description'),
scope: $scope,
popupService.showPrompt(title, null, opts, function(res) {
if (res) $scope.description = res;
});
$scope.commentPopupClose = function() {
commentPopup.close();
};
$scope.commentPopupSave = function() {
$log.debug('Saving description: ' + $scope.data.comment);
$scope.description = $scope.data.comment;
commentPopup.close();
};
};
var setFromPayPro = function(uri, cb) {
@ -87,6 +77,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
$scope.init = function() {
if ($stateParams.paypro) {
return setFromPayPro($stateParams.paypro, function(err) {
if (err && !isChromeApp) {
showAlert(gettext('Could not fetch payment'));
}
});
}
// TODO (URL , etc)
if (!$stateParams.toAddress || !$stateParams.toAmount) {
$log.error('Bad params at amount')
@ -271,7 +268,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (err) return;
walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err);
$state.transitionTo('tabs.home');
$ionicHistory.clearHistory();
$state.go('tabs.home');
});
});
};

View file

@ -75,7 +75,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
return;
}
$log.debug('Got toAddress:' + addr + ' | ' + item.name);
return $state.transitionTo('send.amount', {
return $state.transitionTo('tabs.send.amount', {
toAddress: addr,
toName: item.name,
toEmail: item.email

View file

@ -218,29 +218,24 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
/*
*
* Send
*
*/
/*
*
* Send
*
*/
.state('send', {
url: '/send',
abstract: true,
template: '<ion-nav-view name="send"></ion-nav-view>'
})
.state('send.amount', {
.state('tabs.send.amount', {
url: '/amount/:toAddress/:toName/:toEmail',
views: {
'send': {
'tab-send@tabs': {
templateUrl: 'views/amount.html'
}
}
})
.state('send.confirm', {
.state('tabs.send.confirm', {
url: '/confirm/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro',
views: {
'send': {
'tab-send@tabs': {
templateUrl: 'views/confirm.html'
}
}
@ -256,39 +251,39 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.add', {
url: '/add',
views: {
'tab-home': {
'tab-home@tabs': {
templateUrl: 'views/add.html'
}
}
})
.state('tabs.join', {
.state('tabs.add.join', {
url: '/join/:url',
views: {
'tab-home': {
'tab-home@tabs': {
templateUrl: 'views/join.html'
},
}
})
.state('tabs.import', {
.state('tabs.add.import', {
url: '/import',
views: {
'tab-home': {
'tab-home@tabs': {
templateUrl: 'views/import.html'
},
},
})
.state('tabs.create-personal', {
.state('tabs.add.create-personal', {
url: '/create-personal',
views: {
'tab-home': {
'tab-home@tabs': {
templateUrl: 'views/tab-create-personal.html'
},
}
})
.state('tabs.create-shared', {
.state('tabs.add.create-shared', {
url: '/create-shared',
views: {
'tab-home': {
'tab-home@tabs': {
templateUrl: 'views/tab-create-shared.html'
},
}
@ -303,7 +298,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.language', {
url: '/language',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/preferencesLanguage.html'
}
}
@ -311,7 +306,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.unit', {
url: '/unit',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/preferencesUnit.html'
}
}
@ -319,7 +314,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.fee', {
url: '/fee',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/preferencesFee.html'
}
}
@ -327,7 +322,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.altCurrency', {
url: '/altCurrency',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/preferencesAltCurrency.html'
}
}
@ -335,31 +330,31 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.about', {
url: '/about',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/preferencesAbout.html'
}
}
})
.state('tabs.logs', {
.state('tabs.about.logs', {
url: '/logs',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/preferencesLogs.html'
}
}
})
.state('tabs.termsOfUse', {
.state('tabs.about.termsOfUse', {
url: '/termsOfUse',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/termsOfUse.html',
}
}
})
.state('tabs.translators', {
.state('tabs.about.translators', {
url: '/translators',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/translators.html'
}
}
@ -375,7 +370,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/preferences/:walletId',
abstract: true,
views: {
'tab-settings': {
'tab-settings@tabs': {
template: '<ion-nav-view name="preferences"></ion-nav-view>'
},
}
@ -495,7 +490,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('tabs.addressbook', {
url: '/addressbook',
views: {
'tab-settings': {
'tab-settings@tabs': {
templateUrl: 'views/addressbook.html',
controller: 'addressbookListController'
}

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, bitcore) {
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, $timeout, bitcore) {
var root = {};
@ -26,7 +26,11 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
// data extensions for Payment Protocol with non-backwards-compatible request
if ((/^bitcoin:\?r=[\w+]/).exec(data)) {
data = decodeURIComponent(data.replace('bitcoin:?r=', ''));
$state.go('send.confirm', {paypro: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.confirm', {paypro: data});
}, 100);
return true;
}
@ -41,44 +45,65 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
var amount = parsed.amount ? parsed.amount : '';
if (parsed.r) {
$state.go('send.confirm', {paypro: parsed.r});
} else {
if (amount) {
$state.go('send.confirm', {toAmount: amount, toAddress: addr, description:message})
$state.go('tabs.send');
$timeout(function() {
if (parsed.r) {
$state.transitionTo('tabs.send.confirm', {paypro: parsed.r});
} else {
$state.go('send.amount', {toAddress: addr})
if (amount) {
$state.transitionTo('tabs.send.confirm', {toAmount: amount, toAddress: addr, description:message});
} else {
$state.transitionTo('tabs.send.amount', {toAddress: addr});
}
}
}
}, 100);
return true;
// Plain URL
} else if (/^https?:\/\//.test(data)) {
return $state.go('send.confirm', {paypro: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.confirm', {paypro: data});
}, 100);
return true;
// Plain Address
} else if (bitcore.Address.isValid(data, 'livenet')) {
return $state.go('send.amount', {toAddress: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.amount', {toAddress: data});
}, 100);
return true;
} else if (bitcore.Address.isValid(data, 'testnet')) {
return $state.go('send.amount', {toAddress: data})
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.amount', {toAddress: data});
}, 100);
return true;
// Protocol
} else if (data.indexOf($window.appConfig.name + '://glidera')==0) {
return $state.go('uriglidera', {url: data})
return $state.go('uriglidera', {url: data});
} else if (data.indexOf($window.appConfig.name + '://coinbase')==0) {
return $state.go('uricoinbase', {url: data})
return $state.go('uricoinbase', {url: data});
// Join
} else if (data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
return $state.go('add.join', {url: data})
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.add.join', {url: data});
}, 100);
return true;
// Old join
} else if (data.match(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
return $state.go('add.join', {url: data})
$state.go('tabs.home');
$timeout(function() {
$state.transitionTo('tabs.add.join', {url: data});
}, 100);
return true;
}
return false;
};

View file

@ -32,9 +32,10 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
opts = opts || {};
$ionicPopup.prompt({
title: title,
template: message,
inputType: opts.inputType || 'password',
inputPlaceholder: opts.inputPlaceholder || 'Your password'
subTitle: message,
inputType: opts.inputType,
inputPlaceholder: opts.inputPlaceholder,
defaultText: opts.defaultText
}).then(function(res) {
return cb(res)
});
@ -106,7 +107,7 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
*
* @param {String} Title
* @param {String} Message
* @param {Object} Object{ inputType, inputPlaceholder } (optional)
* @param {Object} Object{ inputType, inputPlaceholder, defaultText } (optional)
* @param {Callback} Function
* @returns {Callback} Return the value of the input if user presses OK
*/