0.0.96 โ€ข Published 4 months ago

react-native-template-rn-homee v0.0.96

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React-Native Boilerplate by Homee!

๐ŸŒŸ Features

React-Native version - 0.76.7

  • โ›ฉ๏ธ Added suport for Reactotron Debugger
  • ๐Ÿš€ TypeScript (.tsx)
  • ๐ŸŒˆ Splash Screen / App Icon (iOS) Natively Changed
  • ๐ŸŽฎ Custom BottomTab with Test Screens
  • ๐ŸŒ“ Dark & Light Theme Support
  • ๐Ÿšข Navigations with React Navigation V6
  • ๐Ÿง™โ€โ™‚๏ธ State Management with the ReduxToolkit and Redux-Persist
  • ๐Ÿงช React-native-Async-Storage for Redux-Persist
  • ๐ŸŒ Axios Api Manager
  • โš™๏ธ Config file with Test APIs and Methods
  • ๐ŸŒ Multiple Language Support with i18n
  • ๐Ÿ’Ž Many Custom Components

๐Ÿš€ Getting started

To create the new project, run the following command:

npx @react-native-community/cli init AwesomeProject --version 0.76.7 --template react-native-template-rn-homee

Replace "AwesomeProject" with your package name.

The boilerplate uses the Poppins font. To download the font, visit Google Fonts - Montserrat and download the Popping Font or any other font of your choice.

Copy the Regular, Medium, and Bold into src/assets/Fonts. Link the assets with:

npx react-native-asset

๐Ÿ“ธ Screenshots

App Screenshot

A customizable loading spinner component for React Native applications with theme support and modal overlay.

Features

  • Modal-based loader overlay
  • Theme integration
  • Customizable spinner animation
  • Responsive styling
  • TypeScript support
  • Fade animation

Basic Usage

import AppLoader from "./path/to/AppLoader";

const MyComponent = () => {
  const [isLoading, setIsLoading] = useState(false);

  return (
    <View>
      <AppLoader isLoading={isLoading} />
      {/* Your component content */}
    </View>
  );
};

With Async Operations

const MyComponent = () => {
  const [isLoading, setIsLoading] = useState(false);

  const handleDataFetch = async () => {
    setIsLoading(true);
    try {
      await fetchData();
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <View>
      <AppLoader isLoading={isLoading} />
      <Button onPress={handleDataFetch} title="Fetch Data" />
    </View>
  );
};

Props

PropTypeRequiredDefaultDescription
isLoadingbooleanNoundefinedControls the visibility of the loader

Spinner Configuration

Uses react-native-spinkit with the following default configuration:

  • Type: 'Wave'
  • Size: 24
  • Color: Theme primary color
  • Visibility tied to isLoading prop

AppText is a reusable, customizable text component for React Native, offering easy styling and support for dynamic content, interactive press actions, and theme integration.

PropsTypeDescription
titlestringTitle text with bold font and default font size 20.
subtitlestringSubtitle text with medium font and default font size 16.
labelstringLabel text with regular font and default font size 14.
styleobjectCustom styles to apply to the text element.
textColorstringCustom text color. Defaults to the theme's text color.
fontSizenumberCustom font size. Default based on title, subtitle, or label.
textAlignstringText alignment ('left', 'right', 'center', 'justify'). Default is 'left'.
numberOfLinesnumberLimits the text to a specific number of lines.
onPressText() => voidCallback for handling text press events.

Example Usage

<AppText title="This is a title" />
<AppText subtitle="This is a subtitle" textColor="#888" fontSize={18} />
<AppText label="This is a label" textAlign="center" />

AppTextInput is a reusable, customizable text input component for React Native, supporting icons on both sides, error handling, and label styling. It allows flexible usage for various types of input fields and integrates easily with themes and custom styling.

Props

PropsTypeDescription
leftIconanyIcon to display on the left side of the input field.
rightIconanyIcon to display on the right side of the input field.
onLeftIconPress() => voidCallback function when the left icon is pressed.
onRightIconPress() => voidCallback function when the right icon is pressed.
containerStyleViewStyleCustom style for the container of the text input.
inputStyleViewStyleCustom style for the input text element.
labelstringLabel text for the input field.
textColorstringCustom text color. Defaults to the theme's primary color.
fontSizenumberCustom font size for the input text. Default is 14.
errorHandleanyCustom error message to display below the input field.
errorMessagestringError message to display if validation fails.

Basic Text Input Example

<AppTextInput
  placeholder="Enter your name"
  leftIcon={Icons.icnUser}
  rightIcon={Icons.icnSearch}
  onLeftIconPress={() => alert("Left icon pressed!")}
  onRightIconPress={() => alert("Right icon pressed!")}
/>

AppScrollView is a reusable, customizable scroll view component built on top of KeyboardAwareScrollView from react-native-keyboard-aware-scroll-view. It enhances the user experience by automatically adjusting the scroll position when the keyboard is shown, with options to customize extra height and bounce behavior.

Props

PropsTypeDescription
childrenReactNodeContent to be displayed inside the scroll view.
extraHeightnumberExtra height added to the scroll view when the keyboard is shown.
bouncesbooleanWhether the scroll view should bounce when the end is reached. Default is true.

Basic Example AppScrollView

<AppScrollView>
  <TextInput placeholder="Type here" />
  <Button title="Submit" onPress={() => alert("Submitted!")} />
</AppScrollView>

AppMainContainer is a customizable wrapper component that provides safe area handling for both the top and bottom of the screen. It uses SafeAreaView to ensure that your content is appropriately placed within the safe areas on devices with notches or rounded corners. It also allows for flexible customization of background colors and the option to hide the top or bottom safe areas.

Props

PropsTypeDescription
childrenReactNodeContent to be displayed inside the container.
styleViewStyleCustom styles to apply to the outer container.
topColorstringBackground color for the top SafeAreaView. Defaults to the theme's background color.
hideTopbooleanIf true, hides the top SafeAreaView. Default is false.
bottomColorstringBackground color for the bottom SafeAreaView. Defaults to the theme's background color.
hideBottombooleanIf true, hides the bottom SafeAreaView. Default is false.

Basic Usage

<AppMainContainer>
  <Text>Your content goes here!</Text>
</AppMainContainer>

API Utility: APIMethods

APIMethods provides utility functions for making GET and POST requests to your API, with built-in internet connectivity checks, error handling, and customizable headers.

Functions

get(endpoint: string, params?: object, customHeaders?: object): Promise<any>

Sends a GET request to the provided API endpoint.

Parameters:

  • endpoint (string): The API endpoint you want to send the request to.
  • params (object, optional): The query parameters to include in the request (default is an empty object).
  • customHeaders (object, optional): Additional headers to send with the request.

Returns:

A promise that resolves to the response data from the API or an error message if the request fails (or no internet connection).

Example:

const data = await APIMethods.get("user/profile", { userId: 123 });
console.log(data);

post(endpoint: string, data: object, customHeaders?: object): Promise<any>

Sends a POST request to the provided API endpoint.

Parameters:

  • endpoint (string): The API endpoint you want to send the request to.
  • data (object): The data to be sent in the request body.
  • customHeaders (object, optional): Additional headers to send with the request.

Returns:

A promise that resolves to the response data from the API or an error message if the request fails (or no internet connection).

Example:

const response = await APIMethods.post("auth/login", {
  username: "user@example.com",
  password: "********",
});
console.log(response);


Theme Provider Utility

A React Native theme management system that provides dark/light theme switching capabilities with Redux integration and system theme support.

Features

  • Dark/Light theme switching
  • System theme detection
  • Redux state management
  • Status bar style management
  • TypeScript support
  • Context-based theme access

Usage

Theme Provider Setup

Wrap your app with the ThemeProvider:

import { ThemeProvider } from "./path/to/ThemeProvider";

const App = () => {
  return (
    <ThemeProvider>
      <YourApp />
    </ThemeProvider>
  );
};

Using Theme Hook

Access theme values and controls in your components:

import { useTheme } from "./path/to/ThemeProvider";

const MyComponent = () => {
  const { isDarkMode, AppColors, toggleTheme } = useTheme();

  return (
    <View style={{ backgroundColor: AppColors.background }}>
      <Text style={{ color: AppColors.text }}>
        Current theme: {isDarkMode ? "Dark" : "Light"}
      </Text>
      <Button onPress={toggleTheme} title="Toggle Theme" />
    </View>
  );
};

API Reference

ThemeProvider Props

  • children (ReactNode): Child components
  • isDisabled (boolean, optional): Forces light theme when true. Default: false

useTheme Hook Returns

  • isDarkMode (boolean): Current theme state
  • AppColors (ThemeTypes): Current theme colors
  • toggleTheme (() => void): Function to switch theme

Error Handling

The useTheme hook will throw an error if used outside of ThemeProvider:

"useTheme must be used within a ThemeProvider";

๐Ÿง™โ€โ™‚๏ธAuthor

Contributions

All talented wizards and witches are welcome to contribute their magic. ๐Ÿช„

0.0.85

5 months ago

0.0.86

4 months ago

0.0.87

4 months ago

0.0.88

4 months ago

0.0.89

4 months ago

0.0.95

4 months ago

0.0.96

4 months ago

0.0.90

4 months ago

0.0.91

4 months ago

0.0.92

4 months ago

0.0.93

4 months ago

0.0.94

4 months ago

0.0.84

9 months ago

0.0.82

9 months ago

0.0.83

9 months ago

0.0.81

1 year ago

0.0.80

1 year ago

0.0.74

1 year ago

0.0.75

1 year ago

0.0.76

1 year ago

0.0.77

1 year ago

0.0.78

1 year ago

0.0.79

1 year ago

0.0.73

1 year ago

0.0.70

1 year ago

0.0.71

1 year ago

0.0.72

1 year ago

0.0.69

1 year ago

0.0.68

1 year ago

0.0.67

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.66

1 year ago

0.0.61

1 year ago

0.0.60

1 year ago

0.0.59

1 year ago

0.0.51

2 years ago

0.0.53

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago