Skip to content

Commit b58042a

Browse files
committed
fix(Tree):自适应高度调整
1 parent 917cb78 commit b58042a

File tree

4 files changed

+4
-30
lines changed

4 files changed

+4
-30
lines changed

example/examples/src/routes/ActionSheet/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class Index extends Component<IndexProps, IndexState> {
3333
<Container>
3434
<Layout>
3535
<Header title={title} description={description} />
36-
<Body>
36+
<Body style={{paddingLeft: 16, paddingRight: 16}}>
3737
<View style={styles.divider} />
3838
<Button onPress={this.onOpen}>打开 ActionSheet</Button>
3939
<ActionSheet

packages/core/src/Calendar/show.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import { View, Text, ViewProps, StyleSheet } from 'react-native';
2+
import { View, ViewProps, StyleSheet } from 'react-native';
33
// import Icon from '../Icon';
4+
import Text from '../Typography/Text';
45

56
export interface ShowProps extends ViewProps {
67
iconColor?: string;

packages/core/src/Tree/components/useTree.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { useEffect, useRef, useState } from 'react';
22
import { useLatest } from '../../utils/hooks';
3-
import { deviceHeight } from '../util';
43
import { EntityNode, EventDataNode, FlattenNode, TreeProps } from '../type';
54
import { arrAdd, arrDel, conductCheck, flattenTreeData, getTreeNodeLevel } from '../util';
65

76
export function useTree(props: TreeProps) {
87
const {
9-
height = deviceHeight,
8+
height,
109
treeData = [],
1110
disabled = false,
1211
onExpand,

packages/core/src/Tree/util.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -243,29 +243,3 @@ export function conductCheck(
243243
}
244244
return [];
245245
}
246-
247-
const { width, height } = Dimensions.get('window');
248-
249-
/** design based on iphone6 */
250-
const defaultPixelRatio = 1;
251-
const designWidth = 375;
252-
const designHeight = 667;
253-
254-
// px转换成dp
255-
const dpWidth = designWidth / defaultPixelRatio;
256-
const dpHeight = designHeight / defaultPixelRatio;
257-
258-
//获取缩放比例
259-
const scale = Math.min(height / dpHeight, width / dpWidth);
260-
261-
export const deviceWidth = width;
262-
export const deviceHeight = height;
263-
export const ONE_PIXEL = StyleSheet.hairlineWidth;
264-
265-
/**
266-
* 适配屏幕大小和像素密度的公共方法
267-
* @param size 设计稿大小
268-
*/
269-
export const px = (size: number) => {
270-
return PixelRatio.roundToNearestPixel(size * scale);
271-
};

0 commit comments

Comments
 (0)