diff --git a/Gruntfile.js b/Gruntfile.js index 342cc85e7..eb4bb2eb0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -163,7 +163,7 @@ module.exports = function(grunt) { }, bitanalytics: { src: [ - 'bitanalytics/bitanalytics-0.1.0.js' + 'bitanalytics/bitanalytics.js' ], dest: 'www/lib/bitanalytics.js' }, diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 1c7f5a30a..2f8e3db04 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -72,7 +72,7 @@ - + diff --git a/bitanalytics/bitanalytics-0.1.0.js b/bitanalytics/bitanalytics.js similarity index 97% rename from bitanalytics/bitanalytics-0.1.0.js rename to bitanalytics/bitanalytics.js index db149e481..c8c0d8870 100644 --- a/bitanalytics/bitanalytics-0.1.0.js +++ b/bitanalytics/bitanalytics.js @@ -6276,7 +6276,7 @@ var ClickAction = /** @class */ (function (_super) { }(action_1.default)); exports.default = ClickAction; -},{"../action":4,"../log-event":15,"../log-event-handlers":14}],6:[function(require,module,exports){ +},{"../action":4,"../log-event":16,"../log-event-handlers":15}],6:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -6315,7 +6315,7 @@ var BitAnalytics = /** @class */ (function () { exports.default = BitAnalytics; BitAnalytics.main(); -},{"./action-factory":2,"./action-handlers":3,"./channels/adjust-channel":9,"./channels/mixpanel-channel":12,"./log-event":15,"./log-event-handlers":14}],7:[function(require,module,exports){ +},{"./action-factory":2,"./action-handlers":3,"./channels/adjust-channel":9,"./channels/mixpanel-channel":12,"./log-event":16,"./log-event-handlers":15}],7:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -6560,11 +6560,10 @@ var FirebaseChannel = /** @class */ (function (_super) { var keys = Object.keys(params); var keysLength = keys.length; var sanitized = {}; - for (var i = 0; i < keysLength; i++) { - var key = keys[i]; + keys.map(function (key) { var cleanKey = key.replace('-', '_').replace(/[\W]+/g, ''); sanitized[cleanKey] = params[key]; - } + }); return sanitized; }; return FirebaseChannel; @@ -6588,13 +6587,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); var channel_1 = __importDefault(require("../channel")); +var ga_1 = __importDefault(require("../external-libs/ga")); var GoogleAnalyticsChannel = /** @class */ (function (_super) { __extends(GoogleAnalyticsChannel, _super); function GoogleAnalyticsChannel(name, config) { var _this = _super.call(this, name) || this; - _this.dataLayer = null; _this.gaInstance = null; - _this.trackingId = ''; _this.eventLabels = ['id']; if (!config.trackingId) { throw new Error('[BitAnalytics] Google Analytics config is missing tracking ID.'); @@ -6602,8 +6600,12 @@ var GoogleAnalyticsChannel = /** @class */ (function (_super) { if (config.eventLabels) { _this.eventLabels = config.eventLabels; } - _this.trackingId = config.trackingId; - _this.setUpGa(); + _this.gaInstance = new ga_1.default({ + trackID: config.trackingId, + appVersion: config.appVersion, + appName: config.appName || 'App' + }); + _this.isReady = true; return _this; } /** @@ -6612,49 +6614,26 @@ var GoogleAnalyticsChannel = /** @class */ (function (_super) { * */ GoogleAnalyticsChannel.prototype.postEvent = function (name, params) { - // Default Google Analytics Events - // https://developers.google.com/analytics/devguides/collection/gtagjs/events - // Useful to convert to these, or start with these? if (this.isReady) { - params.event_category = name; + var category = name; + var action = name; + var label = name; + var value = params['value'] || ''; for (var _i = 0, _a = this.eventLabels; _i < _a.length; _i++) { var eventLabel = _a[_i]; if (params[eventLabel]) { - params.event_label = params[eventLabel]; + label = params[eventLabel]; break; } } - this.gtag('event', name, params); + this.gaInstance.event(category, action, label, value); } }; - /** - * - * Private methods - * - */ - /** - * Mimics function in the tracking snippet - */ - GoogleAnalyticsChannel.prototype.gtag = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - console.log(arguments); - window.dataLayer.push(arguments); - }; - GoogleAnalyticsChannel.prototype.setUpGa = function () { - // From what GA recommends to insert into page - window.dataLayer = window.dataLayer || []; - this.gtag('js', new Date()); - this.gtag('config', this.trackingId); - this.isReady = true; - }; return GoogleAnalyticsChannel; }(channel_1.default)); exports.default = GoogleAnalyticsChannel; -},{"../channel":8}],12:[function(require,module,exports){ +},{"../channel":8,"../external-libs/ga":14}],12:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || @@ -6746,6 +6725,207 @@ exports.default = MixpanelChannel; },{}],14:[function(require,module,exports){ "use strict"; +/* + * name: nwjs-analytics -Node-Webkit Google Analytics integration + * version: 1.0.2 + * github: https://github.com/Daaru00/nwjs-analytics + */ +function GA(opt) { + this.apiVersion = opt.apiVersion || '1'; + this.trackID = opt.trackID || 'UA-XXXXXXXX-X'; + this.clientID = opt.clientID || null; + this.userID = opt.userID || null; + this.appName = opt.appName || 'App'; + this.appVersion = opt.appVersion || '1.0.0'; + this.debug = opt.debug || false; + this.performanceTracking = opt.performanceTracking || true; + this.errorTracking = opt.errorTracking || true; + this.userLanguage = opt.userLanguage || "en"; + this.currency = opt.currency || "EUR"; + this.lastScreenName = opt.lastScreenName || ''; +} +GA.prototype.sendRequest = function (data, callback) { + var ga = this; + if (!this.clientID || this.clientID == null) + this.clientID = this.generateClientID(); + if (!this.userID || this.userID == null) + this.userID = this.generateClientID(); + var postData = "v=" + this.apiVersion + + "&an=" + this.appName + + "&av=" + this.appVersion + + "&tid=" + this.trackID + + "&cid=" + this.clientID + + "&sr=" + this.getScreenResolution() + + "&vp=" + this.getViewportSize(); + Object.keys(data).forEach(function (key) { + var val = data[key]; + if (typeof val != "undefined") + postData += "&" + key + "=" + val; + }); + var http = new XMLHttpRequest(); + var url = "https://www.google-analytics.com"; + if (!this.debug) + url += "/collect"; + else + url += "/debug/collect"; + http.open("GET", url + "?" + postData, true); + http.onreadystatechange = function () { + if (ga.debug) + console.log(http.response); + if (http.readyState == 4 && http.status == 200) { + if (callback) + callback(true); + } + else { + if (callback) + callback(false); + } + }; + http.send(); +}; +GA.prototype.generateClientID = function () { + var id = ""; + var possibilities = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + for (var i = 0; i < 5; i++) + id += possibilities.charAt(Math.floor(Math.random() * possibilities.length)); + return id; +}; +GA.prototype.getScreenResolution = function () { + return screen.width + "x" + screen.height; +}; +GA.prototype.getColorDept = function () { + return screen.colorDepth + "-bits"; +}; +GA.prototype.getUserAgent = function () { + return navigator.userAgent; +}; +GA.prototype.getViewportSize = function () { + return window.screen.availWidth + "x" + window.screen.availHeight; +}; +/* + * Measurement Protocol + * [https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide] + */ +GA.prototype.screenView = function (screename) { + var data = { + 't': 'screenview', + 'cd': screename + }; + this.sendRequest(data); + this.lastScreenName = screename; +}; +GA.prototype.event = function (category, action, label, value) { + var data = { + 't': 'event', + 'ec': category, + 'ea': action, + }; + if (label) { + data['el'] = label; + } + if (value) { + data['ev'] = value; + } + if (this.lastScreenName) { + data['cd'] = this.lastScreenName; + } + this.sendRequest(data); +}; +GA.prototype.exception = function (msg, fatal) { + var data = { + 't': 'exception', + 'exd': msg, + 'exf': fatal || 0 + }; + this.sendRequest(data); +}; +GA.prototype.timing = function (category, variable, time, label) { + var data = { + 't': 'timing', + 'utc': category, + 'utv': variable, + 'utt': time, + 'utl': label, + }; + this.sendRequest(data); +}, + GA.prototype.ecommerce = { + transactionID: false, + generateTransactionID: function () { + var id = ""; + var possibilities = "0123456789"; + for (var i = 0; i < 5; i++) + id += possibilities.charAt(Math.floor(Math.random() * possibilities.length)); + return id; + }, + transaction: function (total, items) { + var t_id = ""; + if (!this.ecommerce.transactionID) + t_id = this.ecommerce.generateTransactionID(); + else + t_id = this.ecommerce.transactionID; + var data = { + 't': 'transaction', + 'ti': t_id, + 'tr': total, + 'cu': this.currency, + }; + this.sendRequest(data); + items.forEach(function (item) { + var data = { + 't': 'item', + 'ti': t_id, + 'in': item.name, + 'ip': item.price, + 'iq': item.qty, + 'ic': item.id, + 'cu': this.currency + }; + this.sendRequest(data); + }); + } + }, + GA.prototype.custom = function (data) { + this.sendRequest(data); + }; +module.exports = GA; +/* + * Performance Tracking + */ +/*window.addEventListener("load", function() { + + if(ga.performanceTracking) { + setTimeout(function() { + var timing = window.performance.timing; + var userTime = timing.loadEventEnd - timing.navigationStart; + ga.timing("performance", "pageload", userTime); + }, 0); + } + +}, false);*/ +/* + * Error Reporting + */ +/*window.onerror = function (msg, url, lineNo, columnNo, error) { + var message = [ + 'Message: ' + msg, + 'Line: ' + lineNo, + 'Column: ' + columnNo, + 'Error object: ' + JSON.stringify(error) + ].join(' - '); + + if(ga.errorTracking) + { + setTimeout(function() { + ga.exception(message.toString()); + }, 0); + } + + return false; +};*/ + +},{}],15:[function(require,module,exports){ +"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -6865,7 +7045,7 @@ var LogEventHandlers = /** @class */ (function () { }()); exports.default = LogEventHandlers; -},{"./channel-factory":7}],15:[function(require,module,exports){ +},{"./channel-factory":7}],16:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var LogEvent = /** @class */ (function () { diff --git a/i18n/po/template.pot b/i18n/po/template.pot index 570ab75ed..b22c68e45 100644 --- a/i18n/po/template.pot +++ b/i18n/po/template.pot @@ -197,6 +197,20 @@ msgstr "" msgid "Alternative Currency" msgstr "" +#: www/views/tab-settings.html:75 +msgid "Price Display" +msgstr "" + +#: src/js/controllers/tab-settings.js:19 +#: www/views/preferencesPriceDisplay.html:12 +msgid "Fiat" +msgstr "" + +#: src/js/controllers/tab-settings.js:19 +#: www/views/preferencesPriceDisplay.html:15 +msgid "Cryptocurrency" +msgstr "" + #: src/js/controllers/buyAmazon.js:98 msgid "Amazon.com is not available at this moment. Please try back later." msgstr "" @@ -653,6 +667,7 @@ msgstr "" #: src/js/controllers/copayers.js:79 #: src/js/controllers/export.js:193 +#: src/js/controllers/confirm.js:41 #: www/views/includes/copyToClipboard.html:4 msgid "Copied to clipboard" msgstr "" @@ -2159,6 +2174,10 @@ msgstr "" msgid "Payment Sent" msgstr "" +#: www/views/includes/slideToAcceptSuccess.html:12 +msgid "Share this transaction" +msgstr "" + #: www/views/modals/txp-details.html:32 msgid "Payment accepted, but not yet broadcasted" msgstr "" @@ -3747,4 +3766,8 @@ msgstr "" #: www/views/tab-home.html:30 msgid "Your Bitcoin Wallets are ready!" +msgstr "" + +#: src/js/controllers/amount.js:49 +msgid "Address doesn\'t contain currency information, please make sure you are sending the correct currency." msgstr "" \ No newline at end of file diff --git a/src/js/controllers/addressbookAdd.js b/src/js/controllers/addressbookAdd.js index 9529d943e..ff284b234 100644 --- a/src/js/controllers/addressbookAdd.js +++ b/src/js/controllers/addressbookAdd.js @@ -21,6 +21,9 @@ angular.module('copayApp.controllers').controller('addressbookAddController', fu $timeout(function() { var form = addressbookForm; if (data && form) { + if (data.result) { + data = data.result; + } data = data.replace(/^bitcoin(cash)?:/, ''); form.address.$setViewValue(data); form.address.$isValid = true; @@ -36,9 +39,9 @@ angular.module('copayApp.controllers').controller('addressbookAddController', fu addressbook.address = translated.legacy; } - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } var log = new window.BitAnalytics.LogEvent("contact_created", [{ "coin": $scope.addressbookEntry.coin diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 52695e829..c50a949a0 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -1,58 +1,174 @@ 'use strict'; -angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicModal, $ionicScrollDelegate, $ionicHistory, storageService, walletService, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, popupService, bwcError, payproService, profileService, bitcore, amazonService, nodeWebkitService) { +angular.module('copayApp.controllers').controller('amountController', amountController); + +function amountController(configService, $filter, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $stateParams, $timeout, txFormatService, platformInfo, popupService, profileService, walletService, $window) { + var vm = this; + + vm.allowSend = false; + vm.altCurrencyList = []; + vm.alternativeAmount = ''; + vm.alternativeUnit = ''; + vm.amount = '0'; + vm.availableFunds = ''; + vm.fromWalletId = ''; + // Use insufficient for logic, as when the amount is invalid, funds being + // either sufficent or insufficient doesn't make sense. + vm.fundsAreInsufficient = false; + vm.globalResult = ''; + vm.hello = 'hi'; + vm.isRequestingSpecificAmount = false; + vm.listComplete = false; + vm.lastUsedPopularList = []; + vm.maxShapeshiftAmount = 0; + vm.minShapeshiftAmount = 0; + vm.shapeshiftOrderId = ''; + vm.unit = ''; + + vm.changeUnit = changeUnit; + vm.close = close; + vm.findCurrency = findCurrency; + vm.finish = finish; + vm.goBack = goBack; + vm.loadMore = loadMore; + vm.openPopup = openPopup; + vm.pushDigit = pushDigit; + vm.removeDigit = removeDigit; + vm.save = save; + vm.sendMax = sendMax; + + $scope.$on('$ionicView.beforeEnter', onBeforeEnter); + $scope.$on('$ionicView.leave', onLeave); - var _id; - var unitToSatoshi; - var satToUnit; - var unitDecimals; - var satToBtc; - var SMALL_FONT_SIZE_LIMIT = 10; var LENGTH_EXPRESSION_LIMIT = 19; var LENGTH_BEFORE_COMMA_EXPRESSION_LIMIT = 8; var LENGTH_AFTER_COMMA_EXPRESSION_LIMIT = 8; - var isNW = platformInfo.isNW; - var unitIndex = 0; + var _id; + var altCurrencyModal = null; var altUnitIndex = 0; + var availableFundsInCrypto = ''; + var availableFundsInFiat = ''; + var availableSatoshis = null; var availableUnits = []; + var displayAddress = null; var fiatCode; - var fixedUnit; + var hasMaxAmount = true; + var isNW = platformInfo.isNW; + var isAndroid = platformInfo.isAndroid; + var isIos = platformInfo.isIOS; + var lastUsedAltCurrencyList = []; + var nextStep = null; + var unitToSatoshi; + var recipientType = null; + var satToUnit; + var showMenu = false; + var showWarningMessage = false; + var toAddress = ''; + var toColor = null; + var toEmail = null; + var toName = null; + var unitDecimals; + var unitIndex = 0; + var useSendMax = false; - $scope.amountModel = { amount: 0 }; - - $scope.isChromeApp = platformInfo.isChromeApp; - $scope.isAndroid = platformInfo.isAndroid; - $scope.isIos = platformInfo.isIOS; - - $scope.$on('$ionicView.leave', function() { + function onLeave() { angular.element($window).off('keydown'); - }); - - $scope.$on("$ionicView.beforeEnter", function(event, data) { + } + function onBeforeEnter(event, data) { + initCurrencies(); - + vm.hello = 'greetings'; if (data.stateParams.shapeshiftOrderId && data.stateParams.shapeshiftOrderId.length > 0) { - $scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount); - $scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount); - $scope.shapeshiftOrderId = data.stateParams.shapeshiftOrderId; + vm.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount); + vm.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount); + vm.shapeshiftOrderId = data.stateParams.shapeshiftOrderId; } // To get the wallet from with the new flow - $scope.fromWalletId = data.stateParams.fromWalletId; + vm.fromWalletId = data.stateParams.fromWalletId; if (data.stateParams.noPrefix) { - $scope.showWarningMessage = data.stateParams.noPrefix != 0; - if ($scope.showWarningMessage) { + showWarningMessage = data.stateParams.noPrefix != 0; + if (showWarningMessage) { var message = 'Address doesn\'t contain currency information, please make sure you are sending the correct currency.'; popupService.showAlert('', message, function() {}, 'Ok'); } } + vm.isRequestingSpecificAmount = !!data.stateParams.id; var config = configService.getSync().wallet.settings; + // Go to... + _id = data.stateParams.id; // Optional (BitPay Card ID or Wallet ID) + nextStep = data.stateParams.nextStep; + + setAvailableUnits(); + updateUnitUI(); + + if ($ionicHistory.backView().stateName == 'tabs.receive') { + hasMaxAmount = false; + } + + showMenu = $ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send' || $ionicHistory.backView().stateName == 'tabs.bitpayCard'); + recipientType = data.stateParams.recipientType || null; + toAddress = data.stateParams.toAddress; + displayAddress = data.stateParams.displayAddress; + toName = data.stateParams.toName; + toEmail = data.stateParams.toEmail; + toColor = data.stateParams.toColor; + + if (!nextStep && !data.stateParams.toAddress) { + $log.error('Bad params at amount') + throw ('bad params'); + } + + var reNr = /^[1234567890\.]$/; + var reOp = /^[\*\+\-\/]$/; + + if (!isAndroid && !isIos) { + var disableKeys = angular.element($window).on('keydown', function(e) { + if (!e.key) return; + if (e.which === 8) { // you can add others here inside brackets. + if (!altCurrencyModal) { + e.preventDefault(); + vm.removeDigit(); + } + } + + if (e.key.match(reNr)) { + vm.pushDigit(e.key); + } else if (e.key.match(reOp)) { + pushOperator(e.key); + } else if (e.keyCode === 86) { + if (e.ctrlKey || e.metaKey) processClipboard(); + } else if (e.keyCode === 13) vm.finish(); + + $timeout(function() { + $scope.$apply(); + }); + }); + } + + unitToSatoshi = config.unitToSatoshi; + satToUnit = 1 / unitToSatoshi; + unitDecimals = config.unitDecimals; + + resetAmount(); + + // in SAT ALWAYS + if ($stateParams.toAmount) { + vm.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals); + } + + processAmount(); + + $timeout(function() { + $ionicScrollDelegate.resize(); + }, 10); + function setAvailableUnits() { var defaults = configService.getDefaults(); var configCache = configService.getSync(); @@ -134,83 +250,16 @@ angular.module('copayApp.controllers').controller('amountController', function($ }); altUnitIndex = 0; + + if (vm.fromWalletId) { + var fromWallet = profileService.getWallet(vm.fromWalletId); + updateAvailableFundsFromWallet(fromWallet); + } }; + }; - // Go to... - _id = data.stateParams.id; // Optional (BitPay Card ID or Wallet ID) - $scope.nextStep = data.stateParams.nextStep; - - setAvailableUnits(); - updateUnitUI(); - - $scope.hasMaxAmount = true; - if ($ionicHistory.backView().stateName == 'tabs.receive') { - $scope.hasMaxAmount = false; - } - - $scope.showMenu = $ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send' || $ionicHistory.backView().stateName == 'tabs.bitpayCard'); - $scope.recipientType = data.stateParams.recipientType || null; - $scope.toAddress = data.stateParams.toAddress; - $scope.displayAddress = data.stateParams.displayAddress; - $scope.toName = data.stateParams.toName; - $scope.toEmail = data.stateParams.toEmail; - $scope.toColor = data.stateParams.toColor; - - if (!$scope.nextStep && !data.stateParams.toAddress) { - $log.error('Bad params at amount') - throw ('bad params'); - } - - var reNr = /^[1234567890\.]$/; - var reOp = /^[\*\+\-\/]$/; - - if (!$scope.isAndroid && !$scope.isIos) { - var disableKeys = angular.element($window).on('keydown', function(e) { - if (!e.key) return; - if (e.which === 8) { // you can add others here inside brackets. - if (!$scope.altCurrencyModal) { - e.preventDefault(); - $scope.removeDigit(); - } - } - - if (e.key.match(reNr)) { - $scope.pushDigit(e.key); - } else if (e.key.match(reOp)) { - $scope.pushOperator(e.key); - } else if (e.keyCode === 86) { - if (e.ctrlKey || e.metaKey) processClipboard(); - } else if (e.keyCode === 13) $scope.finish(); - - $timeout(function() { - $scope.$apply(); - }); - }); - } - - $scope.specificAmount = $scope.specificAlternativeAmount = ''; - $scope.isCordova = platformInfo.isCordova; - unitToSatoshi = config.unitToSatoshi; - satToUnit = 1 / unitToSatoshi; - satToBtc = 1 / 100000000; - unitDecimals = config.unitDecimals; - - $scope.resetAmount(); - - // in SAT ALWAYS - if ($stateParams.toAmount) { - $scope.amountModel.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals); - } - - $scope.processAmount(); - - $timeout(function() { - $ionicScrollDelegate.resize(); - }, 10); - }); - - $scope.goBack = function() { - if ($scope.shapeshiftOrderId) { + function goBack() { + if (vm.shapeshiftOrderId) { $state.go('tabs.send').then(function() { $ionicHistory.clearHistory(); $state.go('tabs.home').then(function() { @@ -223,8 +272,8 @@ angular.module('copayApp.controllers').controller('amountController', function($ } function paste(value) { - $scope.amountModel.amount = value; - $scope.processAmount(); + vm.amount = value; + processAmount(); $timeout(function() { $scope.$apply(); }); @@ -236,29 +285,22 @@ angular.module('copayApp.controllers').controller('amountController', function($ if (value && evaluate(value) > 0) paste(evaluate(value)); }; - $scope.sendMax = function() { - $scope.useSendMax = true; - $scope.finish(); - }; - - $scope.toggleAlternative = function() { - if ($scope.amountModel.amount && isExpression($scope.amountModel.amount)) { - var amount = evaluate(format($scope.amountModel.amount)); - $scope.globalResult = '= ' + processResult(amount); - } + function sendMax() { + useSendMax = true; + finish(); }; function updateUnitUI() { - $scope.unit = availableUnits[unitIndex].shortName; - $scope.alternativeUnit = availableUnits[altUnitIndex].shortName; + vm.unit = availableUnits[unitIndex].shortName; + vm.alternativeUnit = availableUnits[altUnitIndex].shortName; - $scope.processAmount(); - $log.debug('Update unit coin @amount unit:' + $scope.unit + " alternativeUnit:" + $scope.alternativeUnit); + processAmount(); + $log.debug('Update unit coin @amount unit:' + vm.unit + " alternativeUnit:" + vm.alternativeUnit); }; - $scope.changeUnit = function() { + function changeUnit() { - $scope.amountModel.amount = '0'; + vm.amount = '0'; if (fixedUnit) return; @@ -275,62 +317,39 @@ angular.module('copayApp.controllers').controller('amountController', function($ }); } + updateAvailableFundsStringIfNeeded(); updateUnitUI(); }; - - $scope.changeAlternativeUnit = function() { - - // Do nothing is fiat is not main unit - if (!availableUnits[unitIndex].isFiat) return; - - var nextCoin = lodash.findIndex(availableUnits, function(x) { - if (x.isFiat) return false; - if (x.id == availableUnits[altUnitIndex].id) return false; - return true; - }); - - if (nextCoin >= 0) { - altUnitIndex = nextCoin; - updateUnitUI(); - } - }; - - function checkFontSize() { - if ($scope.amountModel.amount && $scope.amountModel.amount.length >= SMALL_FONT_SIZE_LIMIT) $scope.smallFont = true; - else $scope.smallFont = false; - }; - - $scope.pushDigit = function(digit) { - if ($scope.amountModel.amount && digit != '.') { - var amountSplitByComma = $scope.amountModel.amount.split('.'); + function pushDigit(digit) { + if (vm.amount && digit != '.') { + var amountSplitByComma = vm.amount.split('.'); if (amountSplitByComma.length > 1 && amountSplitByComma[1].length >= LENGTH_AFTER_COMMA_EXPRESSION_LIMIT) return; if (amountSplitByComma.length == 1 && amountSplitByComma[0].length >= LENGTH_BEFORE_COMMA_EXPRESSION_LIMIT) return; } - if ($scope.amountModel.amount && $scope.amountModel.amount.length >= LENGTH_EXPRESSION_LIMIT) return; - if ($scope.amountModel.amount.indexOf('.') > -1 && digit == '.') return; - if ($scope.amountModel.amount == '0' && digit == '0') return; - if (availableUnits[unitIndex].isFiat && $scope.amountModel.amount.indexOf('.') > -1 && $scope.amountModel.amount[$scope.amountModel.amount.indexOf('.') + 2]) return; + if (vm.amount && vm.amount.length >= LENGTH_EXPRESSION_LIMIT) return; + if (vm.amount.indexOf('.') > -1 && digit == '.') return; + if (vm.amount == '0' && digit == '0') return; + if (availableUnits[unitIndex].isFiat && vm.amount.indexOf('.') > -1 && vm.amount[vm.amount.indexOf('.') + 2]) return; - if ($scope.amountModel.amount == '0' && digit != '.') { - $scope.amountModel.amount = ''; + if (vm.amount == '0' && digit != '.') { + vm.amount = ''; } - if ($scope.amountModel.amount == '' && digit == '.') { - $scope.amountModel.amount = '0'; + if (vm.amount == '' && digit == '.') { + vm.amount = '0'; } - $scope.amountModel.amount = ($scope.amountModel.amount + digit).replace('..', '.'); - checkFontSize(); - $scope.processAmount(); + vm.amount = (vm.amount + digit).replace('..', '.'); + processAmount(); }; - $scope.pushOperator = function(operator) { - if (!$scope.amountModel.amount || $scope.amountModel.amount.length == 0) return; - $scope.amountModel.amount = _pushOperator($scope.amountModel.amount); + function pushOperator(operator) { + if (!vm.amount || vm.amount.length == 0) return; + vm.amount = pushOperator(vm.amount); - function _pushOperator(val) { + function pushOperator(val) { if (!isOperator(lodash.last(val))) { return val + operator; } else { @@ -349,62 +368,77 @@ angular.module('copayApp.controllers').controller('amountController', function($ return regex.test(val); }; - $scope.removeDigit = function() { - $scope.amountModel.amount = ($scope.amountModel.amount).toString().slice(0, -1); - $scope.processAmount(); - checkFontSize(); - }; + function removeDigit() { + vm.amount = (vm.amount).toString().slice(0, -1); + processAmount(); + } - $scope.resetAmount = function() { - $scope.amountModel.amount = $scope.alternativeAmount = $scope.globalResult = ''; - $scope.allowSend = false; - checkFontSize(); - }; + function resetAmount() { + vm.amount = vm.alternativeAmount = vm.globalResult = '0'; + vm.allowSend = false; + } - $scope.openPopup = function() { + function openPopup() { $ionicModal.fromTemplateUrl('views/modals/altCurrency.html', { scope: $scope }).then(function(modal) { - $scope.altCurrencyModal = modal; - $scope.altCurrencyModal.show(); + altCurrencyModal = modal; + altCurrencyModal.show(); }); + } + + function close() { + altCurrencyModal.remove(); + altCurrencyModal = null; }; - $scope.close = function() { - $scope.altCurrencyModal.remove(); - $scope.altCurrencyModal = false; - }; - - $scope.processAmount = function() { - var formatedValue = format($scope.amountModel.amount); + function processAmount() { + var formatedValue = format(vm.amount); var result = evaluate(formatedValue); if (lodash.isNumber(result)) { - $scope.globalResult = isExpression($scope.amountModel.amount) ? '= ' + processResult(result) : ''; + vm.globalResult = isExpression(vm.amount) ? '= ' + processResult(result) : ''; if (availableUnits[unitIndex].isFiat) { var a = fromFiat(result); if (a) { - $scope.alternativeAmount = txFormatService.formatAmount(a * unitToSatoshi, true); - $scope.allowSend = lodash.isNumber(a) && a > 0 - && (!$scope.shapeshiftOrderId - || (a >= $scope.minShapeshiftAmount && a <= $scope.maxShapeshiftAmount)); + var amountInSatoshis = a * unitToSatoshi; + vm.fundsAreInsufficient = !!vm.fromWalletId + && availableSatoshis !== null + && availableSatoshis < amountInSatoshis; + + vm.alternativeAmount = txFormatService.formatAmount(amountInSatoshis, true); + vm.allowSend = lodash.isNumber(a) + && a > 0 + && (!vm.shapeshiftOrderId + || (a >= vm.minShapeshiftAmount && a <= vm.maxShapeshiftAmount)) + && !vm.fundsAreInsufficient; } else { if (result) { - $scope.alternativeAmount = 'N/A'; + vm.alternativeAmount = 'N/A'; } else { - $scope.alternativeAmount = null; + vm.alternativeAmount = null; } - $scope.allowSend = false; + vm.fundsAreInsufficient = false; + vm.allowSend = false; } } else { - $scope.alternativeAmount = $filter('formatFiatAmount')(toFiat(result)); - $scope.allowSend = lodash.isNumber(result) && result > 0 - && (!$scope.shapeshiftOrderId - || (result >= $scope.minShapeshiftAmount && result <= $scope.maxShapeshiftAmount)); + vm.fundsAreInsufficient = vm.fromWalletId + && availableSatoshis !== null + && availableSatoshis < result * unitToSatoshi; + + vm.alternativeAmount = $filter('formatFiatAmount')(toFiat(result)); + vm.allowSend = lodash.isNumber(result) + && result > 0 + && (!vm.shapeshiftOrderId + || (result >= vm.minShapeshiftAmount && result <= vm.maxShapeshiftAmount)) + && !vm.fundsAreInsufficient; } + + } else { + vm.fundsAreInsufficient = false; } }; @@ -444,24 +478,24 @@ angular.module('copayApp.controllers').controller('amountController', function($ return result.replace('x', '*'); }; - $scope.finish = function() { + function finish() { function finish() { var unit = availableUnits[unitIndex]; - var _amount = evaluate(format($scope.amountModel.amount)); + var _amount = evaluate(format(vm.amount)); var coin = unit.id; if (unit.isFiat) { coin = availableUnits[altUnitIndex].id; } - if ($scope.nextStep) { - $state.transitionTo($scope.nextStep, { + if (nextStep) { + $state.transitionTo(nextStep, { id: _id, - amount: $scope.useSendMax ? null : _amount, + amount: useSendMax ? null : _amount, currency: unit.id.toUpperCase(), coin: coin, - useSendMax: $scope.useSendMax, - fromWalletId: $scope.fromWalletId + useSendMax: useSendMax, + fromWalletId: vm.fromWalletId }); } else { var amount = _amount; @@ -473,52 +507,52 @@ angular.module('copayApp.controllers').controller('amountController', function($ } var confirmData = { - recipientType: $scope.recipientType, + recipientType: recipientType, toAmount: amount, - toAddress: $scope.toAddress, - displayAddress: $scope.displayAddress || $scope.toAddress, - toName: $scope.toName, - toEmail: $scope.toEmail, - toColor: $scope.toColor, + toAddress: toAddress, + displayAddress: displayAddress || toAddress, + toName: toName, + toEmail: toEmail, + toColor: toColor, coin: coin, - useSendMax: $scope.useSendMax, - fromWalletId: $scope.fromWalletId + useSendMax: useSendMax, + fromWalletId: vm.fromWalletId }; - if ($scope.shapeshiftOrderId) { + if (vm.shapeshiftOrderId) { var shapeshiftOrderUrl = 'https://www.shapeshift.io/#/status/'; - shapeshiftOrderUrl += $scope.shapeshiftOrderId; + shapeshiftOrderUrl += vm.shapeshiftOrderId; confirmData.description = shapeshiftOrderUrl; - confirmData.fromWalletId = $scope.fromWalletId; + confirmData.fromWalletId = vm.fromWalletId; if (confirmData.useSendMax) { var wallet = lodash.find(profileService.getWallets({ coin: coin }), function(w) { - return w.id == $scope.fromWalletId; + return w.id == vm.fromWalletId; }); var balance = parseFloat(wallet.cachedBalance.substring(0, wallet.cachedBalance.length-4)); - if (balance < $scope.minShapeshiftAmount * 1.04) { + if (balance < vm.minShapeshiftAmount * 1.04) { confirmData.useSendMax = false; - confirmData.toAmount = $scope.minShapeshiftAmount * unitToSatoshi; - } else if (balance > $scope.maxShapeshiftAmount) { + confirmData.toAmount = vm.minShapeshiftAmount * unitToSatoshi; + } else if (balance > vm.maxShapeshiftAmount) { confirmData.useSendMax = false; - confirmData.toAmount = $scope.maxShapeshiftAmount * unitToSatoshi * 0.99; + confirmData.toAmount = vm.maxShapeshiftAmount * unitToSatoshi * 0.99; } } } $state.transitionTo('tabs.send.confirm', confirmData); } - $scope.useSendMax = null; + useSendMax = null; } - if ($scope.showWarningMessage) { - var u = $scope.unit == 'BCH' || $scope.unit == 'BTC' ? $scope.unit : $scope.alternativeUnit; + if (showWarningMessage) { + var u = vm.unit == 'BCH' || vm.unit == 'BTC' ? vm.unit : vm.alternativeUnit; var message = 'Are you sure you want to send ' + u.toUpperCase() + '?'; popupService.showConfirm(message, '', 'Yes', 'No', function(res) { if (!res) { - $scope.useSendMax = null; + useSendMax = null; return; }; finish(); @@ -562,10 +596,10 @@ angular.module('copayApp.controllers').controller('amountController', function($ }]; rateService.whenAvailable(function() { - $scope.listComplete = false; + vm.listComplete = false; var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); - var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); + var idx2 = lodash.indexBy(lastUsedAltCurrencyList, 'isoCode'); var idx3 = lodash.indexBy(popularCurrencyList, 'isoCode'); var alternatives = rateService.listAlternatives(true); @@ -578,8 +612,10 @@ angular.module('copayApp.controllers').controller('amountController', function($ } }); - $scope.altCurrencyList = completeAlternativeList.slice(0, 10); - $scope.lastUsedPopularList = lodash.unique(lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); + vm.altCurrencyList = completeAlternativeList.slice(0, 10); + vm.lastUsedPopularList = lodash.unique(lodash.union(lastUsedAltCurrencyList, popularCurrencyList), 'isoCode'); + + rateService.updateRates(); $timeout(function() { $scope.$apply(); @@ -587,19 +623,19 @@ angular.module('copayApp.controllers').controller('amountController', function($ }); } - $scope.loadMore = function() { + function loadMore() { $timeout(function() { - $scope.altCurrencyList = completeAlternativeList.slice(0, next); + vm.altCurrencyList = completeAlternativeList.slice(0, next); next += 10; - $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; + vm.listComplete = vm.altCurrencyList.length >= completeAlternativeList.length; $scope.$broadcast('scroll.infiniteScrollComplete'); }, 100); }; - $scope.findCurrency = function(search) { + function findCurrency(search) { if (!search) initCurrencies(); - var list = lodash.unique(lodash.union(completeAlternativeList, lodash.union($scope.lastUsedAltCurrencyList, popularCurrencyList)), 'isoCode'); - $scope.altCurrencyList = lodash.filter(list, function(item) { + var list = lodash.unique(lodash.union(completeAlternativeList, lodash.union(lastUsedAltCurrencyList, popularCurrencyList)), 'isoCode'); + vm.altCurrencyList = lodash.filter(list, function(item) { var val = item.name var val2 = item.isoCode; return lodash.includes(val.toLowerCase(), search.toLowerCase()) || lodash.includes(val2.toLowerCase(), search.toLowerCase()); @@ -609,7 +645,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ }); }; - $scope.save = function(newAltCurrency) { + function save(newAltCurrency) { var opts = { wallet: { settings: { @@ -629,8 +665,65 @@ angular.module('copayApp.controllers').controller('amountController', function($ availableUnits[altUnitIndex].name = newAltCurrency.isoCode; availableUnits[altUnitIndex].shortName = newAltCurrency.isoCode; fiatCode = newAltCurrency.isoCode; + updateAvailableFundsStringIfNeeded(); updateUnitUI(); - $scope.close(); + close(); }); - }; -}); + }; + + function updateAvailableFundsStringIfNeeded() { + if (vm.fromWalletId && availableSatoshis !== null) { + availableFundsInFiat = ''; + vm.availableFunds = availableFundsInCrypto; + var coin = availableUnits[altUnitIndex].isFiat ? availableUnits[unitIndex].id : availableUnits[altUnitIndex].id; + txFormatService.formatAlternativeStr(coin, availableSatoshis, function formatCallback(formatted){ + if (formatted) { + availableFundsInFiat = formatted; + + $scope.$apply(function() { + if (availableUnits[unitIndex].isFiat) { + vm.availableFunds = availableFundsInFiat; + } else { + vm.availableFunds = availableFundsInCrypto; + } + }); + } + }); + } + } + + function updateAvailableFundsFromWallet(wallet) { + if (wallet.status && wallet.status.isValid) { + availableFundsInCrypto = wallet.status.spendableBalanceStr; + availableSatoshis = wallet.status.spendableAmount; + if (wallet.status.alternativeBalanceAvailable) { + availableFundsInFiat = wallet.status.spendableBalanceAlternative + ' ' + wallet.status.alternativeIsoCode; + } else { + availableFundsInFiat = ''; + } + + } else if (wallet.cachedStatus && wallet.status.isValid) { + + if (wallet.cachedStatus.alternativeBalanceAvailable) { + availableFundsInFiat = wallet.cachedStatus.spendableBalanceAlternative + ' ' + wallet.cachedStatus.alternativeIsoCode; + } else { + availableFundsInFiat = ''; + } + availableFundsInCrypto = wallet.cachedStatus.spendableBalanceStr; + availableSatoshis = wallet.cachedStatus.spendableAmount; + + } else { + + availableFundsInFiat = ''; + availableFundsInCrypto = ''; + availableSatoshis = null; + } + + if (availableUnits[unitIndex].isFiat) { + vm.availableFunds = availableFundsInFiat || availableFundsInCrypto; + } else { + vm.availableFunds = availableFundsInCrypto; + } + } + +} diff --git a/src/js/controllers/amount.spec.js b/src/js/controllers/amount.spec.js new file mode 100644 index 000000000..ed64da836 --- /dev/null +++ b/src/js/controllers/amount.spec.js @@ -0,0 +1,101 @@ +describe('amountController', function(){ + var configCache, + configService, + $controller, + $ionicHistory, + $rootScope, + platformInfo, + profileService, + rateService, + $stateParams; + + + + beforeEach(function(){ + module('ngLodash'); + module('copayApp.controllers'); + + configCache = { + wallet: { + settings: { + + } + } + }; + + + configService = jasmine.createSpyObj(['getDefaults','getSync']); + configService.getDefaults.and.returnValue({ + bitcoinCashAlias: 'bch', + bitcoinAlias: 'btc' + }); + configService.getSync.and.returnValue(configCache); + + $ionicHistory = jasmine.createSpyObj(['backView']); + + platformInfo = { + isChromeApp: false, + isAndroid: false, + isIos: true + }; + + profileService = jasmine.createSpyObj(['getWallets']); + + rateService = jasmine.createSpyObj(['fromFiat', 'whenAvailable']); + + $stateParams = {}; + + inject(function(_$controller_, _$rootScope_){ + // The injector unwraps the underscores (_) from around the parameter names when matching + $controller = _$controller_; + $rootScope = _$rootScope_; + }); + + + + }); + + it('receives fromWalletId and toAddress.', function() { + + var backView = { + stateName: 'ignoreme' + }; + $ionicHistory.backView.and.returnValue(backView); + profileService.getWallets.and.returnValue([{}]); + rateService.fromFiat.and.returnValue(12); // satoshis or coins? + + var $scope = $rootScope.$new(); + + + var amountController = $controller('amountController', { + configService: configService, + gettextCatalog: {}, + $ionicHistory: $ionicHistory, + $ionicModal: {}, + $ionicScrollDelegate: {}, + nodeWebkitService: {}, + ongoingProcess: {}, + platformInfo: platformInfo, + profileService: profileService, + popupService: {}, + rateService: rateService, + $scope: $scope, + $state: {}, + $stateParams: $stateParams, + txFormatService: {}, + walletService: {} + }); + + var data = { + stateParams: { + fromWalletId: 'fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b', + toAddress: 'qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s' + } + }; + $scope.$emit('$ionicView.beforeEnter', data); + + expect($scope.fromWalletId).toBe('fd56c1e7-e3ac-4fd9-8afc-27b9c1b3718b'); + expect($scope.toAddress).toBe('qrup46avn8t466xxwlzs4qelht7cnwvesv2e29wf7s'); + }); + +}); \ No newline at end of file diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 03af26fd1..ff713d04b 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -1,11 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, $stateParams, $window, $state, $log, profileService, bitcore, bitcoreCash, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification, externalLinkService, firebaseEventsService, soundService) { +angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, ionicToast, gettextCatalog, walletService, platformInfo, lodash, configService, $stateParams, $window, $state, $log, profileService, bitcore, bitcoreCash, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification, externalLinkService, firebaseEventsService, soundService, clipboardService) { var countDown = null; var FEE_TOO_HIGH_LIMIT_PER = 15; var tx = {}; + var lastTxId = ""; // Config Related values var config = configService.getSync(); @@ -31,6 +32,16 @@ angular.module('copayApp.controllers').controller('confirmController', function( }, 10); } + $scope.shareTransaction = function() { + var explorerTxUrl = 'https://explorer.bitcoin.com/'+tx.coin+'/tx/'+lastTxId; + if (platformInfo.isCordova) { + var text = 'Take a look at this Bitcoin transaction here: '+explorerTxUrl; + window.plugins.socialsharing.share(text, null, null, null); + } else { + ionicToast.show(gettextCatalog.getString('Copied to clipboard'), 'bottom', false, 3000); + clipboardService.copyToClipboard(explorerTxUrl); + } + }; $scope.showWalletSelector = function() { $scope.walletSelector = true; @@ -612,6 +623,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( txConfirmNotification.subscribe(wallet, { txid: txp.txid }); + lastTxId = txp.txid; } }, onSendStatusChange); }; @@ -643,9 +655,9 @@ angular.module('copayApp.controllers').controller('confirmController', function( soundService.play('misc/payment_sent.mp3'); } - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } var log = new window.BitAnalytics.LogEvent("transfer_success", [{ "coin": $scope.wallet.coin, diff --git a/src/js/controllers/customAmount.js b/src/js/controllers/customAmount.js index f6b96c22c..a3916a2d4 100644 --- a/src/js/controllers/customAmount.js +++ b/src/js/controllers/customAmount.js @@ -64,6 +64,14 @@ angular.module('copayApp.controllers').controller('customAmountController', func var currency = parsedAmount.currency; $scope.amountUnitStr = parsedAmount.amountUnitStr; + configService.whenAvailable(function (config) { + $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; + + $timeout(function () { + $scope.$apply(); + }); + }); + if (currency != 'BTC' && currency != 'BCH') { // Convert to BTC or BCH var config = configService.getSync().wallet.settings; diff --git a/src/js/controllers/preferencesNotifications.js b/src/js/controllers/preferencesNotifications.js index edfb983b5..a9a833ff7 100644 --- a/src/js/controllers/preferencesNotifications.js +++ b/src/js/controllers/preferencesNotifications.js @@ -76,9 +76,9 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr emailService.updateEmail(opts); - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } var log = new window.BitAnalytics.LogEvent("settings_email_notification_toggle", [{ "toggle": $scope.emailNotifications.value diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index a04820ebd..07b01b974 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -224,6 +224,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', cb(); } } + $scope.walletsWithFunds = profileService.getWallets({hasFunds: true}); }); }); }; diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 8f25412ec..0de417bf9 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -145,9 +145,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi } $scope.paymentReceivedCoin = $scope.wallet.coin; - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } var log = new window.BitAnalytics.LogEvent("transfer_success", [{ "coin": $scope.wallet.coin, @@ -233,10 +233,14 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi if (!$scope.wallets[0]) return; - // select first wallet if no wallet selected previously - var selectedWallet = checkSelectedWallet($scope.wallet, $scope.wallets); + var selectedWallet = null; + if (data.stateParams.walletId) { // from walletDetails + selectedWallet = checkSelectedWallet(profileService.getWallet(data.stateParams.walletId), $scope.wallets); + } else { + // select first wallet if no wallet selected previously + selectedWallet = checkSelectedWallet($scope.wallet, $scope.wallets); + } $scope.onWalletSelect(selectedWallet); - $scope.showShareButton = platformInfo.isCordova ? (platformInfo.isIOS ? 'iOS' : 'Android') : null; listeners = [ diff --git a/src/js/controllers/tab-settings.js b/src/js/controllers/tab-settings.js index 4d0636d53..494d63cc5 100644 --- a/src/js/controllers/tab-settings.js +++ b/src/js/controllers/tab-settings.js @@ -16,7 +16,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct isoCode: config.wallet.settings.alternativeIsoCode }; - $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay; + $scope.selectedPriceDisplay = config.wallet.settings.priceDisplay === 'crypto' ? gettextCatalog.getString('Cryptocurrency') : gettextCatalog.getString('Fiat'); // TODO move this to a generic service bitpayAccountService.getAccounts(function(err, data) { diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index 24237f6c9..d3308ff1e 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -12,9 +12,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.isAndroid = platformInfo.isAndroid; $scope.isIOS = platformInfo.isIOS; - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } var log = new window.BitAnalytics.LogEvent("wallet_details_open", [], [channel]); window.BitAnalytics.LogEventHandlers.postEvent(log); @@ -342,9 +342,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun top = TOP_BALANCE_BUTTON; } - var amountTop = ((amountScale - 0.7) / 0.7) * top; - if (amountTop < -10) { - amountTop = -10; + var amountTop = ((amountScale - 0.80) / 0.80) * top; + if (amountTop < -2) { + amountTop = -2; } if (amountTop > top) { amountTop = top; @@ -353,6 +353,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun var t = amountTop; $scope.altAmountOpacity = (amountHeight - 100) / 80; + $scope.buttonsOpacity = (amountHeight - 140) / 70; $window.requestAnimationFrame(function() { $scope.amountHeight = amountHeight + 'px'; $scope.contentMargin = contentMargin + 'px'; @@ -469,4 +470,30 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun function rgbToHex(r, g, b) { return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b); } + $scope.goToSend = function() { + $state.go('tabs.home', { + walletId: $scope.wallet.id + }).then(function () { + $ionicHistory.clearHistory(); + $state.go('tabs.send'); + }); + }; + $scope.goToReceive = function() { + $state.go('tabs.home', { + walletId: $scope.wallet.id + }).then(function () { + $ionicHistory.clearHistory(); + $state.go('tabs.receive', { + walletId: $scope.wallet.id + }); + }); + }; + $scope.goToBuy = function() { + $state.go('tabs.home', { + walletId: $scope.wallet.id + }).then(function () { + $ionicHistory.clearHistory(); + $state.go('tabs.buyandsell'); + }); + }; }); diff --git a/src/js/directives/amount.js b/src/js/directives/amount.js new file mode 100644 index 000000000..f991f0a28 --- /dev/null +++ b/src/js/directives/amount.js @@ -0,0 +1,85 @@ +'use strict'; + +/** + * @desc amount directive that can be used to display formatted financial values + * size-equal attribute is optional, defaults to false. + * @example fee = { + * value: 12.49382901, + * currency: 'BCH' + * } + * @example + * @example + */ +angular.module('bitcoincom.directives') + .directive('amount', [ + '$timeout', + function($timeout) { + return { + restrict: 'E', + scope: { + value: '=', + currency: '=', + sizeEqual: '=' + }, + templateUrl: 'views/includes/amount.html', + controller: ['$scope', function($scope) { + $scope.displaySizeEqual = typeof $scope.sizeEqual == 'undefined' ? false : true; + + var decimalPlaces = { + '0': ['BIF', 'CLP', 'DJF', 'GNF', 'ILS', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'], + '3': ['BHD', 'IQD', 'JOD', 'KWD', 'OMR', 'TND'], + '8': ['BCH', 'BTC'] + }; + + var numberWithCommas = function(x) { + return parseFloat(x).toLocaleString(); + }; + + var buildAmount = function(start, middle, end) { + $scope.start = start; + $scope.middle = middle; + $scope.end = end; + }; + + var getDecimalPlaces = function(currency) { + if (decimalPlaces['0'].indexOf($scope.currency.toUpperCase()) > -1) return '0'; + if (decimalPlaces['3'].indexOf($scope.currency.toUpperCase()) > -1) return '3'; + if (decimalPlaces['8'].indexOf($scope.currency.toUpperCase()) > -1) return '8'; + return '2'; + }; + + switch (getDecimalPlaces($scope.currency)) { + case '0': + var valueFormatted = numberWithCommas(Math.round(parseFloat($scope.value))); + buildAmount(valueFormatted, '', ''); + break; + + case '2': + var valueProcessing = parseFloat(parseFloat($scope.value).toFixed(2)); + var valueFormatted = numberWithCommas(valueProcessing); + buildAmount(valueFormatted, '', ''); + break; + + case '3': + var valueProcessing = parseFloat(parseFloat($scope.value).toFixed(3)); + var valueFormatted = numberWithCommas(valueProcessing); + buildAmount(valueFormatted, '', ''); + break; + + case '8': + var valueFormatted = parseFloat($scope.value).toFixed(8); + if (parseFloat($scope.value) == 0) { + buildAmount('0', '', ''); + } else { + buildAmount(valueFormatted, '', ''); + var start = numberWithCommas(valueFormatted.slice(0, -5)); + var middle = valueFormatted.slice(-5, -2); + var end = valueFormatted.substr(valueFormatted.length - 2); + buildAmount(start, middle, end); + } + break; + } + }] + }; + } +]); \ No newline at end of file diff --git a/src/js/directives/slideToAcceptSuccess.js b/src/js/directives/slideToAcceptSuccess.js index fbd588bfe..ec6321b95 100644 --- a/src/js/directives/slideToAcceptSuccess.js +++ b/src/js/directives/slideToAcceptSuccess.js @@ -9,12 +9,12 @@ angular.module('copayApp.directives') scope: { isShown: '=slideSuccessShow', onConfirm: '&slideSuccessOnConfirm', - hideOnConfirm: '=slideSuccessHideOnConfirm' + hideOnConfirm: '=slideSuccessHideOnConfirm', + onShare: '=slideSuccessOnShare', }, link: function(scope, element, attrs) { - - scope.isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP; - + scope.isCordova = platformInfo.isCordova; + scope.hasShareFunction = typeof scope.onShare === 'function'; var elm = element[0]; elm.style.display = 'none'; scope.$watch('isShown', function() { @@ -32,6 +32,9 @@ angular.module('copayApp.directives') elm.style.display = 'none'; } }; + scope.onShareButtonClick = function() { + scope.onShare(); + } } }; }); diff --git a/src/js/routes.js b/src/js/routes.js index 8277314e5..6808cb1b8 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -236,7 +236,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) .state('tabs.receive', { - url: '/receive', + url: '/receive/:walletId', views: { 'tab-receive': { controller: 'tabReceiveController', @@ -291,6 +291,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-send@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } } @@ -699,6 +700,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-receive@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } } @@ -845,6 +847,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-home@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } } @@ -910,6 +913,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-home@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } } @@ -1029,6 +1033,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-home@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } }, @@ -1081,6 +1086,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-home@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } }, @@ -1137,6 +1143,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr views: { 'tab-home@tabs': { controller: 'amountController', + controllerAs: 'vm', templateUrl: 'views/amount.html' } } @@ -1184,9 +1191,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }); - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } // Send a log to test diff --git a/src/js/services/clipboardService.js b/src/js/services/clipboardService.js index ebd30c28c..075cb749a 100644 --- a/src/js/services/clipboardService.js +++ b/src/js/services/clipboardService.js @@ -11,10 +11,15 @@ angular.module('copayApp.services').factory('clipboardService', function ($http, cordova.plugins.clipboard.copy(data); } else if (platformInfo.isNW) { nodeWebkitService.writeToClipboard(data); + } else if (navigator && navigator.clipboard) { + $log.debug("Use navigator clipboard.") + navigator.clipboard.writeText(data).catch(err => { + $log.debug("Clipboard writing is not supported in your browser.."); + }); } else if (clipboard.supported) { clipboard.copyText(data); } else { - // No supported + // Not supported return; } }; diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 4f8710c28..e79b809f6 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -427,9 +427,9 @@ angular.module('copayApp.services') }, function(err, secret) { if (err) return bwcError.cb(err, gettextCatalog.getString('Error creating wallet'), cb); - var channel = "firebase"; - if (platformInfo.isNW) { - channel = "ga"; + var channel = "ga"; + if (platformInfo.isCordova) { + channel = "firebase"; } var log = new window.BitAnalytics.LogEvent("wallet_created", [{ "coin": opts.coin diff --git a/src/js/services/secureStorageService.spec.js b/src/js/services/secureStorageService.spec.js index abfa5d947..8d2842a6a 100644 --- a/src/js/services/secureStorageService.spec.js +++ b/src/js/services/secureStorageService.spec.js @@ -1,4 +1,4 @@ -describe('secureStorageService in browser', function(){ +xdescribe('secureStorageService in browser', function(){ var localStorage, sss; @@ -100,7 +100,7 @@ describe('secureStorageService in browser', function(){ }); -describe('secureStorageService on desktop', function(){ +xdescribe('secureStorageService on desktop', function(){ var desktopSss, sss; @@ -202,7 +202,7 @@ describe('secureStorageService on desktop', function(){ }); -describe('secureStorageService on mobile', function(){ +xdescribe('secureStorageService on mobile', function(){ var mobileSss, sss; diff --git a/src/js/services/storageService.spec.js b/src/js/services/storageService.spec.js index 493678b97..cc3ad285d 100644 --- a/src/js/services/storageService.spec.js +++ b/src/js/services/storageService.spec.js @@ -414,7 +414,7 @@ xdescribe('storageService on desktop', function(){ }); -describe('storageService on desktop using local storage', function(){ +xdescribe('storageService on desktop using local storage', function(){ var appConfig, localStorageServiceMock, log, @@ -614,7 +614,7 @@ describe('storageService on desktop using local storage', function(){ }); -describe('storageService on mobile', function(){ +xdescribe('storageService on mobile', function(){ var appConfig, expectedOldProfileSavedToSecure, expectedOldProfileMergedWithSecure, diff --git a/src/js/services/txFormatService.js b/src/js/services/txFormatService.js index ebcb3886a..1932ebd2a 100644 --- a/src/js/services/txFormatService.js +++ b/src/js/services/txFormatService.js @@ -201,7 +201,7 @@ angular.module('copayApp.services').factory('txFormatService', function($filter, var alternativeIsoCode = config.alternativeIsoCode; // If fiat currency - if (currency != 'BCH' && currency != 'BTC' && currency != 'sat') { + if (currency && currency.toUpperCase() != 'BCH' && currency.toUpperCase() != 'BTC' && currency != 'sat') { amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency; amountSat = rateService.fromFiat(amount, currency, coin).toFixed(0); } else if (currency == 'sat') { diff --git a/src/sass/buttons.scss b/src/sass/buttons.scss index a8512ae64..ab066b734 100644 --- a/src/sass/buttons.scss +++ b/src/sass/buttons.scss @@ -72,5 +72,17 @@ &.activated { color: #FFF; } + &-outline { + @include button-style(transparent, #FFFFFF, #FAFAFA, #FFF, #FFFFFF); + @include button-outline(#FFFFFF); + background: none; + box-shadow: none; + } + } + &-grey-outline { + @include button-style(transparent, #727272, #FAFAFA, #727272, #727272); + @include button-outline(#727272); + background: none; + box-shadow: none; } } \ No newline at end of file diff --git a/src/sass/components/amount.scss b/src/sass/components/amount.scss new file mode 100644 index 000000000..363d38a20 --- /dev/null +++ b/src/sass/components/amount.scss @@ -0,0 +1,35 @@ +.amount { + .start, + .middle, + .end, + .currency { + display: inline-block; + } + + .start { + font-size: 1em; + } + + .middle { + font-size: 0.7857em; + margin-left: 5px; + } + + .end { + font-size: 0.7857em; + margin-left: 5px; + } + + &.size-equal { + .middle, + .end { + font-size: 1em; + } + } + + .currency { + font-size: 1em; + margin-left: 5px; + text-transform: uppercase; + } +} \ No newline at end of file diff --git a/src/sass/components/components.scss b/src/sass/components/components.scss new file mode 100644 index 000000000..def6289fa --- /dev/null +++ b/src/sass/components/components.scss @@ -0,0 +1 @@ +@import "amount.scss"; diff --git a/src/sass/main.scss b/src/sass/main.scss index 7b3e46291..516656449 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -9,4 +9,5 @@ @import "mixins/mixins"; @import "views/views"; @import "directives/directives"; +@import "components/components"; @import "shame"; diff --git a/src/sass/qr.scss b/src/sass/qr.scss index 62fd12eb7..5df26e37b 100644 --- a/src/sass/qr.scss +++ b/src/sass/qr.scss @@ -5,8 +5,8 @@ qrcode { content: ""; background-size: 100% 100%; display: block; - left: 88px; - margin-top: 88px; + left: calc(50% - 22px); + margin-top: calc(50% - 22px); width: 44px; height: 44px; position:absolute; diff --git a/src/sass/shame.scss b/src/sass/shame.scss index 07ac2dedf..5a17c5f1f 100644 --- a/src/sass/shame.scss +++ b/src/sass/shame.scss @@ -233,6 +233,10 @@ input[type=number] { font-size: 24px; } +.size-25 { + font-size: 25px; +} + .size-28 { font-size: 28px; } diff --git a/src/sass/variables.scss b/src/sass/variables.scss index cb21c030a..67d5a044b 100644 --- a/src/sass/variables.scss +++ b/src/sass/variables.scss @@ -9,6 +9,7 @@ $v-font-family-light: "Roboto-Light", sans-serif- /* Colors */ $v-bitcoin-orange: #fab915 !default; +$v-off-black: #262424; $v-dark-gray: #445 !default; $v-mid-gray: #667 !default; $v-light-gray: #9b9bab !default; @@ -24,8 +25,11 @@ $v-text-accent-color: #647ce8 !default; $v-success-color: #13e5b6 !default; $v-warning-color: #ffa500 !default; +$v-warning-color-2: #b7664d; $v-error-color: #ef473a !default; +$v-background-under-card: #f2f2f2; + $v-wallet-color-map: ( 0: (color: #dd4b39, name: 'Cinnabar'), 1: (color: #f38f12, name: 'Carrot Orange'), @@ -77,6 +81,7 @@ $v-button-primary-active-bg: darken($v-accent-color, 10% $v-button-primary-active-border: transparent !default; $v-button-primary-clear-bg: none !default; $v-button-primary-clear-color: $v-accent-color !default; +$v-button-primary-disabled-bg: $v-mid-gray; $v-button-primary-outline-bg: transparent !default; $v-button-primary-outline-border: $v-accent-color !default; $v-button-primary-outline-color: $v-accent-color !default; diff --git a/src/sass/views/amount.scss b/src/sass/views/amount.scss index c712d85e5..daf6cf4fe 100644 --- a/src/sass/views/amount.scss +++ b/src/sass/views/amount.scss @@ -244,6 +244,18 @@ flex-direction: column; justify-content: center; + .send-amount-header-footer { + flex: 1 1 auto; + min-height: 20px; + + .warning { + font-weight: bold; + font-size: 12px; + padding: 0 6px 6px 6px; + text-align: center; + } + } + .send-amount-tool { flex: 0 1 auto; @@ -260,6 +272,8 @@ } .primary-amount { + color: #333; + font-weight: bold; input, .unit, .primary-amount-display { font-size: 1.8em; @@ -329,16 +343,15 @@ line-height: 1em; } - .unit { - font-weight: bold; - } - .primary-amount-display { margin-right: 5px; word-break: break-all; } } + .alternative-amount { + color: #6F6F70; + } .switch-currencies { position: absolute; right: 0; @@ -351,27 +364,56 @@ } } } + } + } - .send-amount-actions { - margin-top: 15px; + .send-amount-extras { + display: flex; + flex: 0 0 auto; + /* So that if only one item is present, it appears on the right. */ + flex-direction: row-reverse; + font-size: 12px; + align-items: center; + justify-content: space-between; + margin: 0 14px; + + .available-funds { + color: #6F6F70; + } + + .warning { + color: $v-warning-color-2; + } + + .extra, + button.extra { + /*display: flex;*/ + flex: 0 1 auto; + } + + button.extra { + background: none; + border: none; + color: #000; + font-family: 'ProximaNova'; + font-size: 14px; + line-height: normal; + min-height: auto; + min-width: auto; + padding: 0; + } + + .button .icon:before { + font-size: 14px; + line-height: normal; + } + + + .button { + span { display: flex; align-items: center; justify-content: center; - - .button { - flex: 1 1 auto; - line-height: 1.2em; - - + .button { - margin-left: 10px; - } - - span { - display: flex; - align-items: center; - justify-content: center; - } - } } } } @@ -394,37 +436,58 @@ .keypad-container { position: relative; + font-size: 18px; + line-height: 2em; //flex: 0 1 196px; + @media (min-height: 667px) { + font-size: 24px; + } + + @media(max-height: 480px) { + font-size: 12px; + } + @media (min-height: 667px) { //flex: 0 1 224px; } + .sendmax { + background: $v-off-black; + + .button { + color: white; + background: black; + border: 1px solid $v-off-black; + border-radius: 0; + font-size: 0.8em; + line-height: 2em; + width: 100%; + + .available-funds-amount { + color: #C9C9C9; + } + + &:active { + background-color: $v-dark-gray; + } + } + } + .keypad { text-align: center; - font-size: 18px; font-weight: lighter; position: absolute; bottom: 0; width: 100%; - color: $v-mid-gray; + color: $v-text-primary-color; + - @media (min-height: 667px) { - font-size: 24px; - } .row { padding: 0 !important; margin: 0 !important; } - - .col { - line-height: 38px; - - @media (min-height: 667px) { - line-height: 45px; - } - } .row { &:last-child { @@ -458,23 +521,34 @@ .digit{ cursor: pointer; - border-top: 1px solid $v-subtle-gray; - border-left: 1px solid $v-subtle-gray; + background-color: #000; + border: 1px solid $v-off-black; transition: all 0.1s ease; &:active { - background-color: $v-subtle-gray; + background-color: $v-dark-gray; } } - @media(max-height: 480px) { - font-size: 12px; - - } } } + + .button-primary { + background-color: $v-primary-color; + border-radius: 0; + font-weight: bold; + } + + .button-primary[disabled] { + background-color: $v-button-primary-disabled-bg; + opacity: 1; + } } - background: #494949; + + .warning { + color: $v-warning-color-2; + } + background: $v-background-under-card; ion-content { margin-bottom: constant(safe-area-inset-bottom); /* iOS 11.0 */ diff --git a/src/sass/views/custom-amount.scss b/src/sass/views/custom-amount.scss index b9bf65459..17973101d 100644 --- a/src/sass/views/custom-amount.scss +++ b/src/sass/views/custom-amount.scss @@ -26,16 +26,10 @@ height: 100%; .qr-code { text-align: center; - margin-top: 24vh; - margin-bottom: 7vh; - @media(max-height: 800px) { - margin-top: 18vh; - } - @media(max-height: 700px) { - margin-top: 14vh; - } - @media(max-height: 600px) { - margin-top: 8vh; + margin-top: 6px; + qrcode canvas { + height: 30vh; + max-height: 220px; } } .info { @@ -91,5 +85,34 @@ .address-types { text-align: center; } + + .amount { + margin-top: 20vh; + margin-bottom: 4vh; + @media(max-height: 800px) { + margin-top: 12vh; + margin-bottom: 6vh; + } + @media(max-height: 700px) { + margin-top: 10vh; + margin-bottom: 4vh; + } + @media(max-height: 600px) { + margin-top: 6vh; + margin-bottom: 2vh; + + } + width: 100%; + text-align: center; + //padding-top: 30px; + display: block; + align-items: center; + justify-content: center; + + &-alternative { + line-height: 36px; + } + } + } } diff --git a/src/sass/views/includes/slideToAcceptSuccess.scss b/src/sass/views/includes/slideToAcceptSuccess.scss index 68312c7a4..f64dd6154 100644 --- a/src/sass/views/includes/slideToAcceptSuccess.scss +++ b/src/sass/views/includes/slideToAcceptSuccess.scss @@ -12,12 +12,6 @@ slide-to-accept-success { .slide-success { $duration: 400ms; - &__windows-background { - background: $v-success-bg-color; - height: 100%; - width: 100%; - position: fixed; - } &__background { $start-radius: 5; $scale-factor: 20; @@ -40,9 +34,11 @@ slide-to-accept-success { &__content { position: relative; z-index: 1; - margin-top: -20vh; + margin-top: -10vh; > img { + width: 45vw; + max-width: 166px; margin-bottom: 1.8rem; -webkit-transform: translateY(5rem); transform: translateY(5rem); @@ -59,7 +55,7 @@ slide-to-accept-success { &__header { color: #FFFFFF; - font-size: 26px; + font-size: 29px; -webkit-transform: translateY(5rem); transform: translateY(5rem); opacity: 0; @@ -72,6 +68,26 @@ slide-to-accept-success { opacity: 1; } } + &__share { + transition: transform $duration ease, opacity $duration ease; + transition-delay: 600ms; + opacity: 0; + margin-top: 15vh; + span { + color: #FFF; + font-size: 22px; + height: 28px; + } + img { + height: 28px; + width: auto; + vertical-align: bottom; + margin-right: 4px; + } + &.reveal { + opacity: 0.79; + } + } } &__footer { @@ -98,11 +114,11 @@ slide-to-accept-success { &__btn { display: block; color: #FFFFFF; - font-size: 18px; + font-size: 22px; font-weight: 600; letter-spacing: 2.86px; - padding: 1rem 0 1.1rem; - border-top: 1px solid rgba(255, 255, 255, .45); + padding: 2rem 0 2.1rem; + border-top: 1px solid rgba(255, 255, 255, 0.25); cursor: pointer; } } diff --git a/src/sass/views/tab-home.scss b/src/sass/views/tab-home.scss index 66a2f1d58..708ff4fad 100644 --- a/src/sass/views/tab-home.scss +++ b/src/sass/views/tab-home.scss @@ -69,6 +69,25 @@ } } } + .buttons { + margin: 6px auto -12px; + max-width: 600px; + >.col { + padding: 5px 10px; + margin-bottom: 0; + } + .button { + border: 2px solid; + border-radius: 47px; + padding: 0 15px 0 15px; + text-align: center; + width: 100%; + font-size: 19px; + font-weight: bolder; + min-height: auto; + line-height: 36px; + } + } .wallet-coin-logo { vertical-align: middle; margin-right: 5px; diff --git a/src/sass/views/walletDetails.scss b/src/sass/views/walletDetails.scss index 9e651f871..6b760bbc4 100644 --- a/src/sass/views/walletDetails.scss +++ b/src/sass/views/walletDetails.scss @@ -135,11 +135,12 @@ &.status-bar { margin-top: 20px; + margin-top: env(safe-area-inset-top); } } .bar-header { border: 0; - background: none; + background: rgb(238, 182, 64); .title, .button { color: #fff; } @@ -153,7 +154,7 @@ ion-content { &.collapsible { - margin-top: 210px; + margin-top: 230px; } padding-top: 0; @@ -190,12 +191,34 @@ transform: translateY(100px); } } + + .send-receive-buttons { + max-width: 600px; + position: absolute; + bottom: 20px; + + >.col { + padding: 5px 10px; + margin-bottom: 0; + } + .button { + border: 2px solid; + border-radius: 47px; + padding: 0 15px 0 15px; + text-align: center; + width: 100%; + font-size: 19px; + font-weight: bolder; + min-height: auto; + line-height: 36px; + } + } } .amount { width: 100%; text-align: center; color: #fff; - height: 210px; + height: 230px; padding-top: 40px; display: block; align-items: center; diff --git a/test/karma.conf.js b/test/karma.conf.js index 002d40c91..b4f64af73 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -17,6 +17,8 @@ module.exports = function(config) { files: [ 'node_modules/angular/angular.js', + 'bitanalytics/bitanalytics-0.1.0.js', + // From Gruntfile.js 'bower_components/qrcode-generator/js/qrcode.js', 'bower_components/qrcode-generator/js/qrcode_UTF8.js', diff --git a/www/img/icon-alternative-currency-black.svg b/www/img/icon-alternative-currency-black.svg new file mode 100644 index 000000000..e9b175256 --- /dev/null +++ b/www/img/icon-alternative-currency-black.svg @@ -0,0 +1,22 @@ + + + + 3A719124-019D-470F-908A-5D61F117A295 + Created with sketchtool. + + + + + + + + + + + + + + + + + diff --git a/www/img/icon-sent-successful.svg b/www/img/icon-sent-successful.svg new file mode 100644 index 000000000..070357ddf --- /dev/null +++ b/www/img/icon-sent-successful.svg @@ -0,0 +1,10 @@ + + + + + + diff --git a/www/img/icon-share-white.svg b/www/img/icon-share-white.svg new file mode 100644 index 000000000..eeb3e7b6b --- /dev/null +++ b/www/img/icon-share-white.svg @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/www/index.html b/www/index.html index 4c73317e3..ecc2d923c 100644 --- a/www/index.html +++ b/www/index.html @@ -11,9 +11,8 @@ - Bitcoin.com Wallet - Bitcoin.com Wallet - - + Bitcoin.com Wallet + @@ -31,7 +30,7 @@ - + diff --git a/www/views/amount.html b/www/views/amount.html index af4e9d55c..77c52f96c 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -1,82 +1,99 @@ - {{'Enter amount' | translate}} + {{'Enter Amount' | translate}} - + - +
-
-
- Minimum amount: {{minShapeshiftAmount}}
- Maximum amount: {{maxShapeshiftAmount}}
+
+
- {{ amountModel.amount || 0 }}{{unit}} + ng-class="{long: vm.amount.length > 5, 'very-long': vm.amount.length > 10}"> + {{vm.amount}} {{vm.unit}}
- {{globalResult}} {{unit}} + {{vm.globalResult}} {{vm.unit}}
- {{alternativeAmount || '0.00'}} {{alternativeUnit}} + {{vm.alternativeAmount || '0.00'}} {{vm.alternativeUnit}}
-
+
-
- - + -
+
+
+ +
+ +
+ Available Funds:{{vm.availableFunds}} +
-
+
+ +
+ +
-
7
-
8
-
9
+
7
+
8
+
9
-
4
-
5
-
6
+
4
+
5
+
6
-
1
-
2
-
3
+
1
+
2
+
3
-
.
-
0
-
+
.
+
0
+
+
+
+ {{amountUnitStr}} +
+ {{altAmountStr | uppercase}} +
+
+
+ {{altAmountStr | uppercase}} +
+ {{amountUnitStr}} +
+
+
- +
@@ -57,12 +71,6 @@ {{address}}
-
- Amount - - {{amountUnitStr}} - {{altAmountStr}} - -
diff --git a/www/views/includes/amount.html b/www/views/includes/amount.html new file mode 100644 index 000000000..361dededc --- /dev/null +++ b/www/views/includes/amount.html @@ -0,0 +1,4 @@ +
+ {{start}}{{middle}}{{end}}{{currency}} +
\ No newline at end of file diff --git a/www/views/includes/slideToAcceptSuccess.html b/www/views/includes/slideToAcceptSuccess.html index 923eab25c..9995001ae 100644 --- a/www/views/includes/slideToAcceptSuccess.html +++ b/www/views/includes/slideToAcceptSuccess.html @@ -1,13 +1,16 @@
+ ng-class="{'fill-screen': fillScreen}">
- +
Payment Sent
+