@sdcx/bottom-sheet 0.17.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.
Files changed (30) hide show
  1. package/README.md +57 -51
  2. package/RNBottomSheet.podspec +5 -4
  3. package/android/build.gradle +42 -19
  4. package/android/src/main/java/com/reactnative/bottomsheet/BottomSheet.java +59 -58
  5. package/android/src/main/java/com/reactnative/bottomsheet/BottomSheetManager.java +12 -6
  6. package/android/src/main/java/com/reactnative/bottomsheet/{BottomSheetState.java → BottomSheetStatus.java} +1 -1
  7. package/android/src/main/java/com/reactnative/bottomsheet/{OffsetChangedEvent.java → OnSlideEvent.java} +5 -3
  8. package/android/src/main/java/com/reactnative/bottomsheet/{StateChangedEvent.java → OnStateChangedEvent.java} +5 -3
  9. package/dist/BottomSheetNativeComponent.d.ts +20 -0
  10. package/dist/BottomSheetNativeComponent.js +2 -0
  11. package/dist/index.d.ts +8 -15
  12. package/dist/index.js +9 -9
  13. package/ios/BottomSheet/{RNBottomSheetOffsetChangedEvent.m → Event/RNBottomSheetOffsetChangedEvent.mm} +3 -1
  14. package/ios/BottomSheet/{RNBottomSheetStateChangedEvent.h → Event/RNBottomSheetStateChangedEvent.h} +1 -3
  15. package/ios/BottomSheet/{RNBottomSheetStateChangedEvent.m → Event/RNBottomSheetStateChangedEvent.mm} +4 -4
  16. package/ios/BottomSheet/RNBottomSheetComponentView.h +10 -0
  17. package/ios/BottomSheet/RNBottomSheetComponentView.mm +555 -0
  18. package/package.json +50 -38
  19. package/src/BottomSheetNativeComponent.ts +26 -0
  20. package/src/index.tsx +51 -70
  21. package/docs/assets/pagerview.gif +0 -0
  22. package/docs/assets/scrollview.gif +0 -0
  23. package/docs/assets/struct.png +0 -0
  24. package/ios/BottomSheet/RNBottomSheet.h +0 -21
  25. package/ios/BottomSheet/RNBottomSheet.m +0 -407
  26. package/ios/BottomSheet/RNBottomSheetManager.h +0 -9
  27. package/ios/BottomSheet/RNBottomSheetManager.m +0 -24
  28. package/ios/BottomSheet/RNBottomSheetState.h +0 -17
  29. package/ios/BottomSheet/RNBottomSheetState.m +0 -38
  30. /package/ios/BottomSheet/{RNBottomSheetOffsetChangedEvent.h → Event/RNBottomSheetOffsetChangedEvent.h} +0 -0
@@ -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 StateChangedEvent extends Event<StateChangedEvent> {
10
- public static final String Name = "stateEvent";
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 StateChangedEvent(int surfaceId, int viewTag, String state) {
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;
@@ -0,0 +1,2 @@
1
+ import { codegenNativeComponent } from 'react-native';
2
+ export default codegenNativeComponent('BottomSheet');
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
- export interface OffsetChangedEventData {
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 interface StateChangedEventData {
11
- state: BottomSheetState;
12
- }
13
- interface NativeBottomSheetProps extends ViewProps {
14
- onSlide?: (event: NativeSyntheticEvent<OffsetChangedEventData>) => void;
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 const BottomSheet: React.ForwardRefExoticComponent<NativeBottomSheetProps & {
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 { requireNativeComponent, StyleSheet, View, } from 'react-native';
2
+ import { StyleSheet, View } from 'react-native';
3
3
  import splitLayoutProps from './splitLayoutProps';
4
- const NativeBottomSheet = requireNativeComponent('BottomSheet');
5
- const BottomSheet = React.forwardRef((props, ref) => {
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 (<NativeBottomSheet style={[StyleSheet.absoluteFill, outer]} peekHeight={peekHeight} draggable={draggable} state={state} {...rest} ref={ref}>
9
- <View style={[
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
- {children}
15
- </View>
16
- </NativeBottomSheet>);
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
- return YES;
39
+ return YES;
38
40
  }
39
41
 
40
42
  - (uint16_t)coalescingKey {
@@ -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:(RNBottomSheetState)state;
7
+ - (instancetype)initWithViewTag:(NSNumber *)viewTag state:(NSString *)state;
10
8
 
11
9
  @end
12
10
 
@@ -4,7 +4,7 @@ static uint16_t _coalescingKey = 0;
4
4
 
5
5
  @interface RNBottomSheetStateChangedEvent ()
6
6
 
7
- @property (nonatomic, assign) RNBottomSheetState state;
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:(RNBottomSheetState)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
- @"state": RNBottomSheetStateToString(self.state)
43
- }];
42
+ @"state": self.state
43
+ }];
44
44
  }
45
45
 
46
46
  - (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent {
@@ -0,0 +1,10 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface RNBottomSheetComponentView : RCTViewComponentView
7
+
8
+ @end
9
+
10
+ NS_ASSUME_NONNULL_END