Skip to content

Commit

Permalink
Merge pull request #994 from MIT-Mobile/sprint-3/mobius-maplist-update
Browse files Browse the repository at this point in the history
Updates to Mobius Map-List machine view. Fixes #974, #970, #969, #968.
  • Loading branch information
bskinner committed Jun 3, 2015
2 parents 35c0886 + a6750f8 commit bbee416
Show file tree
Hide file tree
Showing 25 changed files with 1,728 additions and 503 deletions.
1 change: 1 addition & 0 deletions Common/MapCallout/MITCalloutView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern NSInteger const MITCalloutPermittedArrowDirectionAny;
*/
- (void)calloutViewTapped:(MITCalloutView *)calloutView;

@optional
/**
* Called when the callout is removed from the view hierarchy.
*
Expand Down
3 changes: 3 additions & 0 deletions Common/UI/LoadingActivityView/MITLoadingActivityView.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
@interface MITLoadingActivityView : UIView
@property (nonatomic, assign) BOOL usesBackgroundImage;

@property (nonatomic,readonly,weak) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic,readonly,weak) UILabel *textLabel;

@end
113 changes: 67 additions & 46 deletions Common/UI/LoadingActivityView/MITLoadingActivityView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,92 @@
#import "UIKit+MITAdditions.h"

@interface MITLoadingActivityView ()
@property (nonatomic,retain) UIView *activityView;
@property (nonatomic,strong) UIView *contentView;
@property (nonatomic,weak) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic,weak) UILabel *textLabel;
@end

@implementation MITLoadingActivityView
@implementation MITLoadingActivityView {
BOOL _didSetupViewConstraints;
}

@synthesize activityView = _activityView;
@synthesize usesBackgroundImage = _usesBackgroundImage;

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
UIView *contentView = [[UIView alloc] init];
contentView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:contentView];
_contentView = contentView;

UILabel *textLabel = [[UILabel alloc] init];
textLabel.translatesAutoresizingMaskIntoConstraints = NO;
textLabel.text = @"Loading...";
[contentView addSubview:textLabel];
_textLabel = textLabel;

UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicatorView.translatesAutoresizingMaskIntoConstraints = NO;
[contentView addSubview:activityIndicatorView];
_activityIndicatorView = activityIndicatorView;

self.usesBackgroundImage = YES;

UIView *activityView = [[UIView alloc] init];
UILabel *loadingLabel = [[UILabel alloc] init];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

NSString *loadingText = @"Loading...";

CGSize labelSize = [loadingText sizeWithAttributes:@{NSFontAttributeName: loadingLabel.font}];
labelSize.height = ceil(labelSize.height);
labelSize.width = ceil(labelSize.width);
CGFloat labelLeftMargin = 6.0;
loadingLabel.frame = CGRectMake(spinner.frame.size.width + labelLeftMargin,
0.0,
labelSize.width,
labelSize.height);
loadingLabel.backgroundColor = [UIColor clearColor];
loadingLabel.text = loadingText;

CGRect viewFrame = CGRectMake(0.0,
0.0,
labelSize.width + spinner.frame.size.width + labelLeftMargin,
labelSize.height);

activityView.frame = viewFrame;
activityView.autoresizingMask = UIViewAutoresizingNone;

[activityView addSubview:spinner];
[activityView addSubview:loadingLabel];

[spinner startAnimating];
[self addSubview:activityView];
self.activityView = activityView;

self.backgroundColor = [UIColor redColor];
//self.contentView.backgroundColor = [UIColor blueColor];
}

return self;
}

- (void)layoutSubviews {
// center the loading indicator
CGRect frame = self.activityView.frame;
frame.origin.x = (self.bounds.size.width - frame.size.width) / 2.0;
frame.origin.y = (self.bounds.size.height - frame.size.height - 64.) / 2.0;
// make sure it is always whole pixel aligned
self.activityView.frame = CGRectIntegral(frame);
}
- (void)updateConstraints
{
[super updateConstraints];

if (!_didSetupViewConstraints) {
[self addConstraint:[NSLayoutConstraint constraintWithItem:self.contentView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterX
multiplier:1.
constant:0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem:self.contentView
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterY
multiplier:1.
constant:0]];

[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[activityView]-[textLabel]|"
options:0
metrics:nil
views:@{@"activityView" : self.activityIndicatorView,
@"textLabel" : self.textLabel}]];

[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[activityView]|"
options:0
metrics:nil
views:@{@"activityView" : self.activityIndicatorView}]];

- (void)dealloc {
self.activityView = nil;
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[textLabel]|"
options:0
metrics:nil
views:@{@"textLabel" : self.textLabel}]];
_didSetupViewConstraints = YES;
}
}

- (void)setUsesBackgroundImage:(BOOL)usesBackgroundImage
{
if (usesBackgroundImage != self.usesBackgroundImage) {
_usesBackgroundImage = usesBackgroundImage;
if (self.usesBackgroundImage) {


/*
if (self.usesBackgroundImage) {
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
self.backgroundColor = [UIColor groupTableViewBackgroundColor];
} else {
Expand All @@ -77,6 +97,7 @@ - (void)setUsesBackgroundImage:(BOOL)usesBackgroundImage
self.backgroundColor = [UIColor clearColor];
}
[self setNeedsDisplay];
*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)setTitle:(NSString *)title withDescription:(NSString *)description
self.titleLabel.text = title;
self.descriptionLabel.text = description;
[self setNeedsUpdateConstraints];
[self updateConstraintsIfNeeded];
[self setNeedsLayout];
}

- (void)layoutSubviews
Expand Down
55 changes: 31 additions & 24 deletions Common/UI/MITTitleDescriptionCell/MITTitleDescriptionCell.xib
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="50" id="KGk-i7-Jjw" userLabel="Title Description Cell" customClass="MITTitleDescriptionCell">
<rect key="frame" x="0.0" y="0.0" width="768" height="50"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="50" id="5xD-Li-ndQ" userLabel="Title Description Cell" customClass="MITTitleDescriptionCell">
<rect key="frame" x="0.0" y="0.0" width="467" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5xD-Li-ndQ" id="qkP-na-k98">
<rect key="frame" x="0.0" y="0.0" width="768" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="right" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="lfF-58-8as">
<rect key="frame" x="15" y="2" width="364" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="NKI-Fx-Rt7">
<rect key="frame" x="389" y="2" width="364" height="17"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" usesAttributedText="YES" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="213" translatesAutoresizingMaskIntoConstraints="NO" id="Q4y-Wt-Lln">
<rect key="frame" x="239" y="0.0" width="213" height="17"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="17" id="wZu-oJ-7GY"/>
</constraints>
<attributedString key="attributedText">
<fragment content="Description">
<attributes>
Expand All @@ -33,23 +31,32 @@
</attributedString>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" text="Title" textAlignment="right" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="214" translatesAutoresizingMaskIntoConstraints="NO" id="vRV-pd-UtD">
<rect key="frame" x="17" y="0.0" width="214" height="17"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="17" id="51U-Ql-m9Q"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="NKI-Fx-Rt7" secondAttribute="bottom" constant="4" id="5yH-kw-Su0"/>
<constraint firstAttribute="trailing" secondItem="NKI-Fx-Rt7" secondAttribute="trailing" constant="15" id="GyH-7m-Bcb"/>
<constraint firstItem="NKI-Fx-Rt7" firstAttribute="leading" secondItem="lfF-58-8as" secondAttribute="trailing" constant="10" id="Ml6-4J-RoB"/>
<constraint firstItem="NKI-Fx-Rt7" firstAttribute="top" secondItem="lfF-58-8as" secondAttribute="top" id="ZsU-pE-Mz7"/>
<constraint firstItem="lfF-58-8as" firstAttribute="width" secondItem="NKI-Fx-Rt7" secondAttribute="width" id="dRR-gw-o2T"/>
<constraint firstItem="lfF-58-8as" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="15" id="k52-YI-ngo"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="lfF-58-8as" secondAttribute="bottom" constant="4" id="sfg-Yu-4pC"/>
<constraint firstItem="lfF-58-8as" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="2" id="way-a7-XIR"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Q4y-Wt-Lln" secondAttribute="bottom" priority="750" constant="4" id="G7L-pB-ERg"/>
<constraint firstItem="Q4y-Wt-Lln" firstAttribute="width" secondItem="vRV-pd-UtD" secondAttribute="width" id="UF3-bL-pbo"/>
<constraint firstItem="Q4y-Wt-Lln" firstAttribute="leading" secondItem="vRV-pd-UtD" secondAttribute="trailing" constant="8" symbolic="YES" id="VMB-Y7-Tb0"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="vRV-pd-UtD" secondAttribute="bottom" priority="750" constant="4" id="Xja-ak-FfB"/>
<constraint firstItem="vRV-pd-UtD" firstAttribute="top" secondItem="qkP-na-k98" secondAttribute="top" id="lBR-Kp-tH9"/>
<constraint firstAttribute="trailingMargin" secondItem="Q4y-Wt-Lln" secondAttribute="trailing" constant="7" id="m6g-el-e9B"/>
<constraint firstItem="Q4y-Wt-Lln" firstAttribute="top" secondItem="qkP-na-k98" secondAttribute="top" id="tRp-6r-1ob"/>
<constraint firstItem="vRV-pd-UtD" firstAttribute="leading" secondItem="qkP-na-k98" secondAttribute="leadingMargin" constant="9" id="wv5-Xc-fS0"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="descriptionLabel" destination="NKI-Fx-Rt7" id="P1S-2N-dto"/>
<outlet property="titleLabel" destination="lfF-58-8as" id="Sh9-Cg-vnD"/>
<outlet property="descriptionLabel" destination="Q4y-Wt-Lln" id="WNm-XB-cLi"/>
<outlet property="titleLabel" destination="vRV-pd-UtD" id="UYe-oR-ng6"/>
</connections>
<point key="canvasLocation" x="405" y="173"/>
<point key="canvasLocation" x="254.5" y="321"/>
</tableViewCell>
</objects>
</document>
Loading

0 comments on commit bbee416

Please sign in to comment.