-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
component: add steps component #140
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8dbe0e4
doc: edit layout
yaob421123 f7470a9
fetch upstream
yaob421123 a3e5075
component: add steps component
yaob421123 791f140
Merge branch 'master' of https://github.com/uiwjs/react-native-uiw
yaob421123 479b1d1
edit doc clash
yaob421123 18ab1ad
doc: add steps doc
yaob421123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,62 @@ | ||
import React, {Component, useState} from 'react'; | ||
import {View, Text} from 'react-native'; | ||
import {ComProps} from '../../routes'; | ||
import Layout, {Container} from '../../Layout'; | ||
import {Steps, WingBlank, Button} from '@uiw/react-native'; | ||
|
||
const {Header, Body, Card} = Layout; | ||
|
||
interface StepsViewProps extends ComProps {} | ||
|
||
export default (props: StepsViewProps) => { | ||
const { route } = props; | ||
const [current, setCurrent] = useState<number>(1); | ||
const item = [ | ||
{ 'title': '步骤一', 'desc': '这里是额外的信息,这里是额外的信息'}, | ||
{ 'title': '步骤二', 'desc': '这里是额外的信息,这里是额'}, | ||
{ 'title': '步骤三', 'desc': '这里是'} | ||
] | ||
const item2 = [ | ||
{ 'title': '步骤一', 'desc': '这里是额外的信息,这里是额外的信息', status: 'success'}, | ||
{ 'title': '步骤二', 'desc': '这里是额外的信息,这里是额', status: 'success'}, | ||
{ 'title': '步骤三', 'desc': '这里是', status: 'error'} | ||
] | ||
|
||
const onBtnPress = () => { | ||
let index = current + 1; | ||
if (index > item.length - 1) { | ||
index = 0; | ||
} | ||
setCurrent(index); | ||
} | ||
|
||
const onChange = (index: number) => { | ||
setCurrent(index); | ||
} | ||
|
||
return ( | ||
<Container> | ||
<Header title={route.params.title} description={route.params.description} /> | ||
<Body> | ||
<Card title="基础用法"> | ||
<WingBlank> | ||
<Steps | ||
items={item} | ||
current={current} | ||
// onChange={onChange} | ||
/> | ||
</WingBlank> | ||
<Button style={{ marginLeft: 20, marginRight: 20 }} onPress={onBtnPress}>下一步</Button> | ||
</Card> | ||
<Card title="步骤状态"> | ||
<WingBlank> | ||
<Steps | ||
items={item2} | ||
current={2} | ||
/> | ||
</WingBlank> | ||
</Card> | ||
</Body> | ||
</Container> | ||
) | ||
} |
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,38 @@ | ||
Steps 步骤条 | ||
--- | ||
|
||
## 基础示例 | ||
|
||
```jsx | ||
import { Steps } from '@uiw/react-native'; | ||
|
||
function Demo() { | ||
return ( | ||
<Steps | ||
items={[ | ||
{ 'title': '步骤一', 'desc': '这里是额外的信息,这里是额外的信息'}, | ||
{ 'title': '步骤二', 'desc': '这里是额外的信息,这里是额'}, | ||
{ 'title': '步骤三', 'desc': '这里是'} | ||
]} | ||
current={1} | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
### props | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
| -------------------- | ------------ | ------- | ------- | | ||
| `items` |步骤条数据列表 | Item[] | - | | ||
| `current` | 当前步骤索引值 | Number | 0 | | ||
| `onChange` | 点击时间轴 | (value: number) => void; | - | | ||
|
||
|
||
### Item[] | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
| -------------------- | ------------ | ------- | ------- | | ||
| `title` |步骤标题 | Item[] | - | | ||
| `desc` | 步骤说明文字 | Number | 0 | | ||
| `status` | 步骤的状态,'success' 或 'error' | String | - | |
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,28 @@ | ||
### 步骤条组件 | ||
|
||
``` | ||
<Steps | ||
items={[ | ||
{ 'title': '步骤一', 'desc': '这里是额外的信息,这里是额外的信息'}, | ||
{ 'title': '步骤二', 'desc': '这里是额外的信息,这里是额'}, | ||
{ 'title': '步骤三', 'desc': '这里是'} | ||
]} | ||
current={1} | ||
/> | ||
``` | ||
### props | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
| -------------------- | ------------ | ------- | ------- | | ||
| `items` |步骤条数据列表 | Item[] | - | | ||
| `current` | 当前步骤索引值 | Number | 0 | | ||
| `onChange` | 点击时间轴 | (value: number) => void; | - | | ||
|
||
|
||
### Item[] | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
| -------------------- | ------------ | ------- | ------- | | ||
| `title` |步骤标题 | Item[] | - | | ||
| `desc` | 步骤说明文字 | Number | 0 | | ||
| `status` | 步骤的状态,'success' 或 'error' | String | - | |
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,109 @@ | ||
import React from 'react'; | ||
import {View, Text, StyleSheet, TouchableOpacity} from 'react-native'; | ||
import {Icon} from '@uiw/react-native'; | ||
|
||
type statusType = 'success' | 'error' | string; | ||
|
||
export interface StepsItemsProps { | ||
title?: string; | ||
desc?: string; | ||
status?: statusType; | ||
} | ||
|
||
export interface StepsProps { | ||
items: StepsItemsProps[]; | ||
current?: number; | ||
onChange?: (value: number) => void; | ||
} | ||
|
||
export default (props: StepsProps) => { | ||
const { | ||
items = [], | ||
current = 0, | ||
onChange | ||
} = props; | ||
|
||
const onStepsPress = (index: number) => { | ||
// onChange?.(index); | ||
onChange && onChange(current); | ||
} | ||
|
||
return ( | ||
<View style={styles.steps}> | ||
{items.map((item, index) => ( | ||
<TouchableOpacity style={[styles.item]} key={index} onPress={() => onStepsPress(index)}> | ||
<View style={styles.wrap}> | ||
{index !== 0 && <View style={styles.leftLine}></View>} | ||
<View style={[styles.circular, { | ||
backgroundColor: current >= index && !item?.status ? '#008EF0' : '#e5e5e5', | ||
}]}> | ||
{item?.status === 'error' && <Icon name="circle-close" size={22} fill="#dc3545" />} | ||
{item?.status === 'success' && <Icon name="circle-check" size={22} fill="#008EF0" />} | ||
{!item?.status && <Text style={{ | ||
color: current >= index ? '#fff' : '#333', | ||
}}>{index + 1}</Text>} | ||
</View> | ||
{index < items.length - 1 && <View style={styles.rightLine}></View>} | ||
</View> | ||
<Text>{item.title}</Text> | ||
<Text style={styles.desc}>{item.desc}</Text> | ||
</TouchableOpacity> | ||
))} | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
steps: { | ||
flexDirection: 'row', | ||
paddingTop: 10, | ||
paddingBottom: 10 | ||
}, | ||
item: { | ||
flex: 1, | ||
flexDirection: 'column', | ||
alignItems: 'center' | ||
}, | ||
wrap: { | ||
position: 'relative', | ||
alignItems: 'center', | ||
width: '100%', | ||
marginBottom: 10 | ||
}, | ||
leftLine: { | ||
backgroundColor: '#ccc', | ||
position: 'absolute', | ||
width: '50%', | ||
top: '50%', | ||
height: 1, | ||
left: '0%' | ||
}, | ||
rightLine: { | ||
backgroundColor: '#ccc', | ||
position: 'absolute', | ||
width: "50%", | ||
top: '50%', | ||
height: 1, | ||
right: '0%' | ||
|
||
}, | ||
circular: { | ||
width: 25, | ||
height: 25, | ||
backgroundColor: '#e5e5e5', | ||
borderRadius: 20, | ||
position: 'relative', | ||
zIndex: 3, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
desc: { | ||
color: '#ccc', | ||
fontSize: 12, | ||
textAlign: 'center', | ||
paddingLeft: 5, | ||
paddingRight: 5, | ||
marginTop: 10, | ||
lineHeight: 18 | ||
} | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
组件文档命名
->index.md
README.md
. @yaob421123There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
标识,代码高了
\```jsx
@yaob421123