Skip to content

Commit

Permalink
Merge pull request #479 from ZIMkaRU/feature/add-button-to-minimize-l…
Browse files Browse the repository at this point in the history
…oading-window

Add button to minimize loading window
  • Loading branch information
ezewer authored Jan 20, 2025
2 parents db9fbb5 + 5be96fd commit 50cb307
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/window-creators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ const createLoadingWindow = async () => {
'loadingWindow',
{
width: 350,
height: 350
height: 350,
maximizable: false,
fullscreenable: false
}
)

Expand Down
50 changes: 50 additions & 0 deletions src/window-creators/layouts/app-init.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,44 @@
font-family: "Roboto", sans-serif;
}

.win-control-btn {
position: absolute;
top: 0;
right: 0;
display: block;
min-height: 30px;
margin: 0;
padding: 5px;
}

.minimize-btn {
position: relative;
display: block;
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #172d3e;
transition: background-color .3s;
cursor: pointer;
}

.minimize-btn::after {
content: "";
display: block;
position: absolute;
width: 12px;
height: 1px;
background: #9b9a9a;
bottom: 9px;
left: calc((30px - 12px) / 2);
}

.minimize-btn:hover,
.minimize-btn:active,
.minimize-btn:focus {
background-color: #1c3649;
}

.lds-roller {
display: inline-block;
position: absolute;
Expand Down Expand Up @@ -190,6 +228,9 @@
</head>

<body class="body">
<div class="win-control-btn">
<div id="minBtn" class="minimize-btn"></div>
</div>
<div class="lds-roller">
<div></div>
<div></div>
Expand All @@ -210,6 +251,15 @@
window.addEventListener('load', () => {
const rollers = document.getElementsByClassName('lds-roller')
const descriptionElem = document.getElementById('description')
const minBtnElem = document.getElementById('minBtn')

minBtnElem.onclick = async () => {
try {
await window.bfxReportElectronApi?.hideLoadingWindow()
} catch (err) {
console.error(err)
}
}

setTimeout(() => {
for (const roller of rollers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@ const wins = require('../windows')
const IpcChannelHandlers = require('./ipc.channel.handlers')

class GeneralIpcChannelHandlers extends IpcChannelHandlers {
#hideLoadingWindow = null

constructor (...args) {
super(...args)

// Resolve circular dependency issue
this.#hideLoadingWindow = require(
'../change-loading-win-visibility-state'
).hideLoadingWindow
}

async exitHandler (event, args) {
return app.exit(args?.code ?? 0)
}

async hideLoadingWindowHandler (event, args) {
await this.#hideLoadingWindow()
}

async getTitleHandler (event, args) {
return wins.mainWindow.getTitle()
}
Expand Down
1 change: 1 addition & 0 deletions src/window-creators/main-renderer-ipc-bridge/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const CHANNEL_NAMES = {

const GENERAL_INVOKE_METHOD_NAMES = {
EXIT: 'exit',
HIDE_LOADING_WINDOW: 'hideLoadingWindow',
GET_TITLE: 'getTitle'
}
const GENERAL_EVENT_METHOD_NAMES = {
Expand Down

0 comments on commit 50cb307

Please sign in to comment.