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

Commit

Permalink
Merge pull request #810 from matrix-org/alfogrillo/placeholder-color
Browse files Browse the repository at this point in the history
[iOS] Add support to custom placeholder color
  • Loading branch information
Alfonso Grillo authored Sep 15, 2023
2 parents 2b4aa1e + 11f9833 commit 5aca3bb
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 5aca3bb

Please sign in to comment.