Skip to content

Commit 3c3eecc

Browse files
committed
Splash screen
1 parent c13304a commit 3c3eecc

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

Diff for: index.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const registerIPCHandlers = require('./backend/ipc.js')
66
const registerMenu = require('./backend/menu.js')
77

88
let win = null // main window
9+
let splash = null
10+
let splashTimeout = null
911

1012
// START APP
1113
function createWindow () {
@@ -17,23 +19,37 @@ function createWindow () {
1719
nodeIntegration: false,
1820
webSecurity: true,
1921
enableRemoteModule: false,
20-
preload: path.join(__dirname, "preload.js")
22+
preload: path.join(__dirname, "preload.js"),
23+
show: false
2124
}
2225
})
2326
// and load the index.html of the app.
2427
win.loadFile('ui/arduino/index.html')
28+
// If the app takes a while to open, show splash screen
29+
splashTimeout = setTimeout(() => {
30+
// Create the splash screen
31+
splash = new BrowserWindow({
32+
width: 560,
33+
height: 180,
34+
transparent: true,
35+
frame: false,
36+
alwaysOnTop: true
37+
});
38+
splash.loadFile('ui/arduino/splash.html')
39+
}, 250)
40+
41+
win.once('ready-to-show', () => {
42+
clearTimeout(splashTimeout)
43+
if (splash) splash.destroy()
44+
win.show()
45+
})
2546

2647
registerIPCHandlers(win, ipcMain, app)
2748
registerMenu(win)
2849

2950
app.on('activate', () => {
3051
if (BrowserWindow.getAllWindows().length === 0) createWindow()
3152
})
32-
// app.on('window-all-closed', () => {
33-
// if (process.platform !== 'darwin') app.quit()
34-
// })
3553
}
3654

37-
38-
// TODO: Loading splash screen
39-
app.whenReady().then(createWindow)
55+
app.on('ready', createWindow)

Diff for: ui/arduino/splash.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Arduino Lab for MicroPython</title>
6+
<style media="screen">
7+
body {
8+
margin: 0;
9+
background: white;
10+
width: 100%;
11+
height: 100%;
12+
display: flex;
13+
align-items: center;
14+
justify-content: center;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<img width="100%" src="media/about_image.png" alt="Arduino Lab For MicroPython Logo">
20+
</body>
21+
</html>

0 commit comments

Comments
 (0)