Skip to content

Commit

Permalink
Merge pull request #4 from spoonconsulting/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
zfir authored Jun 20, 2024
2 parents 4d89744 + ee77042 commit d7925fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 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-beta2",
"version": "1.0.0-beta3",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</feature>
</config-file>
<source-file src="src/ios/CDVRoomPlan.swift" />
<source-file src="src/ios/CDVRoomPlan.h" />
<source-file src="src/ios/CDVRoomPlan.h" type="BridgingHeader" />
<dependency id="cordova-plugin-add-swift-support" version="2.0.2"/>
</platform>
</plugin>
13 changes: 10 additions & 3 deletions src/ios/CDVRoomPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
self.activityIndicator?.stopAnimating()
}

// Action for the 'Done' button
@objc func doneScanning(_ sender: UIButton) {
if state == "scanning" {
stopSession()
Expand Down Expand Up @@ -104,9 +103,9 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
let jsonData = try jsonEncoder.encode(finalResults)
try jsonData.write(to: jsonFile)
try finalResults?.export(to: usdzFile, exportOptions: .parametric)
if finalResults != nil {
if (finalResults != nil) && isCapturedRoomNil(capturedRoom: finalResults!) {
let result = ["usdz": usdzFile.absoluteString, "json": jsonFile.absoluteString, "message": "Scanning completed successfully"]
let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: usdzFile.absoluteString)
let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: result)
pluginResult?.keepCallback = true
self.commandDelegate.send(pluginResult, callbackId: self.command.callbackId)
}
Expand Down Expand Up @@ -154,4 +153,12 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat
button.translatesAutoresizingMaskIntoConstraints = false
return button
}

func isCapturedRoomNil(capturedRoom: CapturedRoom) -> Bool {
if #available(iOS 17.0, *) {
return capturedRoom.walls.count != 0 || capturedRoom.doors.count != 0 || capturedRoom.windows.count != 0 || capturedRoom.sections.count != 0 || capturedRoom.floors.count != 0 || capturedRoom.objects.count != 0 || capturedRoom.openings.count != 0
} else {
return false
}
}
}

0 comments on commit d7925fa

Please sign in to comment.