From 92ce0be306263ce8ec76227617b01199dd97186a Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Sun, 22 Apr 2018 23:43:37 +0900 Subject: [PATCH] =?UTF-8?q?=E6=97=A7=E6=B7=BB=E4=BB=98=E7=94=BB=E5=83=8F?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E7=94=BB=E9=9D=A2=E3=82=92=E6=B6=88=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iMast.xcodeproj/project.pbxproj | 4 - iMast/NewPost/NewPost.storyboard | 138 ----------------- .../NewPostSetImageViewController.swift | 146 ------------------ iMast/NewPost/NewPostViewController.swift | 1 - 4 files changed, 289 deletions(-) delete mode 100644 iMast/NewPost/NewPostSetImageViewController.swift diff --git a/iMast.xcodeproj/project.pbxproj b/iMast.xcodeproj/project.pbxproj index 8eb9a2628..317fbfaa8 100644 --- a/iMast.xcodeproj/project.pbxproj +++ b/iMast.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ 2AF352251EAB9C5600777C2E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2AF352231EAB9C5600777C2E /* LaunchScreen.storyboard */; }; 2AF352301EAB9C5600777C2E /* iMastTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AF3522F1EAB9C5600777C2E /* iMastTests.swift */; }; 2AF3523B1EAB9C5600777C2E /* iMastUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AF3523A1EAB9C5600777C2E /* iMastUITests.swift */; }; - 2AFC9FDB1EB5478900888A8B /* NewPostSetImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AFC9FDA1EB5478900888A8B /* NewPostSetImageViewController.swift */; }; 4DA5F6B8581A005E7D478957 /* Pods_iMastUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 233F93890AFA8A380B3A3DC0 /* Pods_iMastUITests.framework */; }; 91732F1F15D3B33F2BE0D33B /* Pods_iMastTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E8E17F42A61B242493C5F81 /* Pods_iMastTests.framework */; }; CE1002C420065CC20041B636 /* MastodonAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1002C320065CC20041B636 /* MastodonAttachment.swift */; }; @@ -197,7 +196,6 @@ 2AF352361EAB9C5600777C2E /* iMastUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iMastUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 2AF3523A1EAB9C5600777C2E /* iMastUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iMastUITests.swift; sourceTree = ""; }; 2AF3523C1EAB9C5600777C2E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 2AFC9FDA1EB5478900888A8B /* NewPostSetImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewPostSetImageViewController.swift; sourceTree = ""; }; 3E8E17F42A61B242493C5F81 /* Pods_iMastTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iMastTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4EABF09BB4A0E0D3ABBB0120 /* Pods_iMast.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iMast.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 694662BBDCFC9D77A4DFC768 /* Pods-iMastShare.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iMastShare.release.xcconfig"; path = "Pods/Target Support Files/Pods-iMastShare/Pods-iMastShare.release.xcconfig"; sourceTree = ""; }; @@ -486,7 +484,6 @@ children = ( 2A533F6E1ECCFE940062630F /* NewPost.storyboard */, 2A492A7E1EB3584500F81E73 /* NewPostViewController.swift */, - 2AFC9FDA1EB5478900888A8B /* NewPostSetImageViewController.swift */, CEE2E79F208B48E60020F86F /* NewPostMediaListViewController.swift */, CEE2E7A0208B48E60020F86F /* NewPostMediaListViewController.xib */, ); @@ -1050,7 +1047,6 @@ CE9B1AA41F9DEDB50044341A /* ProfileCardViewController.swift in Sources */, CE3DFEE01FEE4C51005A480D /* UserDefaultsDict.swift in Sources */, 2A66E7FA1EAEB0DD00735081 /* GoodUtils.swift in Sources */, - 2AFC9FDB1EB5478900888A8B /* NewPostSetImageViewController.swift in Sources */, CEE2542E2004FA76005FEB6F /* MastodonNotification.swift in Sources */, CE1002C820065DA30041B636 /* MastodonSearchResult.swift in Sources */, CEE2542A2004B802005FEB6F /* MastodonApplication.swift in Sources */, diff --git a/iMast/NewPost/NewPost.storyboard b/iMast/NewPost/NewPost.storyboard index 42e46a20a..dfa7ddff6 100644 --- a/iMast/NewPost/NewPost.storyboard +++ b/iMast/NewPost/NewPost.storyboard @@ -6,7 +6,6 @@ - @@ -134,143 +133,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iMast/NewPost/NewPostSetImageViewController.swift b/iMast/NewPost/NewPostSetImageViewController.swift deleted file mode 100644 index 2bf5137d3..000000000 --- a/iMast/NewPost/NewPostSetImageViewController.swift +++ /dev/null @@ -1,146 +0,0 @@ -// -// NewPostSetImageViewController.swift -// iMast -// -// Created by rinsuki on 2017/04/30. -// Copyright © 2017年 rinsuki. All rights reserved. -// - -import UIKit - -class NewPostSetImageViewController: UITableViewController, UIDocumentMenuDelegate, UIDocumentPickerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { - - @IBOutlet weak var imageView: UIImageView! - @IBOutlet weak var nsfwSwitch: UISwitch! - @IBOutlet weak var autoResizeConfigShow: UILabel! - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - let parentVC = self.navigationController!.viewControllers[self.navigationController!.viewControllers.count - 2] as! NewPostViewController - self.imageView.image = parentVC.image - self.nsfwSwitch.isOn = parentVC.isNSFW - updateAutoResizeConfigShow() - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destinationViewController. - // Pass the selected object to the new view controller. - } - */ - - func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) { - documentPicker.delegate = self - present(documentPicker, animated: true, completion: nil) - } - - func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) { - setImage(url: url, image: UIImage(data:try! Data(contentsOf: url,options:NSData.ReadingOptions.mappedIfSafe))!) - } - - func updateAutoResizeConfigShow() { - let nowAutoResizeConfig = Defaults[.autoResizeSize] - self.autoResizeConfigShow.text = (nowAutoResizeConfig == 0 ? "無指定" : String(nowAutoResizeConfig) + "px") - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let selectedRow = indexPath[1] - if selectedRow == 1 { // 画像を選択 - let pickerSelector = UIDocumentMenuViewController( - documentTypes:[ - "public.image" - ], - in: UIDocumentPickerMode.import - ) - pickerSelector.popoverPresentationController?.sourceView = tableView.cellForRow(at: indexPath) - pickerSelector.addOption(withTitle: "フォトライブラリ", image: UIImage(named: "PhotosInline"), order: UIDocumentMenuOrder.first, handler: { - print("photo-library") - let imgPickerC = UIImagePickerController() - imgPickerC.sourceType = UIImagePickerControllerSourceType.photoLibrary - imgPickerC.delegate = self - self.present(imgPickerC, animated: true, completion: nil) - }) - if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) { - pickerSelector.addOption(withTitle: "写真を撮る", image: UIImage(named: "Camera"), order: UIDocumentMenuOrder.first, handler: { - print("camera") - let imgPickerC = UIImagePickerController() - imgPickerC.sourceType = UIImagePickerControllerSourceType.camera - imgPickerC.delegate = self - - self.present(imgPickerC, animated: true, completion: nil) - }) - } - pickerSelector.delegate = self - present(pickerSelector, animated: true, completion: nil) - } else if selectedRow == 3 { // 自動リサイズ - let nowsentaku = Defaults[.autoResizeSize] - let sentakusi = [ // 自動リサイズの選択肢 - 0, - 1280, - 1000, - 750, - 500, - ] - let select = UIAlertController( - title: "自動リサイズ", - message: "現在: " + (nowsentaku == 0 ? "無指定" : String(nowsentaku) + "px四方に収まるサイズ"), - preferredStyle: UIAlertControllerStyle.actionSheet - ) - select.popoverPresentationController?.sourceView = tableView.cellForRow(at: indexPath)?.detailTextLabel - for num in sentakusi { - let title = num == 0 ? "無指定" : String(num) + "px四方に収まるサイズ" - select.addAction(UIAlertAction(title: title, style: UIAlertActionStyle.default, handler: { (action: UIAlertAction!) in - Defaults[.autoResizeSize] = num - self.updateAutoResizeConfigShow() - })) - } - select.addAction(UIAlertAction(title: "キャンセル", style: UIAlertActionStyle.cancel)) - present(select, animated: true, completion: nil) - } else if selectedRow == 4 { // 画像消去 - let parentVC = self.navigationController!.viewControllers[self.navigationController!.viewControllers.count - 2] as! NewPostViewController - self.imageView.image = nil - parentVC.image = nil - parentVC.isPNG = true - } - } - - func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { - print(info) - let url = (info[UIImagePickerControllerReferenceURL] as? URL) ?? URL(string: "https://example.com/example.jpg")! - let pickedImage = info[UIImagePickerControllerOriginalImage] as! UIImage - setImage(url: url, image: pickedImage) - picker.dismiss(animated: true, completion: nil) - } - - func setImage(url: URL, image: UIImage) { - let parentVC = self.navigationController!.viewControllers[self.navigationController!.viewControllers.count - 2] as! NewPostViewController - let urlStr = url.absoluteString.lowercased() - if urlStr.contains(".jpg") || urlStr.contains(".jpeg") { // たぶんJPEG、きっとJPEG、だよな!? - print("maybe jpeg") - parentVC.isPNG = false - } else { - parentVC.isPNG = true - } - selectedImage(image) - } - - func selectedImage(_ image: UIImage) { - let parentVC = self.navigationController!.viewControllers[self.navigationController!.viewControllers.count - 2] as! NewPostViewController - self.imageView.image = image - parentVC.image = image - } - @IBAction func nsfwTap(_ sender: Any) { - let parentVC = self.navigationController!.viewControllers[self.navigationController!.viewControllers.count - 2] as! NewPostViewController - parentVC.isNSFW = self.nsfwSwitch.isOn - } -} diff --git a/iMast/NewPost/NewPostViewController.swift b/iMast/NewPost/NewPostViewController.swift index f495edcbb..ce582ecf1 100644 --- a/iMast/NewPost/NewPostViewController.swift +++ b/iMast/NewPost/NewPostViewController.swift @@ -26,7 +26,6 @@ class NewPostViewController: UIViewController, UITextViewDelegate { cwInput.isHidden = true } } - var image: UIImage? = nil // TODO: あとで消す var images: [UIImage] = [] @IBOutlet weak var nowAccountLabel: UILabel!