SearchBar.js 1.15 KB
import React from 'react';
import {View,Alert} from 'react-native';
import { Searchbar } from 'react-native-paper';

export default class SearchBar extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            query: '',
        };
    }
    
    queryChange=(query)=>{
        this.setState({ query: query });
    }

    submit=()=>{
        this.props.toggleLoading;
        setInterval(()=>{this.props.toggleLoading},5);
        this.setState({query:''});
    }

    voiceRecognition=()=>{
        Alert.alert(
            '음성 인식',
            '아직 구현 못함',
            [
                {text: '확인', onPress: () => {}},
            ],
        )
    }

    render(){
        return(
            <>
            <View>
                <Searchbar
                placeholder="검색할 질문을 입력하세요."
                onChangeText={this.queryChange}
                value={this.state.query}
                icon='microphone'
                onIconPress={this.voiceRecognition}
                onSubmitEditing={this.submit}
                />
            </View>
            </>
        )
    }
}