Spotlight Searc

Installation

To install the Quest react-native-sdk into your project, follow these steps:

  • Open your terminal/command prompt.

  • Navigate to your project's root directory using the cd command if you're not already there.

  • Run the following command to install the quest-sdk package using npm:

npm install @questlabs/react-native-sdk

This command will download and install the package and its dependencies into your project.

Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.

Usage

Root Component

  • Import the QuestProvider Component: Import the QuestProvider component from the @questlabs/react-sdk package.

import { QuestProvider } from '@questlabs/react-sdk';
  • Pass the Required Props: Pass the required props to the QuestProvider. The required props are apiKey, apiSecret, entityId and authenticationToken.

Component Usage

To integrate the SearchBar component into your React native application, follow these steps.

  • Import useSearchBar Hook: Import the useSearchBar component from the @questlabs/react-sdk package.

  • Import the SearchBar Component: Import the QuestList component from the @questlabs/react-sdk package.

  • Pass the Required Props: Pass the required props to the useSearchBar. The required props are questId, questUserId, and userToken or if user don't have quest User id then they can pass own userId to get questUserId and Token.

import { useSearchBar , SearchBar } from "@questlabs/react-native-sdk";

Don't not use QuestProvider and useSearchBar Hook in same file

Props of SearchBar Component

The SearchBar component accepts the following props

Props
Type
Require
Details

actions

ICriteria[]

Require

In offline user need to provide the require filed data.

loading

boolean

optional

don't use in offline mode.

onError

Function

optional

For Showing the Error.

visible

boolean

Require

To show the component as modal

setVisible

Function

Require

Create a fucntion for close comopnent

styleConfig

styleConfig

optional

An object containing Styling properties for styling various components within the get started process, including form, topbar, headings, descriptions, and buttons.

Style Props

styleConfig {
  Form?: ViewStyle;
  Topbar?: ViewStyle;
  Heading?: TextStyle;
  Description?: TextStyle;
  ListCard?:ViewStyle;
  Footer?: {
    FooterStyle?: ViewStyle;
    FooterText?: TextStyle;
    FooterIcon?: TextStyle;
  };
}

Example Usage

App.js

import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
import React, { useState } from "react";
import { QuestProvider } from "@questlabs/react-native-sdk";
import DemoComponent from "./DemoComponent";

export default function App() {
return (
    <SafeAreaView style={styles.container}>
      <StatusBar />
      <QuestProvider
        apiKey="Your-Api-Key"
        apiSecret="Your-Api-Secret"
        entityId="Your-Api-entityId"
        authenticationToken="Your-authentication-token"  >
        
        <DemoComponent />
        
        </QuestProvider>
   
    </SafeAreaView>
  );
}

DemoComponent.tsx

import React from "react";
import {SearchBar,useSearchBar} from "@questlabs/react-native-sdk";
const DemoComponent = () => {
  // const searchBar= useSearchBar({
  //   questId: "Your-Quest_ID" ,
  //   userId:"5235trfet365try67ywry5"
  //   })

  const searchBar= useSearchBar({
    questId: "Your-Quest_ID" ,
    questUserId: "Your-user-id",
    questToken: "Your-Token-id" 
    });
  return (
    <>
      <TouchableOpacity style={{ padding: 10, backgroundColor: "red" }} onPress={() => setOpen(true)}>
        <Text>Open</Text>
      </TouchableOpacity>
      <SearchBar
        actions={searchBar.actions}
        visible={open}
        loading={searchBar.loading}
        setVisible={() => setOpen(false)}
      // styleConfig={{
      //  Description:{color:"red"},
      //  Footer:{
      //   FooterIcon:{color:"red"}
      //  },
      //  Form:{backgroundColor:"lightgray"},
      //  Heading:{color:"yellow"},
      //  ListCard:{backgroundColor:"blue",margin:5,borderRadius:10},
      //  Topbar:{backgroundColor:"orange"}
      // }}
      />
    </>
  );
};
export default DemoComponent;

Demo

Last updated