PictureViewController.swift 3.0 KB

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