1- SearchInputBar 动作面板
1+ SearchInputBar 搜索栏
22---
33
44可用于用户输入搜索信息
55
6- ![ ] ( https://user-images.githubusercontent.com/66067296/140004397-65ffc69e-a79f-425d-9d75-2928c125e5c8.gif ) <!-- rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
6+ <!--  -->
7+ <!-- rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
78
89
910### 基础示例
10-
11- ``` jsx
12- import { Fragment , useState } from ' react' ;
11+ ``` jsx mdx:preview
12+ import React , { useState } from ' react' ;
1313import { SearchInputBar } from ' @uiw/react-native' ;
14+
1415function Demo () {
16+ console .log (' 1' )
1517 const [value , setValue ] = useState (' ' )
1618 return (
17- < Fragment>
1819 < SearchInputBar
1920 onChangeText= {setValue}
2021 onClear= {()=> setValue (' ' )}
@@ -25,73 +26,42 @@ function Demo() {
2526 }
2627 }}
2728 / >
28- < / Fragment>
29- );
29+ )
3030}
31+ export default Demo
3132```
3233
33- ### 一直显示右侧按钮 && 自定义placeholder && 自定右侧搜索内容
34+ ### 自定义搜索按钮
35+ ``` jsx mdx:preview
36+ import React , { useState } from ' react' ;
37+ import SearchInputBar from ' @uiw/react-native/lib/SearchInputBar' ;
3438
35- ``` jsx
36- import { Fragment , useState } from ' react' ;
37- import { SearchInputBar } from ' @uiw/react-native' ;
3839function Demo () {
3940 const [value , setValue ] = useState (' ' )
4041 return (
41- < Fragment>
4242 < SearchInputBar
4343 onChangeText= {setValue}
4444 onClear= {()=> setValue (' ' )}
4545 value= {value}
4646 placeholder= " 请输入搜索关键字"
47- searchRender= {< View style= {styles . search } >< Text > 搜索< / Text >< / View > }
47+ searchRender= {< div style= {{ display : ' flex ' , alignItems : ' center ' }} >< label > 搜索< / label >< / div > }
4848 actionName= " 搜一下"
4949 showActionButton
50- button= {{
51- onPress () {
52- // 点击搜索按钮触法
53- }
54- }}
5550 / >
56- < / Fragment>
57- );
51+ )
5852}
53+ export default Demo
5954```
6055
61- ### 键盘不收起来
62-
63- ** 注意: 每层``` ScrollView ``` 都要写``` keyboardShouldPersistTaps="always" ``` **
64-
65- ``` jsx
66- import { Fragment , useState } from ' react' ;
67- import { SearchInputBar } from ' @uiw/react-native' ;
68- function Demo () {
69- const [value , setValue ] = useState (' ' )
70- return (
71- < ScrollView keyboardShouldPersistTaps= " always" >
72- < SearchInputBar
73- onChangeText= {setValue}
74- onClear= {()=> setValue (' ' )}
75- value= {value}
76- showActionButton
77- button= {{
78- onPress () {
79- // 点击搜索按钮触法
80- }
81- }}
82- / >
83- < / ScrollView>
84- );
85- }
86- ```
8756
8857### 获取输入框 Ref
58+ ``` jsx mdx:preview
59+ import React , { useState , Fragment , useRef } from ' react' ;
60+ import { SearchInputBar , Button } from ' @uiw/react-native' ;
8961
90- ``` jsx
91- import { Fragment , useRef } from ' react' ;
92- import { SearchInputBar } from ' @uiw/react-native' ;
9362function Demo () {
9463 const inputRef = useRef ()
64+ const [value , setValue ] = useState (' ' )
9565 return (
9666 < Fragment>
9767 < SearchInputBar
@@ -113,39 +83,32 @@ function Demo() {
11383 console .log (inputRef .current .inputRef )
11484 }}
11585 > 获取 输入框 Ref< / Button>
116- < / Fragment>
117- );
86+ < / Fragment>
87+ )
11888}
89+ export default Demo
11990```
12091
12192### Props
12293** 注意: 组件继承了``` TextInput ``` 属性**
123- ``` ts
94+
95+ ``` js
12496import { TextInputProps ,StyleProp ,ViewStyle } from ' react-native' ;
12597import { ButtonProps ,IconsProps } from ' @uiw/react-native'
98+ ```
99+
100+ | 参数 | 说明 | 类型 | 默认值 |
101+ | ------| ------| -----| ------|
102+ | containerStyle | 容器样式 | StyleProp<ViewStyle > | - |
103+ | button | 右侧按钮 | ButtonProps | - |
104+ | actionName | 右侧按钮文案 | string | - |
105+ | showActionButton | 是否一直显示右侧按钮 null = 永不显示 | ` boolean ` \| ` null ` | - |
106+ | searchIcon | 搜索图标Icon参数 参考Icon组件 | IconsProps | - |
107+ | onSearch | 点击搜索图标时触发事件 | Function | - |
108+ | closeIcon | 清除图标Icon参数 参考Icon组件 | IconsProps | - |
109+ | onClear | 点击清除图标时触发事件 | Function | - |
110+ | searchRender | 自定义搜索 | React.ReactNode | - |
111+ | inputStyle | 输入框TextInput样式 | TextStyle | - |
112+ | loading | loading加载 | any | - |
113+
126114
127- export interface SearchInputBarProps extends TextInputProps {
128- /** 容器样式 */
129- containerStyle? : StyleProp <ViewStyle >;
130- /** 右侧按钮 */
131- button? : ButtonProps ;
132- /** 右侧按钮文案 */
133- actionName? : string ;
134- /** 是否一直显示右侧按钮 null = 永不显示 */
135- showActionButton? : boolean | null ;
136- /** 搜索图标Icon参数 参考Icon组件 */
137- searchIcon? : IconsProps ;
138- /** 点击搜索图标时触发事件 */
139- onSearch? : Function ;
140- /** 清除图标Icon参数 参考Icon组件 */
141- closeIcon? : IconsProps ;
142- /** 点击清除图标时触发事件 */
143- onClear? : Function ;
144- /** 自定义搜索 */
145- searchRender? : JSX .Element ;
146- /** 输入框TextInput样式 */
147- inputStyle? : TextStyle
148- /** loading加载 */
149- loading? : any
150- }
151- ```
0 commit comments