diff options
author | marinofaggiana <marino@marinofaggiana.com> | 2020-07-23 09:24:28 +0300 |
---|---|---|
committer | marinofaggiana <marino@marinofaggiana.com> | 2020-07-23 09:24:28 +0300 |
commit | ef4d047e6e7e3ea11c4ae9bed1f86891b1132f7c (patch) | |
tree | 45070dacca891462f48fc4585a03291e51388aa2 /Carthage | |
parent | da30429efbcba72b5f9bea305b7a50416fcd102f (diff) |
coding
Diffstat (limited to 'Carthage')
3 files changed, 49 insertions, 14 deletions
diff --git a/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/Base.lproj/Main.storyboard b/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/Base.lproj/Main.storyboard index b0eef3525..df2e036e6 100644 --- a/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/Base.lproj/Main.storyboard +++ b/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/Base.lproj/Main.storyboard @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc"> - <device id="retina4_7" orientation="portrait"> - <adaptation id="fullscreen"/> - </device> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc"> + <device id="retina4_7" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> @@ -19,7 +17,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="50" translatesAutoresizingMaskIntoConstraints="NO" id="3bJ-bG-tue"> - <rect key="frame" x="73" y="144" width="229" height="380"/> + <rect key="frame" x="73" y="57.5" width="229" height="552"/> <subviews> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zpy-9h-CPz"> <rect key="frame" x="0.0" y="0.0" width="229" height="36"/> @@ -29,16 +27,25 @@ <action selector="pickerButtonTap" destination="vXZ-lx-hvc" eventType="touchUpInside" id="0Q7-5M-ogn"/> </connections> </button> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="d6U-qB-bWX"> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WKj-AD-9tA"> <rect key="frame" x="0.0" y="86" width="229" height="36"/> <fontDescription key="fontDescription" type="system" pointSize="20"/> + <state key="normal" title="Only Video Recording"/> + <connections> + <action selector="onlyVideoRecording:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="GbK-VR-G0G"/> + <action selector="pickerButtonTap" destination="vXZ-lx-hvc" eventType="touchUpInside" id="zYL-bG-qij"/> + </connections> + </button> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="d6U-qB-bWX"> + <rect key="frame" x="0.0" y="172" width="229" height="36"/> + <fontDescription key="fontDescription" type="system" pointSize="20"/> <state key="normal" title="Custom CameraCell (Live)"/> <connections> <action selector="pickerWithCustomCameraCell" destination="vXZ-lx-hvc" eventType="touchUpInside" id="fXi-av-gMq"/> </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9kt-E5-QsD"> - <rect key="frame" x="0.0" y="172" width="229" height="36"/> + <rect key="frame" x="0.0" y="258" width="229" height="36"/> <fontDescription key="fontDescription" type="system" pointSize="20"/> <state key="normal" title="Custom BlackStyle"/> <connections> @@ -46,7 +53,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="icR-mj-SY4"> - <rect key="frame" x="0.0" y="258" width="229" height="36"/> + <rect key="frame" x="0.0" y="344" width="229" height="36"/> <fontDescription key="fontDescription" type="system" pointSize="20"/> <state key="normal" title="with NavigationController"> <color key="titleColor" red="0.1019607843" green="0.73725490199999999" blue="0.61176470589999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> @@ -56,7 +63,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VP9-SK-f4B"> - <rect key="frame" x="0.0" y="344" width="229" height="36"/> + <rect key="frame" x="0.0" y="430" width="229" height="36"/> <fontDescription key="fontDescription" type="system" pointSize="20"/> <state key="normal" title="with custom rules"> <color key="titleColor" red="0.27450980390000002" green="0.31372549020000001" blue="0.37647058820000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> @@ -66,7 +73,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W1Y-V8-qUq"> - <rect key="frame" x="0.0" y="344" width="229" height="36"/> + <rect key="frame" x="0.0" y="516" width="229" height="36"/> <fontDescription key="fontDescription" type="system" pointSize="20"/> <state key="normal" title="with Custom Layout"/> <connections> @@ -76,7 +83,7 @@ </subviews> </stackView> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="u8O-io-kHd"> - <rect key="frame" x="137.5" y="534" width="100" height="112"/> + <rect key="frame" x="137.5" y="619.5" width="100" height="112"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="get image message" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9CM-MS-96X"> <rect key="frame" x="3" y="0.0" width="94" height="12"/> diff --git a/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/ViewController.swift b/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/ViewController.swift index a1bb569e2..b6f7cd9df 100644 --- a/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/ViewController.swift +++ b/Carthage/Checkouts/TLPhotoPicker/Example/TLPhotoPicker/ViewController.swift @@ -31,6 +31,24 @@ class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate { self.present(viewController, animated: true, completion: nil) } + @IBAction func onlyVideoRecording(_ sender: Any) { + let viewController = CustomPhotoPickerViewController() + viewController.delegate = self + viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in + self?.showExceededMaximumAlert(vc: picker) + } + var configure = TLPhotosPickerConfigure() + configure.numberOfColumn = 3 + configure.allowedPhotograph = false + configure.allowedVideoRecording = true + configure.mediaType = .video + viewController.configure = configure + viewController.selectedAssets = self.selectedAssets + viewController.logDelegate = self + + self.present(viewController, animated: true, completion: nil) + } + @IBAction func pickerWithCustomCameraCell() { let viewController = CustomPhotoPickerViewController() viewController.delegate = self diff --git a/Carthage/Checkouts/TLPhotoPicker/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift b/Carthage/Checkouts/TLPhotoPicker/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift index 5d043f075..76bc65799 100644 --- a/Carthage/Checkouts/TLPhotoPicker/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift +++ b/Carthage/Checkouts/TLPhotoPicker/TLPhotoPicker/Classes/TLPhotosPickerViewController.swift @@ -67,6 +67,7 @@ public struct TLPhotosPickerConfigure { public var allowedLivePhotos = true public var allowedVideo = true public var allowedAlbumCloudShared = false + public var allowedPhotograph = true public var allowedVideoRecording = true public var recordingVideoQuality: UIImagePickerController.QualityType = .typeMedium public var maxVideoDuration:TimeInterval? = nil @@ -598,14 +599,21 @@ extension TLPhotosPickerViewController: UIImagePickerControllerDelegate, UINavig guard !maxCheck() else { return } let picker = UIImagePickerController() picker.sourceType = .camera - picker.mediaTypes = [kUTTypeImage as String] + var mediaTypes: [String] = [] + if self.configure.allowedPhotograph { + mediaTypes.append(kUTTypeImage as String) + } if self.configure.allowedVideoRecording { - picker.mediaTypes.append(kUTTypeMovie as String) + mediaTypes.append(kUTTypeMovie as String) picker.videoQuality = self.configure.recordingVideoQuality if let duration = self.configure.maxVideoDuration { picker.videoMaximumDuration = duration } } + guard mediaTypes.count > 0 else { + return + } + picker.mediaTypes = mediaTypes picker.allowsEditing = false picker.delegate = self self.present(picker, animated: true, completion: nil) @@ -632,6 +640,7 @@ extension TLPhotosPickerViewController: UIImagePickerControllerDelegate, UINavig let newAssetRequest = PHAssetChangeRequest.creationRequestForAsset(from: image) placeholderAsset = newAssetRequest.placeholderForCreatedAsset }, completionHandler: { [weak self] (success, error) in + guard self?.maxCheck() == false else { return } if success, let `self` = self, let identifier = placeholderAsset?.localIdentifier { guard let asset = PHAsset.fetchAssets(withLocalIdentifiers: [identifier], options: nil).firstObject else { return } var result = TLPHAsset(asset: asset) @@ -648,6 +657,7 @@ extension TLPhotosPickerViewController: UIImagePickerControllerDelegate, UINavig let newAssetRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: info[.mediaURL] as! URL) placeholderAsset = newAssetRequest?.placeholderForCreatedAsset }) { [weak self] (sucess, error) in + guard self?.maxCheck() == false else { return } if sucess, let `self` = self, let identifier = placeholderAsset?.localIdentifier { guard let asset = PHAsset.fetchAssets(withLocalIdentifiers: [identifier], options: nil).firstObject else { return } var result = TLPHAsset(asset: asset) |