-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix:解决MenuDropdown组件下拉报错 * fix:SearchBar组件 * fix:Table表格 * fix:展开组件封装,修复xcode14.5无法运行问题 * fix:update package.json
- Loading branch information
1 parent
be4cd61
commit 8c64661
Showing
10 changed files
with
203 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
ExpandableSection 展开缩放 | ||
--- | ||
|
||
展开缩放 | ||
|
||
### 基础示例 | ||
|
||
<!--DemoStart--> | ||
```js | ||
import { ExpandableSection,H5 } from '@uiw/react-native'; | ||
|
||
class Demo extends Component { | ||
state={ | ||
expanded:false, | ||
top:false | ||
} | ||
render() { | ||
return ( | ||
<ExpandableSection | ||
expanded={this.state.expanded} | ||
onPress={() => this.setState({ expanded: !this.state.expanded })} | ||
sectionHeader={<H5>我是标题</H5>} | ||
top={this.state.top} | ||
> | ||
<View> | ||
<Text style={{ color: 'red' }}>展开的内容</Text> | ||
</View> | ||
</ExpandableSection> | ||
) | ||
} | ||
} | ||
``` | ||
<!--End--> | ||
|
||
## Props | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
|------|------|-----|------| | ||
| `sectionHeader` | 设置标题 | JSX.Element | - | | ||
| `children` | 展开内容| ReactNode | - | | ||
| `labelStyle` | 设置提示文本样式 | TextProps['style'] | - | | ||
| `expanded` | 是否展开 | boolean | - | | ||
| `top` | 展开后显示位置 标题上或标题下 | boolean | - | | ||
| `top` | 点击事件 | void | - | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { LayoutAnimation, StyleSheet, View, TouchableOpacity } from 'react-native'; | ||
|
||
export type ExpandableSectionProps = { | ||
/** | ||
* 标题 | ||
*/ | ||
sectionHeader?: JSX.Element; | ||
/** | ||
* 折叠内容 | ||
*/ | ||
children?: React.ReactNode; | ||
/** | ||
* 是否展开 | ||
*/ | ||
expanded?: boolean; | ||
/** | ||
* 展开后显示位置 标题上或标题下 | ||
*/ | ||
top?: boolean; | ||
/** | ||
* 点击事件 | ||
*/ | ||
onPress?: () => void; | ||
}; | ||
|
||
|
||
function ExpandableSection(props: ExpandableSectionProps) { | ||
const { expanded, sectionHeader, children, top } = props; | ||
|
||
const onPress = () => { | ||
props.onPress?.(); | ||
LayoutAnimation.configureNext({ ...LayoutAnimation.Presets.easeInEaseOut, duration: 300 }); | ||
}; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
{top && expanded && children} | ||
<TouchableOpacity onPress={onPress}>{sectionHeader}</TouchableOpacity> | ||
{!top && expanded && children} | ||
</View> | ||
); | ||
} | ||
|
||
export default ExpandableSection; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
overflow: 'hidden' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const down = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="8" viewBox="0 0 13 8"> | ||
<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)"/> | ||
</svg>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { Component } from 'react'; | ||
import { Text, StyleSheet, Image, View } from 'react-native'; | ||
import Layout, { Container } from '../../Layout'; | ||
import { ExpandableSection } from '../../../components'; | ||
import { ComProps } from '../../typings'; | ||
const { Header, Body, Card, Footer } = Layout; | ||
|
||
export interface ExpandableSection extends ComProps { } | ||
|
||
export default class MenuDropdownView extends Component<ExpandableSection> { | ||
state = { | ||
expanded: false, | ||
top: false | ||
} | ||
getChevron() { | ||
if (this.state.expanded) { | ||
return this.state.top ? <Image style={styles.icon} source={require('../../image/chevronDown.png')} /> : <Image style={styles.icon} source={require('../../image/chevronUp.png')} /> | ||
} | ||
return this.state.top ? <Image style={styles.icon} source={require('../../image/chevronUp.png')} /> : <Image style={styles.icon} source={require('../../image/chevronDown.png')} /> | ||
} | ||
getHeaderElement() { | ||
return ( | ||
<View style={styles.row}> | ||
<Text> | ||
{!this.state.expanded ? '展开' : '折叠'} | ||
</Text> | ||
{this.getChevron()} | ||
</View> | ||
); | ||
} | ||
render() { | ||
const { route } = this.props; | ||
const { expanded, top } = this.state | ||
const description = route.params.description; | ||
const title = route.params.title; | ||
return ( | ||
<Container> | ||
<Layout> | ||
<Header title={title} description={description} /> | ||
<Body> | ||
<Card title="基础实例" style={styles.card}> | ||
<ExpandableSection | ||
expanded={expanded} | ||
onPress={() => this.setState({ expanded: !expanded })} | ||
sectionHeader={this.getHeaderElement()} | ||
top={top} | ||
> | ||
<Card title="我是展开的内容" style={styles.card} /> | ||
<Card title="我是展开的内容" style={styles.card} /> | ||
<Card title="我是展开的内容" style={styles.card} /> | ||
</ExpandableSection> | ||
</Card> | ||
</Body> | ||
<Footer /> | ||
</Layout> | ||
</Container> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
card: { | ||
backgroundColor: '#fff', | ||
paddingLeft: 20, | ||
paddingRight: 20, | ||
}, | ||
icon: { | ||
alignSelf: 'center' | ||
}, | ||
row: { | ||
display: "flex", | ||
flexDirection: "row", | ||
justifyContent: "space-between", | ||
padding: 10 | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters