11ActionBar 底部操作栏
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
37115export 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```
0 commit comments