@lodev09/react-native-true-sheet 3.0.0-beta.9 → 3.0.1
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 +16 -6
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +29 -33
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +3 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +53 -43
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +390 -89
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +42 -4
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +0 -5
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDialogObserver.kt +67 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +70 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetDragEvents.kt +71 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetFocusEvents.kt +65 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +94 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetStateEvents.kt +56 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +37 -33
- package/android/src/main/res/anim/true_sheet_slide_in.xml +13 -0
- package/android/src/main/res/anim/true_sheet_slide_out.xml +13 -0
- package/android/src/main/res/values/styles.xml +13 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +5 -3
- package/ios/TrueSheetContainerView.mm +4 -0
- package/ios/TrueSheetContentView.h +2 -1
- package/ios/TrueSheetContentView.mm +91 -11
- package/ios/TrueSheetView.mm +94 -41
- package/ios/TrueSheetViewController.h +22 -10
- package/ios/TrueSheetViewController.mm +360 -173
- package/ios/core/TrueSheetBlurView.h +26 -0
- package/ios/{utils/ConversionUtil.mm → core/TrueSheetBlurView.mm} +64 -3
- package/ios/core/TrueSheetGrabberView.h +42 -0
- package/ios/core/TrueSheetGrabberView.mm +107 -0
- package/ios/events/TrueSheetDragEvents.h +39 -0
- package/ios/events/TrueSheetDragEvents.mm +62 -0
- package/ios/events/{OnPositionChangeEvent.h → TrueSheetFocusEvents.h} +8 -5
- package/ios/events/TrueSheetFocusEvents.mm +49 -0
- package/ios/events/TrueSheetLifecycleEvents.h +40 -0
- package/ios/events/TrueSheetLifecycleEvents.mm +71 -0
- package/ios/events/TrueSheetStateEvents.h +35 -0
- package/ios/events/TrueSheetStateEvents.mm +49 -0
- package/ios/utils/GestureUtil.h +7 -0
- package/ios/utils/GestureUtil.mm +12 -0
- package/lib/module/TrueSheet.js +72 -12
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +28 -5
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.js +13 -7
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +4 -2
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +4 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +105 -6
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +25 -5
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +8 -2
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/TrueSheet.tsx +87 -10
- package/src/TrueSheet.types.ts +114 -6
- package/src/__mocks__/index.js +0 -5
- package/src/fabric/TrueSheetViewNativeComponent.ts +28 -5
- package/src/index.ts +0 -1
- package/src/reanimated/ReanimatedTrueSheet.tsx +12 -7
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +11 -3
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +0 -32
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +0 -26
- package/ios/events/OnDetentChangeEvent.h +0 -28
- package/ios/events/OnDetentChangeEvent.mm +0 -30
- package/ios/events/OnDidDismissEvent.h +0 -26
- package/ios/events/OnDidDismissEvent.mm +0 -25
- package/ios/events/OnDidPresentEvent.h +0 -28
- package/ios/events/OnDidPresentEvent.mm +0 -30
- package/ios/events/OnDragBeginEvent.h +0 -28
- package/ios/events/OnDragBeginEvent.mm +0 -30
- package/ios/events/OnDragChangeEvent.h +0 -28
- package/ios/events/OnDragChangeEvent.mm +0 -30
- package/ios/events/OnDragEndEvent.h +0 -28
- package/ios/events/OnDragEndEvent.mm +0 -30
- package/ios/events/OnMountEvent.h +0 -26
- package/ios/events/OnMountEvent.mm +0 -25
- package/ios/events/OnPositionChangeEvent.mm +0 -32
- package/ios/events/OnWillDismissEvent.h +0 -26
- package/ios/events/OnWillDismissEvent.mm +0 -25
- package/ios/events/OnWillPresentEvent.h +0 -28
- package/ios/events/OnWillPresentEvent.mm +0 -30
- package/ios/utils/ConversionUtil.h +0 -24
- package/lib/module/TrueSheetGrabber.js +0 -51
- package/lib/module/TrueSheetGrabber.js.map +0 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +0 -1
- package/src/TrueSheetGrabber.tsx +0 -82
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
|
|
13
|
+
@interface TrueSheetBlurView : UIVisualEffectView
|
|
14
|
+
|
|
15
|
+
@property (nonatomic, copy, nullable) NSString *blurTint;
|
|
16
|
+
@property (nonatomic, strong, nullable) NSNumber *blurIntensity;
|
|
17
|
+
@property (nonatomic, assign) BOOL blurInteraction;
|
|
18
|
+
|
|
19
|
+
/// Adds the blur view to a parent view with proper constraints
|
|
20
|
+
- (void)addToView:(UIView *)parentView;
|
|
21
|
+
|
|
22
|
+
- (void)applyBlurEffect;
|
|
23
|
+
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -6,9 +6,13 @@
|
|
|
6
6
|
// LICENSE file in the root directory of this source tree.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#import "
|
|
9
|
+
#import "TrueSheetBlurView.h"
|
|
10
10
|
|
|
11
|
-
@implementation
|
|
11
|
+
@implementation TrueSheetBlurView {
|
|
12
|
+
UIViewPropertyAnimator *_blurAnimator;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#pragma mark - Private
|
|
12
16
|
|
|
13
17
|
+ (UIBlurEffectStyle)blurEffectStyleFromString:(NSString *)tintString {
|
|
14
18
|
static NSDictionary<NSString *, NSNumber *> *styleMap = nil;
|
|
@@ -43,8 +47,65 @@
|
|
|
43
47
|
return (UIBlurEffectStyle)[style integerValue];
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
// Default to light if not recognized
|
|
47
50
|
return UIBlurEffectStyleLight;
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
#pragma mark - Initialization
|
|
54
|
+
|
|
55
|
+
- (instancetype)init {
|
|
56
|
+
if (self = [super init]) {
|
|
57
|
+
_blurInteraction = YES;
|
|
58
|
+
}
|
|
59
|
+
return self;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#pragma mark - Public
|
|
63
|
+
|
|
64
|
+
- (void)addToView:(UIView *)parentView {
|
|
65
|
+
if (self.superview == parentView) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
self.frame = parentView.bounds;
|
|
70
|
+
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
71
|
+
[parentView insertSubview:self atIndex:0];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (void)applyBlurEffect {
|
|
75
|
+
self.userInteractionEnabled = self.blurInteraction;
|
|
76
|
+
|
|
77
|
+
// Create animator only once
|
|
78
|
+
if (!_blurAnimator) {
|
|
79
|
+
UIBlurEffectStyle style = [TrueSheetBlurView blurEffectStyleFromString:self.blurTint];
|
|
80
|
+
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:style];
|
|
81
|
+
|
|
82
|
+
__weak __typeof(self) weakSelf = self;
|
|
83
|
+
_blurAnimator = [[UIViewPropertyAnimator alloc] initWithDuration:1.0
|
|
84
|
+
curve:UIViewAnimationCurveLinear
|
|
85
|
+
animations:^{
|
|
86
|
+
weakSelf.effect = blurEffect;
|
|
87
|
+
}];
|
|
88
|
+
_blurAnimator.pausesOnCompletion = YES;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Update intensity
|
|
92
|
+
CGFloat intensity =
|
|
93
|
+
(self.blurIntensity && [self.blurIntensity floatValue] >= 0) ? [self.blurIntensity floatValue] / 100.0 : 1.0;
|
|
94
|
+
_blurAnimator.fractionComplete = intensity;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
- (void)willMoveToSuperview:(UIView *)newSuperview {
|
|
98
|
+
[super willMoveToSuperview:newSuperview];
|
|
99
|
+
|
|
100
|
+
// Clean up when removed from superview
|
|
101
|
+
if (!newSuperview) {
|
|
102
|
+
if (_blurAnimator) {
|
|
103
|
+
[_blurAnimator stopAnimation:YES];
|
|
104
|
+
_blurAnimator = nil;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
self.effect = nil;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
50
111
|
@end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Native grabber (drag handle) view for the bottom sheet.
|
|
15
|
+
* Uses UIVibrancyEffect to adapt color based on the background.
|
|
16
|
+
*/
|
|
17
|
+
@interface TrueSheetGrabberView : UIView
|
|
18
|
+
|
|
19
|
+
/// Width of the grabber pill (default: 36)
|
|
20
|
+
@property (nonatomic, strong, nullable) NSNumber *grabberWidth;
|
|
21
|
+
|
|
22
|
+
/// Height of the grabber pill (default: 5)
|
|
23
|
+
@property (nonatomic, strong, nullable) NSNumber *grabberHeight;
|
|
24
|
+
|
|
25
|
+
/// Top margin from the sheet edge (default: 5)
|
|
26
|
+
@property (nonatomic, strong, nullable) NSNumber *topMargin;
|
|
27
|
+
|
|
28
|
+
/// Corner radius of the grabber pill (default: height / 2)
|
|
29
|
+
@property (nonatomic, strong, nullable) NSNumber *cornerRadius;
|
|
30
|
+
|
|
31
|
+
/// Custom color for the grabber (uses vibrancy effect when nil)
|
|
32
|
+
@property (nonatomic, strong, nullable) UIColor *color;
|
|
33
|
+
|
|
34
|
+
/// Adds the grabber view to a parent view with proper constraints
|
|
35
|
+
- (void)addToView:(UIView *)parentView;
|
|
36
|
+
|
|
37
|
+
/// Applies the current configuration to the grabber view
|
|
38
|
+
- (void)applyConfiguration;
|
|
39
|
+
|
|
40
|
+
@end
|
|
41
|
+
|
|
42
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "TrueSheetGrabberView.h"
|
|
10
|
+
|
|
11
|
+
static const CGFloat kDefaultGrabberWidth = 36.0;
|
|
12
|
+
static const CGFloat kDefaultGrabberHeight = 5.0;
|
|
13
|
+
static const CGFloat kDefaultGrabberTopMargin = 5.0;
|
|
14
|
+
|
|
15
|
+
@implementation TrueSheetGrabberView {
|
|
16
|
+
UIVisualEffectView *_vibrancyView;
|
|
17
|
+
UIView *_fillView;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#pragma mark - Initialization
|
|
21
|
+
|
|
22
|
+
- (instancetype)init {
|
|
23
|
+
if (self = [super init]) {
|
|
24
|
+
[self setupView];
|
|
25
|
+
}
|
|
26
|
+
return self;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#pragma mark - Computed Properties
|
|
30
|
+
|
|
31
|
+
- (CGFloat)effectiveWidth {
|
|
32
|
+
return _grabberWidth ? [_grabberWidth floatValue] : kDefaultGrabberWidth;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (CGFloat)effectiveHeight {
|
|
36
|
+
return _grabberHeight ? [_grabberHeight floatValue] : kDefaultGrabberHeight;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (CGFloat)effectiveTopMargin {
|
|
40
|
+
return _topMargin ? [_topMargin floatValue] : kDefaultGrabberTopMargin;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (CGFloat)effectiveCornerRadius {
|
|
44
|
+
return _cornerRadius ? [_cornerRadius floatValue] : [self effectiveHeight] / 2.0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#pragma mark - Setup
|
|
48
|
+
|
|
49
|
+
- (void)setupView {
|
|
50
|
+
self.userInteractionEnabled = NO;
|
|
51
|
+
self.clipsToBounds = YES;
|
|
52
|
+
|
|
53
|
+
// Create blur effect for vibrancy base
|
|
54
|
+
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemChromeMaterial];
|
|
55
|
+
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect style:UIVibrancyEffectStyleFill];
|
|
56
|
+
|
|
57
|
+
// Create the vibrancy view that fills this view
|
|
58
|
+
_vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
|
|
59
|
+
_vibrancyView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
60
|
+
[self addSubview:_vibrancyView];
|
|
61
|
+
|
|
62
|
+
// Add a fill view inside vibrancy contentView
|
|
63
|
+
_fillView = [[UIView alloc] init];
|
|
64
|
+
_fillView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
65
|
+
_fillView.backgroundColor = [UIColor.darkGrayColor colorWithAlphaComponent:0.7];
|
|
66
|
+
[_vibrancyView.contentView addSubview:_fillView];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#pragma mark - Public
|
|
70
|
+
|
|
71
|
+
- (void)addToView:(UIView *)parentView {
|
|
72
|
+
if (self.superview == parentView) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[parentView addSubview:self];
|
|
77
|
+
[self applyConfiguration];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (void)applyConfiguration {
|
|
81
|
+
CGFloat width = [self effectiveWidth];
|
|
82
|
+
CGFloat height = [self effectiveHeight];
|
|
83
|
+
CGFloat topMargin = [self effectiveTopMargin];
|
|
84
|
+
CGFloat parentWidth = self.superview ? self.superview.bounds.size.width : UIScreen.mainScreen.bounds.size.width;
|
|
85
|
+
|
|
86
|
+
// Position the grabber: centered horizontally, with top margin
|
|
87
|
+
self.frame = CGRectMake((parentWidth - width) / 2.0, topMargin, width, height);
|
|
88
|
+
self.layer.cornerRadius = [self effectiveCornerRadius];
|
|
89
|
+
|
|
90
|
+
// Update vibrancy and fill view frames
|
|
91
|
+
_vibrancyView.frame = self.bounds;
|
|
92
|
+
_fillView.frame = _vibrancyView.contentView.bounds;
|
|
93
|
+
|
|
94
|
+
// Apply custom color to vibrancy view
|
|
95
|
+
if (_color) {
|
|
96
|
+
_vibrancyView.backgroundColor = _color;
|
|
97
|
+
} else {
|
|
98
|
+
_vibrancyView.backgroundColor = nil;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
- (void)layoutSubviews {
|
|
103
|
+
[super layoutSubviews];
|
|
104
|
+
[self applyConfiguration];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <Foundation/Foundation.h>
|
|
12
|
+
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
13
|
+
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
17
|
+
|
|
18
|
+
@interface TrueSheetDragEvents : NSObject
|
|
19
|
+
|
|
20
|
+
+ (void)emitDragBegin:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
21
|
+
index:(NSInteger)index
|
|
22
|
+
position:(CGFloat)position
|
|
23
|
+
detent:(CGFloat)detent;
|
|
24
|
+
|
|
25
|
+
+ (void)emitDragChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
26
|
+
index:(NSInteger)index
|
|
27
|
+
position:(CGFloat)position
|
|
28
|
+
detent:(CGFloat)detent;
|
|
29
|
+
|
|
30
|
+
+ (void)emitDragEnd:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
31
|
+
index:(NSInteger)index
|
|
32
|
+
position:(CGFloat)position
|
|
33
|
+
detent:(CGFloat)detent;
|
|
34
|
+
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|
|
38
|
+
|
|
39
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetDragEvents.h"
|
|
12
|
+
|
|
13
|
+
@implementation TrueSheetDragEvents
|
|
14
|
+
|
|
15
|
+
+ (void)emitDragBegin:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
16
|
+
index:(NSInteger)index
|
|
17
|
+
position:(CGFloat)position
|
|
18
|
+
detent:(CGFloat)detent {
|
|
19
|
+
if (!eventEmitter)
|
|
20
|
+
return;
|
|
21
|
+
|
|
22
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
23
|
+
TrueSheetViewEventEmitter::OnDragBegin event;
|
|
24
|
+
event.index = static_cast<int>(index);
|
|
25
|
+
event.position = static_cast<double>(position);
|
|
26
|
+
event.detent = static_cast<double>(detent);
|
|
27
|
+
emitter->onDragBegin(event);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
+ (void)emitDragChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
31
|
+
index:(NSInteger)index
|
|
32
|
+
position:(CGFloat)position
|
|
33
|
+
detent:(CGFloat)detent {
|
|
34
|
+
if (!eventEmitter)
|
|
35
|
+
return;
|
|
36
|
+
|
|
37
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
38
|
+
TrueSheetViewEventEmitter::OnDragChange event;
|
|
39
|
+
event.index = static_cast<int>(index);
|
|
40
|
+
event.position = static_cast<double>(position);
|
|
41
|
+
event.detent = static_cast<double>(detent);
|
|
42
|
+
emitter->onDragChange(event);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
+ (void)emitDragEnd:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
46
|
+
index:(NSInteger)index
|
|
47
|
+
position:(CGFloat)position
|
|
48
|
+
detent:(CGFloat)detent {
|
|
49
|
+
if (!eventEmitter)
|
|
50
|
+
return;
|
|
51
|
+
|
|
52
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
53
|
+
TrueSheetViewEventEmitter::OnDragEnd event;
|
|
54
|
+
event.index = static_cast<int>(index);
|
|
55
|
+
event.position = static_cast<double>(position);
|
|
56
|
+
event.detent = static_cast<double>(detent);
|
|
57
|
+
emitter->onDragEnd(event);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@end
|
|
61
|
+
|
|
62
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -15,12 +15,15 @@ using namespace facebook::react;
|
|
|
15
15
|
|
|
16
16
|
NS_ASSUME_NONNULL_BEGIN
|
|
17
17
|
|
|
18
|
-
@interface
|
|
18
|
+
@interface TrueSheetFocusEvents : NSObject
|
|
19
19
|
|
|
20
|
-
+ (void)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
+ (void)emitWillFocus:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
21
|
+
|
|
22
|
+
+ (void)emitDidFocus:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
23
|
+
|
|
24
|
+
+ (void)emitWillBlur:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
25
|
+
|
|
26
|
+
+ (void)emitDidBlur:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
24
27
|
|
|
25
28
|
@end
|
|
26
29
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetFocusEvents.h"
|
|
12
|
+
|
|
13
|
+
@implementation TrueSheetFocusEvents
|
|
14
|
+
|
|
15
|
+
+ (void)emitWillFocus:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
20
|
+
emitter->onWillFocus({});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
+ (void)emitDidFocus:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
24
|
+
if (!eventEmitter)
|
|
25
|
+
return;
|
|
26
|
+
|
|
27
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
28
|
+
emitter->onDidFocus({});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
+ (void)emitWillBlur:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
32
|
+
if (!eventEmitter)
|
|
33
|
+
return;
|
|
34
|
+
|
|
35
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
36
|
+
emitter->onWillBlur({});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
+ (void)emitDidBlur:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
40
|
+
if (!eventEmitter)
|
|
41
|
+
return;
|
|
42
|
+
|
|
43
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
44
|
+
emitter->onDidBlur({});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@end
|
|
48
|
+
|
|
49
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <Foundation/Foundation.h>
|
|
12
|
+
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
13
|
+
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
17
|
+
|
|
18
|
+
@interface TrueSheetLifecycleEvents : NSObject
|
|
19
|
+
|
|
20
|
+
+ (void)emitMount:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
21
|
+
|
|
22
|
+
+ (void)emitWillPresent:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
23
|
+
index:(NSInteger)index
|
|
24
|
+
position:(CGFloat)position
|
|
25
|
+
detent:(CGFloat)detent;
|
|
26
|
+
|
|
27
|
+
+ (void)emitDidPresent:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
28
|
+
index:(NSInteger)index
|
|
29
|
+
position:(CGFloat)position
|
|
30
|
+
detent:(CGFloat)detent;
|
|
31
|
+
|
|
32
|
+
+ (void)emitWillDismiss:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
33
|
+
|
|
34
|
+
+ (void)emitDidDismiss:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter;
|
|
35
|
+
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
NS_ASSUME_NONNULL_END
|
|
39
|
+
|
|
40
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetLifecycleEvents.h"
|
|
12
|
+
|
|
13
|
+
@implementation TrueSheetLifecycleEvents
|
|
14
|
+
|
|
15
|
+
+ (void)emitMount:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
16
|
+
if (!eventEmitter)
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
20
|
+
emitter->onMount({});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
+ (void)emitWillPresent:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
24
|
+
index:(NSInteger)index
|
|
25
|
+
position:(CGFloat)position
|
|
26
|
+
detent:(CGFloat)detent {
|
|
27
|
+
if (!eventEmitter)
|
|
28
|
+
return;
|
|
29
|
+
|
|
30
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
31
|
+
TrueSheetViewEventEmitter::OnWillPresent event;
|
|
32
|
+
event.index = static_cast<int>(index);
|
|
33
|
+
event.position = static_cast<double>(position);
|
|
34
|
+
event.detent = static_cast<double>(detent);
|
|
35
|
+
emitter->onWillPresent(event);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
+ (void)emitDidPresent:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
39
|
+
index:(NSInteger)index
|
|
40
|
+
position:(CGFloat)position
|
|
41
|
+
detent:(CGFloat)detent {
|
|
42
|
+
if (!eventEmitter)
|
|
43
|
+
return;
|
|
44
|
+
|
|
45
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
46
|
+
TrueSheetViewEventEmitter::OnDidPresent event;
|
|
47
|
+
event.index = static_cast<int>(index);
|
|
48
|
+
event.position = static_cast<double>(position);
|
|
49
|
+
event.detent = static_cast<double>(detent);
|
|
50
|
+
emitter->onDidPresent(event);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
+ (void)emitWillDismiss:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
54
|
+
if (!eventEmitter)
|
|
55
|
+
return;
|
|
56
|
+
|
|
57
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
58
|
+
emitter->onWillDismiss({});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
+ (void)emitDidDismiss:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter {
|
|
62
|
+
if (!eventEmitter)
|
|
63
|
+
return;
|
|
64
|
+
|
|
65
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
66
|
+
emitter->onDidDismiss({});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@end
|
|
70
|
+
|
|
71
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <Foundation/Foundation.h>
|
|
12
|
+
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
13
|
+
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
17
|
+
|
|
18
|
+
@interface TrueSheetStateEvents : NSObject
|
|
19
|
+
|
|
20
|
+
+ (void)emitDetentChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
21
|
+
index:(NSInteger)index
|
|
22
|
+
position:(CGFloat)position
|
|
23
|
+
detent:(CGFloat)detent;
|
|
24
|
+
|
|
25
|
+
+ (void)emitPositionChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
26
|
+
index:(CGFloat)index
|
|
27
|
+
position:(CGFloat)position
|
|
28
|
+
detent:(CGFloat)detent
|
|
29
|
+
realtime:(BOOL)realtime;
|
|
30
|
+
|
|
31
|
+
@end
|
|
32
|
+
|
|
33
|
+
NS_ASSUME_NONNULL_END
|
|
34
|
+
|
|
35
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetStateEvents.h"
|
|
12
|
+
|
|
13
|
+
@implementation TrueSheetStateEvents
|
|
14
|
+
|
|
15
|
+
+ (void)emitDetentChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
16
|
+
index:(NSInteger)index
|
|
17
|
+
position:(CGFloat)position
|
|
18
|
+
detent:(CGFloat)detent {
|
|
19
|
+
if (!eventEmitter)
|
|
20
|
+
return;
|
|
21
|
+
|
|
22
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
23
|
+
TrueSheetViewEventEmitter::OnDetentChange event;
|
|
24
|
+
event.index = static_cast<int>(index);
|
|
25
|
+
event.position = static_cast<double>(position);
|
|
26
|
+
event.detent = static_cast<double>(detent);
|
|
27
|
+
emitter->onDetentChange(event);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
+ (void)emitPositionChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
31
|
+
index:(CGFloat)index
|
|
32
|
+
position:(CGFloat)position
|
|
33
|
+
detent:(CGFloat)detent
|
|
34
|
+
realtime:(BOOL)realtime {
|
|
35
|
+
if (!eventEmitter)
|
|
36
|
+
return;
|
|
37
|
+
|
|
38
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
39
|
+
TrueSheetViewEventEmitter::OnPositionChange event;
|
|
40
|
+
event.index = static_cast<double>(index);
|
|
41
|
+
event.position = static_cast<double>(position);
|
|
42
|
+
event.detent = static_cast<double>(detent);
|
|
43
|
+
event.realtime = static_cast<bool>(realtime);
|
|
44
|
+
emitter->onPositionChange(event);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@end
|
|
48
|
+
|
|
49
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
package/ios/utils/GestureUtil.h
CHANGED
|
@@ -20,6 +20,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
20
20
|
*/
|
|
21
21
|
+ (void)attachPanGestureHandler:(UIView *)view target:(id)target selector:(SEL)selector;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Enables or disables all pan gesture recognizers on a view
|
|
25
|
+
* @param view The view whose pan gesture recognizers to enable/disable
|
|
26
|
+
* @param enabled Whether the pan gestures should be enabled
|
|
27
|
+
*/
|
|
28
|
+
+ (void)setPanGesturesEnabled:(BOOL)enabled forView:(UIView *)view;
|
|
29
|
+
|
|
23
30
|
@end
|
|
24
31
|
|
|
25
32
|
NS_ASSUME_NONNULL_END
|
package/ios/utils/GestureUtil.mm
CHANGED
|
@@ -23,4 +23,16 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
+ (void)setPanGesturesEnabled:(BOOL)enabled forView:(UIView *)view {
|
|
27
|
+
if (!view) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
for (UIGestureRecognizer *recognizer in view.gestureRecognizers ?: @[]) {
|
|
32
|
+
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
33
|
+
recognizer.enabled = enabled;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
@end
|