Skip to content

Commit c37b52e

Browse files
committed
Convert MessageView to stack view
1 parent e793bad commit c37b52e

File tree

4 files changed

+189
-56
lines changed

4 files changed

+189
-56
lines changed

SwiftMessages.xcodeproj/project.pbxproj

+32-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
/* Begin PBXBuildFile section */
1010
862C0C6B1D58E93300D06168 /* SwiftMessages.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 862C0C6A1D58E93300D06168 /* SwiftMessages.podspec */; };
11-
862C0CAF1D590A0000D06168 /* Resources in Resources */ = {isa = PBXBuildFile; fileRef = 862C0CAE1D590A0000D06168 /* Resources */; };
1211
862C0CB11D5911C100D06168 /* NSBundle+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 862C0CB01D5911C100D06168 /* NSBundle+Utils.swift */; };
12+
862C0CDC1D5A397F00D06168 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 862C0CD91D5A397F00D06168 /* Images.xcassets */; };
13+
862C0CDD1D5A397F00D06168 /* MessageView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 862C0CDA1D5A397F00D06168 /* MessageView.xib */; };
14+
862C0CDE1D5A397F00D06168 /* StatusLine.xib in Resources */ = {isa = PBXBuildFile; fileRef = 862C0CDB1D5A397F00D06168 /* StatusLine.xib */; };
15+
862C0CE31D5A3A0D00D06168 /* MessageViewIOS8.xib in Resources */ = {isa = PBXBuildFile; fileRef = 862C0CE21D5A3A0D00D06168 /* MessageViewIOS8.xib */; };
1316
864495561D4F7C390056EB2A /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864495551D4F7C390056EB2A /* Identifiable.swift */; };
1417
864495591D4FA0AD0056EB2A /* Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864495581D4FA0AD0056EB2A /* Manager.swift */; };
1518
8644955D1D4FAF7C0056EB2A /* WindowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8644955C1D4FAF7C0056EB2A /* WindowViewController.swift */; };
@@ -50,8 +53,11 @@
5053

5154
/* Begin PBXFileReference section */
5255
862C0C6A1D58E93300D06168 /* SwiftMessages.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = SwiftMessages.podspec; sourceTree = "<group>"; };
53-
862C0CAE1D590A0000D06168 /* Resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Resources; sourceTree = "<group>"; };
5456
862C0CB01D5911C100D06168 /* NSBundle+Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSBundle+Utils.swift"; sourceTree = "<group>"; };
57+
862C0CD91D5A397F00D06168 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Resources/Images.xcassets; sourceTree = "<group>"; };
58+
862C0CDA1D5A397F00D06168 /* MessageView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MessageView.xib; path = Resources/MessageView.xib; sourceTree = "<group>"; };
59+
862C0CDB1D5A397F00D06168 /* StatusLine.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = StatusLine.xib; path = Resources/StatusLine.xib; sourceTree = "<group>"; };
60+
862C0CE21D5A3A0D00D06168 /* MessageViewIOS8.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageViewIOS8.xib; sourceTree = "<group>"; };
5561
864495551D4F7C390056EB2A /* Identifiable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Identifiable.swift; sourceTree = "<group>"; };
5662
864495581D4FA0AD0056EB2A /* Manager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Manager.swift; sourceTree = "<group>"; };
5763
8644955C1D4FAF7C0056EB2A /* WindowViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowViewController.swift; sourceTree = "<group>"; };
@@ -117,6 +123,25 @@
117123
name = SwiftMessagesDemo;
118124
sourceTree = "<group>";
119125
};
126+
862C0CD81D5A396900D06168 /* Resources */ = {
127+
isa = PBXGroup;
128+
children = (
129+
862C0CD91D5A397F00D06168 /* Images.xcassets */,
130+
862C0CDA1D5A397F00D06168 /* MessageView.xib */,
131+
862C0CDB1D5A397F00D06168 /* StatusLine.xib */,
132+
862C0CDF1D5A398900D06168 /* iOS8 */,
133+
);
134+
name = Resources;
135+
sourceTree = "<group>";
136+
};
137+
862C0CDF1D5A398900D06168 /* iOS8 */ = {
138+
isa = PBXGroup;
139+
children = (
140+
862C0CE21D5A3A0D00D06168 /* MessageViewIOS8.xib */,
141+
);
142+
name = iOS8;
143+
sourceTree = "<group>";
144+
};
120145
864495571D4F7C490056EB2A /* Base */ = {
121146
isa = PBXGroup;
122147
children = (
@@ -156,7 +181,7 @@
156181
864495581D4FA0AD0056EB2A /* Manager.swift */,
157182
867E21841D4D044F00594A41 /* Configuration.swift */,
158183
867E21821D4D025200594A41 /* MessageView.swift */,
159-
862C0CAE1D590A0000D06168 /* Resources */,
184+
862C0CD81D5A396900D06168 /* Resources */,
160185
864495571D4F7C490056EB2A /* Base */,
161186
867E218E1D4D3DFD00594A41 /* Internal */,
162187
);
@@ -298,11 +323,14 @@
298323
isa = PBXResourcesBuildPhase;
299324
buildActionMask = 2147483647;
300325
files = (
326+
862C0CDD1D5A397F00D06168 /* MessageView.xib in Resources */,
301327
862C0C6B1D58E93300D06168 /* SwiftMessages.podspec in Resources */,
328+
862C0CDC1D5A397F00D06168 /* Images.xcassets in Resources */,
302329
867E215D1D4D01D500594A41 /* LaunchScreen.storyboard in Resources */,
330+
862C0CDE1D5A397F00D06168 /* StatusLine.xib in Resources */,
303331
867E215A1D4D01D500594A41 /* Assets.xcassets in Resources */,
304332
867E21581D4D01D500594A41 /* Main.storyboard in Resources */,
305-
862C0CAF1D590A0000D06168 /* Resources in Resources */,
333+
862C0CE31D5A3A0D00D06168 /* MessageViewIOS8.xib in Resources */,
306334
);
307335
runOnlyForDeploymentPostprocessing = 0;
308336
};

SwiftMessages/MessageView.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,26 @@ public class MessageView: UIView, Identifiable, MarginAdjustable {
2929
public enum Layout: String {
3030
case MessageView = "MessageView"
3131
case StatusLine = "StatusLine"
32+
case MessageViewIOS8 = "MessageViewIOS8"
3233
}
3334

3435
public static func viewFromNib<T: MessageView>(layout layout: Layout, bundle: NSBundle? = nil) -> T {
3536
return try! MessageView.viewFromNib(named: layout.rawValue, bundle: bundle)
3637
}
3738

38-
public class func viewFromNib<T: MessageView>(bundle bundle: NSBundle? = nil) throws -> T {
39+
public class func viewFromNib<T: MessageView>(bundle bundle: NSBundle = NSBundle.mainBundle()) throws -> T {
3940
let name = description().componentsSeparatedByString(".").last
4041
assert(name != nil)
4142
let view: T = try viewFromNib(named: name!, bundle: bundle)
4243
return view
4344
}
4445

45-
public class func viewFromNib<T: MessageView>(named name: String, bundle: NSBundle? = nil) throws -> T {
46+
public class func viewFromNib<T: MessageView>(named name: String, bundle: NSBundle = NSBundle.mainBundle()) throws -> T {
47+
let view: T = try viewFromNib(named: name, bundle: bundle)
48+
return view
49+
}
50+
51+
private class func viewFromNib<T: MessageView>(named name: String, bundle: NSBundle? = nil) throws -> T {
4652
let resolvedBundle: NSBundle
4753
if let bundle = bundle {
4854
resolvedBundle = bundle

SwiftMessages/MessageViewIOS8.xib

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
3+
<dependencies>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
6+
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
7+
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
8+
</dependencies>
9+
<objects>
10+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
11+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
12+
<view contentMode="scaleToFill" id="D36-3K-dlr" customClass="MessageView" customModule="SwiftMessages" customModuleProvider="target">
13+
<rect key="frame" x="0.0" y="0.0" width="600" height="103"/>
14+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
15+
<subviews>
16+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4g0-UX-cgn" userLabel="Content view">
17+
<rect key="frame" x="8" y="8" width="584" height="87"/>
18+
<subviews>
19+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="😬" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hN0-co-Tho" userLabel="Icon label">
20+
<rect key="frame" x="20" y="24" width="32" height="39"/>
21+
<fontDescription key="fontDescription" type="system" pointSize="32"/>
22+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
23+
<nil key="highlightedColor"/>
24+
</label>
25+
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="252" verticalHuggingPriority="251" image="errorIcon" translatesAutoresizingMaskIntoConstraints="NO" id="q3r-OQ-1bR" userLabel="Icon image view">
26+
<rect key="frame" x="20" y="35" width="32" height="18"/>
27+
</imageView>
28+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hRn-ww-fBK" userLabel="Text container">
29+
<rect key="frame" x="72" y="21" width="492" height="45"/>
30+
<subviews>
31+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="[Title]" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ahp-gB-92W">
32+
<rect key="frame" x="0.0" y="0.0" width="492" height="20"/>
33+
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
34+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
35+
<nil key="highlightedColor"/>
36+
</label>
37+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="[Message Body]" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OV1-yz-3U3">
38+
<rect key="frame" x="0.0" y="25" width="492" height="20"/>
39+
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
40+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
41+
<nil key="highlightedColor"/>
42+
</label>
43+
</subviews>
44+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
45+
<constraints>
46+
<constraint firstAttribute="trailing" secondItem="ahp-gB-92W" secondAttribute="trailing" id="2sf-3u-gfN"/>
47+
<constraint firstItem="OV1-yz-3U3" firstAttribute="top" secondItem="ahp-gB-92W" secondAttribute="bottom" constant="5" id="43Q-Ya-7Wv"/>
48+
<constraint firstItem="OV1-yz-3U3" firstAttribute="leading" secondItem="hRn-ww-fBK" secondAttribute="leading" id="4vN-wA-aCm"/>
49+
<constraint firstAttribute="bottom" secondItem="OV1-yz-3U3" secondAttribute="bottom" id="O66-Ve-8T4"/>
50+
<constraint firstItem="ahp-gB-92W" firstAttribute="top" secondItem="hRn-ww-fBK" secondAttribute="top" id="TAI-Py-Rqq"/>
51+
<constraint firstAttribute="trailing" secondItem="OV1-yz-3U3" secondAttribute="trailing" id="h6Q-XY-v9c"/>
52+
<constraint firstItem="ahp-gB-92W" firstAttribute="leading" secondItem="hRn-ww-fBK" secondAttribute="leading" id="rrA-5L-fts"/>
53+
</constraints>
54+
</view>
55+
</subviews>
56+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
57+
<constraints>
58+
<constraint firstItem="hRn-ww-fBK" firstAttribute="leading" secondItem="hN0-co-Tho" secondAttribute="trailing" constant="20" id="9Mf-Iy-3zb"/>
59+
<constraint firstItem="q3r-OQ-1bR" firstAttribute="leading" secondItem="4g0-UX-cgn" secondAttribute="leading" constant="20" id="9oG-Zs-sAS"/>
60+
<constraint firstItem="hRn-ww-fBK" firstAttribute="leading" secondItem="q3r-OQ-1bR" secondAttribute="trailing" constant="20" id="HPD-bV-5gP"/>
61+
<constraint firstItem="hN0-co-Tho" firstAttribute="centerY" secondItem="4g0-UX-cgn" secondAttribute="centerYWithinMargins" id="Ipr-7h-kui"/>
62+
<constraint firstAttribute="trailing" secondItem="hRn-ww-fBK" secondAttribute="trailing" constant="20" id="Lpa-bU-ecR"/>
63+
<constraint firstItem="hN0-co-Tho" firstAttribute="leading" secondItem="4g0-UX-cgn" secondAttribute="leading" constant="20" id="OUk-54-FJE"/>
64+
<constraint firstItem="q3r-OQ-1bR" firstAttribute="top" relation="greaterThanOrEqual" secondItem="4g0-UX-cgn" secondAttribute="top" constant="20" id="PJH-pA-Odz"/>
65+
<constraint firstItem="hRn-ww-fBK" firstAttribute="centerY" secondItem="4g0-UX-cgn" secondAttribute="centerYWithinMargins" id="Ptv-cW-3dz"/>
66+
<constraint firstItem="hRn-ww-fBK" firstAttribute="top" relation="greaterThanOrEqual" secondItem="4g0-UX-cgn" secondAttribute="top" constant="20" id="w4j-vg-8eK"/>
67+
<constraint firstItem="q3r-OQ-1bR" firstAttribute="centerY" secondItem="4g0-UX-cgn" secondAttribute="centerYWithinMargins" id="wIn-X4-eRd"/>
68+
<constraint firstItem="hN0-co-Tho" firstAttribute="top" relation="greaterThanOrEqual" secondItem="4g0-UX-cgn" secondAttribute="top" constant="20" id="yMi-JN-dIx"/>
69+
</constraints>
70+
</view>
71+
</subviews>
72+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
73+
<constraints>
74+
<constraint firstAttribute="trailingMargin" secondItem="4g0-UX-cgn" secondAttribute="trailing" id="N6z-c2-h8Y"/>
75+
<constraint firstItem="4g0-UX-cgn" firstAttribute="leading" secondItem="D36-3K-dlr" secondAttribute="leadingMargin" id="cLy-WR-pFK"/>
76+
<constraint firstItem="4g0-UX-cgn" firstAttribute="top" secondItem="D36-3K-dlr" secondAttribute="topMargin" id="hqV-tv-Dq3"/>
77+
<constraint firstAttribute="bottomMargin" secondItem="4g0-UX-cgn" secondAttribute="bottom" id="owe-dy-vX4"/>
78+
</constraints>
79+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
80+
<userDefinedRuntimeAttributes>
81+
<userDefinedRuntimeAttribute type="number" keyPath="bounceAnimationOffset">
82+
<real key="value" value="5"/>
83+
</userDefinedRuntimeAttribute>
84+
<userDefinedRuntimeAttribute type="number" keyPath="statusBarOffset">
85+
<real key="value" value="8"/>
86+
</userDefinedRuntimeAttribute>
87+
</userDefinedRuntimeAttributes>
88+
<connections>
89+
<outlet property="bodyLabel" destination="OV1-yz-3U3" id="mc8-61-Icn"/>
90+
<outlet property="contentView" destination="4g0-UX-cgn" id="iSd-BI-YGM"/>
91+
<outlet property="iconImageView" destination="q3r-OQ-1bR" id="R3P-Gs-Mqa"/>
92+
<outlet property="iconLabel" destination="hN0-co-Tho" id="Pkn-8u-E8X"/>
93+
<outlet property="titleLabel" destination="ahp-gB-92W" id="nkU-6v-kIf"/>
94+
</connections>
95+
<point key="canvasLocation" x="360" y="352.5"/>
96+
</view>
97+
</objects>
98+
<resources>
99+
<image name="errorIcon" width="18" height="18"/>
100+
</resources>
101+
</document>

0 commit comments

Comments
 (0)