高性能React Native底部抽屉组件:Reanimated Bottom Sheet

高性能React Native底部抽屉组件:Reanimated Bottom Sheet

项目地址:https://gitcode.com/gh_mirrors/re/react-native-reanimated-bottom-sheet

Reanimated Bottom Sheet 是一个高度可配置的组件,它模拟了原生底部抽屉行为,并以其流畅的60 FPS原生动画为亮点。该组件基于react-native-gesture-handlerreact-native-reanimated构建,无论你是 Expo 用户还是纯RN项目开发者,都能轻松集成。

功能演示

来看看这个组件的动态效果吧!

1 | 2 | 3 | 4
--- | --- | --- | ---

安装步骤

在你的项目根目录下,打开终端运行以下命令:

yarn add reanimated-bottom-sheet

如果你使用的是npm,可以运行:

npm install reanimated-bottom-sheet

接着,我们需要安装react-native-gesture-handlerreact-native-reanimated。对于Expo用户,执行:

expo install react-native-gesture-handler react-native-reanimated

如果不是Expo项目,则运行:

yarn add react-native-reanimated react-native-gesture-handler

现在,你可以编译并运行你的应用啦!

使用方法

下面是一个简单的示例代码:

import * as React from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import Animated from 'react-native-reanimated';
import BottomSheet from 'reanimated-bottom-sheet';

export default function App() {
  const renderContent = () => (
    <View
      style={{
        backgroundColor: 'white',
        padding: 16,
        height: 450,
      }}
    >
      <Text>滑动关闭</Text>
    </View>
  );

  const sheetRef = React.useRef(null);

  return (
    <>
      <View
        style={{
          flex: 1,
          backgroundColor: 'papayawhip',
          alignItems: 'center',
          justifyContent: 'center',
        }}
      >
        <Button
          title="打开底部抽屉"
          onPress={() => sheetRef.current.snapTo(0)}
        />
      </View>
      <BottomSheet
        ref={sheetRef}
        snapPoints={[450, 300, 0]}
        borderRadius={10}
        renderContent={renderContent}
      />
    </>
  );
}

属性详情

组件提供了丰富的自定义属性,如snapPointsinitialSnap等,详细列表见readme中Props部分。

应用场景

这款组件非常适合用于创建如下功能:

  1. 设置面板
  2. 导航菜单
  3. 查看详细信息界面
  4. 搜索表单

项目特点

  • 高性能: 基于react-native-gesture-handler和react-native-reanimated,实现原生级别的60 FPS动画。
  • 高度可定制: 可自定义设置抽屉的停靠点、初始状态、边角半径等。
  • 无需额外依赖: 对于Expo用户,无需脱离Expo环境即可直接使用。
  • 易于集成: 提供清晰的API文档和示例代码,简化开发流程。

总之,Reanimated Bottom Sheet 是一个强大且易用的底部抽屉解决方案,无论您是新手还是经验丰富的React Native开发者,都值得一试。立即尝试将它加入到您的项目中,提升用户体验,让底部抽屉交互更加顺畅自然吧!

react-native-reanimated-bottom-sheet Highly configurable bottom sheet component made with react-native-reanimated and react-native-gesture-handler 项目地址: https://gitcode.com/gh_mirrors/re/react-native-reanimated-bottom-sheet

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘俭渝Erik

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值