Skip to content

Commit

Permalink
Merge pull request #6 from spoonconsulting/fix-orientation
Browse files Browse the repository at this point in the history
Fix orientation
  • Loading branch information
zfir authored Jun 20, 2024
2 parents 280df49 + 538104d commit e380f95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spoonconsulting/cordova-plugin-roomplan",
"version": "1.0.0-beta4",
"version": "1.0.0-beta5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
18 changes: 12 additions & 6 deletions src/ios/CDVRoomPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
private var state: String = "loaded"
private var roomCaptureView: RoomCaptureView!
private var roomCaptureSessionConfig: RoomCaptureSession.Configuration = RoomCaptureSession.Configuration()
private var finalResults: CapturedRoom?
private var processedResult: CapturedRoom?

var command: CDVInvokedUrlCommand!

Expand All @@ -41,6 +41,13 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
roomCaptureView.captureSession.delegate = self
roomCaptureView.delegate = self
viewController.view.addSubview(roomCaptureView)
roomCaptureView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
roomCaptureView.topAnchor.constraint(equalTo: viewController.view.topAnchor),
roomCaptureView.leftAnchor.constraint(equalTo: viewController.view.leftAnchor),
roomCaptureView.bottomAnchor.constraint(equalTo: viewController.view.bottomAnchor),
roomCaptureView.rightAnchor.constraint(equalTo: viewController.view.rightAnchor)
]);
startSession()
}

Expand Down Expand Up @@ -69,7 +76,7 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
self.commandDelegate.send(pluginResult, callbackId: self.command.callbackId)
return
}
finalResults = processedResult
self.processedResult = processedResult
self.activityIndicator?.stopAnimating()
}

Expand Down Expand Up @@ -101,10 +108,10 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
do {
try FileManager.default.createDirectory(at: documentsDirectory, withIntermediateDirectories: true, attributes: nil)
let jsonEncoder = JSONEncoder()
let jsonData = try jsonEncoder.encode(finalResults)
let jsonData = try jsonEncoder.encode(self.processedResult)
try jsonData.write(to: jsonFile)
try finalResults?.export(to: usdzFile, exportOptions: .parametric)
if (finalResults != nil) && isCapturedRoomNil(capturedRoom: finalResults!) {
try self.processedResult?.export(to: usdzFile, exportOptions: .parametric)
if (self.processedResult != nil) && isCapturedRoomNil(capturedRoom: self.processedResult!) {
let result = ["usdz": usdzFile.absoluteString, "json": jsonFile.absoluteString, "message": "Scanning completed successfully"]
let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: result)
pluginResult?.keepCallback = true
Expand All @@ -118,7 +125,6 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
}
}


private func addButtons() {
cancelButton = createButton(title: "Cancel", backgroundColor: UIColor(hex: "#D65745"))
doneButton = createButton(title: "Done", backgroundColor: UIColor(hex: "#00A885"))
Expand Down

0 comments on commit e380f95

Please sign in to comment.