@sdcx/bottom-sheet 0.16.0 → 1.0.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/README.md +57 -51
- package/RNBottomSheet.podspec +5 -4
- package/android/build.gradle +42 -19
- package/android/src/main/java/com/reactnative/bottomsheet/BottomSheet.java +70 -73
- package/android/src/main/java/com/reactnative/bottomsheet/BottomSheetManager.java +12 -6
- package/android/src/main/java/com/reactnative/bottomsheet/{BottomSheetState.java → BottomSheetStatus.java} +1 -1
- package/android/src/main/java/com/reactnative/bottomsheet/{OffsetChangedEvent.java → OnSlideEvent.java} +5 -3
- package/android/src/main/java/com/reactnative/bottomsheet/{StateChangedEvent.java → OnStateChangedEvent.java} +5 -3
- package/dist/BottomSheetNativeComponent.d.ts +20 -0
- package/dist/BottomSheetNativeComponent.js +2 -0
- package/dist/index.d.ts +8 -15
- package/dist/index.js +9 -9
- package/ios/BottomSheet/{RNBottomSheetOffsetChangedEvent.m → Event/RNBottomSheetOffsetChangedEvent.mm} +3 -1
- package/ios/BottomSheet/{RNBottomSheetStateChangedEvent.h → Event/RNBottomSheetStateChangedEvent.h} +1 -3
- package/ios/BottomSheet/{RNBottomSheetStateChangedEvent.m → Event/RNBottomSheetStateChangedEvent.mm} +4 -4
- package/ios/BottomSheet/RNBottomSheetComponentView.h +10 -0
- package/ios/BottomSheet/RNBottomSheetComponentView.mm +555 -0
- package/package.json +50 -38
- package/src/BottomSheetNativeComponent.ts +26 -0
- package/src/index.tsx +51 -70
- package/docs/assets/pagerview.gif +0 -0
- package/docs/assets/scrollview.gif +0 -0
- package/docs/assets/struct.png +0 -0
- package/ios/BottomSheet/RNBottomSheet.h +0 -21
- package/ios/BottomSheet/RNBottomSheet.m +0 -401
- package/ios/BottomSheet/RNBottomSheetManager.h +0 -9
- package/ios/BottomSheet/RNBottomSheetManager.m +0 -24
- package/ios/BottomSheet/RNBottomSheetState.h +0 -17
- package/ios/BottomSheet/RNBottomSheetState.m +0 -38
- /package/ios/BottomSheet/{RNBottomSheetOffsetChangedEvent.h → Event/RNBottomSheetOffsetChangedEvent.h} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnative.bottomsheet;
|
|
2
2
|
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
3
4
|
import androidx.annotation.Nullable;
|
|
4
5
|
|
|
5
6
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -7,21 +8,22 @@ import com.facebook.react.bridge.WritableMap;
|
|
|
7
8
|
import com.facebook.react.uimanager.PixelUtil;
|
|
8
9
|
import com.facebook.react.uimanager.events.Event;
|
|
9
10
|
|
|
10
|
-
public class
|
|
11
|
-
public static final String Name = "
|
|
11
|
+
public class OnSlideEvent extends Event<OnSlideEvent> {
|
|
12
|
+
public static final String Name = "topSlide";
|
|
12
13
|
public static final String JSEventName = "onSlide";
|
|
13
14
|
|
|
14
15
|
private final int offset;
|
|
15
16
|
private final int minOffset;
|
|
16
17
|
private final int maxOffset;
|
|
17
18
|
|
|
18
|
-
public
|
|
19
|
+
public OnSlideEvent(int surfaceId, int viewTag, int offset, int minOffset, int maxOffset) {
|
|
19
20
|
super(surfaceId, viewTag);
|
|
20
21
|
this.offset = offset;
|
|
21
22
|
this.maxOffset = maxOffset;
|
|
22
23
|
this.minOffset = minOffset;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
@NonNull
|
|
25
27
|
@Override
|
|
26
28
|
public String getEventName() {
|
|
27
29
|
return Name;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
package com.reactnative.bottomsheet;
|
|
2
2
|
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
3
4
|
import androidx.annotation.Nullable;
|
|
4
5
|
|
|
5
6
|
import com.facebook.react.bridge.Arguments;
|
|
6
7
|
import com.facebook.react.bridge.WritableMap;
|
|
7
8
|
import com.facebook.react.uimanager.events.Event;
|
|
8
9
|
|
|
9
|
-
public class
|
|
10
|
-
public static final String Name = "
|
|
10
|
+
public class OnStateChangedEvent extends Event<OnStateChangedEvent> {
|
|
11
|
+
public static final String Name = "topStateChanged";
|
|
11
12
|
public static final String JSEventName = "onStateChanged";
|
|
12
13
|
|
|
13
14
|
private final String state;
|
|
14
15
|
|
|
15
|
-
public
|
|
16
|
+
public OnStateChangedEvent(int surfaceId, int viewTag, String state) {
|
|
16
17
|
super(surfaceId, viewTag);
|
|
17
18
|
this.state = state;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
@NonNull
|
|
20
22
|
@Override
|
|
21
23
|
public String getEventName() {
|
|
22
24
|
return Name;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
export type BottomSheetStatus = 'collapsed' | 'expanded' | 'hidden' | 'dragging' | 'settling';
|
|
3
|
+
export type OnStateChangedEventPayload = {
|
|
4
|
+
state: 'collapsed' | 'expanded' | 'hidden';
|
|
5
|
+
};
|
|
6
|
+
export type OnSlideEventPayload = {
|
|
7
|
+
progress: CodegenTypes.Float;
|
|
8
|
+
offset: CodegenTypes.Float;
|
|
9
|
+
expandedOffset: CodegenTypes.Float;
|
|
10
|
+
collapsedOffset: CodegenTypes.Float;
|
|
11
|
+
};
|
|
12
|
+
export interface NativeProps extends ViewProps {
|
|
13
|
+
peekHeight?: CodegenTypes.WithDefault<CodegenTypes.Int32, 200>;
|
|
14
|
+
draggable?: CodegenTypes.WithDefault<boolean, true>;
|
|
15
|
+
status?: CodegenTypes.WithDefault<BottomSheetStatus, 'collapsed'>;
|
|
16
|
+
onSlide?: CodegenTypes.DirectEventHandler<OnSlideEventPayload>;
|
|
17
|
+
onStateChanged?: CodegenTypes.DirectEventHandler<OnStateChangedEventPayload>;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: HostComponent<NativeProps>;
|
|
20
|
+
export default _default;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
3
|
-
|
|
4
|
-
progress: number;
|
|
5
|
-
offset: number;
|
|
6
|
-
expandedOffset: number;
|
|
7
|
-
collapsedOffset: number;
|
|
8
|
-
}
|
|
3
|
+
import type { OnStateChangedEventPayload, OnSlideEventPayload } from './BottomSheetNativeComponent';
|
|
9
4
|
export type BottomSheetState = 'collapsed' | 'expanded' | 'hidden';
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onStateChanged?: (event: NativeSyntheticEvent<StateChangedEventData>) => void;
|
|
5
|
+
export type BottomSheetOnSlideEvent = NativeSyntheticEvent<OnSlideEventPayload>;
|
|
6
|
+
export type BottomSheetOnStateChangedEvent = NativeSyntheticEvent<OnStateChangedEventPayload>;
|
|
7
|
+
interface BottomSheetProps extends ViewProps {
|
|
8
|
+
onSlide?: (event: BottomSheetOnSlideEvent) => void;
|
|
9
|
+
onStateChanged?: (event: BottomSheetOnStateChangedEvent) => void;
|
|
16
10
|
peekHeight?: number;
|
|
17
11
|
draggable?: boolean;
|
|
18
12
|
state?: BottomSheetState;
|
|
13
|
+
fitToContents?: boolean;
|
|
19
14
|
contentContainerStyle?: ViewProps['style'];
|
|
20
15
|
}
|
|
21
|
-
declare
|
|
22
|
-
fitToContents?: boolean | undefined;
|
|
23
|
-
} & React.RefAttributes<React.Component<NativeBottomSheetProps, {}, any> & import("react-native").NativeMethods>>;
|
|
16
|
+
declare function BottomSheet(props: BottomSheetProps): React.JSX.Element;
|
|
24
17
|
export default BottomSheet;
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import splitLayoutProps from './splitLayoutProps';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import BottomSheetNativeComponent from './BottomSheetNativeComponent';
|
|
5
|
+
function BottomSheet(props) {
|
|
6
6
|
const { style, contentContainerStyle, children, peekHeight = 200, draggable = true, state = 'collapsed', fitToContents, ...rest } = props;
|
|
7
7
|
const { outer, inner } = splitLayoutProps(StyleSheet.flatten(style));
|
|
8
|
-
return (<
|
|
9
|
-
|
|
8
|
+
return (<BottomSheetNativeComponent style={[StyleSheet.absoluteFill, outer]} peekHeight={peekHeight} draggable={draggable} status={state} {...rest}>
|
|
9
|
+
<View style={[
|
|
10
10
|
fitToContents ? styles.fitToContents : StyleSheet.absoluteFill,
|
|
11
11
|
inner,
|
|
12
12
|
contentContainerStyle,
|
|
13
13
|
]} collapsable={false}>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
14
|
+
{children}
|
|
15
|
+
</View>
|
|
16
|
+
</BottomSheetNativeComponent>);
|
|
17
|
+
}
|
|
18
18
|
const styles = StyleSheet.create({
|
|
19
19
|
fitToContents: {
|
|
20
20
|
position: 'absolute',
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#import "RNBottomSheetOffsetChangedEvent.h"
|
|
2
2
|
|
|
3
|
+
#import <React/UIView+React.h>
|
|
4
|
+
|
|
3
5
|
@interface RNBottomSheetOffsetChangedEvent ()
|
|
4
6
|
|
|
5
7
|
@property (nonatomic, assign) CGFloat progress;
|
|
@@ -34,7 +36,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
- (BOOL)canCoalesce {
|
|
37
|
-
|
|
39
|
+
return YES;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
- (uint16_t)coalescingKey {
|
package/ios/BottomSheet/{RNBottomSheetStateChangedEvent.h → Event/RNBottomSheetStateChangedEvent.h}
RENAMED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
#import <React/RCTEventDispatcherProtocol.h>
|
|
2
2
|
|
|
3
|
-
#import "RNBottomSheetState.h"
|
|
4
|
-
|
|
5
3
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
4
|
|
|
7
5
|
@interface RNBottomSheetStateChangedEvent : NSObject <RCTEvent>
|
|
8
6
|
|
|
9
|
-
- (instancetype)initWithViewTag:(NSNumber *)viewTag state:(
|
|
7
|
+
- (instancetype)initWithViewTag:(NSNumber *)viewTag state:(NSString *)state;
|
|
10
8
|
|
|
11
9
|
@end
|
|
12
10
|
|
package/ios/BottomSheet/{RNBottomSheetStateChangedEvent.m → Event/RNBottomSheetStateChangedEvent.mm}
RENAMED
|
@@ -4,7 +4,7 @@ static uint16_t _coalescingKey = 0;
|
|
|
4
4
|
|
|
5
5
|
@interface RNBottomSheetStateChangedEvent ()
|
|
6
6
|
|
|
7
|
-
@property (nonatomic,
|
|
7
|
+
@property (nonatomic, copy) NSString *state;
|
|
8
8
|
|
|
9
9
|
@end
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ static uint16_t _coalescingKey = 0;
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|
20
|
-
- (instancetype)initWithViewTag:(NSNumber *)viewTag state:(
|
|
20
|
+
- (instancetype)initWithViewTag:(NSNumber *)viewTag state:(NSString *)state {
|
|
21
21
|
if (self = [super init]) {
|
|
22
22
|
_viewTag = viewTag;
|
|
23
23
|
_state = state;
|
|
@@ -39,8 +39,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|
|
39
39
|
|
|
40
40
|
- (NSArray *)arguments {
|
|
41
41
|
return @[self.viewTag, RCTNormalizeInputEventName(self.eventName), @{
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
@"state": self.state
|
|
43
|
+
}];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent {
|