Skip to content

Commit

Permalink
Merge pull request #5 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 d7925fa + 984c04e commit 280df49
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 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-beta3",
"version": "1.0.0-beta4",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
31 changes: 29 additions & 2 deletions src/ios/CDVRoomPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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!)
Expand All @@ -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),
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 280df49

Please sign in to comment.