Skip to content

Commit e373a3a

Browse files
new zoom config
1 parent 9e6d2ca commit e373a3a

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

info/dev/preparing-changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- electron version update.
2+
- new zoom config.

info/dev/requests.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ Made by Me
3939

4040
=======================================================
4141

42-
--> Criar sistema de alterar o tamanho da fonte do aplicativo (de 50% para 200%) (CSS zoom)
43-
4442
--> Adicionar opção para suporte de thumbs com parametros de animação.
4543
--> Fazer a opção para o app iniciar sozinho com o sistema operacional.
4644

src/app/organisms/settings/pages/Appearance.jsx

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useRef } from 'react';
22

33
import initMatrix from '../../../../client/initMatrix';
44

@@ -12,20 +12,51 @@ import { toggleAction } from '../Api';
1212
import {
1313
toggleSystemTheme, toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents,
1414
} from '../../../../client/action/settings';
15+
import { tinyAppZoomValidator } from '../../../../util/tools';
1516

1617
function AppearanceSection() {
18+
1719
const [, updateState] = useState({});
20+
1821
const [isAnimateAvatarsHidden, setAnimateAvatarsHidden] = useState(false);
1922
const [isEmbedDisabled, setEmbedDisabled] = useState(false);
2023
const [isUNhoverDisabled, setUNhoverDisabled] = useState(false);
2124

25+
const ponyHouseZoomRef = useRef(null);
26+
const ponyHouseZoomRangeRef = useRef(null);
27+
2228
useEffect(() => {
2329

2430
const content = initMatrix.matrixClient.getAccountData('pony.house.appearance')?.getContent() ?? {};
31+
const zoomApp = Number(global.localStorage.getItem('pony-house-zoom'));
32+
2533
setAnimateAvatarsHidden((content.isAnimateAvatarsHidden === true));
2634
setEmbedDisabled((content.isEmbedDisabled === true));
2735
setUNhoverDisabled((content.isUNhoverDisabled === true));
2836

37+
const ponyHouseZoom = $(ponyHouseZoomRef.current);
38+
const ponyHouseZoomRange = $(ponyHouseZoomRangeRef.current);
39+
40+
ponyHouseZoom.val(tinyAppZoomValidator(zoomApp));
41+
ponyHouseZoomRange.val(tinyAppZoomValidator(zoomApp));
42+
43+
ponyHouseZoomRange.on('change keyup keydown keypress input', () => {
44+
45+
const newValue = Number(ponyHouseZoomRange.val());
46+
const value = tinyAppZoomValidator(newValue);
47+
ponyHouseZoom.val(value);
48+
49+
});
50+
51+
ponyHouseZoom.on('change keyup keydown keypress', () => {
52+
53+
const newValue = Number(ponyHouseZoom.val());
54+
const value = tinyAppZoomValidator(newValue);
55+
if (newValue !== value) ponyHouseZoom.val(value);
56+
ponyHouseZoomRange.val(value);
57+
58+
});
59+
2960
}, []);
3061

3162
return (
@@ -34,6 +65,7 @@ function AppearanceSection() {
3465
<div className="card noselect mb-3">
3566
<ul className="list-group list-group-flush">
3667
<li className="list-group-item very-small text-gray">Theme</li>
68+
3769
<SettingTile
3870
title="Follow system theme"
3971
options={(
@@ -45,6 +77,7 @@ function AppearanceSection() {
4577
)}
4678
content={<div className="very-small text-gray">Use light or dark mode based on the system settings.</div>}
4779
/>
80+
4881
<SettingTile
4982
title="Theme"
5083
content={(
@@ -67,6 +100,30 @@ function AppearanceSection() {
67100
</div>
68101
)}
69102
/>
103+
104+
<li className="list-group-item">
105+
106+
<label for='pony_house_zoom' className="form-label small">Zoom</label>
107+
108+
<input ref={ponyHouseZoomRef} type="number" max={200} min={50} className="form-control form-control-bg" id='pony_house_zoom' />
109+
<input ref={ponyHouseZoomRangeRef} max={200} min={50} type="range" class="form-range" />
110+
111+
<div className="very-small text-gray">
112+
{`Set the application zoom. If the configuration doesn't work, it's because your ${__ENV_APP__.electron_mode ? 'client' : 'browser'} is not compatible. (Beta)`}
113+
<button type="button" className="ms-3 btn btn-sm btn-secondary" onClick={async () => {
114+
115+
const ponyHouseZoomRange = $(ponyHouseZoomRangeRef.current);
116+
const newValue = Number(ponyHouseZoomRange.val());
117+
const value = tinyAppZoomValidator(newValue);
118+
119+
global.localStorage.setItem('pony-house-zoom', value);
120+
$('body').css('zoom', `${value}%`);
121+
122+
}}>Change zoom</button>
123+
</div>
124+
125+
</li>
126+
70127
</ul>
71128
</div>
72129

src/app/templates/client/Client.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import initMatrix from '../../../client/initMatrix';
1818
import navigation from '../../../client/state/navigation';
1919
import cons from '../../../client/state/cons';
2020
import DragDrop from './DragDrop';
21-
import { btModal, dice, resizeWindowChecker, scrollFixer } from '../../../util/tools';
21+
import { btModal, dice, resizeWindowChecker, scrollFixer, tinyAppZoomValidator } from '../../../util/tools';
2222
import { startUserAfk, stopUserAfk } from '../../../util/userStatusEffects';
2323
import Mods from './Mods';
2424
import appLoadMsg from '../../../../mods/appLoadMsg';
@@ -154,6 +154,7 @@ function Client() {
154154
});
155155
}
156156

157+
$('body').css('zoom', `${tinyAppZoomValidator(Number(global.localStorage.getItem('pony-house-zoom')))}%`);
157158
const tinyMod = <Mods />;
158159

159160
resizeWindowChecker();

src/util/tools.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ let resizePlace = null;
88
let resizeTimeout = null;
99
let head;
1010

11+
// Zoom Validator
12+
const tinyAppZoomValidator = (value) => !Number.isNaN(value) && Number.isFinite(value) ? value >= 50 ? value <= 200 ? value : 200 : 100 : 100;
13+
export { tinyAppZoomValidator };
14+
1115
// Message to number
1216
export function textValueToNumber(text = '', nb = 11) {
1317

0 commit comments

Comments
 (0)