From c944a91efdf9507979a5fa2bd60d3c9a11f3b71a Mon Sep 17 00:00:00 2001 From: Zafir Sk Heerah Date: Thu, 20 Jun 2024 15:57:15 +0400 Subject: [PATCH 1/2] Behaviour fixes --- src/ios/CDVRoomPlan.swift | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVRoomPlan.swift b/src/ios/CDVRoomPlan.swift index 844a304..8c66c71 100644 --- a/src/ios/CDVRoomPlan.swift +++ b/src/ios/CDVRoomPlan.swift @@ -53,6 +53,7 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat private func stopSession() { state = "scanned" roomCaptureView?.captureSession.stop() + updateButtons() } func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: (Error)?) -> Bool { @@ -119,8 +120,8 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat private func addButtons() { - cancelButton = createButton(title: "Cancel", backgroundColor: UIColor.red) - doneButton = createButton(title: "Done", backgroundColor: UIColor.blue) + cancelButton = createButton(title: "Cancel", backgroundColor: UIColor(hex: "#D65745")) + doneButton = createButton(title: "Done", backgroundColor: UIColor(hex: "#00A885")) cancelButton!.addTarget(self, action: #selector(cancelScanning), for: .touchUpInside) roomCaptureView.addSubview(cancelButton!) @@ -130,6 +131,12 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat setupConstraints() } + private func updateButtons() { + if state == "scanned" { + cancelButton?.removeFromSuperview() + } + } + func setupConstraints() { NSLayoutConstraint.activate([ cancelButton!.leadingAnchor.constraint(equalTo: viewController.view.leadingAnchor, constant: 20), @@ -162,3 +169,23 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat } } } + +extension UIColor { + convenience init(hex: String, alpha: CGFloat = 1.0) { + let hexString = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) + var int: UInt64 = 0 + Scanner(string: hexString).scanHexInt64(&int) + let a, r, g, b: UInt64 + switch hexString.count { + case 3: + (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) + case 6: + (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) + case 8: + (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) + default: + (a, r, g, b) = (255, 0, 0, 0) + } + self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) + } +} From 984c04ed64a4ea299c126d30f18db788318559de Mon Sep 17 00:00:00 2001 From: Zafir Sk Heerah Date: Thu, 20 Jun 2024 16:00:28 +0400 Subject: [PATCH 2/2] Beta 4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b698f2d..6ac44f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta3", + "version": "1.0.0-beta4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta3", + "version": "1.0.0-beta4", "license": "ISC" } } diff --git a/package.json b/package.json index 04129a7..fe3c0a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta3", + "version": "1.0.0-beta4", "description": "", "main": "index.js", "scripts": {