-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathac
More file actions
117 lines (97 loc) · 3.28 KB
/
ac
File metadata and controls
117 lines (97 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import React from 'react';
import { StyleSheet, Image, PixelRatio, Dimensions } from 'react-native';
import { List, MD3LightTheme, Text } from '@jmsstudiosinc/react-native-paper';
import { moderateScale } from 'react-native-size-matters';
const ratio = PixelRatio.get();
const normalize = (size) => {
const { width, height } = Dimensions.get('window');
console.log(ratio);
if (ratio >= 2 && ratio < 3) {
if (width < 360) {
return size * 0.95;
} else if (height < 667) {
return size;
} else if (height >= 667 && height <= 735) {
return size * 1.15;
}
return size * 1.25;
} else if (ratio >= 3 && ratio < 3.5) {
if (width < 360) {
return size;
} else if (height < 667) {
return size * 1.15;
} else if (height >= 667 && height <= 735) {
return size * 1.2;
}
return size * 1.27;
} else if (ratio >= 3.5) {
if (width < 360) {
return size;
} else if (height < 667) {
return size * 1.2;
} else if (height >= 667 && height <= 735) {
return size * 1.25;
}
return size * 1.4;
}
return size;
};
console.log(' normalize ' + normalize(14));
console.log('moderateScale ' + moderateScale(14));
const { width: SCREEN_WIDTH } = Dimensions.get('window');
// Based on iPhone 5s's scale
const scale = SCREEN_WIDTH / 320;
const checkIfTablet = () => {
const pixelDensity = PixelRatio.get();
const adjustedWidth = SCREEN_WIDTH * pixelDensity;
const adjustedHeight = SCREEN_WIDTH * pixelDensity;
if (pixelDensity < 2 && (adjustedWidth >= 1000 || adjustedHeight >= 1000)) {
return true;
} else {
return pixelDensity === 2 && (adjustedWidth >= 1920 || adjustedHeight >= 1920);
}
};
function normalizes(size) {
const isTablet = checkIfTablet();
// NOTE: Tablet scaling hasn't been fully tested.
const newSize = isTablet ? (size * scale) / 2 : size * scale;
if (Platform.OS === 'ios') {
return Math.round(PixelRatio.roundToNearestPixel(newSize));
} else {
return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2;
}
}
console.log(normalizes(14));
const ListImage = ({ src, title, description, right, ...props }) => {
const renderImage = src ? () => <Image source={src} style={styles.image} /> : null;
const renderTitle = ({ selectable, titleEllipsizeMode, color }) => (
<Text
selectable={selectable}
ellipsizeMode={titleEllipsizeMode}
numberOfLines={1}
variant={'bodyLarge'}
style={{ color, paddingLeft: MD3LightTheme.margin / 2 }}
>
{title}
</Text>
);
return (
<List.Item
{...props}
title={renderTitle}
description={description}
left={renderImage}
right={right}
style={{ paddingLeft: 0 }}
descriptionStyle={{ paddingLeft: MD3LightTheme.margin / 2 }}
itemStyle={{ marginVertical: 0, justifyContent: true ? 'flex-start' : 'center' }}
/>
);
};
const styles = StyleSheet.create({
image: {
width: moderateScale(100),
height: moderateScale(56),
},
});
export default ListImage;