Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}
Loading