1.0.4 โ€ข Published 5 months ago

react-native-flexible-screencontainer v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

react-native-flexible-screencontainer

๐Ÿ“Œ Introduction

Brief Overview

A customizable UI library for React Native that includes a dynamic status bar, loaders, shimmer effects, scrollable and non-scrollable views, an empty state handler, and a bottom sheet implementation.

react-native-flexible-screencontainer is a customizable React Native UI library that provides common components like:

  • Status Bar Handling (Dynamic content & color support)
  • Loader Component (Custom or default loading UI)
  • Shimmer Placeholder
  • Empty View Handler (Default & custom empty views when data is unavailable)
  • Bottom Sheet Component (Default & custom bottom sheets using @gorhom/bottom-sheet)
  • Dynamic View & ScrollView Wrapper

This library helps in creating highly customizable and reusable UI components while maintaining optimal performance.


๐Ÿ›  Installation

Ensure you have React Native set up. Then, install the package:

npm install react-native-flexible-screencontainer

or using Yarn:

yarn add react-native-flexible-screencontainer

Also, install peer dependencies manually if not already installed:

yarn add @gorhom/bottom-sheet react-native-linear-gradient react-native-safearea-height

๐Ÿš€ Usage

1๏ธโƒฃ Importing ScreenContainer

import ScreenContainer from 'react-native-flexible-screencontainer';

2๏ธโƒฃ Basic Usage

import React from 'react';
import { View, Text } from 'react-native';
import ScreenContainer from 'react-native-flexible-screencontainer';

const App = () => {
  return (
    <ScreenContainer viewType="View" backgroundColor="white" statusBarStyle="dark-content">
      <Text>Hello World!</Text>
    </ScreenContainer>
  );
};

export default App;

3๏ธโƒฃ Showing Loader

<ScreenContainer showLoader={true} message="Loading..." />

4๏ธโƒฃ Using Shimmer Effect

<ScreenContainer showShimmer={true} shimmerType="default" />

5๏ธโƒฃ Handling Empty View

<ScreenContainer emptyView={true} emptyRendeView="default" emptyMessage="No Data Found" />

6๏ธโƒฃ Custom Empty View

const customEmptyView = () => (
  <View>
    <Text style={{ fontSize: 20, color: 'red' }}>No Records Available</Text>
  </View>
);

<ScreenContainer emptyView={true} emptyRendeView="custom" renderCustomEmptyView={customEmptyView} />

7๏ธโƒฃ Showing Bottom Sheet

<ScreenContainer showSheet={true} data={{ msg: "Hello!", description: "This is a bottom sheet." }} />

8๏ธโƒฃ Custom Bottom Sheet

const customBottomSheet = () => (
  <View style={{ padding: 20, backgroundColor: 'black' }}>
    <Text style={{ color: 'white' }}>Custom Bottom Sheet</Text>
  </View>
);

<ScreenContainer showSheet={true} renderCustomBottomSheet={customBottomSheet} />

๐Ÿ“Œ Features

  • โœ… Dynamic Status Bar (Light/Dark Mode Support)
  • โœ… Customizable Loaders (Text, Image, or Default Indicator)
  • โœ… Shimmer Placeholder for Skeleton UI
  • โœ… Empty View Handler
  • โœ… Default & Custom Bottom Sheets
  • โœ… Seamless Integration with View & ScrollView

๐Ÿ“– Dependencies

This library uses:

  • @gorhom/bottom-sheet (For bottom sheet handling)
  • react-native-linear-gradient (For shimmer effects)
  • react-native-safearea-height (For safe area handling)

โš  Note: We do not claim ownership of any third-party dependencies used in this library. All credit goes to their respective owners. Please refer to their documentation for licensing information.


๐Ÿ›  Contributing

We welcome contributions! If you find a bug or want to improve features, feel free to open a Pull Request.


๐Ÿ“„ License

react-native-flexible-screencontainer is open-source under the ISC License.

๐Ÿš€ Created for React Native Developers to enhance UI experience effortlessly!


๐Ÿง Common Issues & Solutions

๐Ÿ” (NOBRIDGE) ERROR - GestureHandlerRootView Required

If you encounter the following error while using this library:

Warning: Error: GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise, the gestures will not be recognized.

๐Ÿ”ฎ Why is it necessary to add GestureHandlerRootView now?

In the latest versions of react-native-gesture-handler, there is a strict requirement for wrapping components.

Previously, this was implicitly handled within React Native, but now any component using GestureDetector must be wrapped inside GestureHandlerRootView.

๐Ÿ”ฅ Alternative Solution (Not Recommended)

If you donโ€™t want to wrap GestureHandlerRootView everywhere, you can downgrade react-native-gesture-handler to an older version:

yarn add react-native-gesture-handler@2.12.0

Then, clear the cache and restart your project:

yarn start --reset-cache

๐Ÿšซ However, downgrading is not recommended, as newer versions offer better performance and stability.

โœ… Best Practice (Recommended Solution)

To avoid manually wrapping GestureHandlerRootView in multiple places, wrap your entire app inside GestureHandlerRootView in index.js:

๐Ÿ“Œ index.js (Best Solution)

import 'react-native-gesture-handler';
import { AppRegistry } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import App from './App';
import { name as appName } from './app.json';
import { View } from 'react-native';

const RootComponent = () => (
  <GestureHandlerRootView style={{ flex: 1 }}>
    <App />
  </GestureHandlerRootView>
);

AppRegistry.registerComponent(appName, () => RootComponent);

โœ… This will automatically apply GestureHandlerRootView globally, so you won't need to wrap it in App.js or other components manually.


๐Ÿ’– Support & Sponsorship

If you like this library and want to support its development, consider sponsoring me on GitHub Sponsors

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago