Skip to content
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A µFramework for showing alerts like the one used when copying from pasteboard
- iOS 13+
- Can be used in SwiftUI and UIKit applications
- Light/Dark modes
- Custom colors for title, subtitle and icon
- Interactive dismissal
- Queue to show consecutive drops
- Support dynamic font sizing
Expand Down Expand Up @@ -54,7 +55,8 @@ let drop = Drop(
},
position: .bottom,
duration: 5.0,
accessibility: "Alert: Title, Subtitle"
accessibility: "Alert: Title, Subtitle",
titleColor: .blue
)
```

Expand Down
23 changes: 22 additions & 1 deletion Sources/Drop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public struct Drop: ExpressibleByStringLiteral {
/// - position: Position. Defaults to `Drop.Position.top`.
/// - duration: Duration. Defaults to `Drop.Duration.recommended`.
/// - accessibility: Accessibility options. Defaults to `nil` which will use "title, subtitle" as its message.
/// - titleColor: Title color. Defaults to `.label`.
/// - subtitleColor: Subtitle color. Defaults to `.secondaryLabel`.
/// - iconColor: Icon color. Defaults to `.secondaryLabel`.
public init(
title: String,
titleNumberOfLines: Int = 1,
Expand All @@ -49,7 +52,10 @@ public struct Drop: ExpressibleByStringLiteral {
action: Action? = nil,
position: Position = .top,
duration: Duration = .recommended,
accessibility: Accessibility? = nil
accessibility: Accessibility? = nil,
titleColor: UIColor = .label,
subtitleColor: UIColor = .secondaryLabel,
iconColor: UIColor = .secondaryLabel
) {
self.title = title.trimmingCharacters(in: .whitespacesAndNewlines)
self.titleNumberOfLines = titleNumberOfLines
Expand All @@ -63,6 +69,9 @@ public struct Drop: ExpressibleByStringLiteral {
self.duration = duration
self.accessibility = accessibility
?? .init(message: [title, subtitle].compactMap { $0 }.joined(separator: ", "))
self.titleColor = titleColor
self.subtitleColor = subtitleColor
self.iconColor = iconColor
}

/// Create a new accessibility object.
Expand All @@ -74,6 +83,9 @@ public struct Drop: ExpressibleByStringLiteral {
position = .top
duration = .recommended
accessibility = .init(message: title)
titleColor = .label
subtitleColor = .secondaryLabel
iconColor = .secondaryLabel
}

/// Title.
Expand Down Expand Up @@ -102,6 +114,15 @@ public struct Drop: ExpressibleByStringLiteral {

/// Accessibility.
public var accessibility: Accessibility

/// Title Color.
public var titleColor: UIColor

/// Subtitle Color.
public var subtitleColor: UIColor

/// Title Color.
public var iconColor: UIColor
}

public extension Drop {
Expand Down
3 changes: 3 additions & 0 deletions Sources/DropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@ internal final class DropView: UIView {

titleLabel.text = drop.title
titleLabel.numberOfLines = drop.titleNumberOfLines
titleLabel.textColor = drop.titleColor

subtitleLabel.text = drop.subtitle
subtitleLabel.numberOfLines = drop.subtitleNumberOfLines
subtitleLabel.isHidden = drop.subtitle == nil
subtitleLabel.textColor = drop.subtitleColor

imageView.image = drop.icon
imageView.isHidden = drop.icon == nil
imageView.tintColor = drop.iconColor

button.setImage(drop.action?.icon, for: .normal)
button.isHidden = drop.action?.icon == nil
Expand Down