1.0.0 • Published 5 years ago

react-native-animated-searchbar v1.0.0

Weekly downloads
3
License
ISC
Repository
-
Last release
5 years ago

React Native Animated Searchbar for easy usage

:star: Screenshot

npm.io

:arrow_down: Installation

$ yarn add react-native-animated-searchbar

or

$ npm install --save react-native-animated-searchbar

:flashlight: Example Usage

import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import Fontawesome from 'react-native-vector-icons/FontAwesome';
import Feather from 'react-native-vector-icons/Feather';
import AnimatedSearchbar from 'react-native-animated-searchbar';
import { SearchScreen } from './SearchScreen'
Fontawesome.loadFont();
Feather.loadFont();





export const Example = () => {

    const HeaderRight = <View style={styles.rightSide}>
        <Feather name={"message-circle"} size={24} color={"#d32f2f"} />
    </View>

    const SearchBarIcon = <View style={styles.baricon}>
        <Fontawesome name={"search"} size={18} color={"gray"} />
    </View>



    return (
        <AnimatedSearchbar
            headerRight={HeaderRight}
            searchBarIcon={SearchBarIcon}
            searchScreen={<SearchScreen />}
            onChangeText={(text) => console.log(text)}
            title={"Contacts"}
        >
            <View style={styles.mainView}>
                <Text style={styles.text}>Main Screen</Text>
                {/* Your screen */}
            </View>
        </AnimatedSearchbar>
    );
}

const styles = StyleSheet.create({
    rightSide: {
        flex: 1,
        alignSelf: 'stretch',
        flexDirection: 'row',
        justifyContent: 'flex-end',
        alignItems: 'center',
        marginRight: 20
    },
    baricon: {
        alignSelf: 'stretch',
        justifyContent: 'center',
        marginLeft: 10
    },
    mainView: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: 'purple'
    },
    searchScreen: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: 'green'
    },
    text: {
        fontSize: 28,
        color: "white"
    }
})

:paperclip: Config

ParamsTypeDefaultRequiredDescription
backgroundColorstring#191919NOBackground color of the hader
animationDurationnumber150NOComponent animation duration
headerRightComponent-NORight side of the header. You can put your custom component.
headerLeftComponent-NOLeft side of the header. You can put your custom component.
titlestringTitleNoTitle text of the component
cancelTextstringCancelNOCancel text of the searchbar
cancelTextStyleStyleSheet-NOStyles of the cancel text
cancelTextMarginRightnumber20NOMargin right of the cancel text
placeholderstringSearch...NOPlaceholder of the search bar
searchbarStyleStyleSheet-NOStyle of the search bar
placeholderTextColorstringgrayNOPlaceholder color of the searchbar
onPressCancelfunc-NORun on press cancel text
onFocusfunc-NORun on focus search bar
onChangeTextfunc-NORun on change text
headerHeightnumber50NOHeader height without searchbar
searchBarIconComponent-NOSearchbar icon
searchScreenComponent-NOSecond screen for search. Open on focus search bar