Skip to content

Commit

Permalink
[master] - Release 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Daltron committed Jul 17, 2019
1 parent 07c1c00 commit 3eff4e2
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Example/NotificationBanner/CustomBannerColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CustomBannerColors: BannerColors {
switch style {
case .danger: return super.color(for: style)
case .info: return super.color(for: style)
case .none: return super.color(for: style)
case .customView: return super.color(for: style)
case .success: return super.color(for: style)
case .warning: return UIColor(red:0.99, green:0.40, blue:0.13, alpha:1.00)
}
Expand Down
34 changes: 31 additions & 3 deletions Example/NotificationBanner/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ extension ExampleViewController: ExampleViewDelegate {
// Basic Warning Notification with Custom Color
let banner = NotificationBanner(title: "Basic Notification",
subtitle: "Must Be Dismissed Manually",
style: .none)
style: .customView)
banner.delegate = self
banner.backgroundColor = blockColor(at: IndexPath(row: 5, section: 0))
banner.autoDismiss = false
Expand Down Expand Up @@ -230,19 +230,36 @@ extension ExampleViewController: ExampleViewDelegate {
let banner = FloatingNotificationBanner(title: "Success Notification",
subtitle: "This type of banner floats and has the capability of growing to an infinite amount of lines. This one also has a shadow.",
style: .success)

banner.delegate = self
banner.show(queuePosition: selectedQueuePosition(),
bannerPosition: selectedBannerPosition(),
cornerRadius: 10,
shadowBlurRadius: 15)
default:
case 1:
let banner = FloatingNotificationBanner(title: "Danger Notification",
subtitle: "This type of banner floats and has the capability of growing to an infinite amount of lines.",
style: .danger)
banner.delegate = self
banner.show(queuePosition: selectedQueuePosition(),
bannerPosition: selectedBannerPosition(),
cornerRadius: 10)
case 2:
let banner = FloatingNotificationBanner(title: "Info Notification",
subtitle: "With adjusted transparency!",
style: .info)
banner.delegate = self
banner.transparency = 0.75
banner.show(queuePosition: selectedQueuePosition(),
bannerPosition: selectedBannerPosition(),
cornerRadius: 10)
default:
let banner = FloatingNotificationBanner(customView: NorthCarolinaBannerView())
banner.delegate = self
banner.show(queuePosition: selectedQueuePosition(),
bannerPosition: selectedBannerPosition(),
cornerRadius: 10,
shadowBlurRadius: 15)
}
}

Expand Down Expand Up @@ -314,7 +331,7 @@ extension ExampleViewController: ExampleViewDelegate {
case 3:
return 2
case 4:
return 2
return 4
case 5:
return 6
default:
Expand Down Expand Up @@ -420,6 +437,10 @@ extension ExampleViewController: ExampleViewDelegate {
return ("Success Notification", "This type of banner can float and can have its cornerRadius property adjusted")
case 1:
return ("Danger Notification", "This type of banner can float and can have its cornerRadius property adjusted")
case 2:
return ("Info Notification", "With adjusted transparency!")
case 3:
return ("Tarheels Notification", "This type of banner can float and can have its cornerRadius property adjusted")
default:
return ("", nil)
}
Expand Down Expand Up @@ -453,6 +474,13 @@ extension ExampleViewController: ExampleViewDelegate {
default:
return nil
}
} else if indexPath.section == 4 {
switch indexPath.row {
case 3:
return #imageLiteral(resourceName: "unc_logo")
default:
return nil
}
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion NotificationBanner/Classes/BannerColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BannerColors: BannerColorsProtocol {
switch style {
case .danger: return UIColor(red:0.90, green:0.31, blue:0.26, alpha:1.00)
case .info: return UIColor(red:0.23, green:0.60, blue:0.85, alpha:1.00)
case .none: return UIColor.clear
case .customView: return UIColor.clear
case .success: return UIColor(red:0.22, green:0.80, blue:0.46, alpha:1.00)
case .warning: return UIColor(red:1.00, green:0.66, blue:0.16, alpha:1.00)
}
Expand Down
2 changes: 1 addition & 1 deletion NotificationBanner/Classes/BannerStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
public enum BannerStyle: Int {
case danger
case info
case none
case customView
case success
case warning
}
Expand Down
21 changes: 17 additions & 4 deletions NotificationBanner/Classes/BaseNotificationBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class BaseNotificationBanner: UIView {

/// The delegate of the notification banner
public weak var delegate: NotificationBannerDelegate?

/// The style of the notification banner
public let style: BannerStyle

/// The height of the banner when it is presented
public var bannerHeight: CGFloat {
Expand Down Expand Up @@ -82,6 +85,14 @@ public class BaseNotificationBanner: UIView {
}
}

/// The transparency of the background of the notification banner
public var transparency: CGFloat = 1.0 {
didSet {
let color = backgroundColor
self.backgroundColor = color
}
}

/// The type of haptic to generate when a banner is displayed
public var haptic: BannerHaptic = .heavy

Expand Down Expand Up @@ -154,12 +165,14 @@ public class BaseNotificationBanner: UIView {
get {
return contentView.backgroundColor
} set {
contentView.backgroundColor = newValue
spacerView.backgroundColor = newValue
let color = newValue?.withAlphaComponent(transparency)
contentView.backgroundColor = color
spacerView.backgroundColor = color
}
}

init(style: BannerStyle, colors: BannerColorsProtocol? = nil) {
self.style = style
super.init(frame: .zero)

spacerView = UIView()
Expand All @@ -179,8 +192,8 @@ public class BaseNotificationBanner: UIView {
addGestureRecognizer(swipeUpGesture)
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

deinit {
Expand Down
17 changes: 16 additions & 1 deletion NotificationBanner/Classes/FloatingNotificationBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public class FloatingNotificationBanner: GrowingNotificationBanner {
}
}

public init(customView: UIView) {
super.init(style: .customView)
contentView.addSubview(customView)
customView.snp.makeConstraints { (make) in
make.edges.equalTo(contentView)
}

spacerView.backgroundColor = customView.backgroundColor
}

/**
Convenience function to display banner with non .zero default edge insets
*/
Expand All @@ -84,6 +94,11 @@ public class FloatingNotificationBanner: GrowingNotificationBanner {

if let cornerRadius = cornerRadius {
contentView.layer.cornerRadius = cornerRadius
contentView.subviews.last?.layer.cornerRadius = cornerRadius
}

if style == .customView, let customView = contentView.subviews.last {
customView.backgroundColor = customView.backgroundColor?.withAlphaComponent(transparency)
}

show(queuePosition: queuePosition,
Expand Down Expand Up @@ -116,7 +131,7 @@ private extension FloatingNotificationBanner {
cornerRadius: CGFloat = 0,
offset: UIOffset = .zero,
edgeInsets: UIEdgeInsets? = nil) {

guard blurRadius > 0 else { return }

This comment has been minimized.

Copy link
@mrsnow-git

mrsnow-git Sep 6, 2019

Contributor

This is mistake - shadow can exist even if blurradius == zero, but have offset. Why you added it?

contentView.layer.shadowColor = color.cgColor
contentView.layer.shadowOpacity = Float(opacity)
contentView.layer.shadowRadius = blurRadius
Expand Down
2 changes: 1 addition & 1 deletion NotificationBanner/Classes/NotificationBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public class NotificationBanner: BaseNotificationBanner {
}

public init(customView: UIView) {
super.init(style: .none)
super.init(style: .customView)
contentView.addSubview(customView)
customView.snp.makeConstraints { (make) in
make.edges.equalTo(contentView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class StatusBarNotificationBanner: BaseNotificationBanner {
}

public init(customView: UIView) {
super.init(style: .none)
super.init(style: .customView)
contentView.addSubview(customView)
customView.snp.makeConstraints { make in
make.edges.equalTo(contentView)
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 = '2.4.1'
s.version = '2.5.0'
s.summary = 'The easiest way to display in app notification banners in iOS.'

s.description = <<-DESC
Expand Down

0 comments on commit 3eff4e2

Please sign in to comment.