Sfoglia il codice sorgente

롱클릭시 디테일 바로가기 변경, 사진 재정송 추가후 주석처리, 체크아이템 수량 검사 및 삭제 알림문구 처리

서용하 6 anni fa
parent
commit
750d158b2d

+ 59 - 34
MCPlus/Adapter/PhotoCollectionViewAdapter.swift

@@ -71,48 +71,73 @@ extension PhotoCollectionViewAdapter:UICollectionViewDataSource, UICollectionVie
             let app = UIApplication.shared.delegate as! AppDelegate
             guard let nav = app.visibleViewController?.navigationController as? UINavigationController else{ return }
             
-            let alert = UIAlertController(title: "선택", message: "", preferredStyle: .actionSheet)
+//            let alert = UIAlertController(title: "선택", message: "", preferredStyle: .actionSheet)
             
             //개별 앨범 이미지를 삭제한다
-            alert.addAction(UIAlertAction(title: "삭제", style: .destructive){ [weak collectionView](action) in
-                do {
-                    let photos = list[indexPath.first ?? 0].1
-                    let photo = photos[indexPath.row]
-                    if let file = photo.file{
-                        self.fileDelete(file: file)
-                    }
-                    let _ = photo.delete()
-                    self.selectedArr = self.selectedArr.filter({$0 != indexPath})
-                    CustomCameraViewController.photoProcessCommit.value = nil
-                }
-                
-            })
+//            alert.addAction(UIAlertAction(title: "삭제", style: .destructive){ [weak collectionView](action) in
+//                do {
+//                    let photos = list[indexPath.first ?? 0].1
+//                    let photo = photos[indexPath.row]
+//                    if let file = photo.file{
+//                        self.fileDelete(file: file)
+//                    }
+//                    let _ = photo.delete()
+//                    self.selectedArr = self.selectedArr.filter({$0 != indexPath})
+//                    CustomCameraViewController.photoProcessCommit.value = nil
+//                }
+//
+//            })
+            
+            //아이템을 재전송
+//            alert.addAction(UIAlertAction(title: "재전송", style: .destructive){ [weak collectionView](action) in
+//                do {
+//                    let photos = list[indexPath.first ?? 0].1
+//                    let photo = photos[indexPath.row]
+//                    PhotoViewController.reUploadItem.value = photo
+//                    CustomCameraViewController.photoProcessCommit.value = nil
+//                }
+//                
+//            })
             
             //디테일 보기 화면으로 이동한다
-            alert.addAction(UIAlertAction(title: "크게보기", style: .default){ (action) in
-                let storyBoard = UIStoryboard(name: "Main", bundle: nil)
-                let VC = storyBoard.instantiateViewController(withIdentifier: "PhotoDetailViewController") as! PhotoDetailViewController
-                VC.image = image
-                do {
-                    let photos = list[indexPath.first ?? 0].1
-                    let photo = photos[indexPath.row]
-                    VC.photo = photo
-                    VC.callBack = { [weak collectionView] in
-                        collectionView?.reloadData()
-                    }
-                }
-                
-                nav.pushViewController(VC, animated: true)
-            })
+//            alert.addAction(UIAlertAction(title: "크게보기", style: .default){ (action) in
+//                let storyBoard = UIStoryboard(name: "Main", bundle: nil)
+//                let VC = storyBoard.instantiateViewController(withIdentifier: "PhotoDetailViewController") as! PhotoDetailViewController
+//                VC.image = image
+//                do {
+//                    let photos = list[indexPath.first ?? 0].1
+//                    let photo = photos[indexPath.row]
+//                    VC.photo = photo
+//                    VC.callBack = { [weak collectionView] in
+//                        collectionView?.reloadData()
+//                    }
+//                }
+//
+//                nav.pushViewController(VC, animated: true)
+//            })
             
             // show action sheet
-            if let popoverController = alert.popoverPresentationController {
-                popoverController.sourceView = nav.visibleViewController?.view
-                popoverController.sourceRect = CGRect(x: nav.visibleViewController?.view.bounds.midX ?? 0, y: nav.visibleViewController?.view.bounds.midY ?? 0, width: 0, height: 0)
-                popoverController.permittedArrowDirections = []
+//            if let popoverController = alert.popoverPresentationController {
+//                popoverController.sourceView = nav.visibleViewController?.view
+//                popoverController.sourceRect = CGRect(x: nav.visibleViewController?.view.bounds.midX ?? 0, y: nav.visibleViewController?.view.bounds.midY ?? 0, width: 0, height: 0)
+//                popoverController.permittedArrowDirections = []
+//            }
+            
+//            nav.visibleViewController?.present(alert, animated: true, completion: nil)
+            
+            let storyBoard = UIStoryboard(name: "Main", bundle: nil)
+            let VC = storyBoard.instantiateViewController(withIdentifier: "PhotoDetailViewController") as! PhotoDetailViewController
+            VC.image = image
+            do {
+                let photos = list[indexPath.first ?? 0].1
+                let photo = photos[indexPath.row]
+                VC.photo = photo
+                VC.callBack = { [weak collectionView] in
+                    collectionView?.reloadData()
+                }
             }
             
-            nav.visibleViewController?.present(alert, animated: true, completion: nil)
+            nav.pushViewController(VC, animated: true)
             
         }
         

+ 14 - 14
MCPlus/Base.lproj/Main.storyboard

@@ -189,7 +189,7 @@
                                 <rect key="frame" x="0.0" y="44" width="375" height="48"/>
                                 <subviews>
                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="환부이미지촬영" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Gz-wR-Tkc">
-                                        <rect key="frame" x="127" y="13.666666666666664" width="121.33333333333331" height="21"/>
+                                        <rect key="frame" x="130" y="12.999999999999998" width="115.33333333333331" height="22.333333333333329"/>
                                         <fontDescription key="fontDescription" name="NanumSquareB" family="NanumSquare" pointSize="19"/>
                                         <nil key="textColor"/>
                                         <nil key="highlightedColor"/>
@@ -227,13 +227,13 @@
                                         <rect key="frame" x="0.0" y="0.0" width="89.666666666666671" height="110"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="홍길동" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZS3-lT-QK3">
-                                                <rect key="frame" x="20.333333333333332" y="17" width="49.333333333333343" height="20"/>
+                                                <rect key="frame" x="21.333333333333329" y="17" width="47" height="21"/>
                                                 <fontDescription key="fontDescription" name="NanumSquareB" family="NanumSquare" pointSize="18"/>
                                                 <nil key="textColor"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fKT-hb-N98">
-                                                <rect key="frame" x="0.0" y="56.666666666666657" width="89.666666666666671" height="36.333333333333343"/>
+                                                <rect key="frame" x="0.0" y="55" width="89.666666666666671" height="38"/>
                                                 <attributedString key="attributedText">
                                                     <fragment content="내용">
                                                         <attributes>
@@ -270,13 +270,13 @@
                                         <rect key="frame" x="89.666666666666686" y="0.0" width="90" height="110"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="A1000100" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4un-kx-8PH">
-                                                <rect key="frame" x="0.3333333333333286" y="17" width="89" height="20"/>
+                                                <rect key="frame" x="4" y="17" width="82" height="21"/>
                                                 <fontDescription key="fontDescription" name="NanumSquareB" family="NanumSquare" pointSize="18"/>
                                                 <nil key="textColor"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ecd-Ow-N4X">
-                                                <rect key="frame" x="0.0" y="56.666666666666657" width="90" height="36.333333333333343"/>
+                                                <rect key="frame" x="0.0" y="55" width="90" height="38"/>
                                                 <attributedString key="attributedText">
                                                     <fragment>
                                                         <string key="content">내용 텍스트 
@@ -315,7 +315,7 @@
                                         <rect key="frame" x="179.66666666666666" y="0.0" width="89.666666666666657" height="110"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mtS-Sd-L2M">
-                                                <rect key="frame" x="0.0" y="56.666666666666657" width="89.666666666666671" height="36.333333333333343"/>
+                                                <rect key="frame" x="0.0" y="55" width="89.666666666666671" height="38"/>
                                                 <attributedString key="attributedText"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
@@ -342,13 +342,13 @@
                                         <rect key="frame" x="269.33333333333331" y="0.0" width="89.666666666666686" height="110"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="20 / M" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KLU-Vc-9DU">
-                                                <rect key="frame" x="17.666666666666689" y="17" width="54.333333333333343" height="20"/>
+                                                <rect key="frame" x="18.666666666666686" y="17" width="52" height="21"/>
                                                 <fontDescription key="fontDescription" name="NanumSquareB" family="NanumSquare" pointSize="18"/>
                                                 <nil key="textColor"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1NT-Lz-aBT">
-                                                <rect key="frame" x="0.0" y="56.666666666666657" width="89.666666666666671" height="36.333333333333343"/>
+                                                <rect key="frame" x="0.0" y="55" width="89.666666666666671" height="38"/>
                                                 <attributedString key="attributedText">
                                                     <fragment>
                                                         <string key="content">내용 텍스트 
@@ -397,10 +397,10 @@
                                 </userDefinedRuntimeAttributes>
                             </stackView>
                             <view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="x3X-mc-6dm">
-                                <rect key="frame" x="8" y="208" width="359" height="42"/>
+                                <rect key="frame" x="8" y="208" width="359" height="43"/>
                                 <subviews>
                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2018-10-10 외래 or 입원, 진료과" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mLD-MC-fGV">
-                                        <rect key="frame" x="16" y="11" width="327" height="20"/>
+                                        <rect key="frame" x="16" y="11" width="327" height="21"/>
                                         <fontDescription key="fontDescription" name="NanumSquareB" family="NanumSquare" pointSize="18"/>
                                         <color key="textColor" red="0.39215686274509803" green="0.60392156862745094" blue="0.9882352941176471" alpha="1" colorSpace="calibratedRGB"/>
                                         <nil key="highlightedColor"/>
@@ -420,20 +420,20 @@
                                 </userDefinedRuntimeAttributes>
                             </view>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Twe-8h-6Au">
-                                <rect key="frame" x="0.0" y="250" width="375" height="528"/>
+                                <rect key="frame" x="0.0" y="251" width="375" height="527"/>
                                 <subviews>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dat-yv-K6v">
-                                        <rect key="frame" x="0.0" y="10" width="375" height="518"/>
+                                        <rect key="frame" x="0.0" y="10" width="375" height="517"/>
                                         <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     </view>
                                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="camera_lo" translatesAutoresizingMaskIntoConstraints="NO" id="ME9-uU-UZ3">
-                                        <rect key="frame" x="92" y="173.66666666666669" width="191" height="191"/>
+                                        <rect key="frame" x="92" y="173" width="191" height="191"/>
                                         <constraints>
                                             <constraint firstAttribute="width" secondItem="ME9-uU-UZ3" secondAttribute="height" multiplier="1:1" id="DoM-A7-iEK"/>
                                         </constraints>
                                     </imageView>
                                     <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="CvO-ai-fc0">
-                                        <rect key="frame" x="22" y="472" width="331" height="50"/>
+                                        <rect key="frame" x="22" y="471" width="331" height="50"/>
                                         <subviews>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="944-gk-cQs">
                                                 <rect key="frame" x="0.0" y="0.0" width="97" height="50"/>

+ 35 - 18
MCPlus/ViewControllers/PhotoViewController.swift

@@ -131,6 +131,8 @@ class PhotoViewController: UIViewController{
     let adapter = PhotoCollectionViewAdapter()
     
     var list = MutableProperty<[(String,[Photo])]?>(nil)
+    
+    static var reUploadItem = MutableProperty<Photo?>(nil)
 
     var successCount = 0
     var failCount = 0
@@ -156,6 +158,11 @@ extension PhotoViewController{
             }
         }
         
+        PhotoViewController.reUploadItem.signal.observe { [weak self](item) in
+            guard let value = item.value as? Photo else{ return }
+            self?.uploadItem(value)
+        }
+        
     }
     
     override func viewWillLayoutSubviews() {
@@ -175,6 +182,10 @@ extension PhotoViewController{
     func okAction(){
         successCount = 0
         failCount = 0
+        guard self.adapter.selectedArr.count > 0 else{
+            self.showAlert("파일을 한 개 이상 선택해주세요", "", "확인")
+            return
+        }
         //비동기화 통신코드 동기화 구현 필요
         for indexPath in self.adapter.selectedArr{
             guard let list = self.list.value else{ return }
@@ -240,30 +251,36 @@ extension PhotoViewController{
                 }
             }
         
-        
-        
-        
     }
     
     //선택된 사진 삭제
     func deleteAction(){
-        for indexPath in self.adapter.selectedArr{
-            guard let list = self.list.value else{ return }
-            
-            let photos = list[indexPath.first ?? 0].1
-            let photo = photos[indexPath.row]
-            do {
-                if let file = photo.file{
-                    self.fileDelete(file: file)
-                }
-                
-                let _ = photo.delete()
-            }
-            self.adapter.selectedArr = self.adapter.selectedArr.filter({$0 != indexPath})
+        guard self.adapter.selectedArr.count > 0 else{
+            self.showAlert("파일을 한 개 이상 선택해주세요", "", "확인")
+            return
         }
         
-        self.reloadTable()
-        
+        self.showAlert("정말 삭제하시겠습니까?", "", "확인", "취소", { [weak self] (action) in
+            guard let `self` = self else{ return }
+            for indexPath in self.adapter.selectedArr{
+                guard let list = self.list.value else{ return }
+                
+                let photos = list[indexPath.first ?? 0].1
+                let photo = photos[indexPath.row]
+                do {
+                    if let file = photo.file{
+                        self.fileDelete(file: file)
+                    }
+                    
+                    let _ = photo.delete()
+                }
+                self.adapter.selectedArr = self.adapter.selectedArr.filter({$0 != indexPath})
+            }
+            
+            self.reloadTable()
+            }, { [weak self] (action) in
+                
+        })
     }
     
     func fileDelete(file:String){