You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@bayudev/react-native-floating-button

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bayudev/react-native-floating-button

**A component Floating Button built with Reanimated v3+ and React Native Gesture handler V2+**

0.0.4
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

REACT NATIVE FLOATING BUTTON

A component Floating Button built with Reanimated v3+ and React Native Gesture handler V2+

Getting Started

To use the FloatingButton component, you first need to install the package via npm or yarn. Run either of the following commands:

npm install @bayudev/react-native-floating-button
yarn add @bayudev/react-native-floating-button

🚨 🚨 Please note that this library is built with React Native Reanimated v3 and uses React Native Gesture Handler. If you haven't installed Reanimated and Gesture Handler yet, please follow the installation instructions for Reanimated and Gesture Handler.

Usage

First, import the FloatingButton component from the @bayudev/react-native-floating-button library:

import { FloatingButton } from '@bayudev/react-native-floating-button';
import { StatusBar } from "expo-status-bar";
import { Image, Pressable, StyleSheet, Text, View } from "react-native";
import { useEffect, useRef, useState } from "react";

// import here
import {
  FloatingButton,
  FloatingButtonMethods,
} from "@bayudev/react-native-floating-button";

import { GestureHandlerRootView } from "react-native-gesture-handler";

export default function App() {

  // add ref to call methods [show or hide]
  const floatingButtonRef = useRef<FloatingButtonMethods>(null);

  useEffect(() => {
    setTimeout(() => {
      floatingButtonRef.current?.show();
    }, 1000);
  }, []);

  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <View>
        <StatusBar style="auto" />
        
        <FloatingButton
          ref={floatingButtonRef}
          borderRadiusContent={50}
          heightContent={90}
          widthContent={90}
          maxLeft={10}
          maxRight={300}
          maxHeight={150}
          minHeight={80}
        >
          <View
            style={{
              width: 85,
              height: 85,
              borderRadius: 2,
              borderWidth: 1,
              borderColor: "#dedede",
              alignItems: "center",
              justifyContent: "center",
            }}
          >
            <View>
              <Pressable
                style={{
                  alignItems: "center",
                  justifyContent: "center",
                  width: 25,
                  height: 25,
                  position: "absolute",
                  zIndex: 99,
                  top: -10,
                  right: 0,
                  borderWidth: 2,
                  borderColor: "blue",
                  borderRadius: 50,
                }}
                onPress={() => {
                  floatingButtonRef.current?.hide();

                  setTimeout(() => {
                    floatingButtonRef.current?.show();
                  }, 3000);
                }}
              >
                <Text>X</Text>
              </Pressable>
              <Image
                source={require("./assets/giftbox2.gif")}
                style={{
                  width: 80,
                  height: 80,
                }}
              />
            </View>
          </View>
        </FloatingButton>
      </View>
    </GestureHandlerRootView>
  );
}


Properties

PropertyTypeDefaultRequiredDescription
refStringnulltrueusing useRef for manage BottomSheet component for show or hide
widthContentNumber100truewidth of FloatingButton
heightContentNumber100trueheight of FloatingButton
borderRadiusContentNumber50falseborder radius of FloatingButton
maxLeftNumber10falsemaximum left content of FloatingButton
maxRightNumberwidth screen - (width screen / 2.8)falsemaximum right content of FloatingButton
minHeightNumberwidth screen / 2.8falseminimum height content of FloatingButton
maxHeightNumber50falsemaximum height content of FloatingButton
childrenReactNodenull or undefinedtruePut your any component here

Author



Bayu Hendrianto

License

The library is licensed under the MIT License.

Keywords

react-native

FAQs

Package last updated on 11 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts