struct TouchlessView: View {
@State var touchlessModel: TouchlessViewModel = TouchlessViewModel()
@Environment(\.presentationMode) var dismiss2
func dismissView() {
dismiss2.wrappedValue.dismiss()
}
@State var dismiss:Bool = false
var body: some View {
}
// Sample to scan right hand just change orientation for the other hands also
@ViewBuilder
func ScanRightHand() -> some View {
let vc = YesidTouchless(orientation: 1,progress:0).environmentObject(self.touchlessModel)
let host = UIHostingController(rootView: vc)
let scenes = UIApplication.shared.connectedScenes
let windowScene = scenes.first as? UIWindowScene
let application = windowScene?.windows.first
Button(title: "Scan Right Hand"){
application?.rootViewController?.present(host, animated: true, completion: {
let label = UILabel(frame: CGRect(x: host.view.frame.width/2-100, y: host.view.frame.height/2-100 + 50, width: 200, height: 200))
label.text = "TouchlessCancel"
label.textColor = .black
label.textAlignment = .center
let spinner = UIActivityIndicatorView(style: .medium)
spinner.color = .black
spinner.center = CGPoint(x: host.view.frame.width/2, y: host.view.frame.height/2)
spinner.startAnimating()
host.view.addSubview(spinner)
host.view.addSubview(label)
})
}
.onChange(of: self.touchlessModel.isRightFingerScan){ newvalue in
if(newvalue) {
application?.rootViewController?.dismiss(animated: true)
self.touchlessModel.touchlessEnrollmentProgress=1
}
}
}
}