Skip to content

Commit

Permalink
custom cell
Browse files Browse the repository at this point in the history
  • Loading branch information
wade.hawk authored and wade.hawk committed May 15, 2017
1 parent e88fd6f commit 3070e65
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SPEC CHECKSUMS:
Nimble: 415e3aa3267e7bc2c96b05fa814ddea7bb686a29
Nimble-Snapshots: e743439f26c2fa99d8f7e0d7c01c99bcb40aa6f2
Quick: 8024e4a47e6cc03a9d5245ef0948264fc6d27cff
TLPhotoPicker: 44b1e7acd184d34bcce45406d36e3f680a2a2821
TLPhotoPicker: 06eb66d6b6a1a0bf4316522032d6bf6d0e078849

PODFILE CHECKSUM: 6acf64bb276856bfde65e460d32fa3559cc3e913

Expand Down
16 changes: 16 additions & 0 deletions Example/TLPhotoPicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
4F171CBC88CC72E6EA0AF9A9 /* Pods_TLPhotoPicker_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18A9D0696DEEBAAB25DE043D /* Pods_TLPhotoPicker_Tests.framework */; };
5D438D831EC9DB9000D63583 /* CustomCell_Instagram.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D438D821EC9DB9000D63583 /* CustomCell_Instagram.swift */; };
5D438D851EC9DEB400D63583 /* CustomCell_Instagram.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5D438D841EC9DEB400D63583 /* CustomCell_Instagram.xib */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
Expand All @@ -32,6 +34,8 @@
3802EDD404952C3F6A617922 /* Pods-TLPhotoPicker_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLPhotoPicker_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TLPhotoPicker_Tests/Pods-TLPhotoPicker_Tests.debug.xcconfig"; sourceTree = "<group>"; };
3A59BDF34F7DBFA439E9E2FB /* Pods-TLPhotoPicker_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLPhotoPicker_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TLPhotoPicker_Tests/Pods-TLPhotoPicker_Tests.release.xcconfig"; sourceTree = "<group>"; };
51A5A8C94F447050F0C8EC78 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
5D438D821EC9DB9000D63583 /* CustomCell_Instagram.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCell_Instagram.swift; sourceTree = "<group>"; };
5D438D841EC9DEB400D63583 /* CustomCell_Instagram.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CustomCell_Instagram.xib; sourceTree = "<group>"; };
607FACD01AFB9204008FA782 /* TLPhotoPicker_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TLPhotoPicker_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -69,6 +73,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5D438D811EC9DB7E00D63583 /* CustomCells */ = {
isa = PBXGroup;
children = (
5D438D821EC9DB9000D63583 /* CustomCell_Instagram.swift */,
5D438D841EC9DEB400D63583 /* CustomCell_Instagram.xib */,
);
name = CustomCells;
sourceTree = "<group>";
};
607FACC71AFB9204008FA782 = {
isa = PBXGroup;
children = (
Expand All @@ -93,6 +106,7 @@
607FACD21AFB9204008FA782 /* Example for TLPhotoPicker */ = {
isa = PBXGroup;
children = (
5D438D811EC9DB7E00D63583 /* CustomCells */,
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
607FACD71AFB9204008FA782 /* ViewController.swift */,
607FACD91AFB9204008FA782 /* Main.storyboard */,
Expand Down Expand Up @@ -251,6 +265,7 @@
buildActionMask = 2147483647;
files = (
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
5D438D851EC9DEB400D63583 /* CustomCell_Instagram.xib in Resources */,
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
);
Expand Down Expand Up @@ -363,6 +378,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5D438D831EC9DB9000D63583 /* CustomCell_Instagram.swift in Sources */,
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
);
Expand Down
51 changes: 51 additions & 0 deletions Example/TLPhotoPicker/CustomCell_Instagram.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// CustomCell_Instagram.swift
// TLPhotoPicker
//
// Created by wade.hawk on 2017. 5. 15..
// Copyright © 2017년 CocoaPods. All rights reserved.
//

import Foundation
import TLPhotoPicker
import PhotosUI

class CustomCell_Instagram: TLPhotoCollectionViewCell {

let selectedColor = UIColor(red: 88/255, green: 144/255, blue: 255/255, alpha: 1.0)

override var duration: TimeInterval? {
didSet {
self.durationLabel?.isHidden = self.duration == nil ? true : false
guard let duration = self.duration else { return }
self.durationLabel?.text = timeFormatted(timeInterval: duration)
}
}

override var isCameraCell: Bool {
didSet {
self.orderLabel?.isHidden = self.isCameraCell
}
}

override public var selectedAsset: Bool {
willSet(newValue) {
self.orderLabel?.layer.borderColor = newValue ? self.selectedColor.cgColor : UIColor.white.cgColor
self.orderLabel?.backgroundColor = newValue ? self.selectedColor : UIColor(red: 1, green: 1, blue: 1, alpha: 0.3)
}
}

override func awakeFromNib() {
super.awakeFromNib()
self.durationView?.backgroundColor = UIColor.clear
self.orderLabel?.clipsToBounds = true
self.orderLabel?.layer.cornerRadius = 10
self.orderLabel?.layer.borderWidth = 1
self.orderLabel?.layer.borderColor = UIColor.white.cgColor
}

override open func prepareForReuse() {
super.prepareForReuse()
self.durationView?.backgroundColor = UIColor.clear
}
}
95 changes: 95 additions & 0 deletions Example/TLPhotoPicker/CustomCell_Instagram.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="CustomCell_Instagram" id="9Rv-Fn-yCT" customClass="CustomCell_Instagram" customModule="TLPhotoPicker_Example" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="rOH-JI-pE1">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uwg-fz-Lnl">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JhX-P9-VnM">
<rect key="frame" x="75" y="5" width="20" height="20"/>
<constraints>
<constraint firstAttribute="width" secondItem="JhX-P9-VnM" secondAttribute="height" multiplier="1:1" id="HyJ-ox-Pd8"/>
<constraint firstAttribute="width" constant="20" id="ZSd-26-g6g"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="13"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="JhX-P9-VnM" secondAttribute="trailing" constant="5" id="T4h-5Q-DtR"/>
<constraint firstItem="JhX-P9-VnM" firstAttribute="top" secondItem="uwg-fz-Lnl" secondAttribute="top" constant="5" id="hIw-3h-tPP"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dN5-jZ-SiB">
<rect key="frame" x="0.0" y="75" width="100" height="25"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0:02" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0AD-DJ-hk7">
<rect key="frame" x="30" y="0.0" width="65" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="65" id="Hky-qZ-eo9"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="0AD-DJ-hk7" secondAttribute="bottom" id="B6M-k2-HZD"/>
<constraint firstAttribute="trailing" secondItem="0AD-DJ-hk7" secondAttribute="trailing" constant="5" id="c2b-dQ-g7Y"/>
<constraint firstAttribute="height" constant="25" id="fEJ-nX-P4S"/>
<constraint firstItem="0AD-DJ-hk7" firstAttribute="top" secondItem="dN5-jZ-SiB" secondAttribute="top" id="uOO-Wg-zvQ"/>
</constraints>
</view>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="1Zf-X9-xCZ">
<rect key="frame" x="40" y="40" width="20" height="20"/>
</activityIndicatorView>
</subviews>
</view>
<constraints>
<constraint firstItem="1Zf-X9-xCZ" firstAttribute="centerX" secondItem="9Rv-Fn-yCT" secondAttribute="centerX" id="4EP-vr-Yn3"/>
<constraint firstItem="dN5-jZ-SiB" firstAttribute="leading" secondItem="9Rv-Fn-yCT" secondAttribute="leading" id="81d-II-POL"/>
<constraint firstItem="rOH-JI-pE1" firstAttribute="leading" secondItem="9Rv-Fn-yCT" secondAttribute="leading" id="KJ3-eV-OY7"/>
<constraint firstAttribute="trailing" secondItem="dN5-jZ-SiB" secondAttribute="trailing" id="Mbt-2E-UCm"/>
<constraint firstItem="uwg-fz-Lnl" firstAttribute="leading" secondItem="9Rv-Fn-yCT" secondAttribute="leading" id="N99-b3-cRO"/>
<constraint firstAttribute="trailing" secondItem="rOH-JI-pE1" secondAttribute="trailing" id="Ry1-8z-byA"/>
<constraint firstAttribute="bottom" secondItem="dN5-jZ-SiB" secondAttribute="bottom" id="SQo-t4-jNX"/>
<constraint firstItem="1Zf-X9-xCZ" firstAttribute="centerY" secondItem="9Rv-Fn-yCT" secondAttribute="centerY" id="Ti5-PE-sjK"/>
<constraint firstItem="rOH-JI-pE1" firstAttribute="top" secondItem="9Rv-Fn-yCT" secondAttribute="top" id="ZZd-iV-jqo"/>
<constraint firstAttribute="bottom" secondItem="rOH-JI-pE1" secondAttribute="bottom" id="ZfF-qA-gEg"/>
<constraint firstAttribute="bottom" secondItem="uwg-fz-Lnl" secondAttribute="bottom" id="dGK-ts-Oxc"/>
<constraint firstAttribute="trailing" secondItem="uwg-fz-Lnl" secondAttribute="trailing" id="dkB-IK-EYy"/>
<constraint firstItem="uwg-fz-Lnl" firstAttribute="top" secondItem="9Rv-Fn-yCT" secondAttribute="top" id="izZ-b1-P9h"/>
</constraints>
<connections>
<outlet property="durationLabel" destination="0AD-DJ-hk7" id="fAK-hF-IpB"/>
<outlet property="imageView" destination="rOH-JI-pE1" id="tgu-TV-hTi"/>
<outlet property="indicator" destination="1Zf-X9-xCZ" id="b7n-5J-KNK"/>
<outlet property="orderLabel" destination="JhX-P9-VnM" id="Oev-lS-XRO"/>
</connections>
<point key="canvasLocation" x="32" y="-10"/>
</collectionViewCell>
</objects>
</document>
31 changes: 16 additions & 15 deletions Example/TLPhotoPicker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,19 @@ import Photos

class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

var selectedAssets = [TLPHAsset]()
@IBAction func pickerButtonTap() {
let viewController = TLPhotosPickerViewController(withTLPHAssets: { [weak self] (assets) in
self?.selectedAssets = assets
}, didCancel: nil)
//viewController.delegate = self
let viewController = TLPhotosPickerViewController()
// viewController.delegate = self
viewController.didExceedMaximumNumberOfSelection = { [weak self] (picker) in
self?.showAlert(vc: picker)
}
var configure = TLPhotosPickerConfigure()
configure.numberOfColumn = 3
viewController.selectedAssets = self.selectedAssets
//configure.maxSelectedAssets = 10
configure.nibSet = (nibName: "CustomCell_Instagram", bundle: Bundle.main)
viewController.configure = configure
viewController.selectedAssets = self.selectedAssets
self.present(viewController, animated: true, completion: nil)
}
func dismissPhotoPicker(withTLPHAssets: [TLPHAsset]) {
Expand All @@ -44,5 +37,13 @@ class ViewController: UIViewController,TLPhotosPickerViewControllerDelegate {
func photoPickerDidCancel() {
// cancel
}
func didExceedMaximumNumberOfSelection(picker: TLPhotosPickerViewController) {
self.showAlert(vc: picker)
}
func showAlert(vc: UIViewController) {
let alert = UIAlertController(title: "", message: "Exceed Maximum Number Of Selection", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
vc.present(alert, animated: true, completion: nil)
}
}

Binary file added Images/customcell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3070e65

Please sign in to comment.