MediaPicker: use the new MXKMediaCollectionViewCell class.

This commit is contained in:
giomfo 2015-10-22 17:22:10 +02:00
parent c698072630
commit 4fdf0394f8
6 changed files with 32 additions and 183 deletions

View file

@ -23,8 +23,6 @@
F00B1BD01B95D22E001806E3 /* camera_switch.png in Resources */ = {isa = PBXBuildFile; fileRef = F00B1BCE1B95D22E001806E3 /* camera_switch.png */; };
F00B1BD31B95D478001806E3 /* camera_picture.png in Resources */ = {isa = PBXBuildFile; fileRef = F00B1BD11B95D478001806E3 /* camera_picture.png */; };
F00B1BD41B95D478001806E3 /* camera_video.png in Resources */ = {isa = PBXBuildFile; fileRef = F00B1BD21B95D478001806E3 /* camera_video.png */; };
F00B1BD81B96E5DD001806E3 /* MediaAssetCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F00B1BD71B96E5DD001806E3 /* MediaAssetCollectionViewCell.m */; };
F00B1BDA1B96EAF3001806E3 /* MediaAssetCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F00B1BD91B96EAF3001806E3 /* MediaAssetCollectionViewCell.xib */; };
F00B1BDC1B96EF09001806E3 /* selection_tick.png in Resources */ = {isa = PBXBuildFile; fileRef = F00B1BDB1B96EF09001806E3 /* selection_tick.png */; };
F00E08401B8380CF0057012C /* settings.png in Resources */ = {isa = PBXBuildFile; fileRef = F00E083E1B8380CF0057012C /* settings.png */; };
F00E08411B8380CF0057012C /* settings@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F00E083F1B8380CF0057012C /* settings@2x.png */; };
@ -123,9 +121,6 @@
F00B1BCE1B95D22E001806E3 /* camera_switch.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = camera_switch.png; sourceTree = "<group>"; };
F00B1BD11B95D478001806E3 /* camera_picture.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = camera_picture.png; sourceTree = "<group>"; };
F00B1BD21B95D478001806E3 /* camera_video.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = camera_video.png; sourceTree = "<group>"; };
F00B1BD61B96E5DD001806E3 /* MediaAssetCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaAssetCollectionViewCell.h; sourceTree = "<group>"; };
F00B1BD71B96E5DD001806E3 /* MediaAssetCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaAssetCollectionViewCell.m; sourceTree = "<group>"; };
F00B1BD91B96EAF3001806E3 /* MediaAssetCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MediaAssetCollectionViewCell.xib; sourceTree = "<group>"; };
F00B1BDB1B96EF09001806E3 /* selection_tick.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = selection_tick.png; sourceTree = "<group>"; };
F00E083E1B8380CF0057012C /* settings.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = settings.png; sourceTree = "<group>"; };
F00E083F1B8380CF0057012C /* settings@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "settings@2x.png"; sourceTree = "<group>"; };
@ -250,7 +245,6 @@
isa = PBXGroup;
children = (
F084DAAA1BB57BD100B4C530 /* Authentication */,
F00B1BD51B96E5DD001806E3 /* CollectionViewCell */,
F001D7531B8207C000A162C3 /* RoomBubbleList */,
F001D75A1B8207C000A162C3 /* RoomInputToolbar */,
);
@ -280,16 +274,6 @@
path = RoomInputToolbar;
sourceTree = "<group>";
};
F00B1BD51B96E5DD001806E3 /* CollectionViewCell */ = {
isa = PBXGroup;
children = (
F00B1BD61B96E5DD001806E3 /* MediaAssetCollectionViewCell.h */,
F00B1BD71B96E5DD001806E3 /* MediaAssetCollectionViewCell.m */,
F00B1BD91B96EAF3001806E3 /* MediaAssetCollectionViewCell.xib */,
);
path = CollectionViewCell;
sourceTree = "<group>";
};
F084DAAA1BB57BD100B4C530 /* Authentication */ = {
isa = PBXGroup;
children = (
@ -515,6 +499,7 @@
F094A99F1B78D8F000B1FBBF /* Frameworks */,
F094A9A01B78D8F000B1FBBF /* Resources */,
44C35695CFA4F9799C449367 /* Copy Pods Resources */,
CE74DDBF8318D6A2441D715E /* Embed Pods Frameworks */,
);
buildRules = (
);
@ -620,7 +605,6 @@
F00B1BCA1B95CC68001806E3 /* camera_capture.png in Resources */,
F094A9B41B78D8F000B1FBBF /* Main.storyboard in Resources */,
F0316E471B7E4C9A00F03620 /* placeholder.png in Resources */,
F00B1BDA1B96EAF3001806E3 /* MediaAssetCollectionViewCell.xib in Resources */,
F0DD7D601B7AA8C900C4BE02 /* hide.png in Resources */,
F0DD7D741B7AA8C900C4BE02 /* typing.png in Resources */,
F00B1BD31B95D478001806E3 /* camera_picture.png in Resources */,
@ -682,6 +666,21 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
CE74DDBF8318D6A2441D715E /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Vector/Pods-Vector-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -697,7 +696,6 @@
F001D76C1B821E4F00A162C3 /* MediaPickerViewController.m in Sources */,
F084DAAE1BB57BD100B4C530 /* AuthInputsEmailIdentityBasedView.m in Sources */,
F001D75E1B8207C000A162C3 /* RoomIncomingBubbleTableViewCell.m in Sources */,
F00B1BD81B96E5DD001806E3 /* MediaAssetCollectionViewCell.m in Sources */,
F094AA321B78E42600B1FBBF /* GlobalNotificationSettingsViewController.m in Sources */,
F094A9A81B78D8F000B1FBBF /* main.m in Sources */,
F0DD7D881B7B507100C4BE02 /* RoomCreationStep2ViewController.m in Sources */,

View file

@ -16,8 +16,6 @@
#import "MediaPickerViewController.h"
#import "MediaAssetCollectionViewCell.h"
#import <Photos/Photos.h>
#import <MediaPlayer/MediaPlayer.h>
@ -96,7 +94,7 @@ NSString* const recentItemCollectionViewCellId = @"recentItemCollectionViewCellI
currentSelectedAsset = -1;
// Register collection view cell class
[self.recentPicturesCollectionView registerClass:MediaAssetCollectionViewCell.class forCellWithReuseIdentifier:recentItemCollectionViewCellId];
[self.recentPicturesCollectionView registerClass:MXKMediaCollectionViewCell.class forCellWithReuseIdentifier:recentItemCollectionViewCellId];
// Adjust layout according to screen size
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
@ -1126,7 +1124,7 @@ NSString* const recentItemCollectionViewCellId = @"recentItemCollectionViewCellI
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MediaAssetCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:recentItemCollectionViewCellId forIndexPath:indexPath];
MXKMediaCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:recentItemCollectionViewCellId forIndexPath:indexPath];
if (indexPath.row < assetsFetchResult.count)
{
@ -1140,12 +1138,17 @@ NSString* const recentItemCollectionViewCellId = @"recentItemCollectionViewCellI
PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.synchronous = YES;
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:cellSize contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage *result, NSDictionary *info) {
cell.imageView.image = result;
cell.mxkImageView.image = result;
}];
cell.selectionImageView.hidden = ![selectedAssets[indexPath.row] boolValue];
cell.bottomLeftIcon.image = [UIImage imageNamed:@"selection_tick"];
cell.bottomLeftIcon.hidden = ![selectedAssets[indexPath.row] boolValue];
cell.videoIconImageView.hidden = (asset.mediaType == PHAssetMediaTypeImage);
cell.topRightIcon.image = [UIImage imageNamed:@"icon_video"];
cell.topRightIcon.hidden = (asset.mediaType == PHAssetMediaTypeImage);
// Disable user interaction in mxkImageView, in order to let collection handle user selection
cell.mxkImageView.userInteractionEnabled = NO;
}
return cell;

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
@ -112,7 +112,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uSU-qr-XnK" userLabel="Retake Button">
<rect key="frame" x="125" y="364" width="51" height="32"/>
<rect key="frame" x="126" y="364" width="50" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="Retake">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@ -123,7 +123,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PkX-yh-JhO" userLabel="Choose Button">
<rect key="frame" x="422" y="364" width="57" height="32"/>
<rect key="frame" x="422" y="364" width="56" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="Choose">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@ -188,7 +188,7 @@
</connections>
</collectionView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Iem-Jz-DfR" userLabel="Library Button">
<rect key="frame" x="125" y="186" width="50" height="32"/>
<rect key="frame" x="125" y="186" width="51" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="Library">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@ -199,7 +199,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ioK-2h-a8C" userLabel="Choose Button">
<rect key="frame" x="422" y="186" width="57" height="32"/>
<rect key="frame" x="422" y="186" width="56" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="Choose">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>

View file

@ -1,41 +0,0 @@
/*
Copyright 2015 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import <UIKit/UIKit.h>
/**
'MediaAssetCollectionViewCell' class is used to display assets from user's photo library.
*/
@interface MediaAssetCollectionViewCell : UICollectionViewCell
/**
Returns the `UINib` object initialized for the cell.
@return The initialized `UINib` object or `nil` if there were errors during
initialization or the nib file could not be located.
*/
+ (UINib *)nib;
/**
The default reuseIdentifier of the 'MediaAssetCollectionViewCell' class.
*/
+ (NSString*)defaultReuseIdentifier;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIImageView *selectionImageView;
@property (weak, nonatomic) IBOutlet UIImageView *videoIconImageView;
@end

View file

@ -1,57 +0,0 @@
/*
Copyright 2015 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#import "MediaAssetCollectionViewCell.h"
@implementation MediaAssetCollectionViewCell
+ (UINib *)nib
{
// Check whether a nib file is available
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *path = [mainBundle pathForResource:NSStringFromClass([self class]) ofType:@"nib"];
if (path)
{
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil];
}
return nil;
}
+ (NSString*)defaultReuseIdentifier
{
return NSStringFromClass([self class]);
}
- (instancetype)initWithFrame:(CGRect)frame
{
// Check whether a xib is defined
if ([[self class] nib])
{
self = [[[self class] nib] instantiateWithOwner:nil options:nil].firstObject;
self.frame = frame;
}
else
{
self = [super initWithFrame:frame];
}
return self;
}
@end

View file

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</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" id="eCk-zY-LXq" customClass="MediaAssetCollectionViewCell">
<rect key="frame" x="0.0" y="0.0" width="60" height="80"/>
<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="60" height="80"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="N3d-C1-PMc">
<rect key="frame" x="0.0" y="0.0" width="60" height="80"/>
</imageView>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="selection_tick.png" translatesAutoresizingMaskIntoConstraints="NO" id="YB6-Jv-WMr" userLabel="Selection Image View">
<rect key="frame" x="0.0" y="55" width="25" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="25" id="fDo-LF-4CI"/>
<constraint firstAttribute="height" constant="25" id="yQL-WA-w9j"/>
</constraints>
</imageView>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_video.png" translatesAutoresizingMaskIntoConstraints="NO" id="S1K-Sj-lhV" userLabel="video icon">
<rect key="frame" x="23" y="0.0" width="37" height="25"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<constraints>
<constraint firstItem="YB6-Jv-WMr" firstAttribute="leading" secondItem="eCk-zY-LXq" secondAttribute="leading" id="43S-Eh-tnF"/>
<constraint firstItem="N3d-C1-PMc" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" id="9AB-A9-pwf"/>
<constraint firstAttribute="bottom" secondItem="YB6-Jv-WMr" secondAttribute="bottom" id="RTC-59-huH"/>
<constraint firstAttribute="trailing" secondItem="S1K-Sj-lhV" secondAttribute="trailing" id="XfO-xa-DlO"/>
<constraint firstItem="S1K-Sj-lhV" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" id="neN-7y-A6j"/>
<constraint firstItem="N3d-C1-PMc" firstAttribute="leading" secondItem="eCk-zY-LXq" secondAttribute="leading" id="rVE-KB-Bz9"/>
<constraint firstAttribute="bottom" secondItem="N3d-C1-PMc" secondAttribute="bottom" id="sGG-Tg-p9M"/>
<constraint firstAttribute="trailing" secondItem="N3d-C1-PMc" secondAttribute="trailing" id="u8Y-ib-8Ih"/>
</constraints>
<connections>
<outlet property="imageView" destination="N3d-C1-PMc" id="QEf-jc-amr"/>
<outlet property="selectionImageView" destination="YB6-Jv-WMr" id="4lH-AL-CLq"/>
<outlet property="videoIconImageView" destination="S1K-Sj-lhV" id="eIT-IA-DmE"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="icon_video.png" width="37" height="25"/>
<image name="selection_tick.png" width="31" height="31"/>
</resources>
</document>