From dafa729c5e3bcd3b9c5f6315bbedcc85e7e44606 Mon Sep 17 00:00:00 2001 From: WX <42308734@qq.com> Date: Fri, 15 Oct 2021 18:16:58 +0800 Subject: [PATCH] fix:Update SearchBar & SearchInputBar --- .../examples/src/routes/SearchBar/index.tsx | 8 +- .../src/routes/SearchInputBar/index.tsx | 36 +++-- packages/core/src/SearchBar/index.tsx | 95 ++++++-------- packages/core/src/SearchInputBar/README.md | 15 ++- packages/core/src/SearchInputBar/index.tsx | 124 +++++++++++------- 5 files changed, 159 insertions(+), 119 deletions(-) diff --git a/example/examples/src/routes/SearchBar/index.tsx b/example/examples/src/routes/SearchBar/index.tsx index 8d9334ac0..990da85d4 100644 --- a/example/examples/src/routes/SearchBar/index.tsx +++ b/example/examples/src/routes/SearchBar/index.tsx @@ -3,6 +3,11 @@ import {SafeAreaView} from 'react-native'; import {SearchBar} from '@uiw/react-native'; import {ComProps} from '../../routes'; import Layout from '../../Layout'; +interface Columns { + label: string; + value: number | string; +} + const datas = [ {label: '上海', value: 1}, {label: '南京', value: 2}, @@ -10,13 +15,14 @@ const datas = [ {label: '杭州', value: 4}, {label: '北京', value: 5}, ]; + const SearchBarDemo = (props: ComProps) => { const {Header} = Layout; const {route} = props; const description = route.params.description; const title = route.params.title; - const [data, setData] = useState(datas); + const [data, setData] = useState([]); return (
diff --git a/example/examples/src/routes/SearchInputBar/index.tsx b/example/examples/src/routes/SearchInputBar/index.tsx index bada02b4f..87f0b82b1 100644 --- a/example/examples/src/routes/SearchInputBar/index.tsx +++ b/example/examples/src/routes/SearchInputBar/index.tsx @@ -1,15 +1,16 @@ import React, {Component} from 'react'; -import {StyleSheet, View, TextInput} from 'react-native'; +import {StyleSheet, View, Text} from 'react-native'; import Layout, {Container} from '../../Layout'; import {SearchInputBar, Toast} from '@uiw/react-native'; import {ComProps} from '../../routes'; -const {Header, Body, Card, Footer} = Layout; +const {Header, Body, Footer} = Layout; export interface IndexProps extends ComProps {} export interface IndexState { value?: string; value2?: string; + loading?: boolean; } export default class Index extends Component { @@ -20,6 +21,7 @@ export default class Index extends Component { this.state = { value: '', value2: '', + loading: false, }; } onChangeText = (val: string, key: 'value' | 'value2') => { @@ -42,15 +44,20 @@ export default class Index extends Component { ref={this.ref} onChangeText={val => this.onChangeText(val, 'value')} onClear={() => this.onClear('value')} - placeholder="请输入搜索关键字" + placeholder="请输入搜索关键字..." + actionName="搜一下" value={this.state.value} - button={{ - type: 'success', + touchProps={{ onPress: () => { console.log('object', this.ref); - Toast.info('你点击了搜索', 2, 'info'); + this.setState({loading: true}, () => { + setTimeout(() => { + this.setState({loading: false}); + }, 3000); + }); }, }} + loading={this.state.loading} /> { onClear={() => this.onClear('value2')} value={this.state.value2} placeholder="请输入搜索关键字" - actionName=" 搜一下" + searchRender={ + + 搜索 + + } showActionButton - buttonWidth={120} - button={{ + touchProps={{ onPress() { Toast.info('你点击了搜一下', 2, 'info'); }, }} + containerStyle={{ + marginHorizontal: 10, + }} />