PictureViewController.swift 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. }
  21. extension PictureViewController{
  22. override func viewDidLoad() {
  23. super.viewDidLoad()
  24. self.navigationController?.isNavigationBarHidden = true
  25. // 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){
  26. // user = try? JSONDecoder().decode(User.self, from: testData)
  27. // print(user)
  28. // }
  29. PictureViewController.patientId.value = user?.patientId
  30. PictureViewController.patientNm.value = user?.patientNm
  31. PictureViewController.ageGender.value = "\(user?.age ?? "") / \(user?.gender ?? "")"
  32. }
  33. func scanAction(){
  34. let alert = UIAlertController(title: "선택하세요", message: "", preferredStyle: .actionSheet)
  35. alert.addAction(UIAlertAction(title: "카메라", style: .default, handler: self.cameraAction))
  36. alert.addAction(UIAlertAction(title: "갤러리", style: .default, handler: self.gallaryAction))
  37. // show action sheet
  38. if let popoverController = alert.popoverPresentationController {
  39. popoverController.sourceView = self.view
  40. popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
  41. popoverController.permittedArrowDirections = []
  42. }
  43. self.present(alert, animated: true, completion: nil)
  44. }
  45. //커스텀 카메라 호출
  46. func cameraAction(action:UIAlertAction?){
  47. self.cameraContainer.isHidden = false
  48. self.gallaryContainer.isHidden = true
  49. }
  50. //포토 갤러리 호출
  51. func gallaryAction(action:UIAlertAction?){
  52. self.cameraContainer.isHidden = true
  53. self.gallaryContainer.isHidden = false
  54. }
  55. }