@sdcx/bottom-sheet 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +78 -0
- package/RNBottomSheet.podspec +18 -0
- package/android/build.gradle +35 -0
- package/android/proguard-rules.pro +0 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnative/bottomsheet/BottomSheet.java +599 -0
- package/android/src/main/java/com/reactnative/bottomsheet/BottomSheetManager.java +45 -0
- package/android/src/main/java/com/reactnative/bottomsheet/BottomSheetPackage.java +25 -0
- package/android/src/main/java/com/reactnative/bottomsheet/BottomSheetState.java +5 -0
- package/android/src/main/java/com/reactnative/bottomsheet/OffsetChangedEvent.java +40 -0
- package/android/src/main/java/com/reactnative/bottomsheet/StateChangedEvent.java +31 -0
- package/ios/BottomSheet/RNBottomSheet.h +15 -0
- package/ios/BottomSheet/RNBottomSheet.m +321 -0
- package/ios/BottomSheet/RNBottomSheetManager.h +9 -0
- package/ios/BottomSheet/RNBottomSheetManager.m +18 -0
- package/ios/BottomSheet.xcodeproj/project.pbxproj +283 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +31 -0
- package/lib/splitLayoutProps.d.ts +15 -0
- package/lib/splitLayoutProps.js +41 -0
- package/package.json +65 -0
- package/src/index.tsx +74 -0
- package/src/splitLayoutProps.ts +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 http://www.sdcx.tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# BottomSheet
|
|
2
|
+
|
|
3
|
+
`BottomSheet` 是位于屏幕底部的可拖拽的组件,支持嵌套滚动,可以和可滚动视图(FlatList, FlashList, WebView 等等)一起使用。
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn install @sdcx/bottom-sheet
|
|
9
|
+
# &
|
|
10
|
+
pod install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`BottomSheet` 在使用上是非常简单的,几乎没有什么心智负担。
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import BottomSheet from '@sdcx/bottom-sheet'
|
|
19
|
+
|
|
20
|
+
const App = () => {
|
|
21
|
+
return (
|
|
22
|
+
<View style={styles.container}>
|
|
23
|
+
<ScrollView>...</ScrollView>
|
|
24
|
+
<BottomSheet peeekHeight={200}>
|
|
25
|
+
{
|
|
26
|
+
// 在这里放置你的内容,可以是任何组件,如:
|
|
27
|
+
}
|
|
28
|
+
<View />
|
|
29
|
+
<PagerView>
|
|
30
|
+
<FlatList nestedScrollEnabled />
|
|
31
|
+
<ScrollView nestedScrollEnabled />
|
|
32
|
+
<WebView />
|
|
33
|
+
</PagerView>
|
|
34
|
+
</BottomSheet>
|
|
35
|
+
</View>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> :white_check_mark: 当和可滚动视图一起使用时,需要设置 `nestedScrollEnabled` 属性。
|
|
41
|
+
|
|
42
|
+
## 基本概念和 API
|
|
43
|
+
|
|
44
|
+
`BottomSheet` 由内外两层视图组成,外层是绝对定位,默认填满父组件,除非设置了 `top` 样式属性,内层也是绝对定位,默认填满外层视图。外层的位置固定不变,内层则可拖动。
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
`BottomSheet` 拥有 3 个属性和两个回调。
|
|
49
|
+
|
|
50
|
+
### 属性
|
|
51
|
+
|
|
52
|
+
`peekHeight` 是指 `BottomSheet` 收起时,内层在屏幕上露出的高度,默认是 200。
|
|
53
|
+
|
|
54
|
+
`fitToContents` 是指内层的高度是否适应内容。默认情况下,内层的高度是和外层一样的。
|
|
55
|
+
|
|
56
|
+
> 当 `BottomSheet` 中的子组件包含可滚动视图时,请不要打开这个属性。
|
|
57
|
+
|
|
58
|
+
`state` 用来控制 `BottomSheet` 的状态,有 3 种可能的值:
|
|
59
|
+
|
|
60
|
+
- `collapsed`:`BottomSheet` 完全收起,这是默认状态。
|
|
61
|
+
|
|
62
|
+
- `expanded`:`BottomSheet` 完全展开
|
|
63
|
+
|
|
64
|
+
- `hidden`:`BottomSheet` 完全隐藏
|
|
65
|
+
|
|
66
|
+
### 回调
|
|
67
|
+
|
|
68
|
+
`onStateChanged` 回调 和 `state` 属性是一对,用来实现受控模式,当 `BottomSheet` 的状态发生变化时会被调用,它接收一个参数,即 `BottomSheet` 当前的状态。
|
|
69
|
+
|
|
70
|
+
`onSlide` 是 `BottomSheet` 的重要回调函数,它会在 `BottomSheet` 的位置发生偏移时调用,可以用它来实现一些动画效果。`onSlide` 在调用是携带以下参数:
|
|
71
|
+
|
|
72
|
+
- `collapsedOffset` 是指 `BottomSheet` 完全收起时,内层顶部距离外层顶部的距离。可以看到,它的值等于外层的高度减去 `peekHeight`。
|
|
73
|
+
|
|
74
|
+
- `expandedOffset` 是指 `BottomSheet` 完全展开时,内层顶部距离外层顶部的距离,通常是 0。但如果设置了 `fitToContents` 属性,则可能大于 0。
|
|
75
|
+
|
|
76
|
+
- `offset` 是指 `BottomSheet` 当前的位置,它的值在 `collapsedOffset` 和 `expandedOffset` 之间。
|
|
77
|
+
|
|
78
|
+
- `progress` 是指 `BottomSheet` 当前的位置在 `collapsedOffset` 和 `expandedOffset` 之间的比例,它的值在 0 和 1 之间。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "RNBottomSheet"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
s.platforms = { :ios => "10.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/github-account/bottom-sheet.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/BottomSheet/**/*.{h,m,mm}"
|
|
17
|
+
s.dependency "React-Core"
|
|
18
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// android/build.gradle
|
|
2
|
+
|
|
3
|
+
def safeExtGet(prop, fallback) {
|
|
4
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
apply plugin: 'com.android.library'
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
compileOptions {
|
|
11
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
12
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
16
|
+
buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')
|
|
17
|
+
|
|
18
|
+
defaultConfig {
|
|
19
|
+
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
20
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 30)
|
|
21
|
+
versionCode 1
|
|
22
|
+
versionName "1.0.0"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
buildTypes {
|
|
26
|
+
release {
|
|
27
|
+
consumerProguardFiles 'proguard-rules.pro'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dependencies {
|
|
33
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
34
|
+
implementation 'com.facebook.react:react-native:+'
|
|
35
|
+
}
|
|
File without changes
|