From a54df263e27dc6e81160aacbabc124f4f11e6d00 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 17 May 2016 18:59:31 -0300 Subject: [PATCH] replace all toggle buttons --- Gruntfile.js | 1 - public/views/preferences.html | 31 ++++++-------- public/views/preferencesGlobal.html | 54 ++++++++++++------------- src/css/ionic-migration.css | 10 +++++ src/js/app.js | 1 - src/js/controllers/preferences.js | 40 ++++++++---------- src/js/controllers/preferencesGlobal.js | 37 ++++++----------- 7 files changed, 76 insertions(+), 98 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index cffc538c8..bbd916a96 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -97,7 +97,6 @@ module.exports = function(grunt) { 'bower_components/ng-lodash/build/ng-lodash.js', 'bower_components/angular-qrcode/angular-qrcode.js', 'bower_components/angular-gettext/dist/angular-gettext.js', - 'bower_components/angular-ui-switch/angular-ui-switch.js', 'bower_components/angular-sanitize/angular-sanitize.js', 'bower_components/ng-csv/build/ng-csv.js', 'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js' diff --git a/public/views/preferences.html b/public/views/preferences.html index 5d9e11187..d7d8bde31 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -1,6 +1,6 @@ -
@@ -33,17 +33,17 @@
-
+
Color
  • - {{preferences.externalSource}} + {{preferences.externalSource}}
    Hardware wallet
    -
  • +
  • @@ -56,7 +56,7 @@
  • - +
    Advanced
  • @@ -67,20 +67,13 @@
    + + Request Spending Password + - - + + Scan Fingerprint +
    diff --git a/public/views/preferencesGlobal.html b/public/views/preferencesGlobal.html index e86e4c86e..02f346db8 100644 --- a/public/views/preferencesGlobal.html +++ b/public/views/preferencesGlobal.html @@ -1,14 +1,11 @@ -
    -

    -
      +
      • {{prefGlobal.currentLanguageName|translate}} @@ -18,7 +15,8 @@

      -
        + +
        • {{prefGlobal.unitName}} @@ -26,6 +24,7 @@
          Unit
        • +
        • {{prefGlobal.selectedAlternative.name}} @@ -35,7 +34,8 @@

        -
          + +
          • {{prefGlobal.feeOpts[prefGlobal.currentFeeLevel]|translate}} @@ -43,41 +43,37 @@
            Bitcoin Network Fee Policy
          • -
          • - -
            Use Unconfirmed Funds
            -
          + + + Use Unconfirmed Funds + +

          -
            -
          • - -
            Enable push notifications
            -
          • -
          + + Enable push notifications +

          -
            -
          • - -
            Enable Glidera Service
            -
          • -
          + + + Enable Glidera Service +

          -
            -
          • - -
            Enable Coinbase Service
            -
          • -
          + + + Enable Coinbase Service +

          +
          • About Copay
          +
          Push notifications for Copay are currently disabled. Enable them in the Settings app.
            diff --git a/src/css/ionic-migration.css b/src/css/ionic-migration.css index 2578e28bc..3dbe3d652 100644 --- a/src/css/ionic-migration.css +++ b/src/css/ionic-migration.css @@ -16,6 +16,16 @@ display: inherit; } +.item-toggle .toggle { + right: 28px; +} + +.toggle-label { + color: rgb(41, 55, 68); + font-size: 14px; + margin-left: 5px; +} + button, .button { min-width: inherit; min-height: inherit; diff --git a/src/js/app.js b/src/js/app.js index 06da998af..123642847 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -8,7 +8,6 @@ var modules = [ 'gettext', 'ionic', 'ngLodash', - 'uiSwitch', 'ngSanitize', 'ngCsv', 'bwcModule', diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index fb3e98b31..5e60440c0 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -6,20 +6,21 @@ angular.module('copayApp.controllers').controller('preferencesController', var fc = profileService.focusedClient; var config = configService.getSync(); $scope.deleted = false; + if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic) { $scope.deleted = true; } this.init = function() { if (fc) { - $scope.encrypt = walletService.isEncrypted(fc); + $scope.encryptEnabled = walletService.isEncrypted(fc); this.externalSource = fc.getPrivKeyExternalSourceName() == 'ledger' ? "Ledger" : null; // TODO externalAccount //this.externalIndex = fc.getExternalIndex(); } this.touchidAvailable = fingerprintService.isAvailable(); - $scope.touchid = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null; + $scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[fc.credentials.walletId] : null; }; var handleEncryptedWallet = function(client, cb) { @@ -29,60 +30,56 @@ angular.module('copayApp.controllers').controller('preferencesController', }); }; - var unwatchEncrypt = $scope.$watch('encrypt', function(val) { - var fc = profileService.focusedClient; + $scope.encryptChange = function() { if (!fc) return; + var val = $scope.encryptEnabled; if (val && !walletService.isEncrypted(fc)) { $rootScope.$emit('Local/NeedsPassword', true, function(err, password) { if (err || !password) { - $scope.encrypt = false; + $scope.encryptEnabled = false; return; } profileService.setPrivateKeyEncryptionFC(password, function() { $rootScope.$emit('Local/NewEncryptionSetting'); - $scope.encrypt = true; + $scope.encryptEnabled = true; }); }); } else { if (!val && walletService.isEncrypted(fc)) { handleEncryptedWallet(fc, function(err) { if (err) { - $scope.encrypt = true; + $scope.encryptEnabled = true; return; } profileService.disablePrivateKeyEncryptionFC(function(err) { $rootScope.$emit('Local/NewEncryptionSetting'); if (err) { - $scope.encrypt = true; + $scope.encryptEnabled = true; $log.error(err); return; } - $scope.encrypt = false; + $scope.encryptEnabled = false; }); }); } } - }); + }; - var unwatchRequestTouchid = $scope.$watch('touchid', function(newVal, oldVal) { - if (newVal == oldVal || $scope.touchidError) { - $scope.touchidError = false; - return; - } + $scope.touchidChange = function() { var walletId = fc.credentials.walletId; var opts = { touchIdFor: {} }; - opts.touchIdFor[walletId] = newVal; + opts.touchIdFor[walletId] = $scope.touchidEnabled; fingerprintService.check(fc, function(err) { if (err) { $log.debug(err); $timeout(function() { $scope.touchidError = true; - $scope.touchid = oldVal; + $scope.touchidEnabled = false; }, 100); return; } @@ -90,14 +87,9 @@ angular.module('copayApp.controllers').controller('preferencesController', if (err) { $log.debug(err); $scope.touchidError = true; - $scope.touchid = oldVal; + $scope.touchidEnabled = false; } }); }); - }); - - $scope.$on('$destroy', function() { - unwatchEncrypt(); - unwatchRequestTouchid(); - }); + }; }); diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js index 884e904e1..e55dac20e 100644 --- a/src/js/controllers/preferencesGlobal.js +++ b/src/js/controllers/preferencesGlobal.js @@ -36,24 +36,22 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', }); } - var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) { - if (newVal == oldVal) return; + $scope.spendUnconfirmedChange = function() { var opts = { wallet: { - spendUnconfirmed: newVal + spendUnconfirmed: $scope.spendUnconfirmed } }; configService.set(opts, function(err) { - $rootScope.$emit('Local/SpendUnconfirmedUpdated', newVal); + $rootScope.$emit('Local/SpendUnconfirmedUpdated', $scope.spendUnconfirmed); if (err) $log.debug(err); }); - }); + }; - var unwatchPushNotifications = $scope.$watch('pushNotifications', function(newVal, oldVal) { - if (newVal == oldVal) return; + $scope.pushNotificationsChange = function() { var opts = { pushNotifications: { - enabled: newVal + enabled: $scope.pushNotifications } }; configService.set(opts, function(err) { @@ -63,38 +61,29 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', pushNotificationsService.disableNotifications(profileService.walletClients); if (err) $log.debug(err); }); - }); + }; - var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) { - if (newVal == oldVal) return; + $scope.glideraChange = function() { var opts = { glidera: { - enabled: newVal + enabled: $scope.glideraEnabled } }; configService.set(opts, function(err) { $rootScope.$emit('Local/GlideraUpdated'); if (err) $log.debug(err); }); - }); + }; - var unwatchCoinbaseEnabled = $scope.$watch('coinbaseEnabled', function(newVal, oldVal) { - if (newVal == oldVal) return; + $scope.coinbaseChange = function() { var opts = { coinbase: { - enabled: newVal + enabled: $scope.coinbaseEnabled } }; configService.set(opts, function(err) { $rootScope.$emit('Local/CoinbaseUpdated'); if (err) $log.debug(err); }); - }); - - $scope.$on('$destroy', function() { - unwatchSpendUnconfirmed(); - unwatchGlideraEnabled(); - unwatchCoinbaseEnabled(); - unwatchPushNotifications(); - }); + }; });