Skip to content

Commit b70a204

Browse files
committed
feat(ActionBar):add focusIndex api && add 增加首项末项阴影 && add scroll状态下跳转功能
1 parent 0e7c803 commit b70a204

File tree

5 files changed

+278
-45
lines changed

5 files changed

+278
-45
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {ActionBar} from '@uiw/react-native';
2+
import {ActionBar, Button, Icon} from '@uiw/react-native';
33
import {View, Alert} from 'react-native';
44
import {ComProps} from '../../routes';
55
import Layout from '../../Layout';
@@ -17,8 +17,8 @@ export default class ActionBarDemo extends React.Component<ActionBarProps> {
1717
<Header title={title} description={description} />
1818
<View style={{flex: 1}}>
1919
<ActionBar
20-
backgroundColor="#5847FF"
2120
scroll={false}
21+
backgroundColor="#5847FF"
2222
actions={[
2323
{
2424
label: 'Delete',

packages/core/src/ActionBar/README.md

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ActionBar 底部操作栏
22
---
33

4-
底部操作栏
4+
底部操作栏(可滚动)
55

66

77

@@ -19,7 +19,6 @@ export default class Demo extends React.Component<ScreenRootProps> {
1919
return (
2020
<View style={{ flex: 1 }}>
2121
<ActionBar
22-
scroll={false}
2322
actions={[
2423
{ label: 'Delete', onPress: () => Alert.alert('delete'), fontStyle: { fontWeight: 'bold', color: "#5847FF" } },
2524
{ label: 'Replace', onPress: () => Alert.alert('replace photo'), fontStyle: { fontWeight: 'bold', color: "#5847FF" } },
@@ -32,6 +31,85 @@ export default class Demo extends React.Component<ScreenRootProps> {
3231
}
3332
```
3433

34+
### 可航向滚动示例
35+
36+
```jsx
37+
import React from 'react';
38+
import { ActionBar } from '@uiw/react-native';
39+
import { View } from 'react-native'
40+
41+
export interface ScreenRootProps extends ComProps { }
42+
43+
export default class Demo extends React.Component<ScreenRootProps> {
44+
state = {
45+
selectedIndex: 0
46+
}
47+
focus = (index: number) => this.setState({ selectedIndex: index });
48+
render() {
49+
return (
50+
<View style={{ flex: 1 }}>
51+
<ActionBar
52+
scroll={true}
53+
focusIndex={this.state.selectedIndex}
54+
actions={[
55+
{
56+
label: 'Delete',
57+
onPress: () => this.focus(0),
58+
fontStyle: { fontWeight: 'bold', color: '#fff' },
59+
},
60+
{
61+
label: 'Replace',
62+
onPress: () => this.focus(1),
63+
fontStyle: { fontWeight: 'bold', color: '#fff' },
64+
},
65+
{
66+
label: 'Edit',
67+
onPress: () => this.focus(2),
68+
fontStyle: { fontWeight: 'bold', color: '#fff' },
69+
},
70+
{
71+
label: 'Delete',
72+
onPress: () => this.focus(3),
73+
fontStyle: { fontWeight: 'bold', color: '#fff' },
74+
},
75+
{
76+
label: 'Replace',
77+
onPress: () => this.focus(4),
78+
fontStyle: { fontWeight: 'bold', color: '#fff' },
79+
},
80+
{
81+
label: 'ADD',
82+
onPress: () => this.focus(5),
83+
fontStyle: { fontWeight: 'bold', color: '#fff' },
84+
},
85+
{
86+
label: 'CSS',
87+
onPress: () => this.focus(6),
88+
fontStyle: { fontWeight: 'bold', color: '#fff' },
89+
},
90+
{
91+
label: 'React',
92+
onPress: () => this.focus(7),
93+
fontStyle: { fontWeight: 'bold', color: '#fff' },
94+
},
95+
{
96+
label: 'Vue',
97+
onPress: () => this.focus(8),
98+
fontStyle: { fontWeight: 'bold', color: '#fff' },
99+
},
100+
{
101+
label: 'PHP',
102+
onPress: () => this.focus(9),
103+
fontStyle: { fontWeight: 'bold', color: '#fff' },
104+
},
105+
]}
106+
/>
107+
</View>
108+
);
109+
}
110+
}
111+
```
112+
35113
### Props
36114
```tsx
37115
export type ActionBarProps = {
@@ -40,7 +118,7 @@ export type ActionBarProps = {
40118
// 背景色
41119
backgroundColor?: string;
42120
// 按钮
43-
actions: Array<{
121+
actions?: Array<{
44122
label?: string;
45123
onPress?: () => void;
46124
fontStyle?: TextStyle;
@@ -53,5 +131,7 @@ export type ActionBarProps = {
53131
style?: ViewStyle;
54132
// 是否横向滚动
55133
scroll?: boolean
134+
// scroll横行滚动时,item跳转下标
135+
focusIndex?: number
56136
};
57137
```
1.67 KB
Loading

0 commit comments

Comments
 (0)