0.31.0 • Published 1 year ago

senderrand-shared-components v0.31.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

senderrand-shared-components

WIP: intented collection of similar components used across out applications

Installation

npm install senderrand-shared-components

UI Components

Rigid Chat & Functionalities

Header Component Usage

import { Header } from 'senderrand-shared-components';
import { Entypo } from '@expo/vector-icons';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => (
 <Header
   lang={'ar'}
   detail={'Typing..'}
   title={'SendErrand'}
   family={family}
   entypo={Entypo}
   options={['History', 'Locations', 'Profile', 'FAQs']}
/>
)

Features

  • Styled Header with logo, title, detail & options

Tech

The Header component uses a number of open source projects to work properly:

  • styled-components - For styling.
  • expo-constant - To get status bar height

props

Below are the listed props that can be passed to the header component

PropertyTypeRequiredDescription
containerStyleStylefalseThe style passed to the header container
imagestringfalseThe image url passed to the header logo, defaults to senderrand logo
titlestringfalseThe text string to be displayed in the title
titleStyleStylefalseThe style passed to the header title
detailstringfalseThe text string to be displayed in the detail below the title
detailStyleStylefalseThe style passed to the header detail
optionsarrayfalseAn string array of options passed to the header menu options
entypo@expo/vector-iconstrueIt takes in Entypo component to represent the menu icon
optionTxtStyleStylefalseThe style passed to the option text component
onPressOptionFunctionfalseThis function call when each menu option is tapped. It returns the index of the tapped option as parameter
familyobjecttrueAn object that contains the font family used for the text elements in the header component. An example is shown above.
langstringfalseThe language that should be used for the default text in the component. Defaults to en.

Header2 Component Usage

import { Header2 } from 'senderrand-shared-components';
import { Entypo, MaterialIcons } from '@expo/vector-icons';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => (
  <Header2
    lang={'en'}
    entypo={Entypo}
    title={'Earnings'}
    family={family}
    back={() => props.navigation.goBack()}
    options={['One', 'Two']}
    materialIcons={MaterialIcons}
  />
)

Features

  • Styled Header with title, detail & options

Tech

The Header2 component uses a number of open source projects to work properly:

  • styled-components - For styling.
  • expo-constant - To get status bar height

props

Below are the listed props that can be passed to the header2 component

PropertyTypeRequiredDescription
containerStyleStylefalseThe style passed to the header container
titlestringfalseThe text string to be displayed in the title
leftReact.ComponentfalseA component displayed on the left part of the header.
rightReact.ComponentfalseA component displayed on the right part of the header.
backfunctionfalseA function called when back button is pressed. When passed the back button displays.
optionsarrayfalseAn string array of options passed to the header menu options
entypo@expo/vector-iconstrueIt takes in Entypo component to represent the menu icon
optionTxtStyleStylefalseThe style passed to the option text component
onPressOptionFunctionfalseThis function call when each menu option is tapped. It returns the index of the tapped option as parameter
familyobjecttrueAn object that contains the font family used for the text elements in the header component. An example is shown above.
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
inputReffunctionfalseTakes the ref of the footer input as parameter.
keyboardTypestringfalseTakes the keyboard type of the footer input.

Footer Component Usage

import { Footer } from 'senderrand-shared-components';

let fontFamily = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => (
 <Footer
   send={send}
   family={family}
   ionicons={Ionicons}
   antDesign={AntDesign}
   materialCommunityIcons={MaterialCommunityIcons}
   onSelectOption={(index: number) => console.log(index)}
   footerOnPressLaunchIcon={() => {}}
   onError={(message: string) => Alert.alert('Failed', message)}
 />
);

Features

  • Camera.
  • Image Picker.
  • Audio Recorder.
  • Text Input

Tech

The Footer component uses a number of open source projects to work properly:

  • expo-av - For Audio Recording.
  • expo-image-picker - To take picture from camera or select from library.
  • react-native-actionsheet - To display Footer options.
  • expo-file-system - To get the URI of the recorded audio.

props

Below are the listed props that can be passed to the footer component

PropertyTypeRequiredDescription
defaultOptionsarrayfalseThis array is passed to the footer options to display. Defaults to ['Camera', 'Photo Library']
cancetTxtstringfalseThe string to replace the cancel text. Defaults to Cancel
optionsarrayfalseAdditional options passed to the footer to display.
replyobjectfalseA message object passed to the footer to display when replying a message.
sendfunctionfalseA functions that returns the message object as a parameter.
onErrorfunctionfalseA function that returns error message as a parameter.
onSelectOptionfunctionfalseThe function returns the index of the selected option as parameter.
footerOnPressLaunchIconfunctionfalseWhen specified, the function is executed when the Plus or Location Icon is pressed instead of showing the Action Sheet.
onSelectDefaultOptionfunctionfalseThe function returns the index of the selected option as parameter.
ionicons@expo/vector-iconstrueIt takes in Ionicons component to display icons in the footer component
familyobjecttrueAn object that contains the font family used for the text elements in the footer component. An example is shown above.
multilinebooleanfalseThe multiline props for the footer text input.
placeholderstringfalseThe placeholder props for the footer text input.
keyboardTypestringfalseThe keyboardType props for the footer text input.
antDesign@expo/vector-iconstrueIt takes in AntDesign component to display icons in the footer component
loadingbooleanfalseTo disable all footer functionalities and display the loading component.
materialCommunityIcons@expo/vector-iconstrueIt takes in MaterialCommunityIcons component to display icons in the footer component
sheetOneTitlestringfalseThe title of the first action sheet, defaults to Options.
sheetTwoTitlestringfalseThe title of the second action sheet, defaults to Options.
onChangeTextfunctionfalseHandles text input change, returns text string as parameter.
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
setTypingfunctionfalseThis function property lets know when user is typing by sending true when typing and false when not.
setRecordingfunctionfalseThis function property lets know when user is recording by sending true when recording and false when not.

Success Modal 1

import { SuccessModal } from 'senderrand-shared-components';
import { useState } from 'react';
import { Entypo } from '@expo/vector-icons';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {
  let [visible, setVisible] = useState(true)

  return (
    <SuccessModal
      family={family}
      visible={visible}
      title={'Congratulations'}
      close={() => setVisible(false)}
      btnTitle={'Close Modal'}
      entypo={Entypo}
      content={'We are exited to have you join our team!'}
    />
  )
}

Features

  • A styled success modal to be displayed after successful action

props

Below are the listed props that can be passed to the header component

PropertyTypeRequiredDescription
animationTypestringfalseDefault animationType options for react native modal. Defaults to slide
visiblebooleantrueSet the visibility of the modal to true or false
entypo@expo/vector-iconstrueIt takes in Entypo component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
titlestringfalseThe text string to be displayed as title ex: 'Congrats'
contentstringfalseThe details string displayed below the title
closefunctionfalseA function called after the button is pressed
btnTitlestringfalseThe title of the button displayed

Success Modal 2

import { SuccessModal2 } from 'senderrand-shared-components';
import { useState } from 'react';
import { Entypo } from '@expo/vector-icons';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {
  let [visible, setVisible] = useState(true)

  return (
    <SuccessModal2
      entypo={Entypo}
      family={family}
      visible={visible}
      text={'Verified Successfully'}
      press={() => setVisible(false)}
      btnTitle={'Continue'}
    />
  )
}

Features

  • A styled success modal to be displayed after successful action

props

Below are the listed props that can be passed to the header component

PropertyTypeRequiredDescription
bluebooleanfalsePass blue to display the blue version, defaults to green
visiblebooleantrueSet the visibility of the modal to true or false
entypo@expo/vector-iconstrueIt takes in Entypo component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
textstringfalseThe text string to be displayed as title ex: 'Verified Successfully'
pressfunctionfalseA function called after the button is pressed
btnTitlestringfalseThe title of the button displayed

Custom Modal

import { CustomModal } from 'senderrand-shared-components';
import { useState } from 'react';
import { AntDesign } from '@expo/vector-icons';

const Example = () => {
  let [visible, setVisible] = useState(true)

  return (
    <CustomModal
      visible={visible}
      close={() => setVisible(false)}
      antdesign={AntDesign}
    >
      <Text>Hello, here is a sample modal content</Text>
    </CustomModal>
  )
}

Features

  • A styled custom modal, that takes in a JSX Element as children to be displayed in the modal container.

props

Below are the listed props that can be passed to the custom modal component

PropertyTypeRequiredDescription
visiblebooleantrueSet the visibility of the modal to true or false
antdesign@expo/vector-iconstrueIt takes in AntDesign component to display icons in the component
closefunctiontrueA function called after the close button is pressed
childrenJSX.ElementtrueChildren element that is displayed in the modal

TextBox Component

import { TextBox } from 'senderrand-shared-components';
import { Ionicons } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <TextBox
          family={family}
          ionicons={Ionicons}
          reply={item.reply}
          status={item.status} // 0: not sent, 1: sent, 2: received, 3:read
          text={item.text}
          date={item.date}
          sender={item.sender.id === 1}
          toReply={() => scrollToMsg(item.reply)}
          onSelectOption={() => {}}
        />
      )}
    />
  )
}

Features

  • A chat text box component

props

Below are the listed props that can be passed to the TextBox

PropertyTypeRequiredDescription
optionsarrayfalseOptions displayed on long press of the chat text box.
cancetTxtstringfalseThe string to replace the cancel text. Defaults to Cancel
ionicons@expo/vector-iconstrueIt takes in ionicons component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
onSelectOptionfunctionfalseThe function returns the index of the selected option as parameter.
senderbooleantrueThe boolean that denotes the sender of the message
replyobjectfalseA message object passed to display the message replied to
toReplyfunctiontrueThe function that calls when the reply component in the chat box in tapped.
textstringfalseThe text message displayed in the text box.
dateDatefalseA date object to be displayed in the text box.
statusnumberfalseThe status of the current message 0 = sending(not send), 1 = sent, 2 = received, 3 = read.
optionTitlestringfalseThe title of the displayed options, defaults to Options
langstringfalseThe language that should be used for the default text in the component. Defaults to en.

VoiceNote Component

import { VoiceNote } from 'senderrand-shared-components';
import { Ionicons, Entypo } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <VoiceNote
          image={'http//jpg'}
          entypo={Entypo}
          ionicons={Ionicons}
          status={item.status}
          date={item.date}
          audio={item.file && item.file.uri}
          sender={item.sender.id === 1}
          onSelectOption={() => {}}
        />
      )}
    />
  )
}

Features

  • A chat voice note component

props

Below are the listed props that can be passed to the VoiceNote

PropertyTypeRequiredDescription
optionsarrayfalseOptions displayed on long press of the chat text box.
cancetTxtstringfalseThe string to replace the cancel text. Defaults to Cancel
audiostringtrueThe audio url.
ionicons@expo/vector-iconstrueIt takes in Ionicons component to display icons in the component
entypo@expo/vector-iconstrueIt takes in Entypo component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
onSelectOptionfunctionfalseThe function returns the index of the selected option as parameter.
senderbooleantrueThe boolean that denotes the sender of the message
dateDatefalseA date object to be displayed in the text box.
statusnumberfalseThe status of the current message 0 = sending(not send), 1 = sent, 2 = received, 3 = read.
optionTitlestringfalseThe title of the displayed options, defaults to 'Options'
imagestringfalseThe image of the voice note sender.

ImageBox Component

import { ImageBox } from 'senderrand-shared-components';
import { Ionicons } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <VoiceNote
          image={'http//jpg'}
          entypo={Entypo}
          ionicons={Ionicons}
          status={item.status}
          date={item.date}
          audio={item.file && item.file.uri}
          sender={item.sender.id === 1}
          onSelectOption={() => {}}
        />
      )}
    />
  )
}

Features

  • A chat image box component

props

Below are the listed props that can be passed to the ImageBox

PropertyTypeRequiredDescription
imagestringfalseThe image url to be displayed.
optionsarrayfalseOptions displayed on long press of the chat text box.
cancetTxtstringfalseThe string to replace the cancel text. Defaults to Cancel
ionicons@expo/vector-iconstrueIt takes in ionicons component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
onSelectOptionfunctionfalseThe function returns the index of the selected option as parameter.
senderbooleantrueThe boolean that denotes the sender of the message
dateDatefalseA date object to be displayed in the text box.
statusnumberfalseThe status of the current message 0 = sending(not send), 1 = sent, 2 = received, 3 = read.
optionTitlestringfalseThe title of the displayed options, defaults to 'Options'

VideoBox Component

import { ImageBox } from 'senderrand-shared-components';
import { Ionicons } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <VideoBox
          lang={'en'}
          ionicons={Ionicons}
          status={item.status}
          date={item.date}
          video={item.file && item.file.uri}
          sender={item.sender.id === 1}
          onSelectOption={() => {}}
        />
      )}
    />
  )
}

Features

  • A chat video box component

props

Below are the listed props that can be passed to the VideoBox

PropertyTypeRequiredDescription
videostringfalseThe video url.
ionicons@expo/vector-iconstrueIt takes in ionicons component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
senderbooleantrueThe boolean that denotes the sender of the message
dateDatefalseA date object to be displayed in the text box.
statusnumberfalseThe status of the current message 0 = sending(not send), 1 = sent, 2 = received, 3 = read.

FooterOptions Component

import { FooterOptions } from 'senderrand-shared-components';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FooterOptions
      family={family}
      press={(index: number) => console.log(index)}
      options={['Purchase', 'Pick Up']}
    />
  )
}

Features

  • A UI component that display an array of buttons

props

Below are the listed props that can be passed to the FooterOptions

PropertyTypeRequiredDescription
optionsarraytrueThe string array representing each button to be displayed. Each button displays the string passed.
familyobjecttrueAn object containing the app font family, example above
pressfunctiontrueThe function called when a button is pressed, with the index of the particular button pressed.

LocationBox Component

import { LocationBox } from 'senderrand-shared-components';
import { Ionicons, Entypo, MaterialIcons } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <LocationBox
          lang={'en'}
          family={family}
          ionicons={Ionicons}
          entypo={Entypo}
          materialIcons={MaterialIcons}
          status={item.status} // 0: not sent, 1: sent, 2: received, 3:read
          text={item.data && item.data.address && item.data.address}
          date={item.date}
          sender={true}
          options={['Option 1', 'Option 2']}
          onSelectOption={() => {}}
          location_type={item.data && item.data.location_type}
        />
      )}
    />
  )
}

Features

  • A component to display selected location in a chat text box

props

Below are the listed props that can be passed to the LocationBox

PropertyTypeRequiredDescription
optionsarrayfalseOptions displayed on long press of the chat text box.
cancetTxtstringfalseThe string to replace the cancel text. Defaults to Cancel
ionicons@expo/vector-iconstrueIt takes in ionicons component to display icons in the component
entypo@expo/vector-iconstrueIt takes in entypo component to display icons in the component
materialIcons@expo/vector-iconstrueIt takes in materialIcons component to display icons in the component
familyobjecttrueAn object containing the app font family, example above
onSelectOptionfunctionfalseThe function returns the index of the selected option as parameter.
senderbooleantrueThe boolean that denotes the sender of the message
replyobjectfalseA message object passed to display the message replied to
toReplyfunctiontrueThe function that calls when the reply component in the chat box in tapped.
textstringfalseThe text message displayed in the text box.
dateDatefalseA date object to be displayed in the text box.
statusnumberfalseThe status of the current message 0 = sending(not send), 1 = sent, 2 = received, 3 = read.
optionTitlestringfalseThe title of the displayed options, defaults to Options
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
location_typestringfalseIf it has store as it's value, it uses a store icon, otherwise it uses a location pin icon.

FleetFooter Component

import { FleetFooter } from 'senderrand-shared-components';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FleetFooter select={(index: number) => {}} />
  )
}

Features

  • A UI component that display the fleet options to selection

props

Below are the listed props that can be passed to the FleetFooter

PropertyTypeRequiredDescription
selectfunctiontrueThe function called when a fleet is selected, returning the index of the selected fleet as parameter.

FleetBox Component

import { FleetBox } from 'senderrand-shared-components';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <FleetBox
          lang={'en'}
          date={item.date}
          index={1}
          sender={true}
          family={family}
          options={['Edit', 'Delete']}
          onSelectOption={() => {}}
        />
      )}
    />
  )
}

Features

  • A component to displays the selected fleet

props

Below are the listed props that can be passed to the FleetBox

PropertyTypeRequiredDescription
indexnumbertrueThe index of the selected fleet.
optionsarrayfalseOptions displayed on long press of the chat text box.
cancetTxtstringfalseThe string to replace the cancel text. Defaults to Cancel
familyobjecttrueAn object containing the app font family, example above
onSelectOptionfunctionfalseThe function returns the index of the selected option as parameter.
senderbooleantrueThe boolean that denotes the sender of the message
dateDatefalseA date object to be displayed in the FleetBox.
statusnumberfalseThe status of the current message 0 = sending(not send), 1 = sent, 2 = received, 3 = read.
optionTitlestringfalseThe title of the displayed options, defaults to Options
langstringfalseThe language that should be used for the default text in the component. Defaults to en.

StatusBox Component

import { StatusBox } from 'senderrand-shared-components';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <StatusBox
          family={family}
          text={item.text}
          color={item.data && item.data.color && item.data.color}
          loading={false}
        />
      )}
    />
  )
}

Features

  • A component to displays the errand status within the chat

props

Below are the listed props that can be passed to the StatusBox

PropertyTypeRequiredDescription
familyobjecttrueAn object containing the app font family, example above
textstringfalseThe text to be displayed.
colorstringfalseThe text color
loadingbooleanfalseDisplays loading spinner when set to true.

NewRunner Component

import { NewRunner } from 'senderrand-shared-components';
import { AntDesign } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <NewRunner
          lang={'ar'}
          antDesign={AntDesign}
          family={family}
          text={'Runner YINKA joined the chat'}
          name={'Runner Yinka'}
          runs={'90+ Runs'}
          rate={4}
          image={
            'https://media.istockphoto.com/photos/portrait-of-a-girl-picture-id938709362?s=612x612'
          }
        />
      )}
    />
  )
}

Features

  • A component to displays the newly added runner

props

Below are the listed props that can be passed to the NewRunner

PropertyTypeRequiredDescription
familyobjecttrueAn object containing the app font family, example above
textstringfalseThe status text to be displayed.
namestringfalseThe name of the runner.
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
runsstringfalseThe amount of runs text.
ratenumberfalseThe runners rating ranges from 0 - 5.
imagestringfalseDisplays the image url passed as the runners photo.
antDesign@expo/vector-iconstrueIt takes in antDesign component to display icons in the component

InvoiceBox Component

import { InvoiceBox } from 'senderrand-shared-components';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <InvoiceBox
          lang={'ar'}
          txt1={item.text}
          txt2={item.text}
          txt3={item.text}
          date={item.date}
          family={family}
          invoiceID={item.id}
          price={'100 AED'}
        />
      )}
    />
  )
}

Features

  • An invoice UI component

props

Below are the listed props that can be passed to the InvoiceBox

PropertyTypeRequiredDescription
familyobjecttrueAn object containing the app font family, example above
txt1stringfalseDefaults to Invoice.
txt2stringfalseDefaults to Grand Total:.
txt2stringfalseDefaults to View Invoice.
pressfunctionfalseThe function called when the component is pressed.
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
invoiceIDstringfalseDisplays the invoice ID passed to it.
pricestringfalseDisplays the string passed as price.
dateDatefalseA date object to be displayed in the InvoiceBox.

TrackBox Component

import { TrackBox } from 'senderrand-shared-components';
import { Feather } from '@expo/vector-icons';
import { FlatList } from 'react-native';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {

  return (
    <FlatList
      data={[]}
      renderItem={(item: any) => (
        <TrackBox
          lang={'en'}
          feather={Feather}
          text={item.text}
          date={item.date}
          family={family}
          region={item.data && item.data.region && item.data.region}
          position={item.data && item.data.position && item.data.position}
        />
      )}
    />
  )
}

Features

  • An location tracking UI component

props

Below are the listed props that can be passed to the TrackBox

PropertyTypeRequiredDescription
familyobjecttrueAn object containing the app font family, example above
textstringfalseDefaults to Track Delivery.
pressfunctionfalseThe function called when the component is pressed.
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
dateDatefalseA date object to be displayed in the InvoiceBox.
regionobjecttrueAn object containing longitude and latitude.
positionobjecttrueAn object containing longitude and latitude.
Feather@expo/vector-iconstrueIt takes in Feather component to display icons in the component

SwipeUp Component

import { SwipeUp } from 'senderrand-shared-components';

const Example = () => (
  <SwipeUp>
    // ... children
  </SwipeUp>
);

Features

  • An component for swiping up and down

props

Below are the listed props that can be passed to the SwipeUp

PropertyTypeRequiredDescription
containerHeightnumberfalseThe default height of the swipe box.
closefuncitonfalseSet swipe visibility to false when called.
disableSwipebooleanfalseTo disable the swipe up and down if it's not required.
containerStylestylefalseStyle passed to the container.
avoidbooleanfalseAdd avoid prop if keyboard is present in the swipe children.

LoadingModal

import { LoadingModal } from 'senderrand-shared-components';
import { useState } from 'react';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {
  let [visible, setVisible] = useState(true)

  return (
    <LoadingModal
      visible={loading}
      family={family}
      text={'Processing Payment..'}
    />
  )
}

Features

  • A modal to display loading UI

props

Below are the listed props that can be passed to the loading component

PropertyTypeRequiredDescription
textstringfalseThe value to the text displayed in the loader.
visiblebooleantrueSet the visibility of the modal to true or false
familyobjecttrueAn object containing the app font family, example above
closefunctionfalseToggle visibility to close modal when user taps the modal.

InvoiceModal

import { InvoiceModal } from 'senderrand-shared-components';
import { useState } from 'react';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

const Example = () => {
  let [visible, setVisible] = useState(true)

  let invoice = [
    {
      item: 'Brake pads for Honda accord 2009 Front and Rear',
      quantity: 1,
      price: 200,
    },
    {
      item: 'Brake discs for Honda accord 2009. Front and Rear',
      quantity: 2,
      price: 400,
    },
    {
      item: 'Brake Oil',
      quantity: 2,
      price: 20,
    },
    {
      item: 'Errand cost',
      quantity: 1,
      price: 100,
    },
  ];

  let totals = [
    { title: 'SUBTOTAL', value: '720 NGN' },
    { title: 'DISCOUNT', value: '110 NGN', discount: '3%' },
    { title: 'TAX', value: '10 NGN' },
  ];

  return (
    <InvoiceModal
      lang={'en'}
      currency={'NGN'}
      visible={visible}
      family={family}
      totalItems={totals}
      items={invoice}
      nameKey={'item'}
      qtyKey={'quantity'}
      rateKey={'price'}
      grandTotal={'610 NGN'}
      txt2={"Runner's Name: YINKA"}
      txt3={'#12345673'}
      close={() => setInvoice(false)}
      press={(index: number) => console.log(index)}
    />
  )
}

Features

  • A modal to display invoice UI

props

Below are the listed props that can be passed to the invoice component

PropertyTypeRequiredDescription
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
currencystringtrueThe currency to be displayed in the invoice.
visiblebooleantrueSet the visibility of the modal to true or false
familyobjecttrueAn object containing the app font family, example above
closefunctionfalseToggle visibility to close modal when user taps the modal.
totalItemsarraytrueAn array including the subtotal, discount, tax, etc.
titlesarrayfalseAn array of string titles, defaults to ['DESCRIPTION', 'RATE', 'QTY', 'SUBTOTAL'].
txt1stringfalseDefaults to You’ve received an invoice.
txt2stringfalseDefaults to Runner.
txt3stringfalseInvoice ID should be passed here. Empty if nothing is passed.
nameKeystringfalseThe key of the item name within the invoice object.
qtyKeystringfalseThe key of the quantity name within the invoice object.
rateKeystringfalseThe key of the price within the invoice object.
grandTotalstringfalseThe invoice total.
grandTotalTxtstringfalseDefaults to GRAND TOTAL.
pressfunctionfalseWhen the press prop is passed, the accept and decline CTA button displays. It returns the index of the button pressed as parameter 1 for accept, 2 for decline.
acceptTxtstringfalseDefaults to Accept.
declineTxtstringfalseDefaults to Decline.

ReasonSwipe Component

import { ReasonSwipe } from 'senderrand-shared-components';
import { Ionicons } from '@expo/vector-icons';

let reasons = [
  { reason: 'Runner took too long to respond' },
  { reason: 'Wrong pickup location' },
  { reason: 'I don’t need the service anymore' },
  { reason: 'Have to attend to an Emergency' },
];

const Example = () => (
  <ReasonSwipe
    lang={'en'}
    ionicons={Ionicons}
    family={family}
    data={reasons}
    textKey={'reason'}
    onSend={(item) => console.log(item)}
    onSelect={(item) => console.log(item)}
  />
);

Features

  • A component for displaying the array of reasons

props

Below are the listed props that can be passed to the ReasonSwipe

PropertyTypeRequiredDescription
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
dataarraytrueAn array or reasons passed to the component, example above.
onSelectfuncitontrueThe function called when a reason is selected returning she selected reason as parameter.
textKeystringtrueThe key to the reason string in the object.
othersTxtstringfalseDefaults to Others:.
onSendfunctiontrueThe function returns the custom reason entered in the input field.
familyobjecttrueAn object containing the app font family, example above
ionicons@expo/vector-iconstrueIt takes in Ionicons component to display icons in the component

LocationSwipe Component

import { LocationSwipe } from 'senderrand-shared-components';
import { Ionicons, MaterialIcons } from '@expo/vector-icons';

let locations = [
  {
    distance: '1.3km',
    timing: 'Deira',
    address: 'Dubai Deira International Market',
  },
  {
    distance: '400m',
    timing: '10am - 10:30pm',
    status: 1,
    address: 'Auto Pro, Silicon Oasis, Dubai',
  },
  {
    distance: '2km',
    timing: '10am - 2:30pm',
    status: 2,
    address: 'Zoom Enoc, Silicon Oasis, Dubai',
  },
];

const Example = () => (
  <LocationSwipe
    lang={'en'}
    family={family}
    data={locations}
    ionicons={Ionicons}
    materialIcons={MaterialIcons}
    onSelect={(item) => console.log(item)}
  />
);

Features

  • A component displaying locations

props

Below are the listed props that can be passed to the LocationSwipe

PropertyTypeRequiredDescription
langstringfalseThe language that should be used for the default text in the component. Defaults to en.
dataarraytrueAn array or locations passed to the component, example above.
onSelectfuncitontrueThe function called when a location is selected returning she selected location as parameter.
chooseTxtstringfalseDefaults to Choose from Map.
savedTxtstringfalseDefaults to Saved Locations.
onPressSavedfunctiontrueThe function called when saved location is tapped.
onPressChoosefunctiontrueThe function called when choose from map is tapped.
familyobjecttrueAn object containing the app font family, example above
ionicons@expo/vector-iconstrueIt takes in Ionicons component to display icons in the component
materialIcons@expo/vector-iconstrueIt takes in MaterialIcons component to display icons in the component

Exported Libraries

  • react-native-webview
  • react-native-remote-svg
  • expo-asset
  • expo-av
  • expo-constants
  • expo-document-picker
  • expo-file-system
  • expo-font
  • expo-image-manipulator
  • expo-image-picker
  • moment
  • react-native-actionsheet
  • react-native-animatable
  • react-native-maps
  • react-native-size-matters
  • react-native-sliders
  • react-native-svg
  • react-native-zigzag-lines
  • react-swipeable-views-native
  • styled-components

Contributing

Rigid Chat

import Errand from "senderrand-shared-components";
import {
  Ionicons,
  AntDesign,
  Feather,
  MaterialIcons,
  MaterialCommunityIcons,
  Entypo,
} from '@expo/vector-icons';
import Chat, {
  getInvoiceMessage,
  getStatusMessage,
  getNewRunnerMessage,
  xmppSend,
  runnerInterface,
  getTrackerMessage, // @ts-ignore
} from 'senderrand-shared-components';

const family = {
  light: 'Light',
  regular: 'Regular',
  medium: 'Medium',
  bold: 'Bold',
  italic: 'RegularItalic',
};

let sender = { id: 1, name: 'Ollan Monsur' };
let sender2 = { id: 2, name: 'Yinka Azeez' };
let msg = getInvoiceMessage(
  '1',
  '#1223342',
  '20 AED',
  sender2,
  'Mirdif City Center',
  'ar'
);
let msg2 = getTrackerMessage(
  '1',
  { longitude: 55.3863, latitude: 25.1279 },
  { longitude: 55.3775, latitude: 25.1218 },
  sender2,
  'en'
);
let msg3 = getStatusMessage(
  '1',
  'Yinka is arriving somewhere currently',
  sender2
);
let runner: runnerInterface = {
  ...sender2,
  image:
    'url.png',
  rate: 4,
  runs: 110,
};
let msg4 = getNewRunnerMessage('1', runner, 'ar');

// ...

export default () => {
  let [messages, setMessages] = useState([...data, msg, msg2, msg3, msg4]);
  let send = (message: any) => {
    setMessages([...messages, message]);
    xmppSend('from jabber id', 'to jabber id', message);
  };

  return (
    <Wrap>
      <Errand
        orderID={1}
        headerOptions={['History', 'Locations', 'Settings', 'FAQ']}
        headerOnSelectOption={(index) => console.log(index)}
        family={family}
        user={sender}
        send={send}
        messages={messages}
        ionicons={Ionicons}
        entypo={Entypo}
        materialIcons={MaterialIcons}
        antDesign={AntDesign}
        invoiceBoxPress={(item) => console.log(item)}
        trackBoxPress={(item) => console.log(item)}
        feather={Feather}
        loading={false}
        footerOnError={(error: string) => Alert.alert('Failed', error)}
        materialCommunityIcons={MaterialCommunityIcons}
      />
    </Wrap>
  );
};

props

Below are the listed props that can be passed to the header component

PropertyTypeRequiredDescription
langstringfalseThe language code for the chat. Defaults to en.
useruserDatatrueThis is the currently logged in user. It's an object that should consist of id, name and image. image is not compulsory.
sendfunctiontrueTakes in the message data as parameter. See example above.
textBoxOnSelectOptionfunctionfalseTakes the index and the item selected from the text box options.
mediaOnSelectOptionfunctionfalseTakes the index and the item selected from the media box options.
locationBoxOnSelectOptionfunctionfalseTakes the index and the item selected from the location box options.
fleetBoxOnSelectOptionfunctionfalseTakes the index and the item selected from the fleet box options.
footerOnSelectOptionfunctionfalseTakes the index of the selected option from the footer options.
footerOnSelectDefaultOptionfunctionfalseTakes the index of the selected option from the default footer options.
headerOnSelectOptionfunctionfalseTakes the index of the selected option from the header options.
familyobjecttrueAn object that contains the font family used for the text elements in the component. An example is shown above.
messagesarraytrueAn array of messages.
entypo@expo/vector-iconstrueIt takes in Entypo component to display icons in the component. Example above.
ionicons@expo/vector-iconstrueIt takes in Ionicons component to display icons in the component. Example above.
materialIcons@expo/vector-iconstrueIt takes in MaterialIcons component to display icons in the component. Example above.
antDesign@expo/vector-iconstrueIt takes in AntDesign component to display icons in the component. Example above.
feather@expo/vector-iconstrueIt takes in Feather component to display icons in the component. Example above.
materialCommunityIcons@expo/vector-iconstrueIt takes in MaterialCommunityIcons component to display icons in the component. Example above.
textBoxOptionsarrayfalseAn array of string passed as the text box options.
voiceNoteOptionsarrayfalseAn array of string passed as the voice note options.
imageBoxOptionsarrayfalseAn array of string passed as the image box options.
errandLocationOptionsarrayfalseAn array of string passed as the errand location box options.
fleetBoxOptionsarrayfalseAn array of string passed as the fleet box options.
footerOptionsarrayfalseAn array of string passed as the footer options.
footerDefaultOptionsarrayfalseAn array of string passed as the footer default options. Defaults to ['Camera', 'Library']
headerOptionsarrayfalseAn array of string passed as the header options.
textBoxBtnPressfunctionfalseThe property called when the button in the text box is pressed. It returns the message item as parameter.
invoiceBoxPressfunctionfalseThe prop called when the invoice box is pressed. It returns the message item as parameter.
trackBoxPressfunctionfalseThe props called when the tracker box is pressed. It returns the message item as parameter.
loadingbooleanfalseTo disable actions in the component and show loading.
footerOnErrorfunctiontrueThe function called to return the error parameter when there is an error to report in the component.
footerOnChangeTextfunctionfalseHandles the onChangeText for the footer TextInput.
footerOptionsPressfunctionfalseThe prop called when a button is pressed from the footer button options. It returns the index and item as parameter.
footerTypestringfalseTo change the footer type. The available types are fleet, options, footer. Defaults to footer.
headerTitlestringfalseThe string title passed to the header.
headerDetailstringfalseThe text shown below the header title.
newRunnerPressfunctionfalseThe prop called when the new runner component is tapped.
footerSetTypingfunctionfalseThe prop called when user starts and stops typing. It take in a boolean as parameter. True for typing, False for not typing.
footerSetRecordingfunctionfalseThe prop called when user starts and stops recording. It take in a boolean as parameter. True for recording, False for not recording.
footerInputReffunctionfalseTakes the ref of the footer input as parameter.
footerKeyboardTypestringfalseTakes the keyboard type of the footer input.
clearbooleanfalseTo trigger the clearing of the input field.
removeFooterbooleanfalseHides the footer, defaults to false.

Get Invoice Message

import { getInvoiceMessage } from 'senderrand-shared-components';

let sender2 = { id: 2, name: 'Abdul Mumin' };
let msg = getInvoiceMessage(
  '1',
  '#1223342',
  '20 AED',
  sender2,
  'Mirdif City Center',
  'ar'
);

Details

A function call to get the message data structure of an invoice message. The message is then sent to the chat. NOTE: Pass invoiceID when there is a full invoice and don't pass it when there is only total price.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
orderIDstring or numbertrueThe order ID
pricestringtrueThe total price to be displayed. EX '120 Naira'
invoiceIDstringtrueWhen invoiceID is passed, it means invoice has been computed. If not passed, it means there is only total price.
senderDatasenderInterfacetrueThe senders data which includes id, name, and image where image image is not compulsory.
locationstringfalseThe invoice location, which is the point of purchase. Example above.
langstringfalseThe language that should be used for the default text. Defaults to en.

Get Tracker Message

import { getTrackerMessage } from 'senderrand-shared-components';

let sender2 = { id: 2, name: 'Abdul Mumin' };
let msg = getTrackerMessage(
  '1',
  { longitude: 55.3863, latitude: 25.1279 },
  { longitude: 55.3775, latitude: 25.1218 },
  sender2,
  'en'
);

Details

A function call to get the message data structure of a tracking message. The message is then sent to the chat.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
orderIDstring or numbertrueThe order ID
regioncoordinateInterfacetrueThe coordinate of the region where the user is.
positioncoordinateInterfacetrueThe coordinate of the current user position.
senderDatasenderInterfacetrueThe senders data which includes id, name, and image where image image is not compulsory.
langstringfalseThe language that should be used for the default text. Defaults to en.

Get Status Message

import { getStatusMessage } from 'senderrand-shared-components';

let sender2 = { id: 2, name: 'Abdul Mumin' };
let msg =  getStatusMessage(
  '1',
  'Yinka is arriving somewhere currently',
  sender2
);

Details

A function call to get the message data structure of a status message. The message is then sent to the chat.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
orderIDstring or numbertrueThe order ID
statusstringtrueThe status to be sent.
loadingbooleanfalseTo add loading indicator to the status.
senderDatasenderInterfacetrueThe senders data which includes id, name, and image where image image is not compulsory.
colorstringfalseTo change the color of the status text.

Get New Runner Message

import { getNewRunnerMessage, runnerInterface } from 'senderrand-shared-components';

let sender2 = { id: 2, name: 'Abdul Mumin' };
let runner: runnerInterface = {
  ...sender2,
  image: 'oseni.png',
  rate: 4,
  runs: 110,
};
let msg = getNewRunnerMessage('1', runner, 'ar');

Details

A function call to get the message data structure of a new runner message. The message is then sent to the chat.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
orderIDstring / numbertrueThe order ID
runnerrunnerInterfacetrueThe runners data which includes id, name, image, rate, runs.
langstringfalseThe language that should be used for the default text. Defaults to en.

Create Table

import { createTable } from 'senderrand-shared-components';

createTable()

Details

The function is to be called to create the sql table if it doesn't exist, when the application opens.

Send Message

import { sendMessage, messageInterface } from 'senderrand-shared-components';

let message: messageInterface = {
  sender: { id: 2, name: 'The sender' },
  id: 76,
  status: 3,
  date: new Date(),
  text: 'The sender has accepted the Invoice, Proceed to make payment.',
  file: null,
  type: 'text',
  reply: null,
  orderID: 1,
  data: { btnTitle: 'PAY' },
} // Pass required data
sendMessage(
  message,
  (res) => res && console.log(res)
);

Details

The function is called to send message into the device, after sending you can call the getMessages to get updates. The response is false if it fails to send.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
messagemessageInterfacetrueThe message to be sent to the chat. Example above
callbackfunctiontrueCallback when the promise completes. The response is false if sending fails, but returns an array of messages when it succeeds.

Get Messages

import { getMessages } from 'senderrand-shared-components';

getMessages('order ID')

Details

The function is called to get the messages on the device,

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
orderIDstringtrueThe order id of the messages to be retrieved.

Update Message

import { updateMessage } from 'senderrand-shared-components';

updateMessage(
  'status',
  3,
  'orderID',
  orderID,
  (res) => res && callback({ type: 'messages' })
);

Details

The function is called to update messages on the device,

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
primaryKeystringtrueThe key of the item to be updated ex: status, file.
primaryValuestring / numbertrueThe value to be updated with. Stringify it if the value is neither string nor number.
secondaryKeystringtrueA key in the particular row to be updated. ex id, orderID
secondaryValuestring | numbertrueThe value of the secondary key.
callbackfunctiontrueCallback when the promise completes. The response is false if update fails, but returns an array of messages when it succeeds.

Delete Message

import { deleteMessage } from 'senderrand-shared-components';

deleteMessage(
  'id',
  3,
  (res) => res && callback({ type: 'messages' })
);

Details

The function is called to delete messages on the device,

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
keystringtrueA key in the object to be deleted.
valuestring / numbertrueThe value to be deleted. Stringify it if the value is neither string nor number.
callbackfunctiontrueCallback when the promise completes. The response is false if delete fails, but returns an array of messages when it succeeds.

XMPP Client

import { XmppClient } from 'senderrand-shared-components';

const App = () => (
  <XmppClient
    user={{
      id: 1,
      jabber_id: '',
      phone: '',
    }}
    service={''}
    domain={''}
    change={(res: any) => console.log(res, 'hello there')}
  />
)

Details

The component is used globally in the app to handle xmpp request and response.,

props

Below are the listed properties to be passed to the component

PropertyTypeRequiredDescription
userobjecttrueThe user object containing the user id jabber_id and phone number.
servicestringtrueThe server url.
domainstringtrueThe service domain.
changefunctiontrueWhen there is an update on the xmpp.

XMPP Send

import { xmppSend } from 'senderrand-shared-components';

xmppSend('from', 'to', {/* data */})

Details

The function is called to send request to xmpp,

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
fromstringtrueThe senders jabber id.
tostringtrueThe receivers jabber id.
dataobjecttrueThe data to be sent through xmpp.

Send Typing

import { sendTyping } from 'senderrand-shared-components';

sendTyping(true, 'orderID', 'from', 'to')

Details

The function is called to denote that user is currently typing.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
typingbooleantrueWeather typing is true or false.
orderIDstringtrueThe orderID of the current conversation.
fromstringtrueThe senders jabber id.
tostringtrueThe receivers jabber id.

Send Recording

import { sendRecording } from 'senderrand-shared-components';

sendRecording(true, 'orderID', 'from', 'to')

Details

The function is called to denote that user is currently recording voice note.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
recordingbooleantrueWeather recording is true or false.
orderIDstringtrueThe orderID of the current conversation.
fromstringtrueThe senders jabber id.
tostringtrueThe receivers jabber id.

Get Msg

import { getMsg } from 'senderrand-shared-components';

getMsg() // messageInterface parameters
// sender
// orderID
// type
// status
// text
// file
// data
// reply
// duration

Details

The function is called to format message data, It takes in messageInterface parameters where sender, orderID and type are compulsory.

Format URL Msg

import { formatURLMsg } from 'senderrand-shared-components';

formatURLMsg({}, 'http//') // messageInterface parameters
// messageInterface
// url

Details

The function is called when replacing uri with url. Pass the message data and the url, then get new message format.

Send Read

import { sendRead } from 'senderrand-shared-components';

sendRead('orderID', 'from', 'to')

Details

The function is called to denote that user has read received messages.

parameters

Below are the listed parameter to be passed to the function

PropertyTypeRequiredDescription
orderIDstringtrueThe orderID of the current conversation.
fromstringtrueThe senders jabber id.
tostringtrueThe receivers jabber id.

Currency Format

import { currencyFormat } from 'senderrand-shared-components';

currencyFormat(10000) // call function passing in integer value and it returns 10,000

Details

The function is called to format a number into currency value ex 10000 to 10,000.

Interfaces

export interface runnerInterface {
  id: string | number;
  name: string;
  image: string;
  rate: number;
  runs: number;
}

export interface coordinateInterface {
  longitude: number;
  latitude: number;
  longitudeDelta?: number;
  latitudeDelta?: number;
}

export interface senderInterface {
  id: string | number;
  name?: string;
  image?: string;
}
export interface messageInterface {
  id: string | number;
  text: string;
  date: Date | number;
  file: any;
  duration?: number;
  sender: senderInterface;
  reply?: messageInterface | null;
  data?: any;
  type: string;
  status: number;
  orderID: string | number;
}

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT