Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for Dark Mode on iOS 13 #170

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Example/Swift/Bulletin/BulletinDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,16 @@ enum BulletinDataSource {
let page = BLTNPageItem(title: "Setup Completed")
page.image = #imageLiteral(resourceName: "IntroCompletion")
page.imageAccessibilityLabel = "Checkmark"
page.appearance.actionButtonColor = #colorLiteral(red: 0.2980392157, green: 0.8509803922, blue: 0.3921568627, alpha: 1)
page.appearance.imageViewTintColor = #colorLiteral(red: 0.2980392157, green: 0.8509803922, blue: 0.3921568627, alpha: 1)

let tintColor: UIColor
if #available(iOS 13.0, *) {
tintColor = .systemGreen
} else {
tintColor = #colorLiteral(red: 0.2980392157, green: 0.8509803922, blue: 0.3921568627, alpha: 1)
}
page.appearance.actionButtonColor = tintColor
page.appearance.imageViewTintColor = tintColor

page.appearance.actionButtonTitleColor = .white

page.descriptionText = "PetBoard is ready for you to use. Happy browsing!"
Expand Down
50 changes: 40 additions & 10 deletions Sources/Appearance/BLTNItemAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ import UIKit

// MARK: - Color Customization

/// The tint color to apply to the action button (default blue).
@objc public var actionButtonColor: UIColor = #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
/// The tint color to apply to the action button (default `.link` on iOS 13 and `.blue` on older systems).
@objc public var actionButtonColor: UIColor = {
if #available(iOS 13.0, *) {
return .link
} else {
return #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
}
}()

/// The button image to apply to the action button
@objc public var actionButtonImage: UIImage?
Expand All @@ -28,23 +34,47 @@ import UIKit
/// The border width to apply to action button.
@objc public var actionButtonBorderWidth: CGFloat = 1.0

/// The title color to apply to the alternative button (default blue).
@objc public var alternativeButtonTitleColor: UIColor = #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
/// The title color to apply to the alternative button (default `.link` on iOS 13 and `.blue` on older systems).
@objc public var alternativeButtonTitleColor: UIColor = {
if #available(iOS 13.0, *) {
return .link
} else {
return #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
}
}()

/// The border color to apply to the alternative button.
@objc public var alternativeButtonBorderColor: UIColor? = nil

/// The border width to apply to the alternative button.
@objc public var alternativeButtonBorderWidth: CGFloat = 1.0

/// The tint color to apply to the imageView (if image rendered in template mode, default blue).
@objc public var imageViewTintColor = #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
/// The tint color to apply to the imageView (if image rendered in template mode, default `.link` on iOS 13 and `.blue` on older systems).
@objc public var imageViewTintColor: UIColor = {
if #available(iOS 13.0, *) {
return .link
} else {
return #colorLiteral(red: 0, green: 0.4784313725, blue: 1, alpha: 1)
}
}()

/// The color of title text labels (default light gray).
@objc public var titleTextColor = #colorLiteral(red: 0.568627451, green: 0.5647058824, blue: 0.5725490196, alpha: 1)
/// The color of title text labels (default `.secondaryLabel` on iOS 13 and light gray on older systems).
@objc public var titleTextColor: UIColor = {
if #available(iOS 13.0, *) {
return .secondaryLabel
} else {
return #colorLiteral(red: 0.568627451, green: 0.5647058824, blue: 0.5725490196, alpha: 1)
}
}()

/// The color of description text labels (default black).
@objc public var descriptionTextColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
/// The color of description text labels (default `.label` on iOS 13 and black on older systems).
@objc public var descriptionTextColor: UIColor = {
if #available(iOS 13.0, *) {
return .label
} else {
return #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
}
}()

// MARK: - Corner Radius Customization

Expand Down
28 changes: 22 additions & 6 deletions Sources/BLTNItemManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ import UIKit
// MARK: - Background

/**
* The background color of the bulletin card. Defaults to white.
* The background color of the bulletin card. Defaults to `systemBackground` on iOS 13
* and white on older versions of the OS.
*
* Set this value before presenting the bulletin. Changing it after will have no effect.
*/

@objc public var backgroundColor: UIColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
@objc public var backgroundColor: UIColor = {
if #available(iOS 13.0, *) {
return .systemBackground
} else {
return .white
}
}()

/**
* The style of the view covering the content. Defaults to `.dimmed`.
Expand Down Expand Up @@ -247,21 +254,30 @@ extension BLTNItemManager {
* Displaying the loading indicator does not change the height of the page or the current item. It will disable
* dismissal by tapping and swiping to allow the task to complete and avoid resource deallocation.
*
* - parameter color: The color of the activity indicator to display. Defaults to black.
* - parameter color: The color of the activity indicator to display. Defaults to .label on iOS 13 and .black on older systems.
*
* Displaying the loading indicator does not change the height of the page or the current item.
*/

@objc public func displayActivityIndicator(color: UIColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)) {
@objc public func displayActivityIndicator(color: UIColor? = nil) {

assertIsPrepared()
assertIsMainThread()

shouldDisplayActivityIndicator = true
lastActivityIndicatorColor = color
lastActivityIndicatorColor = color ?? defaultActivityIndicatorColor

bulletinController.displayActivityIndicator(color: color)
bulletinController.displayActivityIndicator(color: lastActivityIndicatorColor)
}

/// Provides a default color for activity indicator views.
/// Defaults to .label on iOS 13 and .black on older systems.
private var defaultActivityIndicatorColor: UIColor {
if #available(iOS 13.0, *) {
return .label
} else {
return .black
}
}

/**
Expand Down