Skip to content

Commit aabffb9

Browse files
committed
Add center presentation style
1 parent 0f324aa commit aabffb9

34 files changed

+1273
-690
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.4.0](https://github.com/SwiftKickMobile/SwiftMessages/releases/tag/3.4.0)
5+
6+
### Features
7+
* Added `.center` presentation style with a physics-based dismissal gesture.
8+
* Added `.custom(animator:)` presentation style, where you provide an instance of the `Animator` protocol. The `TopBottomAnimation` and `CenterAnimation` animations both implement `Animator` and may be subclassed (configuration options will be added in a future release). `PhysicsPanHandler` class to provide a physics-based dismissal gesture.
9+
* Added `.centered` message view layout with elements centered and arranged vertically.
10+
* Added `configureBackgroundView(width:)` and `configureBackgroundView(sideMargin:)` convenience methods to `MessageView`.
11+
412
## [3.3.4](https://github.com/SwiftKickMobile/SwiftMessages/releases/tag/3.3.4)
513

614
### Features

Demo/Demo.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
);
213213
runOnlyForDeploymentPostprocessing = 0;
214214
shellPath = /bin/sh;
215-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
215+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
216216
showEnvVarsInLog = 0;
217217
};
218218
/* End PBXShellScriptBuildPhase section */

Demo/Demo/AppDelegate.swift

-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3838
func applicationWillTerminate(_ application: UIApplication) {
3939
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4040
}
41-
42-
4341
}
4442

Demo/Demo/Base.lproj/Main.storyboard

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="JQZ-C5-7mw">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="JQZ-C5-7mw">
33
<device id="retina4_0" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
99
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -36,7 +36,7 @@
3636
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3737
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3838
<prototypes>
39-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TitleBody" rowHeight="80" id="2n5-7h-3B5" userLabel="TitleBodyCell" customClass="TitleBodyCell" customModule="Demo" customModuleProvider="target">
39+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TitleBody" rowHeight="80" id="2n5-7h-3B5" userLabel="TitleBody Cell" customClass="TitleBodyCell" customModule="Demo" customModuleProvider="target">
4040
<rect key="frame" x="0.0" y="28" width="320" height="80"/>
4141
<autoresizingMask key="autoresizingMask"/>
4242
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2n5-7h-3B5" id="Q5r-8D-38q">
@@ -71,7 +71,7 @@
7171
<outlet property="titleLabel" destination="Icl-Ci-lfe" id="XnB-LL-hx6"/>
7272
</connections>
7373
</tableViewCell>
74-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Explore" rowHeight="80" id="4Pm-kC-YGr" userLabel="ExploreCell" customClass="TitleBodyCell" customModule="Demo" customModuleProvider="target">
74+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Explore" rowHeight="80" id="4Pm-kC-YGr" userLabel="Explore Cell" customClass="TitleBodyCell" customModule="Demo" customModuleProvider="target">
7575
<rect key="frame" x="0.0" y="108" width="320" height="80"/>
7676
<autoresizingMask key="autoresizingMask"/>
7777
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="4Pm-kC-YGr" id="LmG-UL-Bu8">
@@ -144,10 +144,11 @@
144144
<nil key="highlightedColor"/>
145145
</label>
146146
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="Agu-Vo-ckI">
147-
<rect key="frame" x="18" y="29" width="119" height="29"/>
147+
<rect key="frame" x="18" y="29" width="179" height="29"/>
148148
<segments>
149149
<segment title="Top"/>
150150
<segment title="Bottom"/>
151+
<segment title="Center"/>
151152
</segments>
152153
</segmentedControl>
153154
</subviews>
@@ -691,7 +692,7 @@
691692
</tableViewController>
692693
<placeholder placeholderIdentifier="IBFirstResponder" id="skR-IF-bf8" userLabel="First Responder" sceneMemberID="firstResponder"/>
693694
</objects>
694-
<point key="canvasLocation" x="2340.8000000000002" y="303.14842578710648"/>
695+
<point key="canvasLocation" x="2115" y="304"/>
695696
</scene>
696697
<!--Demo-->
697698
<scene sceneID="TNg-VF-1BI">

Demo/Demo/ExploreViewController.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class ExploreViewController: UITableViewController, UITextFieldDelegate {
1818
let view: MessageView
1919
switch layout.selectedSegmentIndex {
2020
case 1:
21-
view = MessageView.viewFromNib(layout: .CardView)
21+
view = MessageView.viewFromNib(layout: .cardView)
2222
case 2:
23-
view = MessageView.viewFromNib(layout: .TabView)
23+
view = MessageView.viewFromNib(layout: .tabView)
2424
case 3:
25-
view = MessageView.viewFromNib(layout: .StatusLine)
25+
view = MessageView.viewFromNib(layout: .statusLine)
2626
default:
2727
view = try! SwiftMessages.viewFromNib()
2828
}
@@ -85,6 +85,8 @@ class ExploreViewController: UITableViewController, UITextFieldDelegate {
8585
switch presentationStyle.selectedSegmentIndex {
8686
case 1:
8787
config.presentationStyle = .bottom
88+
case 2:
89+
config.presentationStyle = .center
8890
default:
8991
break
9092
}

Demo/Demo/ViewController.swift

+23-10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class ViewController: UITableViewController {
1616
.titleBody(title: "ANY VIEW", body: "Any view, no matter how cute, can be displayed as a message.", function: ViewController.demoAnyView),
1717
.titleBody(title: "CUSTOMIZE", body: "Easily customize by copying one of the SwiftMessages nib files into your project as a starting point. Then order some tacos.", function: ViewController.demoCustomNib),
1818
.explore,
19+
.titleBody(title: "CENTERED", body: "Show cenetered messages with a fun, physics-based dismissal gesture.", function: ViewController.demoCentered),
1920
]
2021

2122
/*
@@ -55,12 +56,12 @@ class ViewController: UITableViewController {
5556

5657
static func demoBasics() -> Void {
5758

58-
let error = MessageView.viewFromNib(layout: .TabView)
59+
let error = MessageView.viewFromNib(layout: .tabView)
5960
error.configureTheme(.error)
6061
error.configureContent(title: "Error", body: "Something is horribly wrong!")
6162
error.button?.setTitle("Stop", for: .normal)
6263

63-
let warning = MessageView.viewFromNib(layout: .CardView)
64+
let warning = MessageView.viewFromNib(layout: .cardView)
6465
warning.configureTheme(.warning)
6566
warning.configureDropShadow()
6667

@@ -70,31 +71,31 @@ class ViewController: UITableViewController {
7071
var warningConfig = SwiftMessages.defaultConfig
7172
warningConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
7273

73-
let success = MessageView.viewFromNib(layout: .CardView)
74+
let success = MessageView.viewFromNib(layout: .cardView)
7475
success.configureTheme(.success)
7576
success.configureDropShadow()
7677
success.configureContent(title: "Success", body: "Something good happened!")
7778
success.button?.isHidden = true
7879
var successConfig = SwiftMessages.defaultConfig
79-
successConfig.presentationStyle = .bottom
80+
successConfig.presentationStyle = .center
8081
successConfig.presentationContext = .window(windowLevel: UIWindowLevelNormal)
8182

82-
let info = MessageView.viewFromNib(layout: .MessageView)
83+
let info = MessageView.viewFromNib(layout: .messageView)
8384
info.configureTheme(.info)
8485
info.button?.isHidden = true
8586
info.configureContent(title: "Info", body: "This is a very lengthy and informative info message that wraps across multiple lines and grows in height as needed.")
8687
var infoConfig = SwiftMessages.defaultConfig
8788
infoConfig.presentationStyle = .bottom
8889
infoConfig.duration = .seconds(seconds: 0.25)
8990

90-
let status = MessageView.viewFromNib(layout: .StatusLine)
91+
let status = MessageView.viewFromNib(layout: .statusLine)
9192
status.backgroundView.backgroundColor = UIColor.purple
9293
status.bodyLabel?.textColor = UIColor.white
9394
status.configureContent(body: "A tiny line of text covering the status bar.")
9495
var statusConfig = SwiftMessages.defaultConfig
9596
statusConfig.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
9697

97-
let status2 = MessageView.viewFromNib(layout: .StatusLine)
98+
let status2 = MessageView.viewFromNib(layout: .statusLine)
9899
status2.backgroundView.backgroundColor = UIColor.orange
99100
status2.bodyLabel?.textColor = UIColor.white
100101
status2.configureContent(body: "Switched to light status bar!")
@@ -138,8 +139,20 @@ class ViewController: UITableViewController {
138139
SwiftMessages.show(config: config, view: view)
139140
}
140141

141-
static func demoExplore() {
142-
142+
static func demoCentered() {
143+
let messageView: MessageView = MessageView.viewFromNib(layout: .centeredView)
144+
messageView.configureBackgroundView(width: 250)
145+
messageView.configureContent(title: "Hey There!", body: "Please try swiping to dismiss this message.", iconImage: nil, iconText: "🦄", buttonImage: nil, buttonTitle: "No Thanks") { _ in
146+
SwiftMessages.hide()
147+
}
148+
messageView.backgroundView.backgroundColor = UIColor.init(white: 0.97, alpha: 1)
149+
messageView.backgroundView.layer.cornerRadius = 12
150+
var config = SwiftMessages.defaultConfig
151+
config.presentationStyle = .center
152+
config.duration = .forever
153+
config.dimMode = .blur(style: .dark, alpha: 1, interactive: true)
154+
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
155+
SwiftMessages.show(config: config, view: messageView)
143156
}
144157
}
145158

@@ -149,7 +162,7 @@ enum Item {
149162

150163
case titleBody(title: String, body: String, function: Function)
151164
case explore
152-
165+
153166
func dequeueCell(_ tableView: UITableView) -> UITableViewCell {
154167
switch self {
155168
case .titleBody(let data):

Demo/Podfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- SwiftMessages (3.3.0)
2+
- SwiftMessages (3.4.0)
33

44
DEPENDENCIES:
55
- SwiftMessages (from `../`)
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
SwiftMessages: 1e6f8140374c014befafcbf3149da86b323b0575
12+
SwiftMessages: dd4ce974e4b8f20e4cde4c77a33577c6ae5e17a0
1313

1414
PODFILE CHECKSUM: 6431c980c9207084d738b6ba87b2101dd9eb5097
1515

16-
COCOAPODS: 1.2.0
16+
COCOAPODS: 1.2.1

Demo/Pods/Local Podspecs/SwiftMessages.podspec.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/Pods/Manifest.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)