Skip to content

Commit 4ebd2b4

Browse files
authored
Merge pull request #208 from Resgrid/develop
RU-T47 Fixing build
2 parents ba305b6 + f93e920 commit 4ebd2b4

File tree

6 files changed

+88
-14
lines changed

6 files changed

+88
-14
lines changed

assets/icon.ico

19.4 KB
Binary file not shown.

electron-builder.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ module.exports = {
4646
{ target: 'nsis', arch: ['x64'] },
4747
{ target: 'portable', arch: ['x64'] },
4848
],
49-
icon: 'assets/icon.png',
49+
icon: 'assets/icon.ico',
5050
},
5151

5252
nsis: {
5353
oneClick: false,
5454
allowToChangeInstallationDirectory: true,
55-
installerIcon: 'assets/icon.png',
56-
uninstallerIcon: 'assets/icon.png',
57-
installerHeaderIcon: 'assets/icon.png',
55+
installerIcon: 'assets/icon.ico',
56+
uninstallerIcon: 'assets/icon.ico',
57+
installerHeaderIcon: 'assets/icon.ico',
5858
createDesktopShortcut: true,
5959
createStartMenuShortcut: true,
6060
shortcutName: 'Resgrid Unit',

lint.json

267 KB
Binary file not shown.

lint.txt

4.09 KB
Binary file not shown.

scripts/generate-ico.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* eslint-env node */
2+
const fs = require('fs');
3+
const path = require('path');
4+
const { execSync } = require('child_process');
5+
6+
const inputPng = path.join(__dirname, '../assets/icon.png');
7+
const outputIco = path.join(__dirname, '../assets/icon.ico');
8+
const tempPng = path.join(__dirname, '../assets/icon-256.png');
9+
10+
try {
11+
console.log('Resizing icon to 256x256 using PowerShell...');
12+
// Use PowerShell to resize the image because we don't want to add sharp/jimp dependencies just for this one-off
13+
const psCommand = `
14+
Add-Type -AssemblyName System.Drawing;
15+
$img = [System.Drawing.Image]::FromFile('${inputPng}');
16+
$newImg = new-object System.Drawing.Bitmap(256, 256);
17+
$graph = [System.Drawing.Graphics]::FromImage($newImg);
18+
$graph.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic;
19+
$graph.DrawImage($img, 0, 0, 256, 256);
20+
$newImg.Save('${tempPng}', [System.Drawing.Imaging.ImageFormat]::Png);
21+
$img.Dispose();
22+
$newImg.Dispose();
23+
$graph.Dispose();
24+
`;
25+
26+
execSync(`powershell -Command "${psCommand.replace(/\n/g, ' ')}"`, { stdio: 'inherit' });
27+
28+
if (!fs.existsSync(tempPng)) {
29+
throw new Error('Failed to create resized PNG');
30+
}
31+
32+
console.log('Generating ICO file...');
33+
const pngBuffer = fs.readFileSync(tempPng);
34+
// size variable removed as it was unused
35+
36+
// ICO Header
37+
// 0-1: Reserved (0)
38+
// 2-3: Type (1 for ICO)
39+
// 4-5: Number of images (1)
40+
const header = Buffer.alloc(6);
41+
header.writeUInt16LE(0, 0);
42+
header.writeUInt16LE(1, 2);
43+
header.writeUInt16LE(1, 4);
44+
45+
// Icon Directory Entry
46+
// 0: Width (0 for 256)
47+
// 1: Height (0 for 256)
48+
// 2: Color count (0 for >= 256 colors)
49+
// 3: Reserved (0)
50+
// 4-5: Color planes (1)
51+
// 6-7: Bits per pixel (32)
52+
// 8-11: Size of image data
53+
// 12-15: Offset of image data
54+
const entry = Buffer.alloc(16);
55+
entry.writeUInt8(0, 0); // 256 width -> 0
56+
entry.writeUInt8(0, 1); // 256 height -> 0
57+
entry.writeUInt8(0, 2);
58+
entry.writeUInt8(0, 3);
59+
entry.writeUInt16LE(1, 4);
60+
entry.writeUInt16LE(32, 6);
61+
entry.writeUInt32LE(pngBuffer.length, 8);
62+
entry.writeUInt32LE(6 + 16, 12); // Header (6) + 1 Entry (16)
63+
64+
const icoBuffer = Buffer.concat([header, entry, pngBuffer]);
65+
fs.writeFileSync(outputIco, icoBuffer);
66+
67+
// Clean up
68+
fs.unlinkSync(tempPng);
69+
70+
console.log(`Successfully created ${outputIco}`);
71+
} catch (error) {
72+
console.error('Error generating ICO:', error);
73+
process.exit(1);
74+
}

src/components/ui/bottomsheet/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const BottomSheetContext = createContext<{
4242
}>({
4343
visible: false,
4444
bottomSheetRef: null,
45-
handleClose: () => { },
46-
handleOpen: () => { },
45+
handleClose: () => {},
46+
handleOpen: () => {},
4747
});
4848

4949
type IBottomSheetProps = React.ComponentProps<typeof GorhomBottomSheet>;
@@ -166,14 +166,14 @@ export const BottomSheetContent = ({ ...props }: IBottomSheetContent) => {
166166
const keyDownHandlers = useMemo(() => {
167167
return Platform.OS === 'web'
168168
? {
169-
onKeyDown: (e: React.KeyboardEvent) => {
170-
if (e.key === 'Escape') {
171-
e.preventDefault();
172-
handleClose();
173-
return;
174-
}
175-
},
176-
}
169+
onKeyDown: (e: React.KeyboardEvent) => {
170+
if (e.key === 'Escape') {
171+
e.preventDefault();
172+
handleClose();
173+
return;
174+
}
175+
},
176+
}
177177
: {};
178178
}, [handleClose]);
179179

0 commit comments

Comments
 (0)