From cacf5f63edb69817745e98daa25e04652dbcd855 Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Mon, 21 Aug 2023 18:57:03 +0200 Subject: [PATCH] enh(loader): display the cesium logo, in the loader div, instead of the text "Cesium" enh(home): Use larger logo, on medium mobile screen fix(home): Do not ask fullscreen toggle, if user response "no" (store response in settings) fix(home): Remove the state 'app.login' (menu now use loginAndGo() that open the wallet) --- www/index.html | 5 ++- www/js/controllers/app-controllers.js | 36 +++++++++++++++++----- www/js/controllers/home-controllers.js | 28 +++++++++++++---- www/js/controllers/login-controllers.js | 35 --------------------- www/js/controllers/transfer-controllers.js | 2 +- www/js/controllers/wot-controllers.js | 3 +- www/js/services/settings-services.js | 1 + www/templates/home/home.html | 2 +- www/templates/menu.html | 6 ++-- 9 files changed, 61 insertions(+), 57 deletions(-) diff --git a/www/index.html b/www/index.html index 59b00cdad..4b500bcee 100644 --- a/www/index.html +++ b/www/index.html @@ -59,9 +59,8 @@ ng-class="{'nobackdrop': $root.tour, 'expert-mode': $root.settings.expertMode, 'demo': $root.config.demo && !$root.config.readonly, 'readonly': $root.config.readonly}" style="background-color: #1a237e;"> <ion-nav-view> - <div class="loader"> - <h3 style="text-align: center; padding-top: 25px; color: whitesmoke;"><b>Cesium</b></h3> - <h4 style="text-align: center; color: whitesmoke;"><i class="icon ion-load-a"></i></h4> + <div class="loader center"> + <div class="logo"></div> </div> </ion-nav-view> diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index 875081255..2b4464c7e 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -204,8 +204,8 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ if (csConfig.httpsMode && $window.location && $window.location.protocol !== 'https:') { var href = $window.location.href; var hashIndex = href.indexOf('#'); - var rootPath = (hashIndex != -1) ? href.substr(0, hashIndex) : href; - rootPath = 'https' + rootPath.substr(4); + var rootPath = (hashIndex !== -1) ? href.substring(0, hashIndex) : href; + rootPath = 'https' + rootPath.substring(4); href = rootPath + $state.href(state); if (csConfig.httpsModeDebug) { // Debug mode: just log, then continue @@ -569,19 +569,41 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ var skip = $scope.fullscreen || !UIUtils.screen.isSmall() || !Device.isWeb(); if (skip) return; + // Already ask + if (csSettings.data.useFullscreen === false) { + $scope.toggleFullscreen(false); + return; + } + + // User already say 'yes' => need o ask again (chrome will avoid changed if no gesture has been done) + //if (csSettings.data.useFullscreen === true) { + // $scope.toggleFullscreen(true); + // return; + //} + return UIUtils.alert.confirm('CONFIRM.FULLSCREEN', undefined, { cancelText: 'COMMON.BTN_NO', okText: 'COMMON.BTN_YES' }) .then(function(confirm) { - if (!confirm) return; - $scope.toggleFullscreen(); + $scope.toggleFullscreen(confirm); }); }; - $scope.toggleFullscreen = function() { - $scope.fullscreen = !UIUtils.screen.fullscreen.isEnabled(); - UIUtils.screen.fullscreen.toggleAll(); + $scope.toggleFullscreen = function(enable, options) { + enable = angular.isDefined(enable) ? enable : !UIUtils.screen.fullscreen.isEnabled(); + + $scope.fullscreen = enable; + + if (enable !== UIUtils.screen.fullscreen.isEnabled()) { + UIUtils.screen.fullscreen.toggleAll(); + } + + // Save into settings + if ((csSettings.data.useFullscreen !== enable) && (!options || options.emitEvent !== false)) { + csSettings.data.useFullscreen = enable; + return $timeout(csSettings.store, 2000); + } }; // removeIf(no-device) diff --git a/www/js/controllers/home-controllers.js b/www/js/controllers/home-controllers.js index be727b9fd..46cb297ab 100644 --- a/www/js/controllers/home-controllers.js +++ b/www/js/controllers/home-controllers.js @@ -7,7 +7,7 @@ angular.module('cesium.home.controllers', ['cesium.platform', 'cesium.services'] .state('app.home', { - url: "/home?error&uri", + url: "/home?error&uri&login", views: { 'menuContent': { templateUrl: "templates/home/home.html", @@ -25,7 +25,7 @@ angular.module('cesium.home.controllers', ['cesium.platform', 'cesium.services'] ; function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $translate, $http, $q, $location, - UIUtils, BMA, Device, csConfig, csHttp, csCache, csPlatform, csNetwork, csCurrency, csSettings) { + UIUtils, BMA, Device, csConfig, csHttp, csCache, csPlatform, csNetwork, csCurrency, csSettings, csWallet) { 'ngInject'; $scope.loading = true; @@ -45,7 +45,6 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra } if (state && state.stateParams && state.stateParams.uri) { - return $scope.handleUri(state.stateParams.uri) .then(function() { $scope.loading = false; @@ -56,6 +55,7 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra $scope.node = csCurrency.data.node; $scope.loading = false; $scope.cleanLocationHref(state); + return $q.when(); } else { @@ -77,8 +77,10 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra $scope.$broadcast('$$rebind::loading'); // force rebind loading }, 200); + var hasLoginParam = state && state.stateParams && state.stateParams.login || false; + // Wait platform to be ready - csPlatform.ready() + return csPlatform.ready() .catch(function(err) { $scope.node = csCurrency.data.node; $scope.error = err; @@ -91,6 +93,14 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra $scope.loadingMessage = ''; $scope.loadingPct = 100; $scope.$broadcast('$$rebind::loading'); // force rebind loading + $scope.$broadcast('$$rebind::feed'); // force rebind feed + + // Open the login modal + if (hasLoginParam && !csWallet.isLogin() && !$scope.error) { + $scope.cleanLocationHref(state); + + return csWallet.login(); + } }); } }; @@ -126,8 +136,11 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra }; $scope.toggleFeed = function(show) { + $scope.showFeed = (show !== undefined) ? show : !$scope.showFeed; - $scope.$broadcast('$$rebind::feed'); // force rebind feed + if (!this.loading) { + $scope.$broadcast('$$rebind::feed'); // force rebind feed + } }; /* -- show/hide locales popup -- */ @@ -152,10 +165,13 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra // remove '?uri&error' from the location URI, and inside history $scope.cleanLocationHref = function(state) { + state = state || {stateName: 'app.home'}; + state.stateParams = state.stateParams || {}; if (state && state.stateParams) { var stateParams = angular.copy(state.stateParams); delete stateParams.uri; delete stateParams.error; + delete stateParams.login; $location.search(stateParams).replace(); @@ -167,7 +183,7 @@ function HomeController($scope, $state, $timeout, $interval, $ionicHistory, $tra }); return $state.go(state.stateName, stateParams, { reload: false, - inherit: true, + inherit: false, notify: false }); } diff --git a/www/js/controllers/login-controllers.js b/www/js/controllers/login-controllers.js index 47b0e1cbc..f921716f1 100644 --- a/www/js/controllers/login-controllers.js +++ b/www/js/controllers/login-controllers.js @@ -1,24 +1,6 @@ angular.module('cesium.login.controllers', ['cesium.services']) - .config(function($stateProvider) { - 'ngInject'; - - $stateProvider - .state('app.login', { - url: "/login", - views: { - 'menuContent': { - templateUrl: "templates/home/home.html", - controller: 'LoginCtrl' - } - } - }) - ; - }) - - .controller('LoginCtrl', LoginController) - .controller('LoginModalCtrl', LoginModalController) .controller('AuthCtrl', AuthController) @@ -26,23 +8,6 @@ angular.module('cesium.login.controllers', ['cesium.services']) ; -function LoginController($scope, $timeout, $controller, csWallet) { - 'ngInject'; - - // Initialize the super class and extend it. - angular.extend(this, $controller('HomeCtrl', {$scope: $scope})); - - $scope.showLoginModal = function() { - if ($scope.loading) return $timeout($scope.showLoginModal, 500); // recursive call - - if (!csWallet.isLogin() && !$scope.error) { - return $timeout(csWallet.login, 300); - } - }; - $scope.$on('$ionicView.enter', $scope.showLoginModal); - -} - function LoginModalController($scope, $timeout, $q, $ionicPopover, $window, CryptoUtils, csCrypto, ionicReady, UIUtils, BMA, Modals, csConfig, csSettings, Device, parameters) { 'ngInject'; diff --git a/www/js/controllers/transfer-controllers.js b/www/js/controllers/transfer-controllers.js index 03d370e77..dd774d50d 100644 --- a/www/js/controllers/transfer-controllers.js +++ b/www/js/controllers/transfer-controllers.js @@ -129,7 +129,7 @@ function TransferModalController($scope, $q, $translate, $timeout, $filter, $foc $scope.destPub = parameters.pubkey; } if (parameters.amount) { - var amount = Number(parameters.amount) + var amount = Number(parameters.amount); // Trunc at 2 decimals $scope.formData.amount = !isNaN(amount) ? Math.trunc(parseFloat(parameters.amount) * 100) / 100 : null; $scope.formData.useRelative=false; diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 6336b6df7..3c9e50f13 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -1118,7 +1118,8 @@ function WotIdentityViewController($scope, $rootScope, $controller, $timeout, $s } $scope.removeActionParamInLocationHref(state); - } + }; + var onLoadSuccess = function() { $scope.doMotion(); diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index ff47d939a..988ea9686 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -93,6 +93,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) useRelative: false, useLocalStorage: !!$window.localStorage, // Overwritten to false if not a device useLocalStorageEncryption: false, + useFullscreen: null, persistCache: false, // disable by default (waiting resolution of issue #885) walletHistoryTimeSecond: 30 * 24 * 60 * 60, // 30 days walletHistorySliceSecond: 5 * 24 * 60 * 60, // download using 5 days slice - need for cache diff --git a/www/templates/home/home.html b/www/templates/home/home.html index 26cd84200..5bdc95c17 100644 --- a/www/templates/home/home.html +++ b/www/templates/home/home.html @@ -1,4 +1,4 @@ -<ion-view id="home" bind-notifier="{locale:$root.settings.locale.id, feed: showFeed, loading: loading}"> +<ion-view id="home" bind-notifier="{locale:$root.settings.locale.id, loading: loading}"> <!-- no title --> <ion-nav-title></ion-nav-title> diff --git a/www/templates/menu.html b/www/templates/menu.html index 9af34b7a3..141aa8da8 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -68,7 +68,8 @@ <div class="visible-sm visible-xs hero"> <div class="content"> - <i class="avatar avatar-member hero-icon" ng-if="!walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}" ng-click="!login ? showHome() : loginAndGo()" menu-close></i> + <i class="avatar avatar-member hero-icon" ng-if="!walletData.avatar" ng-class="{'royal-bg': login, 'stable-bg': !login}" + ng-click="loginAndGo()" menu-close></i> <a class="avatar hero-icon" ng-if="walletData.avatar" style="background-image: url('{{walletData.avatar.src}}')" ui-sref="app.view_wallet" menu-close></a> <h4 ng-if="login"> <a class="light" ui-sref="app.view_wallet" menu-close> @@ -77,8 +78,7 @@ </a> </h4> <h4 ng-if="!login"> - <a class="light" ui-sref="app.login" - menu-close> + <a class="light" ng-click="loginAndGo()" menu-close> {{'COMMON.BTN_LOGIN'|translate}} <i class="ion-arrow-right-b"></i> </a> -- GitLab