Git Product home page Git Product logo

iq-scm / react-native-dynamic-search-bar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wrathchaos/react-native-dynamic-search-bar

0.0 0.0 0.0 48.68 MB

Medium Article: https://freakycoder.com/react-native-library-dynamic-search-bar-c03fea9fae36

License: MIT License

Shell 0.27% JavaScript 20.29% Ruby 2.31% C++ 12.98% Objective-C 4.44% Java 29.03% TypeScript 18.47% Objective-C++ 8.28% Makefile 2.81% Starlark 1.12%

react-native-dynamic-search-bar's Introduction

React Native Dynamic Search Bar

Battle Tested โœ…

Fully customizable Dynamic Search Bar for React Native

npm version npm expo-compatible Platform - Android and iOS License: MIT

React Native Dynamic Search Bar

React Native Dynamic Search Bar React Native Dynamic Search Bar

Built-in Spinner

React Native Dynamic Search Bar

Version 2.0 ๐Ÿฅณ

Version 2.0 is here ๐Ÿฅณ

  • Completely re-written from scratch ๐Ÿ’ช
  • Much better coding for maintenance and less dependency
  • 3 dependencies are removed ๐Ÿ˜ฑ
  • Better prop management and cool customizations are possible now
  • Dark Mode integration ๐ŸŒ™

I can't wait to see what you're going to make with this SearchBar ๐Ÿ˜

Installation

Add the dependency:

React Native

npm i react-native-dynamic-search-bar
npm i react-native-spinkit
npm i @freakycoder/react-native-bounceable

Expo Version

npm i WrathChaos/react-native-dynamic-search-bar#expo
npm i react-native-animated-spinkit
npm i @freakycoder/react-native-bounceable

Peer Dependencies

IMPORTANT! You need install them
"react-native-spinkit": ">= 1.5.0",
"@freakycoder/react-native-bounceable": ">= 0.2.2",

Expo Peer Dependencies

IMPORTANT! You need install them
"react-native-animated-spinkit": ">= 1.5.0",
"@freakycoder/react-native-bounceable": ">= 0.2.2",

Usage

Import

import SearchBar from "react-native-dynamic-search-bar";

Basic Usage

<SearchBar
  placeholder="Search here"
  onPress={() => alert("onPress")}
  onChangeText={(text) => console.log(text)}
/>

Advanced Usage

You can check the example for the advanced usage

<SearchBar
  fontColor="#c6c6c6"
  iconColor="#c6c6c6"
  shadowColor="#282828"
  cancelIconColor="#c6c6c6"
  backgroundColor="#353d5e"
  placeholder="Search here"
  onChangeText={(text) => this.filterList(text)}
  onSearchPress={() => console.log("Search Icon is pressed")}
  onClearPress={() => this.filterList("")}
  onPress={() => alert("onPress")}
/>

Advanced Built-in Spinner Usage

You can check the example for the advanced built-in spinner usage

import React, { Component } from "react";
import { View } from "react-native";
import SearchBar from "react-native-dynamic-search-bar";

export default class Test extends Component {
  handleOnChangeText = (text) => {
    // ? Visible the spinner
    this.setState({
      searchText: text,
      spinnerVisibility: true,
    });

    // ? After you've done to implement your use-case
    // ? Do not forget to set false to spinner's visibility
    this.setState({
      spinnerVisibility: false,
    });
  };

  render() {
    const { spinnerVisibility } = this.state;
    return (
      <View>
        <SearchBar
          height={50}
          fontSize={24}
          fontColor="#fdfdfd"
          iconColor="#fdfdfd"
          shadowColor="#282828"
          cancelIconColor="#fdfdfd"
          backgroundColor="#ba312f"
          spinnerVisibility={spinnerVisibility}
          placeholder="Search any cosmetics ..."
          fontFamily="BurbankBigCondensed-Black"
          shadowStyle={styles.searchBarShadowStyle}
          onChangeText={this.handleOnChangeText}
        />
      </View>
    );
  }
}

Configuration - Props

Property Type Default Description
style ViewStyle default set or override the style object for the main search view
darkMode boolean false enable the dark mode
onChangeText function function set your own function for the onChangeText logic
onPress function function set your own function for the onPress functionality
onSearchPress function function set your own function for the search button's onPress functionality
onClearPress function function set your own function for the clear button's onPress functionality
onBlur function function set your own function for the text input's onBlur functionality
onFocus function function set your own function for the text input's onBlur functionality
textInputStyle TextStyle default set or override the style object for the text input
searchIconImageStyle ImageStyle default set or override the style object for the search icon image style
clearIconImageStyle ImageStyle default set or override the style object for the clear icon image style
ImageComponent component Image set your own Image component instead of react-native's default Image one
searchIconComponent component default set your own component instead of Icon for the search component
clearIconComponent component default set your own component instead of Icon for the clear component
searchIconImageSource ISource default change the search icon image source
clearIconImageSource ISource default change the clear icon image source
clearIconImageSource ISource default change the clear icon image source
placeholder string "Search here..." set your own placeholder string
placeholderTextColor color undefined set placeholder text color
spinnerColor color #fdfdfd change the spinner color
spinnerSize number default change the spinner size
SpinnerType component Circle change the spinner type
spinnerVisibility boolean false change the spinner visibility

Expo Compatibility

Dynamic Search Bar is usable with Expo. You just need to add a peer dependency:

"react-native-dynamic-vector-icons": "WrathChaos/react-native-dynamic-vector-icons#expo"

Known Issues

Android

Vector Icons are not showing :O

-> You need to add this line of code into app/gradle

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Animations are not working on the Android like the example?

-> You need to enable experimental LayoutAnimation on the android. Here is how to do it:

import { UIManager } from 'react-native';

constructor() {
    super();
    if (Platform.OS === 'android') {
      UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
    }
}

Roadmap

  • Completely rewritten with better coding and less dependency
  • Full code refactoring with better Typescript
  • LICENSE
  • Write an article about the lib on Medium
  • Typescript Challenge!
  • Update the Expo version to latest features
  • Built-in Shadow Style Removal
  • Wrapper Shadow Example on Documentation
  • Better Example and GIFs

Author

FreakyCoder, [email protected]

License

React Native Dynamic Search Bar Library is available under the MIT license. See the LICENSE file for more info.

react-native-dynamic-search-bar's People

Contributors

abhishekdewan101 avatar dependabot-preview[bot] avatar dependabot[bot] avatar showcasecode avatar tiagostutz avatar wrathchaos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.