Skip to content

Commit e5cb7cc

Browse files
committed
Framework debugging
1 parent 2abacd6 commit e5cb7cc

14 files changed

+89
-68
lines changed

SwiftMessages.podspec

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ Pod::Spec.new do |spec|
55
spec.homepage = 'https://github.com/SwiftKickMobile/swift-messages-ios'
66
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }
77
spec.summary = 'A designer-friendly iOS message bar written in Swift.'
8-
spec.source = { :git => 'https://github.com/SwiftKickMobile/swift-messages-ios.git', :tag => 'v0.0.1' }
9-
spec.platform = :ios, '8.0'
8+
spec.source = {:git => 'https://github.com/SwiftKickMobile/swift-messages-ios.git', :tag => 'v0.0.1'}
9+
spec.platform = :ios, '8.0'
1010
spec.ios.deployment_target = '8.0'
11-
spec.source_files = 'SwiftMessages/**/*'
12-
spec.frameworks = 'UIKit'
11+
spec.source_files = 'SwiftMessages/**/*.swift'
12+
spec.resource_bundles = {'SwiftMessages' => ['SwiftMessages/Resources/**/*']}
13+
spec.framework = 'UIKit'
1314
spec.requires_arc = true
1415
end

SwiftMessages.xcodeproj/project.pbxproj

+9-21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
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 */; };
12+
862C0CB11D5911C100D06168 /* NSBundle+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 862C0CB01D5911C100D06168 /* NSBundle+Utils.swift */; };
1113
864495561D4F7C390056EB2A /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864495551D4F7C390056EB2A /* Identifiable.swift */; };
1214
864495591D4FA0AD0056EB2A /* Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864495581D4FA0AD0056EB2A /* Manager.swift */; };
1315
8644955D1D4FAF7C0056EB2A /* WindowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8644955C1D4FAF7C0056EB2A /* WindowViewController.swift */; };
@@ -20,15 +22,12 @@
2022
867E21731D4D01D500594A41 /* SwiftMessagesUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 867E21721D4D01D500594A41 /* SwiftMessagesUITests.swift */; };
2123
867E21831D4D025200594A41 /* MessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 867E21821D4D025200594A41 /* MessageView.swift */; };
2224
867E21851D4D044F00594A41 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 867E21841D4D044F00594A41 /* Configuration.swift */; };
23-
867E21871D4D04C600594A41 /* MessageView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 867E21861D4D04C600594A41 /* MessageView.xib */; };
24-
867E21891D4D06D900594A41 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 867E21881D4D06D900594A41 /* Images.xcassets */; };
2525
867E21901D4D3E5E00594A41 /* UIView+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 867E218F1D4D3E5E00594A41 /* UIView+Utils.swift */; };
2626
867E21941D4D50BB00594A41 /* Presenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 867E21931D4D50BB00594A41 /* Presenter.swift */; };
2727
86AAF8181D54F0650031EE32 /* PassthroughView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF8171D54F0650031EE32 /* PassthroughView.swift */; };
2828
86AAF81A1D54F0850031EE32 /* PassthroughWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF8191D54F0850031EE32 /* PassthroughWindow.swift */; };
2929
86AAF81C1D551FE70031EE32 /* UIViewController+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF81B1D551FE60031EE32 /* UIViewController+Utils.swift */; };
3030
86AAF81E1D5549680031EE32 /* MarginAdjustable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF81D1D5549680031EE32 /* MarginAdjustable.swift */; };
31-
86AAF8261D5553170031EE32 /* StatusLine.xib in Resources */ = {isa = PBXBuildFile; fileRef = 86AAF8251D5553170031EE32 /* StatusLine.xib */; };
3231
86AAF82B1D580DD70031EE32 /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF82A1D580DD70031EE32 /* Error.swift */; };
3332
86AAF82D1D580F410031EE32 /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF82C1D580F410031EE32 /* Icon.swift */; };
3433
/* End PBXBuildFile section */
@@ -52,6 +51,8 @@
5251

5352
/* Begin PBXFileReference section */
5453
862C0C6A1D58E93300D06168 /* SwiftMessages.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = SwiftMessages.podspec; sourceTree = "<group>"; };
54+
862C0CAE1D590A0000D06168 /* Resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Resources; sourceTree = "<group>"; };
55+
862C0CB01D5911C100D06168 /* NSBundle+Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSBundle+Utils.swift"; sourceTree = "<group>"; };
5556
864495551D4F7C390056EB2A /* Identifiable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Identifiable.swift; sourceTree = "<group>"; };
5657
864495581D4FA0AD0056EB2A /* Manager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Manager.swift; sourceTree = "<group>"; };
5758
8644955C1D4FAF7C0056EB2A /* WindowViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowViewController.swift; sourceTree = "<group>"; };
@@ -70,15 +71,12 @@
7071
867E21741D4D01D500594A41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7172
867E21821D4D025200594A41 /* MessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageView.swift; sourceTree = "<group>"; };
7273
867E21841D4D044F00594A41 /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
73-
867E21861D4D04C600594A41 /* MessageView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageView.xib; sourceTree = "<group>"; };
74-
867E21881D4D06D900594A41 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
7574
867E218F1D4D3E5E00594A41 /* UIView+Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Utils.swift"; sourceTree = "<group>"; };
7675
867E21931D4D50BB00594A41 /* Presenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Presenter.swift; sourceTree = "<group>"; };
7776
86AAF8171D54F0650031EE32 /* PassthroughView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PassthroughView.swift; sourceTree = "<group>"; };
7877
86AAF8191D54F0850031EE32 /* PassthroughWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PassthroughWindow.swift; sourceTree = "<group>"; };
7978
86AAF81B1D551FE60031EE32 /* UIViewController+Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Utils.swift"; sourceTree = "<group>"; };
8079
86AAF81D1D5549680031EE32 /* MarginAdjustable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginAdjustable.swift; sourceTree = "<group>"; };
81-
86AAF8251D5553170031EE32 /* StatusLine.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = StatusLine.xib; sourceTree = "<group>"; };
8280
86AAF82A1D580DD70031EE32 /* Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = "<group>"; };
8381
86AAF82C1D580F410031EE32 /* Icon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = "<group>"; };
8482
/* End PBXFileReference section */
@@ -160,7 +158,8 @@
160158
children = (
161159
864495581D4FA0AD0056EB2A /* Manager.swift */,
162160
867E21841D4D044F00594A41 /* Configuration.swift */,
163-
867E218A1D4D3CCC00594A41 /* Views */,
161+
867E21821D4D025200594A41 /* MessageView.swift */,
162+
862C0CAE1D590A0000D06168 /* Resources */,
164163
864495571D4F7C490056EB2A /* Base */,
165164
867E218E1D4D3DFD00594A41 /* Internal */,
166165
);
@@ -185,17 +184,6 @@
185184
path = SwiftMessagesUITests;
186185
sourceTree = "<group>";
187186
};
188-
867E218A1D4D3CCC00594A41 /* Views */ = {
189-
isa = PBXGroup;
190-
children = (
191-
867E21881D4D06D900594A41 /* Images.xcassets */,
192-
867E21821D4D025200594A41 /* MessageView.swift */,
193-
867E21861D4D04C600594A41 /* MessageView.xib */,
194-
86AAF8251D5553170031EE32 /* StatusLine.xib */,
195-
);
196-
name = Views;
197-
sourceTree = "<group>";
198-
};
199187
867E218E1D4D3DFD00594A41 /* Internal */ = {
200188
isa = PBXGroup;
201189
children = (
@@ -204,6 +192,7 @@
204192
86AAF8191D54F0850031EE32 /* PassthroughWindow.swift */,
205193
8644955C1D4FAF7C0056EB2A /* WindowViewController.swift */,
206194
86AAF81B1D551FE60031EE32 /* UIViewController+Utils.swift */,
195+
862C0CB01D5911C100D06168 /* NSBundle+Utils.swift */,
207196
);
208197
name = Internal;
209198
sourceTree = "<group>";
@@ -313,12 +302,10 @@
313302
buildActionMask = 2147483647;
314303
files = (
315304
862C0C6B1D58E93300D06168 /* SwiftMessages.podspec in Resources */,
316-
867E21871D4D04C600594A41 /* MessageView.xib in Resources */,
317-
86AAF8261D5553170031EE32 /* StatusLine.xib in Resources */,
318-
867E21891D4D06D900594A41 /* Images.xcassets in Resources */,
319305
867E215D1D4D01D500594A41 /* LaunchScreen.storyboard in Resources */,
320306
867E215A1D4D01D500594A41 /* Assets.xcassets in Resources */,
321307
867E21581D4D01D500594A41 /* Main.storyboard in Resources */,
308+
862C0CAF1D590A0000D06168 /* Resources in Resources */,
322309
);
323310
runOnlyForDeploymentPostprocessing = 0;
324311
};
@@ -349,6 +336,7 @@
349336
867E21551D4D01D500594A41 /* GalleryTableViewController.swift in Sources */,
350337
864495591D4FA0AD0056EB2A /* Manager.swift in Sources */,
351338
86AAF8181D54F0650031EE32 /* PassthroughView.swift in Sources */,
339+
862C0CB11D5911C100D06168 /* NSBundle+Utils.swift in Sources */,
352340
867E21851D4D044F00594A41 /* Configuration.swift in Sources */,
353341
86AAF82D1D580F410031EE32 /* Icon.swift in Sources */,
354342
867E21941D4D50BB00594A41 /* Presenter.swift in Sources */,

SwiftMessages/Configuration.swift

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public enum Duration {
2727

2828
public struct Configuration {
2929

30+
public init() {}
31+
3032
public var duration = Duration.Automatic
3133

3234
public var presentationStyle = PresentationStyle.Top

SwiftMessages/Icon.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public enum Icon: String {
1414
case Warning = "warningIcon"
1515
case Info = "infoIcon"
1616

17-
public var image: UIImage {
18-
return UIImage(named: rawValue)!
17+
public var image: UIImage {
18+
return UIImage(named: rawValue, inBundle: NSBundle.frameworkBundle(), compatibleWithTraitCollection: nil)!
1919
}
2020
}

SwiftMessages/Manager.swift

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ public class Manager {
2626
A block that returns an arbitrary view.
2727
*/
2828
public typealias ViewProvider = () -> UIView
29-
29+
30+
/**
31+
*/
32+
public func add(viewProvider viewProvider: ViewProvider) {
33+
add(configuration: Configuration(), viewProvider: viewProvider)
34+
}
35+
3036
/**
3137
Add the given configuration and view, as provided by the `viewProvider` block,
3238
to the message display queue.
@@ -47,6 +53,12 @@ public class Manager {
4753
}
4854
}
4955

56+
/**
57+
*/
58+
public func add(view view: UIView) {
59+
add(configuration: Configuration(), view: view)
60+
}
61+
5062
/**
5163
Add the given configuration and view to the message display queue.
5264
- parameter configuration: Configuration options for showing the message view.

SwiftMessages/MessageView.swift

+8-13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class MessageView: UIView, Identifiable, MarginAdjustable {
2020
@IBOutlet public var iconLabel: UILabel?
2121
@IBOutlet public var button: UIButton?
2222
@IBOutlet public var contentView: UIView?
23+
@IBOutlet public var backgroundView: UIView?
2324

2425
/*
2526
MARK: - Creating message views
@@ -30,24 +31,23 @@ public class MessageView: UIView, Identifiable, MarginAdjustable {
3031
case StatusLine = "StatusLine"
3132
}
3233

33-
public static func viewFromNib(layout layout: Layout) -> MessageView {
34-
return try! MessageView.viewFromNib(named: layout.rawValue)
34+
public static func viewFromNib(layout layout: Layout, bundle: NSBundle? = nil) -> MessageView {
35+
return try! MessageView.viewFromNib(named: layout.rawValue, bundle: bundle)
3536
}
3637

3738
/*
3839
MARK: - Configuring the theme
3940
*/
4041

4142
public func configureErrorTheme() {
42-
if iconImageView?.image == nil && iconLabel?.text?.isEmpty ?? true {
43-
iconImageView?.image = Icon.Error.image
44-
}
43+
iconImageView?.image = Icon.Error.image
44+
iconLabel?.text = nil
4545
iconImageView?.tintColor = UIColor.whiteColor()
46-
contentView?.backgroundColor = UIColor(red: 249.0/255.0, green: 66.0/255.0, blue: 47.0/255.0, alpha: 1.0)
46+
let backgroundView = self.backgroundView ?? self
47+
backgroundView.backgroundColor = UIColor(red: 249.0/255.0, green: 66.0/255.0, blue: 47.0/255.0, alpha: 1.0)
4748
iconLabel?.textColor = UIColor.whiteColor()
4849
titleLabel?.textColor = UIColor.whiteColor()
4950
bodyLabel?.textColor = UIColor.whiteColor()
50-
backgroundColor = UIColor.clearColor()
5151
}
5252

5353
// public func configureWarningTheme() {
@@ -99,12 +99,7 @@ public class MessageView: UIView, Identifiable, MarginAdjustable {
9999
*/
100100

101101
public override func awakeFromNib() {
102-
titleLabel?.text = nil
103-
bodyLabel?.text = nil
104-
iconImageView?.image = nil
105-
iconLabel?.text = nil
106-
button?.setImage(nil, forState: .Normal)
107-
button?.setTitle(nil, forState: .Normal)
102+
backgroundColor = UIColor.clearColor()
108103
layoutMargins = UIEdgeInsetsZero
109104
}
110105

SwiftMessages/NSBundle+Utils.swift

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// NSBundle+Utils.swift
3+
// SwiftMessages
4+
//
5+
// Created by Tim Moose on 8/8/16.
6+
// Copyright © 2016 SwiftKick Mobile. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
extension NSBundle {
12+
static func frameworkBundle() -> NSBundle {
13+
let path = NSBundle(forClass: MessageView.self).pathForResource("SwiftMessages", ofType: "bundle")!
14+
return NSBundle(path: path)!
15+
}
16+
}

SwiftMessages/Presenter.swift

+13-2
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,21 @@ class Presenter {
117117
case .Bottom:
118118
bottom += adjustable.bounceAnimationOffset
119119
}
120-
if let vc = presentationContext as? WindowViewController where vc.windowLevel == UIWindowLevelNormal && !UIApplication.sharedApplication().statusBarHidden {
121-
top += adjustable.statusBarOffset
120+
if !UIApplication.sharedApplication().statusBarHidden {
121+
if let vc = presentationContext as? WindowViewController {
122+
if vc.windowLevel == UIWindowLevelNormal {
123+
top += adjustable.statusBarOffset
124+
}
125+
} else if let vc = presentationContext as? UINavigationController {
126+
if vc.isVisible(view: vc.navigationBar) {
127+
top += adjustable.statusBarOffset
128+
}
129+
} else {
130+
top += adjustable.statusBarOffset
131+
}
122132
}
123133
view.layoutMargins = UIEdgeInsets(top: top, left: 0.0, bottom: bottom, right: 0.0)
134+
print("view.layoutMargins=\(view.layoutMargins)")
124135
}
125136
let size = view.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize)
126137
translationConstraint.constant -= size.height

SwiftMessages/MessageView.xib SwiftMessages/Resources/MessageView.xib

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@
1717
<rect key="frame" x="8" y="8" width="584" height="87"/>
1818
<subviews>
1919
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="😬" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1Bu-DY-qZo" userLabel="Icon label">
20-
<rect key="frame" x="20" y="24.5" width="32" height="38.5"/>
20+
<rect key="frame" x="20" y="24" width="32" height="39"/>
2121
<fontDescription key="fontDescription" type="system" pointSize="32"/>
22-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
22+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
2323
<nil key="highlightedColor"/>
2424
</label>
2525
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="252" verticalHuggingPriority="251" image="errorIcon" translatesAutoresizingMaskIntoConstraints="NO" id="PbA-QP-XpA" userLabel="Icon image view">
2626
<rect key="frame" x="20" y="35" width="32" height="18"/>
2727
</imageView>
2828
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="90y-Jf-WFn" userLabel="Text container">
29-
<rect key="frame" x="72" y="24" width="492" height="39.5"/>
29+
<rect key="frame" x="72" y="24" width="492" height="40"/>
3030
<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="8T6-4T-ytS">
32-
<rect key="frame" x="0.0" y="0.0" width="492" height="19.5"/>
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="8T6-4T-ytS">
32+
<rect key="frame" x="0.0" y="0.0" width="492" height="20"/>
3333
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
34-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
34+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
3535
<nil key="highlightedColor"/>
3636
</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="dFP-4Z-N2a">
38-
<rect key="frame" x="0.0" y="19.5" width="492" height="20"/>
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="dFP-4Z-N2a">
38+
<rect key="frame" x="0.0" y="20" width="492" height="20"/>
3939
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
40-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
40+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
4141
<nil key="highlightedColor"/>
4242
</label>
4343
</subviews>

0 commit comments

Comments
 (0)