Remove .xib for home view cells; adapter home view to RTL.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-07-11 17:56:22 -04:00
parent eaacac9d8b
commit 04fb3642b2
8 changed files with 174 additions and 250 deletions

View File

@ -51,7 +51,6 @@
34B3F87C1E8DF1700035BE1A /* FingerprintViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8461E8DF1700035BE1A /* FingerprintViewController.m */; };
34B3F87D1E8DF1700035BE1A /* FullImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8481E8DF1700035BE1A /* FullImageViewController.m */; };
34B3F87E1E8DF1700035BE1A /* InboxTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */; };
34B3F87F1E8DF1700035BE1A /* InboxTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34B3F84B1E8DF1700035BE1A /* InboxTableViewCell.xib */; };
34B3F8801E8DF1700035BE1A /* InviteFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */; };
34B3F8811E8DF1700035BE1A /* LockInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84E1E8DF1700035BE1A /* LockInteractionController.m */; };
34B3F8821E8DF1700035BE1A /* MessageComposeTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8501E8DF1700035BE1A /* MessageComposeTableViewController.m */; };
@ -451,7 +450,6 @@
34B3F8481E8DF1700035BE1A /* FullImageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FullImageViewController.m; sourceTree = "<group>"; };
34B3F8491E8DF1700035BE1A /* InboxTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InboxTableViewCell.h; sourceTree = "<group>"; };
34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InboxTableViewCell.m; sourceTree = "<group>"; };
34B3F84B1E8DF1700035BE1A /* InboxTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InboxTableViewCell.xib; sourceTree = "<group>"; };
34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InviteFlow.swift; sourceTree = "<group>"; };
34B3F84D1E8DF1700035BE1A /* LockInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LockInteractionController.h; sourceTree = "<group>"; };
34B3F84E1E8DF1700035BE1A /* LockInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LockInteractionController.m; sourceTree = "<group>"; };
@ -966,7 +964,6 @@
34D5CCA81EAE3D30005515DB /* GroupViewHelper.m */,
34B3F8491E8DF1700035BE1A /* InboxTableViewCell.h */,
34B3F84A1E8DF1700035BE1A /* InboxTableViewCell.m */,
34B3F84B1E8DF1700035BE1A /* InboxTableViewCell.xib */,
34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */,
34B3F84D1E8DF1700035BE1A /* LockInteractionController.h */,
34B3F84E1E8DF1700035BE1A /* LockInteractionController.m */,
@ -1909,7 +1906,6 @@
AD83FF401A73426500B5C81A /* audio_pause_button_blue@2x.png in Resources */,
B66DBF4A19D5BBC8006EA940 /* Images.xcassets in Resources */,
70B8FEE21909FE360042E3F0 /* 171756__nenadsimic__picked-coin-echo-2.wav in Resources */,
34B3F87F1E8DF1700035BE1A /* InboxTableViewCell.xib in Resources */,
4517642A1DE939FD00EDB8B9 /* ContactCell.xib in Resources */,
AD83FF431A73426500B5C81A /* audio_play_button@2x.png in Resources */,
45CB2FA81CB7146C00E1B343 /* Launch Screen.storyboard in Resources */,

View File

@ -85,6 +85,10 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value);
+ (UIView *)containerView;
- (void)setHLayoutMargins:(CGFloat)value;
#pragma mark - Formatting
+ (NSString *)formatInt:(int)value;
#pragma mark - Debugging
- (void)addBorderWithColor:(UIColor *)color;

View File

@ -257,7 +257,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
{
OWSAssert(view);
NSLayoutConstraint *constraint = [self autoPinLeadingToTrailingOfView:view margin:0];
return [self autoPinLeadingToTrailingOfView:view margin:0];
}
- (NSLayoutConstraint *)autoPinLeadingToTrailingOfView:(UIView *)view margin:(CGFloat)margin
@ -325,6 +325,19 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
self.layoutMargins = layoutMargins;
}
#pragma mark - Formatting
+ (NSString *)formatInt:(int)value
{
static NSNumberFormatter *formatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
formatter = [NSNumberFormatter new];
formatter.numberStyle = NSNumberFormatterNoStyle;
});
return [formatter stringFromNumber:@(value)];
}
#pragma mark - Debugging
- (void)addBorderWithColor:(UIColor *)color

View File

@ -2,35 +2,21 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSThread.h"
NS_ASSUME_NONNULL_BEGIN
@class Contact;
@class TSThread;
@class OWSContactsManager;
@class AvatarImageView;
@interface InboxTableViewCell : UITableViewCell <UIScrollViewDelegate>
@property (nonatomic) IBOutlet UILabel *nameLabel;
@property (nonatomic) IBOutlet UILabel *snippetLabel;
@property (nonatomic) IBOutlet AvatarImageView *contactPictureView;
@property (nonatomic) IBOutlet UILabel *timeLabel;
@property (nonatomic) IBOutlet UIView *contentContainerView;
@property (nonatomic) IBOutlet UIView *messageCounter;
@property (nonatomic) NSString *threadId;
@property (nonatomic) NSString *contactId;
+ (instancetype)inboxTableViewCell;
@interface InboxTableViewCell : UITableViewCell
+ (CGFloat)rowHeight;
+ (NSString *)cellReuseIdentifier;
- (void)configureWithThread:(TSThread *)thread
contactsManager:(OWSContactsManager *)contactsManager
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet;
- (void)animateDisappear;
@end
NS_ASSUME_NONNULL_END

View File

@ -3,18 +3,13 @@
//
#import "InboxTableViewCell.h"
#import "Environment.h"
#import "OWSAvatarBuilder.h"
#import "OWSContactAvatarBuilder.h"
#import "PropertyListPreferences.h"
#import "Signal-Swift.h"
#import "TSContactThread.h"
#import "TSGroupThread.h"
#import "TSMessagesManager.h"
#import "Util.h"
#import <JSQMessagesViewController/JSQMessagesAvatarImageFactory.h>
#import <JSQMessagesViewController/UIImage+JSQMessages.h>
#import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/TSContactThread.h>
#import <SignalServiceKit/TSGroupThread.h>
#import <SignalServiceKit/TSMessagesManager.h>
#import <SignalServiceKit/TSThread.h>
NS_ASSUME_NONNULL_BEGIN
@ -24,26 +19,113 @@ NS_ASSUME_NONNULL_BEGIN
#define DATE_LABEL_SIZE 13
#define SWIPE_ARCHIVE_OFFSET -50
const NSUInteger kContactPictureViewDiameter = 52;
const NSUInteger kavatarViewDiameter = 52;
@interface InboxTableViewCell ()
@property (nonatomic) NSUInteger unreadMessages;
@property (nonatomic) UIView *messagesBadge;
@property (nonatomic) AvatarImageView *avatarView;
@property (nonatomic) UILabel *nameLabel;
@property (nonatomic) UILabel *snippetLabel;
@property (nonatomic) UILabel *timeLabel;
@property (nonatomic) UIView *unreadBadge;
@property (nonatomic) UILabel *unreadLabel;
@property (nonatomic) NSString *threadId;
@end
#pragma mark -
@implementation InboxTableViewCell
+ (instancetype)inboxTableViewCell {
InboxTableViewCell *cell =
[NSBundle.mainBundle loadNibNamed:NSStringFromClass(self.class) owner:self options:nil][0];
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self commontInit];
}
return self;
}
[cell initializeLayout];
return cell;
// `[UIView init]` invokes `[self initWithFrame:...]`.
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self commontInit];
}
return self;
}
- (void)commontInit
{
OWSAssert(!self.avatarView);
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
self.preservesSuperviewLayoutMargins = YES;
self.contentView.preservesSuperviewLayoutMargins = YES;
self.backgroundColor = [UIColor whiteColor];
self.avatarView = [[AvatarImageView alloc] init];
[self.contentView addSubview:self.avatarView];
[self.avatarView autoSetDimension:ALDimensionWidth toSize:52.f];
[self.avatarView autoSetDimension:ALDimensionHeight toSize:52.f];
[self.avatarView autoPinLeadingToSuperView];
[self.avatarView autoVCenterInSuperview];
self.nameLabel = [UILabel new];
self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[self.contentView addSubview:self.nameLabel];
[self.nameLabel autoPinLeadingToTrailingOfView:self.avatarView margin:13.f];
[self.nameLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.avatarView];
[self.nameLabel setContentHuggingHorizontalLow];
self.snippetLabel = [UILabel new];
self.snippetLabel.font = [UIFont ows_regularFontWithSize:14.f];
self.snippetLabel.lineBreakMode = NSLineBreakByTruncatingTail;
self.snippetLabel.textColor = [UIColor colorWithWhite:2 / 3.f alpha:1.f];
self.snippetLabel.numberOfLines = 2;
self.snippetLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[self.contentView addSubview:self.snippetLabel];
[self.snippetLabel autoPinLeadingToTrailingOfView:self.avatarView margin:13.f];
[self.snippetLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.nameLabel withOffset:5.f];
[self.snippetLabel autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:self.nameLabel];
[self.snippetLabel setContentHuggingHorizontalLow];
self.timeLabel = [UILabel new];
self.timeLabel.font = [UIFont ows_lightFontWithSize:14.f];
[self.contentView addSubview:self.timeLabel];
[self.timeLabel autoPinTrailingToSuperView];
[self.timeLabel autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.nameLabel];
[self.timeLabel autoPinLeadingToTrailingOfView:self.nameLabel margin:10.f];
[self.timeLabel setContentHuggingHorizontalHigh];
[self.timeLabel setCompressionResistanceHigh];
const int kunreadBadgeSize = 24;
self.unreadBadge = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kunreadBadgeSize, kunreadBadgeSize)];
self.unreadBadge.layer.cornerRadius = kunreadBadgeSize / 2;
self.unreadBadge.backgroundColor = [UIColor ows_materialBlueColor];
[self.contentView addSubview:self.unreadBadge];
[self.unreadBadge autoSetDimension:ALDimensionWidth toSize:kunreadBadgeSize];
[self.unreadBadge autoSetDimension:ALDimensionHeight toSize:kunreadBadgeSize];
[self.unreadBadge autoPinTrailingToSuperView];
[self.unreadBadge autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.avatarView];
[self.unreadBadge setContentHuggingHorizontalHigh];
[self.unreadBadge setCompressionResistanceHigh];
self.unreadLabel = [UILabel new];
self.unreadLabel.font = [UIFont ows_regularFontWithSize:12.f];
self.unreadLabel.textColor = [UIColor whiteColor];
self.unreadLabel.lineBreakMode = NSLineBreakByTruncatingTail;
self.unreadLabel.textAlignment = NSTextAlignmentCenter;
[self.unreadBadge addSubview:self.unreadLabel];
[self.unreadLabel autoVCenterInSuperview];
[self.unreadLabel autoPinWidthToSuperview];
}
+ (NSString *)cellReuseIdentifier
{
return NSStringFromClass([self class]);
}
+ (CGFloat)rowHeight
@ -121,31 +203,36 @@ const NSUInteger kContactPictureViewDiameter = 52;
self.nameLabel.text = name;
self.snippetLabel.attributedText = snippetText;
self.timeLabel.attributedText = attributedDate;
self.contactPictureView.image = nil;
self.avatarView.image = nil;
self.separatorInset = UIEdgeInsetsMake(0, _contactPictureView.frame.size.width * 1.5f, 0, 0);
self.separatorInset = UIEdgeInsetsMake(0, _avatarView.frame.size.width * 1.5f, 0, 0);
if (thread.hasUnreadMessages) {
[self updateCellForUnreadMessage];
} else {
[self updateCellForReadMessage];
}
[self setUnreadMsgCount:unreadCount];
if (unreadCount > 0) {
self.unreadBadge.hidden = NO;
self.unreadLabel.hidden = NO;
self.unreadLabel.text = [UIView formatInt:MIN(99, (int)unreadCount)];
} else {
self.unreadBadge.hidden = YES;
self.unreadLabel.hidden = YES;
}
NSString *threadIdCopy = thread.uniqueId;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage *avatar = [OWSAvatarBuilder buildImageForThread:thread
contactsManager:contactsManager
diameter:kContactPictureViewDiameter];
UIImage *avatar =
[OWSAvatarBuilder buildImageForThread:thread contactsManager:contactsManager diameter:kavatarViewDiameter];
dispatch_async(dispatch_get_main_queue(), ^{
if ([_threadId isEqualToString:threadIdCopy]) {
self.contactPictureView.image = avatar;
self.avatarView.image = avatar;
}
});
});
}
- (void)updateCellForUnreadMessage {
_nameLabel.font = [UIFont ows_boldFontWithSize:14.0f];
_nameLabel.textColor = [UIColor ows_blackColor];
@ -184,68 +271,11 @@ const NSUInteger kContactPictureViewDiameter = 52;
return attributedString;
}
- (void)setUnreadMsgCount:(NSUInteger)unreadMessages {
if (_unreadMessages != unreadMessages) {
_unreadMessages = unreadMessages;
if (_unreadMessages > 0) {
if (_messagesBadge == nil) {
static UIImage *backgroundImage = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(25.0f, 25.0f), false, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor ows_materialBlueColor].CGColor);
CGContextFillEllipseInRect(context, CGRectMake(0.0f, 0.0f, 25.0f, 25.0f));
backgroundImage =
[UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:8 topCapHeight:8];
UIGraphicsEndImageContext();
});
_messagesBadge = [[UIImageView alloc]
initWithFrame:CGRectMake(
0.0f, 0.0f, _messageCounter.frame.size.height, _messageCounter.frame.size.width)];
_messagesBadge.userInteractionEnabled = NO;
_messagesBadge.layer.zPosition = 2000;
UIImageView *unreadBackground = [[UIImageView alloc] initWithImage:backgroundImage];
[_messageCounter addSubview:unreadBackground];
_unreadLabel = [[UILabel alloc] init];
_unreadLabel.backgroundColor = [UIColor clearColor];
_unreadLabel.textColor = [UIColor whiteColor];
_unreadLabel.font = [UIFont systemFontOfSize:12];
[_messageCounter addSubview:_unreadLabel];
}
// Max out the unread count at 99+.
const NSUInteger kMaxUnreadCount = 99;
_unreadLabel.text = [@(MIN(kMaxUnreadCount, unreadMessages)) stringValue];
[_unreadLabel sizeToFit];
CGPoint offset = CGPointMake(0.0f, 5.0f);
_unreadLabel.frame
= CGRectMake(offset.x + (CGFloat)floor((2.0f * (25.0f - _unreadLabel.frame.size.width) / 2.0f) / 2.0f),
offset.y,
_unreadLabel.frame.size.width,
_unreadLabel.frame.size.height);
_messageCounter.hidden = NO;
} else {
_messageCounter.hidden = YES;
}
}
- (void)prepareForReuse
{
[super prepareForReuse];
}
#pragma mark - Animation
- (void)animateDisappear {
[UIView animateWithDuration:1.0f
animations:^() {
self.alpha = 0;
}];
}
@end
NS_ASSUME_NONNULL_END

View File

@ -1,108 +0,0 @@
<?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" 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"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="InboxTableViewCell" rowHeight="72" id="axX-Rb-kiK" customClass="InboxTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="400" height="72"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" multipleTouchEnabled="YES" contentMode="center" tableViewCell="axX-Rb-kiK" id="BRG-hJ-lRa">
<rect key="frame" x="0.0" y="0.0" width="400" height="71.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kq8-RD-txC" userLabel="Container View">
<rect key="frame" x="0.0" y="0.0" width="400" height="47"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="p9o-x6-nT5" customClass="AvatarImageView" customModule="Signal" customModuleProvider="target">
<rect key="frame" x="10" y="10" width="52" height="52"/>
<constraints>
<constraint firstAttribute="width" secondItem="p9o-x6-nT5" secondAttribute="height" multiplier="1:1" id="IjZ-Ac-GiV"/>
<constraint firstAttribute="width" constant="52" id="mb7-1o-58k"/>
</constraints>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" enabled="NO" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bp6-EC-9eP">
<rect key="frame" x="383" y="10" width="0.0" height="17"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="kgo-Kw-ZP3"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="14"/>
<color key="textColor" red="0.13725490200000001" green="0.1215686275" blue="0.12549019610000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" enabled="NO" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qgj-EY-BWC">
<rect key="frame" x="75" y="29" width="236" height="33"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="14"/>
<color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="KNJ-HQ-UVM" userLabel="New Messages Tag">
<rect key="frame" x="353" y="35" width="27" height="27"/>
<color key="backgroundColor" red="0.22317156195640564" green="0.71476894617080688" blue="0.19350609183311462" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="27" id="S3w-sZ-O53"/>
<constraint firstAttribute="width" secondItem="KNJ-HQ-UVM" secondAttribute="height" multiplier="1:1" id="pRB-Zk-iwR"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mfN-2A-QxN">
<rect key="frame" x="75" y="6" width="236" height="0.0"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="KNJ-HQ-UVM" firstAttribute="top" secondItem="kq8-RD-txC" secondAttribute="top" constant="35" id="1fE-Dr-blB"/>
<constraint firstItem="Qgj-EY-BWC" firstAttribute="bottom" secondItem="KNJ-HQ-UVM" secondAttribute="bottom" id="AKd-U0-qM0"/>
<constraint firstItem="p9o-x6-nT5" firstAttribute="leading" secondItem="kq8-RD-txC" secondAttribute="leading" constant="10" id="EXY-ll-Ulo"/>
<constraint firstAttribute="trailing" secondItem="KNJ-HQ-UVM" secondAttribute="trailing" constant="20" id="MME-Mn-YIq"/>
<constraint firstAttribute="trailing" secondItem="mfN-2A-QxN" secondAttribute="trailing" constant="89" id="S4b-7i-rpp"/>
<constraint firstAttribute="bottom" secondItem="mfN-2A-QxN" secondAttribute="bottom" constant="41" id="TTx-u5-eDX"/>
<constraint firstItem="KNJ-HQ-UVM" firstAttribute="top" secondItem="bp6-EC-9eP" secondAttribute="bottom" constant="8" id="Xxt-Pd-bUm"/>
<constraint firstItem="p9o-x6-nT5" firstAttribute="centerY" secondItem="kq8-RD-txC" secondAttribute="centerY" id="Yk2-fP-LXc"/>
<constraint firstItem="Qgj-EY-BWC" firstAttribute="trailing" secondItem="mfN-2A-QxN" secondAttribute="trailing" id="fPa-M6-Cjl"/>
<constraint firstItem="mfN-2A-QxN" firstAttribute="top" secondItem="kq8-RD-txC" secondAttribute="top" constant="6" id="ic3-WA-xFo"/>
<constraint firstItem="Qgj-EY-BWC" firstAttribute="top" secondItem="kq8-RD-txC" secondAttribute="top" constant="29" id="jHb-Ij-oxU"/>
<constraint firstItem="Qgj-EY-BWC" firstAttribute="leading" secondItem="mfN-2A-QxN" secondAttribute="leading" id="kuk-P5-Tgp"/>
<constraint firstItem="bp6-EC-9eP" firstAttribute="top" secondItem="p9o-x6-nT5" secondAttribute="top" id="oNW-MD-rmQ"/>
<constraint firstItem="mfN-2A-QxN" firstAttribute="leading" secondItem="p9o-x6-nT5" secondAttribute="trailing" constant="13" id="prC-xO-Y0J"/>
<constraint firstAttribute="trailing" secondItem="bp6-EC-9eP" secondAttribute="trailing" constant="17" id="vMu-Lr-eTJ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="kq8-RD-txC" firstAttribute="centerX" secondItem="BRG-hJ-lRa" secondAttribute="centerX" id="7r4-bD-FQ6"/>
<constraint firstItem="kq8-RD-txC" firstAttribute="height" secondItem="BRG-hJ-lRa" secondAttribute="height" id="ZfP-IE-NYS"/>
<constraint firstItem="kq8-RD-txC" firstAttribute="centerY" secondItem="BRG-hJ-lRa" secondAttribute="centerY" id="em2-Xt-SpY"/>
<constraint firstItem="kq8-RD-txC" firstAttribute="width" secondItem="BRG-hJ-lRa" secondAttribute="width" id="pNl-2B-oKE"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="contactPictureView" destination="p9o-x6-nT5" id="oUA-O3-JIc"/>
<outlet property="contentContainerView" destination="kq8-RD-txC" id="yaJ-z3-8sC"/>
<outlet property="messageCounter" destination="KNJ-HQ-UVM" id="Ysu-EC-k1P"/>
<outlet property="nameLabel" destination="mfN-2A-QxN" id="Jr0-05-R1t"/>
<outlet property="snippetLabel" destination="Qgj-EY-BWC" id="EIb-je-Cw5"/>
<outlet property="timeLabel" destination="bp6-EC-9eP" id="O4O-ST-o3v"/>
</connections>
<point key="canvasLocation" x="253" y="340"/>
</tableViewCell>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>

View File

@ -223,8 +223,8 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
callingCode = [localNumber getCountryCode];
OWSAssert(callingCode);
if (callingCode) {
countryCode = [[PhoneNumberUtil sharedUtil]
probableCountryCodeForCallingCode:[@"+" stringByAppendingString:[callingCode description]]];
NSString *prefix = [NSString stringWithFormat:@"+%d", callingCode.intValue];
countryCode = [[PhoneNumberUtil sharedUtil] probableCountryCodeForCallingCode:prefix];
}
}

View File

@ -201,6 +201,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView registerClass:[InboxTableViewCell class]
forCellReuseIdentifier:InboxTableViewCell.cellReuseIdentifier];
[self.view addSubview:self.tableView];
[self.tableView autoPinWidthToSuperview];
[self.tableView autoPinToBottomLayoutGuideOfViewController:self withInset:0];
@ -270,34 +272,37 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
- (void)updateBarButtonItems {
const CGFloat kBarButtonSize = 44;
if (YES) {
// We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of
// UIBarButtonItem in order to ensure that these buttons are spaced tightly.
// The contents of the navigation bar are cramped in this view.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"button_settings_white"];
[button setImage:image
forState:UIControlStateNormal];
UIEdgeInsets imageEdgeInsets = UIEdgeInsetsZero;
// We normally would want to use left and right insets that ensure the button
// is square and the icon is centered. However UINavigationBar doesn't offer us
// control over the margins and spacing of its content, and the buttons end up
// too far apart and too far from the edge of the screen. So we use a smaller
// left inset tighten up the layout.
imageEdgeInsets.right = round((kBarButtonSize - image.size.width) * 0.5f);
imageEdgeInsets.left = round((kBarButtonSize - (image.size.width + imageEdgeInsets.right)) * 0.5f);
imageEdgeInsets.top = round((kBarButtonSize - image.size.height) * 0.5f);
imageEdgeInsets.bottom = round(kBarButtonSize - (image.size.height + imageEdgeInsets.top));
button.imageEdgeInsets = imageEdgeInsets;
button.accessibilityLabel = NSLocalizedString(@"OPEN_SETTINGS_BUTTON", "Label for button which opens the settings UI");
[button addTarget:self
action:@selector(settingsButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0, 0,
round(image.size.width + imageEdgeInsets.left + imageEdgeInsets.right),
round(image.size.height + imageEdgeInsets.top + imageEdgeInsets.bottom));
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
// We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of
// UIBarButtonItem in order to ensure that these buttons are spaced tightly.
// The contents of the navigation bar are cramped in this view.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"button_settings_white"];
[button setImage:image forState:UIControlStateNormal];
UIEdgeInsets imageEdgeInsets = UIEdgeInsetsZero;
// We normally would want to use left and right insets that ensure the button
// is square and the icon is centered. However UINavigationBar doesn't offer us
// control over the margins and spacing of its content, and the buttons end up
// too far apart and too far from the edge of the screen. So we use a smaller
// leading inset tighten up the layout.
CGFloat hInset = round((kBarButtonSize - image.size.width) * 0.5f);
if (self.view.isRTL) {
imageEdgeInsets.right = hInset;
imageEdgeInsets.left = round((kBarButtonSize - (image.size.width + hInset)) * 0.5f);
} else {
imageEdgeInsets.left = hInset;
imageEdgeInsets.right = round((kBarButtonSize - (image.size.width + hInset)) * 0.5f);
}
imageEdgeInsets.top = round((kBarButtonSize - image.size.height) * 0.5f);
imageEdgeInsets.bottom = round(kBarButtonSize - (image.size.height + imageEdgeInsets.top));
button.imageEdgeInsets = imageEdgeInsets;
button.accessibilityLabel
= NSLocalizedString(@"OPEN_SETTINGS_BUTTON", "Label for button which opens the settings UI");
[button addTarget:self action:@selector(settingsButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(0,
0,
round(image.size.width + imageEdgeInsets.left + imageEdgeInsets.right),
round(image.size.height + imageEdgeInsets.top + imageEdgeInsets.bottom));
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
}
- (void)settingsButtonPressed:(id)sender {
@ -559,12 +564,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
InboxTableViewCell *cell =
[self.tableView dequeueReusableCellWithIdentifier:NSStringFromClass([InboxTableViewCell class])];
TSThread *thread = [self threadForIndexPath:indexPath];
[self.tableView dequeueReusableCellWithIdentifier:InboxTableViewCell.cellReuseIdentifier];
OWSAssert(cell);
if (!cell) {
cell = [InboxTableViewCell inboxTableViewCell];
}
TSThread *thread = [self threadForIndexPath:indexPath];
[cell configureWithThread:thread contactsManager:self.contactsManager blockedPhoneNumberSet:_blockedPhoneNumberSet];