1- import React , { useState , useEffect } from 'react' ;
1+ import React , { useState , useEffect , useRef } from 'react' ;
22
33import initMatrix from '../../../../client/initMatrix' ;
44
@@ -12,20 +12,51 @@ import { toggleAction } from '../Api';
1212import {
1313 toggleSystemTheme , toggleMarkdown , toggleMembershipEvents , toggleNickAvatarEvents ,
1414} from '../../../../client/action/settings' ;
15+ import { tinyAppZoomValidator } from '../../../../util/tools' ;
1516
1617function 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
0 commit comments