Skip to content

Commit

Permalink
Merge pull request MailCore#191 from paulyoung/message-preview-in-exa…
Browse files Browse the repository at this point in the history
…mples

Add message preview to iOS example.
  • Loading branch information
dinhvh committed Jul 17, 2013
2 parents df1f253 + 739398c commit c2f75bf
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 10 deletions.
6 changes: 6 additions & 0 deletions example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
C6D71951178BB8B4008ED15F /* GTMOAuth2ViewControllerTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = C6D71947178BA812008ED15F /* GTMOAuth2ViewControllerTouch.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
C6D71952178BB8B4008ED15F /* GTMOAuth2ViewTouch.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6D71948178BA812008ED15F /* GTMOAuth2ViewTouch.xib */; };
C6D71954178BB91E008ED15F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6D71953178BB91E008ED15F /* SystemConfiguration.framework */; };
DA9AD477179331A600743873 /* MCTTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DA9AD476179331A600743873 /* MCTTableViewCell.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -126,6 +127,8 @@
C6D71947178BA812008ED15F /* GTMOAuth2ViewControllerTouch.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GTMOAuth2ViewControllerTouch.m; sourceTree = "<group>"; };
C6D71948178BA812008ED15F /* GTMOAuth2ViewTouch.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GTMOAuth2ViewTouch.xib; sourceTree = "<group>"; };
C6D71953178BB91E008ED15F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
DA9AD475179331A600743873 /* MCTTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCTTableViewCell.h; sourceTree = "<group>"; };
DA9AD476179331A600743873 /* MCTTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCTTableViewCell.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -222,6 +225,8 @@
AB9EAE3517036FD700D750C7 /* SettingsViewController.xib */,
AB9EAE0C170368F000D750C7 /* Supporting Files */,
AB665BC917134336007F2151 /* common */,
DA9AD475179331A600743873 /* MCTTableViewCell.h */,
DA9AD476179331A600743873 /* MCTTableViewCell.m */,
);
path = "iOS UI Test";
sourceTree = "<group>";
Expand Down Expand Up @@ -408,6 +413,7 @@
C6D7194F178BB8B4008ED15F /* GTMOAuth2Authentication.m in Sources */,
B12AAA3417322654003551C7 /* MCOMessageView.mm in Sources */,
B12AAA3517322654003551C7 /* MCTMsgViewController.mm in Sources */,
DA9AD477179331A600743873 /* MCTTableViewCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
16 changes: 16 additions & 0 deletions example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// MCTTableViewCell.h
// iOS UI Test
//
// Created by Paul Young on 14/07/2013.
// Copyright (c) 2013 AppJon. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MailCore/MailCore.h>

@interface MCTTableViewCell : UITableViewCell

@property (nonatomic, strong) MCOIMAPMessageRenderingOperation * messageRenderingOperation;

@end
25 changes: 25 additions & 0 deletions example/ios/iOS UI Test/iOS UI Test/MCTTableViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// MCTTableViewCell.m
// iOS UI Test
//
// Created by Paul Young on 14/07/2013.
// Copyright (c) 2013 AppJon. All rights reserved.
//

#import "MCTTableViewCell.h"

@implementation MCTTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
return self;
}

- (void)prepareForReuse
{
[self.messageRenderingOperation cancel];
self.detailTextLabel.text = @" ";
}

@end
15 changes: 13 additions & 2 deletions example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "FXKeychain.h"
#import "MCTMsgViewController.h"
#import "GTMOAuth2ViewControllerTouch.h"
#import "MCTTableViewCell.h"

#define CLIENT_ID @"the-client-id"
#define CLIENT_SECRET @"the-client-secret"
Expand Down Expand Up @@ -167,10 +168,20 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

NSString * cellIdentifier = @"Cell";
[tableView registerClass:[MCTTableViewCell class] forCellReuseIdentifier:cellIdentifier];

MCTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
MCOIMAPMessage *message = self.messages[indexPath.row];

cell.textLabel.text = message.header.subject;
cell.messageRenderingOperation = [self.imapSession plainTextBodyRenderingOperationWithMessage:message
folder:@"INBOX"];

[cell.messageRenderingOperation start:^(NSString * plainTextBodyString, NSError * error) {
cell.detailTextLabel.text = plainTextBodyString;
cell.messageRenderingOperation = nil;
}];

return cell;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="4457.6" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" variant="6xAndEarlier" propertyAccessControl="none" useAutolayout="YES" initialViewController="3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="3">
<dependencies>
<deployment defaultVersion="1552" identifier="iOS"/>
<development version="4600" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3682.6"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="11">
<objects>
<navigationController id="3" sceneMemberID="viewController">
<extendedEdge key="edgesForExtendedLayout"/>
<navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="4">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
Expand All @@ -31,20 +30,25 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="phq-AM-6qj" style="IBUITableViewCellStyleDefault" id="lJ0-d7-vTF">
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="phq-AM-6qj" detailTextLabel="uHd-0U-sVX" style="IBUITableViewCellStyleSubtitle" id="lJ0-d7-vTF" customClass="MCTTableViewCell">
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="300" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="phq-AM-6qj">
<rect key="frame" x="10" y="0.0" width="280" height="43"/>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="phq-AM-6qj">
<rect key="frame" x="10" y="2" width="38" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uHd-0U-sVX">
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
Expand All @@ -57,7 +61,6 @@
<outlet property="delegate" destination="12" id="15"/>
</connections>
</tableView>
<extendedEdge key="edgesForExtendedLayout"/>
<navigationItem key="navigationItem" title="Inbox" id="36">
<barButtonItem key="rightBarButtonItem" title="Settings" id="91f-3m-Uww">
<connections>
Expand All @@ -72,6 +75,9 @@
</scene>
</scenes>
<classes>
<class className="MCTTableViewCell" superclassName="UITableViewCell">
<source key="sourceIdentifier" type="project" relativePath="./Classes/MCTTableViewCell.h"/>
</class>
<class className="MasterViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/MasterViewController.h"/>
<relationships>
Expand Down

0 comments on commit c2f75bf

Please sign in to comment.