contact details: make view scrollable for small screens

This commit is contained in:
Gautier Pelloux-Prayer 2016-04-11 14:55:27 +02:00
parent 414939c13a
commit 2b863caa20
5 changed files with 41 additions and 19 deletions

View file

@ -24,6 +24,7 @@ Group changes to describe their impact on the project, as follows:
- Parse user input as SIP address or phone number depending on default account settings: if "substitute + by country code" is set,
consider inputs to be phone numbers, otherwise SIP addresses.
- Automatically start call when answering from within notification in iOS9+
- Contact details view is now scrollable to fix issue on small screens
## [3.12.1] - 2016-02-19

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="9531" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ContactDetailsView">
@ -10,7 +10,7 @@
<outlet property="avatarImage" destination="B6X-C9-2vm" id="tQc-xv-nJg"/>
<outlet property="backButton" destination="9" id="50"/>
<outlet property="cancelButton" destination="bPQ-aJ-Lk6" id="QHN-qi-QNv"/>
<outlet property="contentView" destination="QET-r4-TFd" id="HlS-is-Sd4"/>
<outlet property="contentView" destination="8D6-vy-obt" id="GZW-ov-Wfv"/>
<outlet property="deleteButton" destination="MuB-yy-R9o" id="cni-lk-awn"/>
<outlet property="editButton" destination="8" id="31"/>
<outlet property="emptyLabel" destination="Mdj-Pz-nu4" id="ijc-2c-waE"/>
@ -103,7 +103,7 @@
</button>
</subviews>
</view>
<view tag="7" contentMode="scaleToFill" id="QET-r4-TFd" userLabel="contentView">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" tag="7" contentMode="scaleToFill" directionalLockEnabled="YES" showsHorizontalScrollIndicator="NO" id="8D6-vy-obt" userLabel="contentView">
<rect key="frame" x="0.0" y="66" width="375" height="493"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
@ -121,7 +121,7 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" tag="10" contentMode="scaleToFill" directionalLockEnabled="YES" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" style="plain" allowsSelection="NO" allowsSelectionDuringEditing="YES" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" sectionHeaderHeight="1" sectionFooterHeight="1" id="19" userLabel="tableView">
<tableView clipsSubviews="YES" tag="10" contentMode="scaleToFill" directionalLockEnabled="YES" alwaysBounceVertical="YES" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" style="plain" allowsSelection="NO" allowsSelectionDuringEditing="YES" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" sectionHeaderHeight="1" sectionFooterHeight="1" id="19" userLabel="tableView">
<rect key="frame" x="0.0" y="156" width="375" height="337"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -133,8 +133,7 @@
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</scrollView>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" tag="40" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No contact selected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Mdj-Pz-nu4" userLabel="emptyLabel">
<rect key="frame" x="0.0" y="66" width="375" height="493"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@ -149,7 +148,7 @@
</subviews>
<color key="backgroundColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
<point key="canvasLocation" x="-136.5" y="242.5"/>
<point key="canvasLocation" x="-436.5" y="192.5"/>
</view>
<view contentMode="scaleToFill" id="gnD-7x-PSh" userLabel="iphone6MetricsView">
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
@ -232,7 +231,7 @@
</button>
</subviews>
</view>
<view tag="7" contentMode="scaleToFill" id="wOx-fs-kG2" userLabel="contentView">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" tag="7" contentMode="scaleToFill" directionalLockEnabled="YES" showsHorizontalScrollIndicator="NO" id="8D6-vy-oby" userLabel="contentView">
<rect key="frame" x="0.0" y="66" width="667" height="267"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<subviews>
@ -247,7 +246,7 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" tag="10" contentMode="scaleToFill" directionalLockEnabled="YES" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" style="plain" allowsSelection="NO" allowsSelectionDuringEditing="YES" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" sectionHeaderHeight="1" sectionFooterHeight="1" id="WMA-Yo-NbI" userLabel="tableView">
<tableView clipsSubviews="YES" tag="10" contentMode="scaleToFill" directionalLockEnabled="YES" alwaysBounceVertical="YES" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" style="plain" allowsSelection="NO" allowsSelectionDuringEditing="YES" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" sectionHeaderHeight="1" sectionFooterHeight="1" id="WMA-Yo-NbI" userLabel="tableView" customClass="TPKeyboardAvoidingTableView">
<rect key="frame" x="0.0" y="84" width="667" height="183"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@ -259,8 +258,7 @@
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</scrollView>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" tag="40" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No contact selected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="oFA-SG-IDe" userLabel="emptyLabel">
<rect key="frame" x="0.0" y="66" width="667" height="267"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

View file

@ -137,7 +137,8 @@
} else if (section == ContactSections_Number) {
return _contact.phoneNumbers.count;
} else if (section == ContactSections_Email) {
return _contact.emails.count;
BOOL showEmails = [LinphoneManager.instance lpConfigBoolForKey:@"show_contacts_emails_preference"];
return showEmails ? _contact.emails.count : 0;
}
return 0;
}

View file

@ -38,7 +38,7 @@
@property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property(weak, nonatomic) IBOutlet UILabel *nameLabel;
@property(weak, nonatomic) IBOutlet UIToggleButton *deleteButton;
@property(weak, nonatomic) IBOutlet UIView *contentView;
@property(weak, nonatomic) IBOutlet UIScrollView *contentView;
@property(weak, nonatomic) IBOutlet UILabel *emptyLabel;
- (IBAction)onBackClick:(id)event;

View file

@ -199,9 +199,14 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_editButton.hidden = ([ContactSelection getSelectionMode] != ContactSelectionModeEdit &&
[ContactSelection getSelectionMode] != ContactSelectionModeNone);
[_tableController.tableView addObserver:self forKeyPath:@"contentSize" options:0 context:NULL];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[_tableController.tableView removeObserver:self forKeyPath:@"contentSize"];
}
#pragma mark - UICompositeViewDelegate Functions
@ -250,21 +255,38 @@ static UICompositeViewDescription *compositeDescription = nil;
[ContactDisplay setDisplayNameLabel:_nameLabel forContact:_contact];
if ([self viewIsCurrentlyPortrait]) {
CGRect frame = self.contentView.frame;
frame.size.height -= _avatarImage.frame.origin.y + _avatarImage.frame.size.height;
frame.origin.y = _nameLabel.frame.origin.y;
CGRect frame = _tableController.tableView.frame;
frame.origin.y = _avatarImage.frame.size.height + _avatarImage.frame.origin.y;
if (!editing) {
frame.origin.y += _nameLabel.frame.size.height;
frame.size.height -= _nameLabel.frame.size.height;
}
frame.size.height = _tableController.tableView.contentSize.height;
_tableController.tableView.frame = frame;
[self recomputeContentViewSize];
}
if (animated) {
[UIView commitAnimations];
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
CGRect frame = _tableController.tableView.frame;
frame.size = _tableController.tableView.contentSize;
_tableController.tableView.frame = frame;
[self recomputeContentViewSize];
}
- (void)recomputeContentViewSize {
_contentView.contentSize =
CGSizeMake(_tableController.tableView.frame.size.width + _tableController.tableView.frame.origin.x,
_tableController.tableView.frame.size.height + _tableController.tableView.frame.origin.y);
}
#pragma mark - Action Functions
- (IBAction)onCancelClick:(id)event {