|
1 | 1 | (function () { |
2 | 2 | 'use strict'; |
3 | 3 |
|
4 | | - angular.module('ariaNg').factory('ariaNgNativeElectronService', ['$q', 'ariaNgLogService', 'ariaNgLocalizationService', function ($q, ariaNgLogService, ariaNgLocalizationService) { |
| 4 | + angular.module('ariaNg').factory('ariaNgNativeElectronService', ['$window', '$q', 'ariaNgLogService', 'ariaNgLocalizationService', function ($window, $q, ariaNgLogService, ariaNgLocalizationService) { |
5 | 5 | var electron = angular.isFunction(window.nodeRequire) ? nodeRequire('electron') : {}; |
6 | 6 | var ipcRenderer = electron.ipcRenderer || {}; |
7 | 7 |
|
|
73 | 73 | setNativeTheme: function (theme) { |
74 | 74 | invokeMainProcessMethod('render-set-native-theme', theme); |
75 | 75 | }, |
76 | | - setTitleBarColor: function (titleBarBackgroundColor, titleBarSymbolColor) { |
77 | | - invokeMainProcessMethod('render-set-titlebar-color', titleBarBackgroundColor, titleBarSymbolColor); |
| 76 | + updateTitleBarBackgroundColor: function () { |
| 77 | + var titleBar = angular.element('#window-title-bar'); |
| 78 | + |
| 79 | + if (!titleBar || !titleBar[0]) { |
| 80 | + return; |
| 81 | + } |
| 82 | + |
| 83 | + var computedStyle = $window.getComputedStyle(titleBar[0]); |
| 84 | + var backgroundColor = computedStyle.getPropertyValue('background-color'); |
| 85 | + var symbolColor = computedStyle.getPropertyValue('color'); |
| 86 | + invokeMainProcessMethod('render-set-titlebar-color', backgroundColor, symbolColor); |
| 87 | + }, |
| 88 | + updateTitleBarBackgroundColorWithSweetAlertOverlay: function () { |
| 89 | + var titleBar = angular.element('#window-title-bar'); |
| 90 | + |
| 91 | + if (!titleBar || !titleBar[0]) { |
| 92 | + return; |
| 93 | + } |
| 94 | + |
| 95 | + var computedStyle = $window.getComputedStyle(titleBar[0]); |
| 96 | + var backgroundColor = computedStyle.getPropertyValue('background-color'); |
| 97 | + var symbolColor = computedStyle.getPropertyValue('color'); |
| 98 | + |
| 99 | + // This electron version not support transparent title bar, so we set hard code color |
| 100 | + var currentTheme = angular.element('body').hasClass('theme-dark') ? 'dark' : 'light'; |
| 101 | + |
| 102 | + if (currentTheme === 'light') { |
| 103 | + backgroundColor = 'rgb(148, 148, 148)'; |
| 104 | + } else if (currentTheme === 'dark') { |
| 105 | + backgroundColor = 'rgb(7, 7, 7)'; |
| 106 | + } |
| 107 | + |
| 108 | + invokeMainProcessMethod('render-set-titlebar-color', backgroundColor, symbolColor); |
| 109 | + }, |
| 110 | + updateTitleBarBackgroundColorWithModalOverlay: function () { |
| 111 | + var titleBar = angular.element('#window-title-bar'); |
| 112 | + |
| 113 | + if (!titleBar || !titleBar[0]) { |
| 114 | + return; |
| 115 | + } |
| 116 | + |
| 117 | + var computedStyle = $window.getComputedStyle(titleBar[0]); |
| 118 | + var backgroundColor = computedStyle.getPropertyValue('background-color'); |
| 119 | + var symbolColor = computedStyle.getPropertyValue('color'); |
| 120 | + |
| 121 | + // This electron version not support transparent title bar, so we set hard code color |
| 122 | + var currentTheme = angular.element('body').hasClass('theme-dark') ? 'dark' : 'light'; |
| 123 | + |
| 124 | + if (currentTheme === 'light') { |
| 125 | + backgroundColor = 'rgb(86, 86, 86)'; |
| 126 | + } else if (currentTheme === 'dark') { |
| 127 | + backgroundColor = 'rgb(6, 6, 6)'; |
| 128 | + } |
| 129 | + |
| 130 | + invokeMainProcessMethod('render-set-titlebar-color', backgroundColor, symbolColor); |
78 | 131 | }, |
79 | 132 | reload: function () { |
80 | 133 | invokeMainProcessMethod('render-reload-native-window'); |
|
0 commit comments