@chem-po/react-native 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/hooks/useRefreshFontScale.js +16 -2
- package/lib/commonjs/hooks/useRefreshFontScale.js.map +1 -1
- package/lib/module/hooks/useRefreshFontScale.js +17 -3
- package/lib/module/hooks/useRefreshFontScale.js.map +1 -1
- package/lib/typescript/hooks/useRefreshFontScale.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/hooks/useRefreshFontScale.ts +16 -3
|
@@ -24,10 +24,24 @@ function useRefreshFontScale(disableFontScaling = false) {
|
|
|
24
24
|
fontScale: _reactNative.PixelRatio.getFontScale() ?? 1
|
|
25
25
|
});
|
|
26
26
|
refresh();
|
|
27
|
-
const
|
|
27
|
+
const appStateSub = _reactNative.AppState.addEventListener('change', nextState => {
|
|
28
28
|
if (nextState === 'active') refresh();
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
// On Android, font scale changes come through Dimensions 'change' events
|
|
32
|
+
// triggered by Android configuration changes. AppState alone is not sufficient
|
|
33
|
+
// because PixelRatio.getFontScale() may not have updated yet when AppState fires.
|
|
34
|
+
const dimensionsSub = _reactNative.Platform.OS === 'android' ? _reactNative.Dimensions.addEventListener('change', ({
|
|
35
|
+
window
|
|
36
|
+
}) => {
|
|
37
|
+
_useFontScale.useFontScale.setState({
|
|
38
|
+
fontScale: window.fontScale ?? 1
|
|
39
|
+
});
|
|
40
|
+
}) : null;
|
|
41
|
+
return () => {
|
|
42
|
+
appStateSub.remove();
|
|
43
|
+
dimensionsSub === null || dimensionsSub === void 0 || dimensionsSub.remove();
|
|
44
|
+
};
|
|
31
45
|
}, [disableFontScaling]);
|
|
32
46
|
}
|
|
33
47
|
//# sourceMappingURL=useRefreshFontScale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_useFontScale","useRefreshFontScale","disableFontScaling","useEffect","useFontScale","setState","fontScale","refresh","PixelRatio","getFontScale","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_useFontScale","useRefreshFontScale","disableFontScaling","useEffect","useFontScale","setState","fontScale","refresh","PixelRatio","getFontScale","appStateSub","AppState","addEventListener","nextState","dimensionsSub","Platform","OS","Dimensions","window","remove"],"sourceRoot":"..\\..\\..\\src","sources":["hooks/useRefreshFontScale.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,SAASG,mBAAmBA,CAACC,kBAAkB,GAAG,KAAK,EAAE;EAC9D,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAID,kBAAkB,EAAE;MACtBE,0BAAY,CAACC,QAAQ,CAAC;QAAEC,SAAS,EAAE;MAAE,CAAC,CAAC;MACvC,OAAO,MAAM,CAAC,CAAC;IACjB;IACA,MAAMC,OAAO,GAAGA,CAAA,KAAMH,0BAAY,CAACC,QAAQ,CAAC;MAAEC,SAAS,EAAEE,uBAAU,CAACC,YAAY,CAAC,CAAC,IAAI;IAAE,CAAC,CAAC;IAE1FF,OAAO,CAAC,CAAC;IAET,MAAMG,WAAW,GAAGC,qBAAQ,CAACC,gBAAgB,CAAC,QAAQ,EAAEC,SAAS,IAAI;MACnE,IAAIA,SAAS,KAAK,QAAQ,EAAEN,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC;;IAEF;IACA;IACA;IACA,MAAMO,aAAa,GACjBC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACrBC,uBAAU,CAACL,gBAAgB,CAAC,QAAQ,EAAE,CAAC;MAAEM;IAAO,CAAC,KAAK;MACpDd,0BAAY,CAACC,QAAQ,CAAC;QAAEC,SAAS,EAAEY,MAAM,CAACZ,SAAS,IAAI;MAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,GACF,IAAI;IAEV,OAAO,MAAM;MACXI,WAAW,CAACS,MAAM,CAAC,CAAC;MACpBL,aAAa,aAAbA,aAAa,eAAbA,aAAa,CAAEK,MAAM,CAAC,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CAACjB,kBAAkB,CAAC,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import { AppState, PixelRatio } from 'react-native';
|
|
2
|
+
import { AppState, Dimensions, PixelRatio, Platform } from 'react-native';
|
|
3
3
|
import { useFontScale } from '../store/useFontScale';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -19,10 +19,24 @@ export function useRefreshFontScale(disableFontScaling = false) {
|
|
|
19
19
|
fontScale: PixelRatio.getFontScale() ?? 1
|
|
20
20
|
});
|
|
21
21
|
refresh();
|
|
22
|
-
const
|
|
22
|
+
const appStateSub = AppState.addEventListener('change', nextState => {
|
|
23
23
|
if (nextState === 'active') refresh();
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
// On Android, font scale changes come through Dimensions 'change' events
|
|
27
|
+
// triggered by Android configuration changes. AppState alone is not sufficient
|
|
28
|
+
// because PixelRatio.getFontScale() may not have updated yet when AppState fires.
|
|
29
|
+
const dimensionsSub = Platform.OS === 'android' ? Dimensions.addEventListener('change', ({
|
|
30
|
+
window
|
|
31
|
+
}) => {
|
|
32
|
+
useFontScale.setState({
|
|
33
|
+
fontScale: window.fontScale ?? 1
|
|
34
|
+
});
|
|
35
|
+
}) : null;
|
|
36
|
+
return () => {
|
|
37
|
+
appStateSub.remove();
|
|
38
|
+
dimensionsSub === null || dimensionsSub === void 0 || dimensionsSub.remove();
|
|
39
|
+
};
|
|
26
40
|
}, [disableFontScaling]);
|
|
27
41
|
}
|
|
28
42
|
//# sourceMappingURL=useRefreshFontScale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","AppState","PixelRatio","useFontScale","useRefreshFontScale","disableFontScaling","setState","fontScale","refresh","getFontScale","
|
|
1
|
+
{"version":3,"names":["useEffect","AppState","Dimensions","PixelRatio","Platform","useFontScale","useRefreshFontScale","disableFontScaling","setState","fontScale","refresh","getFontScale","appStateSub","addEventListener","nextState","dimensionsSub","OS","window","remove"],"sourceRoot":"..\\..\\..\\src","sources":["hooks/useRefreshFontScale.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,cAAc;AACzE,SAASC,YAAY,QAAQ,uBAAuB;;AAEpD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,kBAAkB,GAAG,KAAK,EAAE;EAC9DP,SAAS,CAAC,MAAM;IACd,IAAIO,kBAAkB,EAAE;MACtBF,YAAY,CAACG,QAAQ,CAAC;QAAEC,SAAS,EAAE;MAAE,CAAC,CAAC;MACvC,OAAO,MAAM,CAAC,CAAC;IACjB;IACA,MAAMC,OAAO,GAAGA,CAAA,KAAML,YAAY,CAACG,QAAQ,CAAC;MAAEC,SAAS,EAAEN,UAAU,CAACQ,YAAY,CAAC,CAAC,IAAI;IAAE,CAAC,CAAC;IAE1FD,OAAO,CAAC,CAAC;IAET,MAAME,WAAW,GAAGX,QAAQ,CAACY,gBAAgB,CAAC,QAAQ,EAAEC,SAAS,IAAI;MACnE,IAAIA,SAAS,KAAK,QAAQ,EAAEJ,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC;;IAEF;IACA;IACA;IACA,MAAMK,aAAa,GACjBX,QAAQ,CAACY,EAAE,KAAK,SAAS,GACrBd,UAAU,CAACW,gBAAgB,CAAC,QAAQ,EAAE,CAAC;MAAEI;IAAO,CAAC,KAAK;MACpDZ,YAAY,CAACG,QAAQ,CAAC;QAAEC,SAAS,EAAEQ,MAAM,CAACR,SAAS,IAAI;MAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,GACF,IAAI;IAEV,OAAO,MAAM;MACXG,WAAW,CAACM,MAAM,CAAC,CAAC;MACpBH,aAAa,aAAbA,aAAa,eAAbA,aAAa,CAAEG,MAAM,CAAC,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CAACX,kBAAkB,CAAC,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRefreshFontScale.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRefreshFontScale.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,kBAAkB,UAAQ,
|
|
1
|
+
{"version":3,"file":"useRefreshFontScale.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRefreshFontScale.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,kBAAkB,UAAQ,QA6B7D"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@chem-po/react-native",
|
|
3
3
|
"author": "Elan Canfield",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.52",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"expo-file-system": "~19.0.0",
|
|
72
72
|
"expo-image-picker": "~17.0.0",
|
|
73
73
|
"expo-sharing": "~14.0.0",
|
|
74
|
-
"@chem-po/core": "0.0.
|
|
75
|
-
"@chem-po/react": "0.0.
|
|
74
|
+
"@chem-po/core": "0.0.52",
|
|
75
|
+
"@chem-po/react": "0.0.52"
|
|
76
76
|
},
|
|
77
77
|
"react-native-builder-bob": {
|
|
78
78
|
"source": "src",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react'
|
|
2
|
-
import { AppState, PixelRatio } from 'react-native'
|
|
2
|
+
import { AppState, Dimensions, PixelRatio, Platform } from 'react-native'
|
|
3
3
|
import { useFontScale } from '../store/useFontScale'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -17,10 +17,23 @@ export function useRefreshFontScale(disableFontScaling = false) {
|
|
|
17
17
|
|
|
18
18
|
refresh()
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const appStateSub = AppState.addEventListener('change', nextState => {
|
|
21
21
|
if (nextState === 'active') refresh()
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
// On Android, font scale changes come through Dimensions 'change' events
|
|
25
|
+
// triggered by Android configuration changes. AppState alone is not sufficient
|
|
26
|
+
// because PixelRatio.getFontScale() may not have updated yet when AppState fires.
|
|
27
|
+
const dimensionsSub =
|
|
28
|
+
Platform.OS === 'android'
|
|
29
|
+
? Dimensions.addEventListener('change', ({ window }) => {
|
|
30
|
+
useFontScale.setState({ fontScale: window.fontScale ?? 1 })
|
|
31
|
+
})
|
|
32
|
+
: null
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
appStateSub.remove()
|
|
36
|
+
dimensionsSub?.remove()
|
|
37
|
+
}
|
|
25
38
|
}, [disableFontScaling])
|
|
26
39
|
}
|