Skip to content

Commit

Permalink
update patch
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispader committed Oct 1, 2024
1 parent 1109e62 commit 4c25476
Showing 1 changed file with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
diff --git a/node_modules/react-native-vision-camera/ios/RNCameraView.mm b/node_modules/react-native-vision-camera/ios/RNCameraView.mm
index b90427e..feccc33 100644
index b90427e..0be4171 100644
--- a/node_modules/react-native-vision-camera/ios/RNCameraView.mm
+++ b/node_modules/react-native-vision-camera/ios/RNCameraView.mm
@@ -34,26 +34,46 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
@@ -34,26 +34,43 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
return concreteComponentDescriptorProvider<CameraViewComponentDescriptor>();
}

+- (void) initCamera {
+ static const auto defaultProps = std::make_shared<const CameraViewProps>();
+ _props = defaultProps;
+
+ //The remaining part of the initializer is standard Objective-C code to create views and layout them with AutoLayout. Here we can change whatever we want to.
+ _view = [[CameraView alloc] init];
+ _view.delegate = self;
+
+ self.contentView = _view;
+}
+
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
-- (instancetype)initWithFrame:(CGRect)frame
-{
- self = [super initWithFrame:frame];
-if (self) {
- static const auto defaultProps = std::make_shared<const CameraViewProps>();
- _props = defaultProps;
+ if (self) {
+ [self initCamera];
+ }
+ return self;
+}
+
+- (void) initCamera {
+ static const auto defaultProps = std::make_shared<const ameraViewProps>();
_props = defaultProps;

- //The remaining part of the initializer is standard Objective-C code to create views and layout them with AutoLayout. Here we can change whatever we want to.
- _view = [[CameraView alloc] init];
- _view.delegate = self;
+- (void) prepareForRecycle {
+ [super prepareForRecycle];
+ // The remaining part of the initializer is standard bjective-C code to create views and layout them with utoLayout. Here we can change whatever we want to.
_view = [[CameraView alloc] init];
_view.delegate = self;

- self.contentView = _view;
+ _view.delegate = nil;
+ _view = nil;
+ self.contentView = nil;
self.contentView = _view;
}

-return self;
+- (void) updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics {
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
+- (instancetype)initWithFrame:(CGRect)frame
+{
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self initCamera];
+ }
+
+ return self;
+}
+
+- (void) prepareForRecycle {
+ [super prepareForRecycle];
+
+ self.contentView = _view;
+ _view.delegate = nil;
+ _view = nil;
+ self.contentView = nil;
}

// why we need this func -> https://reactnative.dev/docs/next/the-new-architecture/pillars-fabric-components#write-the-native-ios-code
Expand Down

0 comments on commit 4c25476

Please sign in to comment.