//
//  ConsentViewController.swift
//  SAGE_RK_ML
//
//  Created by Juan David Lopez Regalado on 31/01/25.
//

import UIKit
import ResearchKit
import ResearchKitUI

class ConsentViewController: UIViewController, ORKTaskViewControllerDelegate {


    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.hidesBackButton = false


        // Do any additional setup after loading the view.
    }
    
    @IBAction func consentButton(_ sender: UIButton) {
        let taskViewController = ORKTaskViewController(task: ConsentTask, taskRun: nil)
        taskViewController.delegate = self
        taskViewController.modalPresentationStyle = .fullScreen
        present(taskViewController, animated: true, completion: nil)
    }
    
    func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskFinishReason, error: (any Error)?) {
        if let error = error {
            print("Error en ResearchKit: \(error.localizedDescription)")
        }
        taskViewController.dismiss(animated: true, completion: nil)
    }
    

}
