Skip to content

Commit 2ce5c49

Browse files
committed
[master] - Release v3.0.6
1 parent 32daef4 commit 2ce5c49

File tree

7 files changed

+88
-48
lines changed

7 files changed

+88
-48
lines changed

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- MarqueeLabel (4.0.5)
3-
- NotificationBannerSwift (3.0.3):
3+
- NotificationBannerSwift (3.0.5):
44
- MarqueeLabel (~> 4.0.5)
55
- SnapKit (~> 5.0.1)
66
- Reveal-SDK (27)
@@ -22,7 +22,7 @@ EXTERNAL SOURCES:
2222

2323
SPEC CHECKSUMS:
2424
MarqueeLabel: 00cc0bcd087111dca575878b3531af980559707d
25-
NotificationBannerSwift: f3c11fce47c2f3b6ec7cd62af2c91f75871ca0b2
25+
NotificationBannerSwift: 7642b11ee9c2ac8a0abda33f9a5b4cb665f068b1
2626
Reveal-SDK: 306e2880395ee396f5a8b4c485c3a86dd19866c7
2727
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
2828

Example/Pods/Local Podspecs/NotificationBannerSwift.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Target Support Files/NotificationBannerSwift/NotificationBannerSwift-Info.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NotificationBanner/Classes/BaseNotificationBanner.swift

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ open class BaseNotificationBanner: UIView {
217217
}
218218

219219
deinit {
220-
NotificationCenter.default.removeObserver(self,
221-
name: UIDevice.orientationDidChangeNotification,
222-
object: nil)
220+
NotificationCenter.default.removeObserver(
221+
self,
222+
name: UIDevice.orientationDidChangeNotification,
223+
object: nil
224+
)
223225
}
224226

225227
/**
@@ -508,8 +510,9 @@ open class BaseNotificationBanner: UIView {
508510
Changes the frame of the notification banner when the orientation of the device changes
509511
*/
510512
@objc private dynamic func onOrientationChanged() {
511-
guard let window = appWindow else { return }
512-
513+
guard let window = appWindow,
514+
currentDeviceOrientationIsSupportedByApp() else { return }
515+
513516
updateSpacerViewHeight()
514517

515518
let edgeInsets = bannerEdgeInsets ?? .zero
@@ -619,8 +622,8 @@ open class BaseNotificationBanner: UIView {
619622

620623

621624
/**
622-
Determines wether or not the status bar should be shown when displaying a banner underneath
623-
the navigation bar
625+
Determines wether or not the status bar should be shown when displaying
626+
a banner underneath the navigation bar
624627
*/
625628
private func statusBarShouldBeShown() -> Bool {
626629

@@ -632,6 +635,27 @@ open class BaseNotificationBanner: UIView {
632635

633636
return true
634637
}
638+
639+
/**
640+
Determines wether or not the current orientation that the device is in
641+
is supported by the current application.
642+
*/
643+
private func currentDeviceOrientationIsSupportedByApp() -> Bool {
644+
let supportedOrientations = UIApplication.shared.supportedInterfaceOrientations(for: appWindow)
645+
646+
switch UIDevice.current.orientation {
647+
case .portrait:
648+
return supportedOrientations.contains(.portrait)
649+
case .portraitUpsideDown:
650+
return supportedOrientations.contains(.portraitUpsideDown)
651+
case .landscapeLeft:
652+
return supportedOrientations.contains(.landscapeLeft)
653+
case .landscapeRight:
654+
return supportedOrientations.contains(.landscapeRight)
655+
default:
656+
return false
657+
}
658+
}
635659

636660
/**
637661
Calculates the maximum `y` position that a notification banner can slide in from

NotificationBannerSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Pod::Spec.new do |s|
33
s.name = 'NotificationBannerSwift'
4-
s.version = '3.0.5'
4+
s.version = '3.0.6'
55
s.summary = 'The easiest way to display in app notification banners in iOS.'
66

77
s.description = <<-DESC

README.md

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,21 @@ banner.delegate = self
242242
Then just make sure to implement the following methods:
243243

244244
```swift
245-
internal func notificationBannerWillAppear(_ banner: BaseNotificationBanner)
246-
internal func notificationBannerDidAppear(_ banner: BaseNotificationBanner)
247-
internal func notificationBannerWillDisappear(_ banner: BaseNotificationBanner)
248-
internal func notificationBannerDidDisappear(_ banner: BaseNotificationBanner)
245+
func notificationBannerWillAppear(_ banner: BaseNotificationBanner)
246+
func notificationBannerDidAppear(_ banner: BaseNotificationBanner)
247+
func notificationBannerWillDisappear(_ banner: BaseNotificationBanner)
248+
func notificationBannerDidDisappear(_ banner: BaseNotificationBanner)
249249
```
250250

251251
## Haptic Feedback Support
252252
By default, when a banner is displayed, a haptic feedback will be generated on devices that support it. The types of haptic feedback are as follows:
253253

254254
```swift
255255
public enum BannerHaptic {
256-
case light
257-
case medium
258-
case heavy
259-
case none
256+
case light
257+
case medium
258+
case heavy
259+
case none
260260
}
261261
```
262262

@@ -301,50 +301,66 @@ let bannerQueueToDisplaySeveralBanners = NotificationBannerQueue(maxBannersOnScr
301301
Create five different banners:
302302

303303
```swift
304-
let banner1 = FloatingNotificationBanner(title: "Success Notification - 1",
305-
subtitle: "First Notification from 5 in current queue with 3 banners allowed simultaneously",
306-
style: .success)
304+
let banner1 = FloatingNotificationBanner(
305+
title: "Success Notification - 1",
306+
subtitle: "First Notification from 5 in current queue with 3 banners allowed simultaneously",
307+
style: .success
308+
)
307309
banner1.delegate = self
308310

309-
let banner2 = FloatingNotificationBanner(title: "Danger Notification - 2",
310-
subtitle: "Second Notification from 5 in current queue with 3 banners allowed simultaneously",
311-
style: .danger)
311+
let banner2 = FloatingNotificationBanner(
312+
title: "Danger Notification - 2",
313+
subtitle: "Second Notification from 5 in current queue with 3 banners allowed simultaneously",
314+
style: .danger
315+
)
312316
banner2.delegate = self
313317

314-
let banner3 = FloatingNotificationBanner(title: "Info Notification - 3",
315-
subtitle: "Third Notification from 5 in current queue with 3 banners allowed simultaneously",
316-
style: .info)
318+
let banner3 = FloatingNotificationBanner(
319+
title: "Info Notification - 3",
320+
subtitle: "Third Notification from 5 in current queue with 3 banners allowed simultaneously",
321+
style: .info
322+
)
317323
banner3.delegate = self
318324

319-
let banner4 = FloatingNotificationBanner(title: "Success Notification - 4",
320-
subtitle: "Fourth Notification from 5 in current queue with 3 banners allowed simultaneously",
321-
style: .success)
325+
let banner4 = FloatingNotificationBanner(
326+
title: "Success Notification - 4",
327+
subtitle: "Fourth Notification from 5 in current queue with 3 banners allowed simultaneously",
328+
style: .success
329+
)
322330
banner4.delegate = self
323331

324-
let banner5 = FloatingNotificationBanner(title: "Info Notification - 5",
325-
subtitle: "Fifth Notification from 5 in current queue with 3 banners allowed simultaneously",
326-
style: .info)
332+
let banner5 = FloatingNotificationBanner(
333+
title: "Info Notification - 5",
334+
subtitle: "Fifth Notification from 5 in current queue with 3 banners allowed simultaneously",
335+
style: .info
336+
)
327337
banner5.delegate = self
328338
```
329339

330340
and show all five banners at once:
331341
```swift
332-
showBanners([banner1, banner2, banner3, banner4, banner5],
333-
in: bannerQueue5AllowedMixed)
342+
showBanners(
343+
[banner1, banner2, banner3, banner4, banner5],
344+
in: bannerQueue5AllowedMixed
345+
)
334346
```
335347

336348
using this supporting method
337349

338350
```swift
339-
func showBanners(_ banners: [FloatingNotificationBanner],
340-
in notificationBannerQueue: NotificationBannerQueue) {
351+
func showBanners(
352+
_ banners: [FloatingNotificationBanner],
353+
in notificationBannerQueue: NotificationBannerQueue
354+
) {
341355
banners.forEach { banner in
342-
banner.show(bannerPosition: selectedBannerPosition(),
343-
queue: notificationBannerQueue,
344-
cornerRadius: 8,
345-
shadowColor: UIColor(red: 0.431, green: 0.459, blue: 0.494, alpha: 1),
346-
shadowBlurRadius: 16,
347-
shadowEdgeInsets: UIEdgeInsets(top: 8, left: 8, bottom: 0, right: 8))
356+
banner.show(
357+
bannerPosition: selectedBannerPosition(),
358+
queue: notificationBannerQueue,
359+
cornerRadius: 8,
360+
shadowColor: UIColor(red: 0.431, green: 0.459, blue: 0.494, alpha: 1),
361+
shadowBlurRadius: 16,
362+
shadowEdgeInsets: UIEdgeInsets(top: 8, left: 8, bottom: 0, right: 8)
363+
)
348364
}
349365
}
350366
```

0 commit comments

Comments
 (0)