Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Add support to custom placeholder color #95

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public struct WysiwygComposerView: View {
// MARK: - Private

private let placeholder: String
private let placeholderColor: Color
private let viewModel: WysiwygComposerViewModelProtocol
private let itemProviderHelper: WysiwygItemProviderHelper?
private let keyCommandHandler: KeyCommandHandler?
Expand All @@ -51,6 +52,7 @@ public struct WysiwygComposerView: View {
///
/// - Parameters:
/// - placeholder: Placeholder for empty composer.
/// - placeholderColor: The color of the placeholder.
/// - viewModel: The main view model of the composer.
/// See `WysiwygComposerViewModel.swift` for triggerable actions.
/// - itemProviderHelper: A helper to determine if an item can be pasted into the hosting application.
Expand All @@ -60,11 +62,13 @@ public struct WysiwygComposerView: View {
/// - pasteHandler: A handler for paste events.
/// If omitted, the composer will try to paste content as raw text.
public init(placeholder: String,
placeholderColor: Color = .init(UIColor.placeholderText),
viewModel: WysiwygComposerViewModelProtocol,
itemProviderHelper: WysiwygItemProviderHelper?,
keyCommandHandler: KeyCommandHandler?,
pasteHandler: PasteHandler?) {
self.placeholder = placeholder
self.placeholderColor = placeholderColor
self.viewModel = viewModel
self.itemProviderHelper = itemProviderHelper
self.keyCommandHandler = keyCommandHandler
Expand All @@ -87,7 +91,7 @@ public struct WysiwygComposerView: View {
if viewModel.isContentEmpty {
Text(placeholder)
.font(Font(UIFont.preferredFont(forTextStyle: .body)))
.foregroundColor(Color(UIColor.placeholderText))
.foregroundColor(placeholderColor)
.accessibilityHidden(true)
}
}
Expand Down