AttributedText icon indicating copy to clipboard operation
AttributedText copied to clipboard

Added access to linkTextAttributes

Open jefferythomas opened this issue 3 years ago • 0 comments

Description

A Pull Request to implement a solution for issue https://github.com/gonzalezreal/AttributedText/issues/21.

Created linkTextAttributes environment value. Added linkTextAttributes view modifier. Set the linkTextAttributes in iOS, macOS, and tvOS based on the context environment.

Implementation

Added linkTextAttributes as an internal property of EnvironmentValues. This limits access to linkTextAttributes to just the AttributedText package. In AttributedTextImpl.updateUIView, if linkTextAttributes has been set, then set the underlying TextView's linkTextAttributes property.

Examples

There are two ways of setting the linkTextAttributes.

  1. Setting with a value
AttributedText(…)
  .linkTextAttributes([.foregroundColor: UIColor.black])
  1. Setting with a closure
AttributedText(…)
  .linkTextAttributes {
    [.foregroundColor: UIColor.black]
  }

jefferythomas avatar Mar 13 '22 20:03 jefferythomas