@@ -90,7 +90,6 @@ - (void)layoutSubviews
90
90
self.manager .previewLayer .frame = self.bounds ;
91
91
}
92
92
[self setBackgroundColor: [UIColor blackColor ]];
93
- NSLog (@" sublayers count: %d " , [self .layer.sublayers count ]);
94
93
if ([self .layer.sublayers count ] == 0 ) {
95
94
[self .layer insertSublayer: self .manager.previewLayer atIndex: 0 ];
96
95
}
@@ -123,59 +122,58 @@ - (void)orientationChanged:(NSNotification *)notification{
123
122
}
124
123
125
124
126
- - (void ) touchesBegan : (NSSet *)touches withEvent : (UIEvent *)event
125
+ - (void )touchesBegan : (NSSet *)touches withEvent : (UIEvent *)event
127
126
{
128
- // Update the touch state.
129
- if ([[event touchesForView: self ] count ] > 1 ) {
130
- _multipleTouches = YES ;
131
- }
132
-
127
+ // Update the touch state.
128
+ if ([[event touchesForView: self ] count ] > 1 ) {
129
+ _multipleTouches = YES ;
130
+ }
133
131
}
134
132
135
133
- (void )touchesEnded : (NSSet *)touches withEvent : (UIEvent *)event
136
134
{
137
- if (!_onFocusChanged) return ;
138
-
139
- BOOL allTouchesEnded = ([touches count ] == [[event touchesForView: self ] count ]);
140
-
141
- // Do not conflict with zooming and etc.
142
- if (allTouchesEnded && !_multipleTouches) {
143
- UITouch *touch = [[event allTouches ] anyObject ];
144
- CGPoint touchPoint = [touch locationInView: touch.view];
145
- // Focus camera on this point
146
- [self .manager focusAtThePoint: touchPoint];
147
-
148
- if (self.camFocus )
149
- {
150
- [self .camFocus removeFromSuperview ];
151
- }
152
- NSDictionary *event = @{
153
- @" target" : self.reactTag ,
154
- @" touchPoint" : @{
155
- @" x" : [NSNumber numberWithDouble: touchPoint.x],
156
- @" y" : [NSNumber numberWithDouble: touchPoint.y]
157
- }
158
- };
159
- [self .bridge.eventDispatcher sendInputEventWithName: @" focusChanged" body: event];
160
-
161
- // Show animated rectangle on the touched area
162
- if (_defaultOnFocusComponent) {
163
- self.camFocus = [[RCTCameraFocusSquare alloc ]initWithFrame:CGRectMake (touchPoint.x-40 , touchPoint.y-40 , 80 , 80 )];
164
- [self .camFocus setBackgroundColor: [UIColor clearColor ]];
165
- [self addSubview: self .camFocus];
166
- [self .camFocus setNeedsDisplay ];
167
-
168
- [UIView beginAnimations: nil context: NULL ];
169
- [UIView setAnimationDuration: 1.0 ];
170
- [self .camFocus setAlpha: 0.0 ];
171
- [UIView commitAnimations ];
172
- }
173
- }
135
+ if (!_onFocusChanged && false ) return ;
136
+
137
+ BOOL allTouchesEnded = ([touches count ] == [[event touchesForView: self ] count ]);
174
138
175
- if (allTouchesEnded) {
176
- _multipleTouches = NO ;
139
+ // Do not conflict with zooming and etc.
140
+ if (allTouchesEnded && !_multipleTouches) {
141
+ UITouch *touch = [[event allTouches ] anyObject ];
142
+ CGPoint touchPoint = [touch locationInView: touch.view];
143
+ // Focus camera on this point
144
+ [self .manager focusAtThePoint: touchPoint];
145
+
146
+ if (self.camFocus )
147
+ {
148
+ [self .camFocus removeFromSuperview ];
149
+ }
150
+ NSDictionary *event = @{
151
+ @" target" : self.reactTag ,
152
+ @" touchPoint" : @{
153
+ @" x" : [NSNumber numberWithDouble: touchPoint.x],
154
+ @" y" : [NSNumber numberWithDouble: touchPoint.y]
155
+ }
156
+ };
157
+ [self .bridge.eventDispatcher sendAppEventWithName: @" onPressCamera" body: event];
158
+ [self .bridge.eventDispatcher sendInputEventWithName: @" focusChanged" body: event];
159
+
160
+ // Show animated rectangle on the touched area
161
+ if (_defaultOnFocusComponent) {
162
+ self.camFocus = [[RCTCameraFocusSquare alloc ] initWithFrame: CGRectMake (touchPoint.x-40 , touchPoint.y-40 , 80 , 80 )];
163
+ [self .camFocus setBackgroundColor: [UIColor clearColor ]];
164
+ [self addSubview: self .camFocus];
165
+ [self .camFocus setNeedsDisplay ];
166
+
167
+ [UIView beginAnimations: nil context: NULL ];
168
+ [UIView setAnimationDuration: 1.0 ];
169
+ [self .camFocus setAlpha: 0.0 ];
170
+ [UIView commitAnimations ];
177
171
}
172
+ }
178
173
174
+ if (allTouchesEnded) {
175
+ _multipleTouches = NO ;
176
+ }
179
177
}
180
178
181
179
0 commit comments