Skip to content

About

Native UI Component for React Native, including nested-scroll, pull-to-refresh, bottom-sheet, etc.

Resources

Stars

263 stars

Watchers

4 watching

Forks

Repository files navigation

React Native 原生 UI 组件

本仓库包含一系列原生组件:

版本兼容

版本 RN 版本 新旧架构
0.x < 0.82 旧架构
1.x >= 0.82 新架构(nested-scroll、pull-to-refresh、bottom-sheet、keyboard-insets 1.1+/1.2+ 已接入 @sdcx/coordination)
2.x >= 0.82 新架构(@sdcx/overlay 2.x 升级为单常驻宿主 Surface + JS 统一浮层管理)

架构与协同文档

库

纯原生跨包协同契约与无状态原语包,为 @sdcx/nested-scroll、@sdcx/pull-to-refresh、@sdcx/bottom-sheet 与 @sdcx/keyboard-insets 提供编译期强类型接口和公共视图原语。

注意:React Native autolinking 默认仅扫描宿主工程 package.json 的直接依赖。安装上述任一组件(1.1+ / 1.2+)时,请将 @sdcx/coordination 一并作为直接依赖安装并重新执行 pod install / 构建 Android。

用于实现嵌套滚动,使用简单。可以和 PagerView,TabView 等组合使用。

提供了在 React 层自定义下拉刷新的能力。

将 Android 的 BottomSheetBehavior 迁移到了 React Native 中,在 API 设计上也尽量和 Android 保持一致,同时支持 iOS。主要组件已支持新架构,支持 RN 0.82 及以上,已发布 1.x 版本。

BottomSheet 顶层协同演示

进入 BottomSheet → BottomSheet 顶层协同演示,体验 BottomSheet、NestedScrollView、PullToRefresh、WheelPicker 与 KeyboardInsetsView(keyboardBehavior="lift")的跨包原生协同,源码见 BottomSheetCoordination。

BottomSheet 高度过渡演示

进入 BottomSheet → BottomSheet + Animated Height,切换长短内容、比较动画开关、验证固定底栏与限高滚动。演示用 BottomModal 通过 animateContentHeight、footer、background 组合共享内容高度组件;详见 组件用法与原生重建说明。

SwipePager 演示

首页 SwipePager 展示相邻卡片、整页图片、跟手分页点及按钮切换。整页图片在离场时缩小至 94%,入场时恢复至原尺寸。进入 BottomSheet → BottomSheet + SwipePager,可从图片区域左右翻页、上下拖动面板,并与同屏普通纵向滑块比对;滑块无需弹层专用包装。

通用组件位于 demo/components/SwipePager,示例位于 demo/swipe-pager。它使用 Gesture Handler Pan + Reanimated,与演示项目已有的 PagerView 示例并存,不是新增的 npm 包。运行方式仍是 yarn start 后启动 iOS / Android 调试应用;Bottom Sheet 的手势修正涉及原生代码,已有应用需要重新构建。

在 Android 上实现了和 iOS 类似的菊花组件。

用来实现头像裁剪,和社区其它方案不同,仅仅只是个 View,非常方便页面的自定义布局。

也可以用来实现图片裁剪,支持设置裁剪区域。

KeyboardInsetsView 是一个 React Native 原生 UI 组件,用于处理软键盘遮挡输入框的问题。自动模式下使用非常简单,不需要额外代码来处理键盘。

含输入框的 BottomSheet 由 KeyboardInsetsView 包住完整弹层,示例入口为 BottomSheet / Keyboard Insets → BottomSheet + KeyboardInsetsView。详见 嵌套与额外避让规则。

如果想要实现类似聊天界面那样的效果,也不在话下。

@sdcx/overlay 是一个 React Native 新架构原生顶层浮层基础设施(2.x 起采用单一常驻宿主 Surface + JS 单树分层编排),支持 zIndex 排序、实时窗口指标(useOverlayMetrics)与 Android 返回键按层级仲裁,可用于实现 Alert、Toast、全局 Loading、动态提示条与 Hoverball 等顶层 UI。

进入 Overlay → Overlay 协同与分层,可验证多浮层 zIndex 排序、局部穿透、实时安全区与快速启停压测,源码见 CoordinationScreen。

一个非常简单的 WheelPicker

一个非常帅的 WheelPicker

About

Native UI Component for React Native, including nested-scroll, pull-to-refresh, bottom-sheet, etc.

Resources

Stars

263 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages