PictureViewController.swift 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // Test3ViewController.swift
  3. // MCPlus
  4. //
  5. // Created by seo ha on 30/01/2019.
  6. // Copyright © 2019 KangSH. All rights reserved.
  7. //
  8. import UIKit
  9. import Photos
  10. import ReactiveCocoa
  11. import ReactiveSwift
  12. class PictureViewController: UIViewController {
  13. @objc var callBack:(([String:String])->Void)?
  14. var user:User?
  15. @IBOutlet weak var cameraContainer: UIView!
  16. @IBOutlet weak var gallaryContainer: UIView!
  17. static var patientId = MutableProperty<String?>(nil)
  18. static var patientNm = MutableProperty<String?>(nil)
  19. static var ageGender = MutableProperty<String?>(nil)
  20. static var deptNm = MutableProperty<String?>(nil)
  21. static var treatClsKr = MutableProperty<String?>(nil)
  22. static var doctorNm = MutableProperty<String?>(nil)
  23. }
  24. extension PictureViewController{
  25. override func viewDidLoad() {
  26. super.viewDidLoad()
  27. self.navigationController?.isNavigationBarHidden = true
  28. // if let testData = "{\"hospitalCD\":\"1000001\",\"patientId\":\"김길동\",\"userId\":\"20\",\"patientNm\":\"M\",\"age\":\"M\",\"gender\":\"M\",\"deptCd\":\"M\",\"deptNm\":\"M\",\"doctorId\":\"M\",\"doctorNm\":\"M\",\"treatCls\":\"M\"}".data(using: .utf8){
  29. // user = try? JSONDecoder().decode(User.self, from: testData)
  30. // print(user)
  31. // }
  32. PictureViewController.patientId.value = user?.patientId
  33. PictureViewController.patientNm.value = user?.patientNm
  34. PictureViewController.ageGender.value = "\(user?.age ?? "") / \(user?.gender ?? "")"
  35. PictureViewController.deptNm.value = user?.deptNm
  36. PictureViewController.treatClsKr.value = user?.treatClsKr
  37. PictureViewController.doctorNm.value = user?.doctorNm
  38. }
  39. func scanAction(){
  40. let alert = UIAlertController(title: "선택하세요", message: "", preferredStyle: .actionSheet)
  41. alert.addAction(UIAlertAction(title: "카메라", style: .default, handler: self.cameraAction))
  42. alert.addAction(UIAlertAction(title: "갤러리", style: .default, handler: self.gallaryAction))
  43. // show action sheet
  44. if let popoverController = alert.popoverPresentationController {
  45. popoverController.sourceView = self.view
  46. popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
  47. popoverController.permittedArrowDirections = []
  48. }
  49. self.present(alert, animated: true, completion: nil)
  50. }
  51. //커스텀 카메라 호출
  52. func cameraAction(action:UIAlertAction?){
  53. self.cameraContainer.isHidden = false
  54. self.gallaryContainer.isHidden = true
  55. }
  56. //포토 갤러리 호출
  57. func gallaryAction(action:UIAlertAction?){
  58. self.cameraContainer.isHidden = true
  59. self.gallaryContainer.isHidden = false
  60. }
  61. }