Skip to content

Commit 0d02660

Browse files
committed
fix(ios): improvements and bug fixes
1 parent e8af122 commit 0d02660

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
pod "NextLevel", "~> 0.16.3"
1+
pod "NextLevel", :git => 'https://github.com/Akylas/NextLevel.git', :branch => "0.16.4"
2+
# pod "NextLevel", :path => '/Volumes/dev/ios/NextLevel'

packages/ui-cameraview/platforms/ios/src/NSCameraView.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ public class NSCameraView: UIView, NextLevelVideoDelegate, NextLevelPhotoDelegat
8787
}
8888
}
8989

90+
public var automaticallyUpdatesDeviceOrientation: Bool {
91+
get {
92+
return self.nextLevel?.automaticallyUpdatesDeviceOrientation ?? true
93+
}
94+
set {
95+
self.nextLevel?.automaticallyUpdatesDeviceOrientation = newValue
96+
}
97+
}
98+
9099
func commonInit() {
91100
self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
92101
self.backgroundColor = UIColor.black
@@ -160,6 +169,11 @@ public class NSCameraView: UIView, NextLevelVideoDelegate, NextLevelPhotoDelegat
160169
return self.nextLevel?.canCaptureVideo ?? false
161170
}
162171
}
172+
public var videoOrientation: Int {
173+
get {
174+
return (self.nextLevel?.previewLayer.connection?.videoOrientation ?? AVCaptureVideoOrientation.portrait).rawValue
175+
}
176+
}
163177
public func capturePhoto() {
164178
if let nextLevel = self.nextLevel , self.canCapturePhoto {
165179
if ( nextLevel.captureMode == NextLevelCaptureMode.photo) {
@@ -196,7 +210,18 @@ public class NSCameraView: UIView, NextLevelVideoDelegate, NextLevelPhotoDelegat
196210
}
197211

198212
public func nextLevelSessionWillStart(_ nextLevel: NextLevel) {
199-
213+
// DispatchQueue.main.async {
214+
// var uiOrientation: UIInterfaceOrientation = .portrait
215+
//// if #available(iOS 13.0, *) {
216+
//// uiOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation ?? UIApplication.shared.statusBarOrientation
217+
//// } else {
218+
// uiOrientation = UIApplication.shared.statusBarOrientation
219+
//// }
220+
//
221+
// let orientation = AVCaptureVideoOrientation.init(rawValue: uiOrientation.rawValue) ?? AVCaptureVideoOrientation.portrait
222+
// nextLevel.previewLayer.connection?.videoOrientation = orientation;
223+
// }
224+
200225
}
201226

202227
public func nextLevelSessionDidStart(_ nextLevel: NextLevel) {

src/ui-cameraview/index.ios.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,27 +248,29 @@ export class CameraView extends CameraViewBase {
248248
}
249249

250250
[flashModeProperty.setNative](value: string | number) {
251+
const nativeView = this.nativeViewProtected;
252+
console.log('flashModeProperty.setNative', value, AVCaptureTorchMode.On);
251253
if (typeof value === 'string') {
252254
switch (value) {
253255
case 'off':
254-
this.nativeViewProtected.torchMode = AVCaptureTorchMode.Off;
255-
this.nativeViewProtected.flashMode = AVCaptureFlashMode.Off;
256+
nativeView.torchMode = AVCaptureTorchMode.Off;
257+
nativeView.flashMode = AVCaptureFlashMode.Off;
256258
break;
257259
case 'on':
258-
this.nativeViewProtected.torchMode = AVCaptureTorchMode.Off;
259-
this.nativeViewProtected.flashMode = AVCaptureFlashMode.On;
260+
nativeView.torchMode = AVCaptureTorchMode.Off;
261+
nativeView.flashMode = AVCaptureFlashMode.On;
260262
break;
261263
case 'auto':
262-
this.nativeViewProtected.torchMode = AVCaptureTorchMode.Off;
263-
this.nativeViewProtected.flashMode = AVCaptureFlashMode.Auto;
264+
nativeView.torchMode = AVCaptureTorchMode.Off;
265+
nativeView.flashMode = AVCaptureFlashMode.Auto;
264266
break;
265267
case 'torch':
266-
this.nativeViewProtected.flashMode = AVCaptureFlashMode.Off;
267-
this.nativeViewProtected.torchMode = AVCaptureTorchMode.On;
268+
nativeView.flashMode = AVCaptureFlashMode.Off;
269+
nativeView.torchMode = AVCaptureTorchMode.On;
268270
break;
269271
}
270272
} else {
271-
this.nativeViewProtected.torchMode = value;
273+
nativeView.flashMode = value;
272274
}
273275
}
274276

0 commit comments

Comments
 (0)