@hero-design/rn 7.1.3-alpha3 → 7.1.3-alpha4
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/es/index.js +65 -6
- package/lib/index.js +64 -5
- package/package.json +1 -1
- package/src/utils/scale.ts +68 -5
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useMemo, createElement, useRef, useEffect } from 'react';
|
|
2
|
-
import require$$0$1, { Dimensions, View, Text as Text$1, Platform, TouchableWithoutFeedback, Animated, StyleSheet as StyleSheet$1, TouchableHighlight, TouchableOpacity } from 'react-native';
|
|
2
|
+
import require$$0$1, { PixelRatio, Dimensions, View, Text as Text$1, Platform, TouchableWithoutFeedback, Animated, StyleSheet as StyleSheet$1, TouchableHighlight, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
4
|
|
|
5
5
|
function ownKeys(object, enumerableOnly) {
|
|
@@ -9875,13 +9875,72 @@ var systemPalette = {
|
|
|
9875
9875
|
|
|
9876
9876
|
var BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
9877
9877
|
|
|
9878
|
+
var pixelRatio = PixelRatio.get();
|
|
9879
|
+
var deviceHeight = Dimensions.get('window').height;
|
|
9880
|
+
var deviceWidth = Dimensions.get('window').width;
|
|
9878
9881
|
var scale = function scale(size) {
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
+
if (pixelRatio >= 2 && pixelRatio < 3) {
|
|
9883
|
+
// iphone 5s and older Androids
|
|
9884
|
+
if (deviceWidth < BASE_WIDTH) {
|
|
9885
|
+
return size * 0.95;
|
|
9886
|
+
} // iphone 5
|
|
9882
9887
|
|
|
9883
|
-
|
|
9884
|
-
|
|
9888
|
+
|
|
9889
|
+
if (deviceHeight < 667) {
|
|
9890
|
+
return size; // iphone 6-6s
|
|
9891
|
+
}
|
|
9892
|
+
|
|
9893
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
9894
|
+
return size * 1.15;
|
|
9895
|
+
} // older phablets
|
|
9896
|
+
|
|
9897
|
+
|
|
9898
|
+
return size * 1.25;
|
|
9899
|
+
}
|
|
9900
|
+
|
|
9901
|
+
if (pixelRatio >= 3 && pixelRatio < 3.5) {
|
|
9902
|
+
// catch Android font scaling on small machines
|
|
9903
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
9904
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
9905
|
+
return size;
|
|
9906
|
+
} // Catch other weird android width sizings
|
|
9907
|
+
|
|
9908
|
+
|
|
9909
|
+
if (deviceHeight < 667) {
|
|
9910
|
+
return size * 1.15; // catch in-between size Androids and scale font up
|
|
9911
|
+
// a tad but not too much
|
|
9912
|
+
}
|
|
9913
|
+
|
|
9914
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
9915
|
+
return size * 1.2;
|
|
9916
|
+
} // catch larger devices
|
|
9917
|
+
// ie iphone 6s plus / 7 plus / mi note 等等
|
|
9918
|
+
|
|
9919
|
+
|
|
9920
|
+
return size * 1.27;
|
|
9921
|
+
}
|
|
9922
|
+
|
|
9923
|
+
if (pixelRatio >= 3.5) {
|
|
9924
|
+
// catch Android font scaling on small machines
|
|
9925
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
9926
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
9927
|
+
return size; // Catch other smaller android height sizings
|
|
9928
|
+
}
|
|
9929
|
+
|
|
9930
|
+
if (deviceHeight < 667) {
|
|
9931
|
+
return size * 1.2; // catch in-between size Androids and scale font up
|
|
9932
|
+
// a tad but not too much
|
|
9933
|
+
}
|
|
9934
|
+
|
|
9935
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
9936
|
+
return size * 1.25;
|
|
9937
|
+
} // catch larger phablet devices
|
|
9938
|
+
|
|
9939
|
+
|
|
9940
|
+
return size * 1.4;
|
|
9941
|
+
}
|
|
9942
|
+
|
|
9943
|
+
return size;
|
|
9885
9944
|
};
|
|
9886
9945
|
|
|
9887
9946
|
var BASE$1 = 8;
|
package/lib/index.js
CHANGED
|
@@ -9884,13 +9884,72 @@ var systemPalette = {
|
|
|
9884
9884
|
|
|
9885
9885
|
var BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
9886
9886
|
|
|
9887
|
+
var pixelRatio = require$$0$1.PixelRatio.get();
|
|
9888
|
+
var deviceHeight = require$$0$1.Dimensions.get('window').height;
|
|
9889
|
+
var deviceWidth = require$$0$1.Dimensions.get('window').width;
|
|
9887
9890
|
var scale = function scale(size) {
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
+
if (pixelRatio >= 2 && pixelRatio < 3) {
|
|
9892
|
+
// iphone 5s and older Androids
|
|
9893
|
+
if (deviceWidth < BASE_WIDTH) {
|
|
9894
|
+
return size * 0.95;
|
|
9895
|
+
} // iphone 5
|
|
9891
9896
|
|
|
9892
|
-
|
|
9893
|
-
|
|
9897
|
+
|
|
9898
|
+
if (deviceHeight < 667) {
|
|
9899
|
+
return size; // iphone 6-6s
|
|
9900
|
+
}
|
|
9901
|
+
|
|
9902
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
9903
|
+
return size * 1.15;
|
|
9904
|
+
} // older phablets
|
|
9905
|
+
|
|
9906
|
+
|
|
9907
|
+
return size * 1.25;
|
|
9908
|
+
}
|
|
9909
|
+
|
|
9910
|
+
if (pixelRatio >= 3 && pixelRatio < 3.5) {
|
|
9911
|
+
// catch Android font scaling on small machines
|
|
9912
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
9913
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
9914
|
+
return size;
|
|
9915
|
+
} // Catch other weird android width sizings
|
|
9916
|
+
|
|
9917
|
+
|
|
9918
|
+
if (deviceHeight < 667) {
|
|
9919
|
+
return size * 1.15; // catch in-between size Androids and scale font up
|
|
9920
|
+
// a tad but not too much
|
|
9921
|
+
}
|
|
9922
|
+
|
|
9923
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
9924
|
+
return size * 1.2;
|
|
9925
|
+
} // catch larger devices
|
|
9926
|
+
// ie iphone 6s plus / 7 plus / mi note 等等
|
|
9927
|
+
|
|
9928
|
+
|
|
9929
|
+
return size * 1.27;
|
|
9930
|
+
}
|
|
9931
|
+
|
|
9932
|
+
if (pixelRatio >= 3.5) {
|
|
9933
|
+
// catch Android font scaling on small machines
|
|
9934
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
9935
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
9936
|
+
return size; // Catch other smaller android height sizings
|
|
9937
|
+
}
|
|
9938
|
+
|
|
9939
|
+
if (deviceHeight < 667) {
|
|
9940
|
+
return size * 1.2; // catch in-between size Androids and scale font up
|
|
9941
|
+
// a tad but not too much
|
|
9942
|
+
}
|
|
9943
|
+
|
|
9944
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
9945
|
+
return size * 1.25;
|
|
9946
|
+
} // catch larger phablet devices
|
|
9947
|
+
|
|
9948
|
+
|
|
9949
|
+
return size * 1.4;
|
|
9950
|
+
}
|
|
9951
|
+
|
|
9952
|
+
return size;
|
|
9894
9953
|
};
|
|
9895
9954
|
|
|
9896
9955
|
var BASE$1 = 8;
|
package/package.json
CHANGED
package/src/utils/scale.ts
CHANGED
|
@@ -1,10 +1,73 @@
|
|
|
1
|
-
import { Dimensions } from 'react-native';
|
|
1
|
+
import { PixelRatio, Dimensions } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
4
|
-
|
|
4
|
+
const pixelRatio = PixelRatio.get();
|
|
5
|
+
const deviceHeight = Dimensions.get('window').height;
|
|
6
|
+
const deviceWidth = Dimensions.get('window').width;
|
|
5
7
|
export const scale = (size: number) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
if (pixelRatio >= 2 && pixelRatio < 3) {
|
|
9
|
+
// iphone 5s and older Androids
|
|
10
|
+
if (deviceWidth < BASE_WIDTH) {
|
|
11
|
+
return size * 0.95;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// iphone 5
|
|
15
|
+
if (deviceHeight < 667) {
|
|
16
|
+
return size;
|
|
17
|
+
// iphone 6-6s
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
21
|
+
return size * 1.15;
|
|
22
|
+
}
|
|
23
|
+
// older phablets
|
|
24
|
+
return size * 1.25;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (pixelRatio >= 3 && pixelRatio < 3.5) {
|
|
28
|
+
// catch Android font scaling on small machines
|
|
29
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
30
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
31
|
+
return size;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Catch other weird android width sizings
|
|
35
|
+
if (deviceHeight < 667) {
|
|
36
|
+
return size * 1.15;
|
|
37
|
+
// catch in-between size Androids and scale font up
|
|
38
|
+
// a tad but not too much
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
42
|
+
return size * 1.2;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// catch larger devices
|
|
46
|
+
// ie iphone 6s plus / 7 plus / mi note 等等
|
|
47
|
+
return size * 1.27;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (pixelRatio >= 3.5) {
|
|
51
|
+
// catch Android font scaling on small machines
|
|
52
|
+
// where pixel ratio / font scale ratio => 3:3
|
|
53
|
+
if (deviceWidth <= BASE_WIDTH) {
|
|
54
|
+
return size;
|
|
55
|
+
// Catch other smaller android height sizings
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (deviceHeight < 667) {
|
|
59
|
+
return size * 1.2;
|
|
60
|
+
// catch in-between size Androids and scale font up
|
|
61
|
+
// a tad but not too much
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (deviceHeight >= 667 && deviceHeight <= 735) {
|
|
65
|
+
return size * 1.25;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// catch larger phablet devices
|
|
69
|
+
return size * 1.4;
|
|
70
|
+
}
|
|
8
71
|
|
|
9
|
-
return
|
|
72
|
+
return size;
|
|
10
73
|
};
|