Skip to content

Commit

Permalink
[master] - Release v3.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Daltron committed Dec 17, 2020
1 parent 32daef4 commit 2ce5c49
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- MarqueeLabel (4.0.5)
- NotificationBannerSwift (3.0.3):
- NotificationBannerSwift (3.0.5):
- MarqueeLabel (~> 4.0.5)
- SnapKit (~> 5.0.1)
- Reveal-SDK (27)
Expand All @@ -22,7 +22,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
MarqueeLabel: 00cc0bcd087111dca575878b3531af980559707d
NotificationBannerSwift: f3c11fce47c2f3b6ec7cd62af2c91f75871ca0b2
NotificationBannerSwift: 7642b11ee9c2ac8a0abda33f9a5b4cb665f068b1
Reveal-SDK: 306e2880395ee396f5a8b4c485c3a86dd19866c7
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 31 additions & 7 deletions NotificationBanner/Classes/BaseNotificationBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ open class BaseNotificationBanner: UIView {
}

deinit {
NotificationCenter.default.removeObserver(self,
name: UIDevice.orientationDidChangeNotification,
object: nil)
NotificationCenter.default.removeObserver(
self,
name: UIDevice.orientationDidChangeNotification,
object: nil
)
}

/**
Expand Down Expand Up @@ -508,8 +510,9 @@ open class BaseNotificationBanner: UIView {
Changes the frame of the notification banner when the orientation of the device changes
*/
@objc private dynamic func onOrientationChanged() {
guard let window = appWindow else { return }

guard let window = appWindow,
currentDeviceOrientationIsSupportedByApp() else { return }

updateSpacerViewHeight()

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


/**
Determines wether or not the status bar should be shown when displaying a banner underneath
the navigation bar
Determines wether or not the status bar should be shown when displaying
a banner underneath the navigation bar
*/
private func statusBarShouldBeShown() -> Bool {

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

return true
}

/**
Determines wether or not the current orientation that the device is in
is supported by the current application.
*/
private func currentDeviceOrientationIsSupportedByApp() -> Bool {
let supportedOrientations = UIApplication.shared.supportedInterfaceOrientations(for: appWindow)

switch UIDevice.current.orientation {
case .portrait:
return supportedOrientations.contains(.portrait)
case .portraitUpsideDown:
return supportedOrientations.contains(.portraitUpsideDown)
case .landscapeLeft:
return supportedOrientations.contains(.landscapeLeft)
case .landscapeRight:
return supportedOrientations.contains(.landscapeRight)
default:
return false
}
}

/**
Calculates the maximum `y` position that a notification banner can slide in from
Expand Down
2 changes: 1 addition & 1 deletion NotificationBannerSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'NotificationBannerSwift'
s.version = '3.0.5'
s.version = '3.0.6'
s.summary = 'The easiest way to display in app notification banners in iOS.'

s.description = <<-DESC
Expand Down
82 changes: 49 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,21 @@ banner.delegate = self
Then just make sure to implement the following methods:

```swift
internal func notificationBannerWillAppear(_ banner: BaseNotificationBanner)
internal func notificationBannerDidAppear(_ banner: BaseNotificationBanner)
internal func notificationBannerWillDisappear(_ banner: BaseNotificationBanner)
internal func notificationBannerDidDisappear(_ banner: BaseNotificationBanner)
func notificationBannerWillAppear(_ banner: BaseNotificationBanner)
func notificationBannerDidAppear(_ banner: BaseNotificationBanner)
func notificationBannerWillDisappear(_ banner: BaseNotificationBanner)
func notificationBannerDidDisappear(_ banner: BaseNotificationBanner)
```

## Haptic Feedback Support
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:

```swift
public enum BannerHaptic {
case light
case medium
case heavy
case none
case light
case medium
case heavy
case none
}
```

Expand Down Expand Up @@ -301,50 +301,66 @@ let bannerQueueToDisplaySeveralBanners = NotificationBannerQueue(maxBannersOnScr
Create five different banners:

```swift
let banner1 = FloatingNotificationBanner(title: "Success Notification - 1",
subtitle: "First Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .success)
let banner1 = FloatingNotificationBanner(
title: "Success Notification - 1",
subtitle: "First Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .success
)
banner1.delegate = self

let banner2 = FloatingNotificationBanner(title: "Danger Notification - 2",
subtitle: "Second Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .danger)
let banner2 = FloatingNotificationBanner(
title: "Danger Notification - 2",
subtitle: "Second Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .danger
)
banner2.delegate = self

let banner3 = FloatingNotificationBanner(title: "Info Notification - 3",
subtitle: "Third Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .info)
let banner3 = FloatingNotificationBanner(
title: "Info Notification - 3",
subtitle: "Third Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .info
)
banner3.delegate = self

let banner4 = FloatingNotificationBanner(title: "Success Notification - 4",
subtitle: "Fourth Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .success)
let banner4 = FloatingNotificationBanner(
title: "Success Notification - 4",
subtitle: "Fourth Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .success
)
banner4.delegate = self

let banner5 = FloatingNotificationBanner(title: "Info Notification - 5",
subtitle: "Fifth Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .info)
let banner5 = FloatingNotificationBanner(
title: "Info Notification - 5",
subtitle: "Fifth Notification from 5 in current queue with 3 banners allowed simultaneously",
style: .info
)
banner5.delegate = self
```

and show all five banners at once:
```swift
showBanners([banner1, banner2, banner3, banner4, banner5],
in: bannerQueue5AllowedMixed)
showBanners(
[banner1, banner2, banner3, banner4, banner5],
in: bannerQueue5AllowedMixed
)
```

using this supporting method

```swift
func showBanners(_ banners: [FloatingNotificationBanner],
in notificationBannerQueue: NotificationBannerQueue) {
func showBanners(
_ banners: [FloatingNotificationBanner],
in notificationBannerQueue: NotificationBannerQueue
) {
banners.forEach { banner in
banner.show(bannerPosition: selectedBannerPosition(),
queue: notificationBannerQueue,
cornerRadius: 8,
shadowColor: UIColor(red: 0.431, green: 0.459, blue: 0.494, alpha: 1),
shadowBlurRadius: 16,
shadowEdgeInsets: UIEdgeInsets(top: 8, left: 8, bottom: 0, right: 8))
banner.show(
bannerPosition: selectedBannerPosition(),
queue: notificationBannerQueue,
cornerRadius: 8,
shadowColor: UIColor(red: 0.431, green: 0.459, blue: 0.494, alpha: 1),
shadowBlurRadius: 16,
shadowEdgeInsets: UIEdgeInsets(top: 8, left: 8, bottom: 0, right: 8)
)
}
}
```
Expand Down

0 comments on commit 2ce5c49

Please sign in to comment.