Skip to content

Commit 8c64661

Browse files
authored
Wx (#103)
* fix:解决MenuDropdown组件下拉报错 * fix:SearchBar组件 * fix:Table表格 * fix:展开组件封装,修复xcode14.5无法运行问题 * fix:update package.json
1 parent be4cd61 commit 8c64661

File tree

10 files changed

+203
-21
lines changed

10 files changed

+203
-21
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
ExpandableSection 展开缩放
2+
---
3+
4+
展开缩放
5+
6+
### 基础示例
7+
8+
<!--DemoStart-->
9+
```js
10+
import { ExpandableSection,H5 } from '@uiw/react-native';
11+
12+
class Demo extends Component {
13+
state={
14+
expanded:false,
15+
top:false
16+
}
17+
render() {
18+
return (
19+
<ExpandableSection
20+
expanded={this.state.expanded}
21+
onPress={() => this.setState({ expanded: !this.state.expanded })}
22+
sectionHeader={<H5>我是标题</H5>}
23+
top={this.state.top}
24+
>
25+
<View>
26+
<Text style={{ color: 'red' }}>展开的内容</Text>
27+
</View>
28+
</ExpandableSection>
29+
)
30+
}
31+
}
32+
```
33+
<!--End-->
34+
35+
## Props
36+
37+
| 参数 | 说明 | 类型 | 默认值 |
38+
|------|------|-----|------|
39+
| `sectionHeader` | 设置标题 | JSX.Element | - |
40+
| `children` | 展开内容| ReactNode | - |
41+
| `labelStyle` | 设置提示文本样式 | TextProps['style'] | - |
42+
| `expanded` | 是否展开 | boolean | - |
43+
| `top` | 展开后显示位置 标题上或标题下 | boolean | - |
44+
| `top` | 点击事件 | void | - |
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import { LayoutAnimation, StyleSheet, View, TouchableOpacity } from 'react-native';
3+
4+
export type ExpandableSectionProps = {
5+
/**
6+
* 标题
7+
*/
8+
sectionHeader?: JSX.Element;
9+
/**
10+
* 折叠内容
11+
*/
12+
children?: React.ReactNode;
13+
/**
14+
* 是否展开
15+
*/
16+
expanded?: boolean;
17+
/**
18+
* 展开后显示位置 标题上或标题下
19+
*/
20+
top?: boolean;
21+
/**
22+
* 点击事件
23+
*/
24+
onPress?: () => void;
25+
};
26+
27+
28+
function ExpandableSection(props: ExpandableSectionProps) {
29+
const { expanded, sectionHeader, children, top } = props;
30+
31+
const onPress = () => {
32+
props.onPress?.();
33+
LayoutAnimation.configureNext({ ...LayoutAnimation.Presets.easeInEaseOut, duration: 300 });
34+
};
35+
36+
return (
37+
<View style={styles.container}>
38+
{top && expanded && children}
39+
<TouchableOpacity onPress={onPress}>{sectionHeader}</TouchableOpacity>
40+
{!top && expanded && children}
41+
</View>
42+
);
43+
}
44+
45+
export default ExpandableSection;
46+
47+
const styles = StyleSheet.create({
48+
container: {
49+
overflow: 'hidden'
50+
}
51+
});

components/SearchBar/svg.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const down = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="8" viewBox="0 0 13 8">
2+
<polyline fill="none" stroke="#C7C7CC" stroke-width="2" points="365 203 370.45 208.45 365 213.9" transform="rotate(90 289.725 -74.55)"/>
3+
</svg>`;

components/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export {default as Toast} from './Toast';
2727
export {default as SwipeAction} from './SwipeAction';
2828
export {default as Input} from './Input';
2929
export {default as SelectCascader} from './SelectCascader';
30+
export {default as ExpandableSection} from './ExpandableSection';
3031

3132
/**
3233
* Typography

ios/Podfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ target 'UIW' do
2020
# Enables Flipper.
2121
#
2222
# Note that if you have use_frameworks! enabled, Flipper will not work and
23-
# you should disable the next line.
24-
use_flipper!()
25-
23+
# you should disable these next few lines.
24+
use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
2625
post_install do |installer|
27-
react_native_post_install(installer)
26+
flipper_post_install(installer)
2827
end
2928
end

src/image/chevronDown.png

175 Bytes
Loading

src/image/chevronUp.png

532 Bytes
Loading

src/routes.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,12 @@ export const stackPageData: Routes[] = [
257257
description: '表格Table',
258258
},
259259
},
260+
{
261+
name: 'ExpandableSection',
262+
component: require('./routes/ExpandableSection').default,
263+
params: {
264+
title: 'ExpandableSection 折叠展开',
265+
description: '折叠展开ExpandableSection',
266+
},
267+
},
260268
];
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React, { Component } from 'react';
2+
import { Text, StyleSheet, Image, View } from 'react-native';
3+
import Layout, { Container } from '../../Layout';
4+
import { ExpandableSection } from '../../../components';
5+
import { ComProps } from '../../typings';
6+
const { Header, Body, Card, Footer } = Layout;
7+
8+
export interface ExpandableSection extends ComProps { }
9+
10+
export default class MenuDropdownView extends Component<ExpandableSection> {
11+
state = {
12+
expanded: false,
13+
top: false
14+
}
15+
getChevron() {
16+
if (this.state.expanded) {
17+
return this.state.top ? <Image style={styles.icon} source={require('../../image/chevronDown.png')} /> : <Image style={styles.icon} source={require('../../image/chevronUp.png')} />
18+
}
19+
return this.state.top ? <Image style={styles.icon} source={require('../../image/chevronUp.png')} /> : <Image style={styles.icon} source={require('../../image/chevronDown.png')} />
20+
}
21+
getHeaderElement() {
22+
return (
23+
<View style={styles.row}>
24+
<Text>
25+
{!this.state.expanded ? '展开' : '折叠'}
26+
</Text>
27+
{this.getChevron()}
28+
</View>
29+
);
30+
}
31+
render() {
32+
const { route } = this.props;
33+
const { expanded, top } = this.state
34+
const description = route.params.description;
35+
const title = route.params.title;
36+
return (
37+
<Container>
38+
<Layout>
39+
<Header title={title} description={description} />
40+
<Body>
41+
<Card title="基础实例" style={styles.card}>
42+
<ExpandableSection
43+
expanded={expanded}
44+
onPress={() => this.setState({ expanded: !expanded })}
45+
sectionHeader={this.getHeaderElement()}
46+
top={top}
47+
>
48+
<Card title="我是展开的内容" style={styles.card} />
49+
<Card title="我是展开的内容" style={styles.card} />
50+
<Card title="我是展开的内容" style={styles.card} />
51+
</ExpandableSection>
52+
</Card>
53+
</Body>
54+
<Footer />
55+
</Layout>
56+
</Container>
57+
);
58+
}
59+
}
60+
61+
const styles = StyleSheet.create({
62+
card: {
63+
backgroundColor: '#fff',
64+
paddingLeft: 20,
65+
paddingRight: 20,
66+
},
67+
icon: {
68+
alignSelf: 'center'
69+
},
70+
row: {
71+
display: "flex",
72+
flexDirection: "row",
73+
justifyContent: "space-between",
74+
padding: 10
75+
}
76+
});

yarn.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,10 +1098,10 @@
10981098
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.10.tgz#5dda643e19e587793bc2034dd9bf7398ad43d401"
10991099
integrity sha512-rk4sWFsmtOw8oyx8SD3KSvawwaK7gRBSEIy2TAwURyGt+3TizssXP1r8nx3zY+R7v2vYYHXZ+k2/GULAT/bcaQ==
11001100

1101-
"@react-native-picker/picker@1.16.0":
1102-
version "1.16.0"
1103-
resolved "https://registry.yarnpkg.com/@react-native-picker/picker/-/picker-1.16.0.tgz#3e5268da892349a35c66ab7bd75e834147621e5a"
1104-
integrity sha512-kQcL8U5CYQRgmNtlyhEH1BIp06Eaxhj7Lybd7rV4asd4Q90kCEm52b5x5WnE0J6WdVvC6sRzdcbPCb0s9yc4mQ==
1101+
"@react-native-picker/picker@1.12.0":
1102+
version "1.12.0"
1103+
resolved "https://registry.yarnpkg.com/@react-native-picker/picker/-/picker-1.12.0.tgz#215d7c950935c8f1a834af0832a93122b4bab0f1"
1104+
integrity sha512-LxtFcuQ/jxsNwH9byM4mMSusqGfaj0LHXTh6fJgvIKOBjAWwV+FjWHszQSPCbnycdezirf8dFLhF9phcNuE8CA==
11051105

11061106
"@react-native/assets@1.0.0":
11071107
version "1.0.0"
@@ -1118,23 +1118,23 @@
11181118
resolved "https://registry.yarnpkg.com/@react-native/polyfills/-/polyfills-1.0.0.tgz#05bb0031533598f9458cf65a502b8df0eecae780"
11191119
integrity sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w==
11201120

1121-
"@react-navigation/core@^5.15.3":
1122-
version "5.15.3"
1123-
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.15.3.tgz#dce7090bf3ea0d302993d742c706825e495b812e"
1124-
integrity sha512-3ZdyDInh8qg1kygCNkmh9lFgpDf29lTvPsaMe2mm/qvmxLKSgttWBz07P2fc181aV9jTdgQpzYfWZ5KWT036zw==
1121+
"@react-navigation/core@^5.15.2":
1122+
version "5.15.2"
1123+
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.15.2.tgz#6aa374c7bcb6ffcaac8e2a7f8bdb2f9aba469b31"
1124+
integrity sha512-jNSP0FMu1N6Pa1Slsy8b/JbmlTAXcVeXVwnxrEMVGWeiNqUVYl+tx1FuQAqi3q1m4cg9ygXkGsgLgRmnXAEC8g==
11251125
dependencies:
11261126
"@react-navigation/routers" "^5.7.2"
11271127
escape-string-regexp "^4.0.0"
11281128
nanoid "^3.1.15"
11291129
query-string "^6.13.6"
11301130
react-is "^16.13.0"
11311131

1132-
"@react-navigation/native@5.9.4":
1133-
version "5.9.4"
1134-
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-5.9.4.tgz#414c044423c58aa1cdde1b6494309e0b51da08b8"
1135-
integrity sha512-BUCrOXfZDdKWBqM8OhOKQhCX5we4HUo5XG6tCQtVqQAep+7UcApZmMUuemUXDxVe8NPESUpoUlB0RaEpyIdfTQ==
1132+
"@react-navigation/native@5.9.3":
1133+
version "5.9.3"
1134+
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-5.9.3.tgz#3859f439adc9a744b79a98fbc7606bdd459574d5"
1135+
integrity sha512-xaRlCDRVuFGxHsP/IetwLdNvLJwIJBYCUIx/ufWs6QkT9Q0EB0DtKzXCItuHydjMEVPd1Cy7lfjUlSM6hZ6Q3Q==
11361136
dependencies:
1137-
"@react-navigation/core" "^5.15.3"
1137+
"@react-navigation/core" "^5.15.2"
11381138
escape-string-regexp "^4.0.0"
11391139
nanoid "^3.1.15"
11401140

@@ -1145,10 +1145,10 @@
11451145
dependencies:
11461146
nanoid "^3.1.15"
11471147

1148-
"@react-navigation/stack@5.14.5":
1149-
version "5.14.5"
1150-
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.14.5.tgz#dc615cd7d270ba79e3330dcb50c2819d0e1f3850"
1151-
integrity sha512-hpdn1SS0tc3/3atkV2Q2y++n5B4e0rUcCj4W43PODMu72yX2m0LkKAAcpkPDCWAvwnLLIoLAEl5BEifZigl/6A==
1148+
"@react-navigation/stack@5.14.3":
1149+
version "5.14.3"
1150+
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.14.3.tgz#3d15fcd2cf8d0d2a1248686565c6a85e2d8e1c55"
1151+
integrity sha512-7rHc13DHsYP7l7GcgBcLEyX2/IAuCcRZ1Iu3MtOZSayjvFXxBBYKFKw0OyY9NxOfZUdLl3Q3mLiUHVFZkHMcuA==
11521152
dependencies:
11531153
color "^3.1.3"
11541154
react-native-iphone-x-helper "^1.3.0"

0 commit comments

Comments
 (0)