AttributedString attributes not implemented
Open
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 330
- Forks
- 76
- Avg merge
- 3h 6m
- Merged PRs (30d)
- 1
Description
struct WelcomeView : View {
var text: AttributedString {
var attributedString = AttributedString("Welcome")
// Apply attributes to the whole string
attributedString.font = Font.system(size: 16)
attributedString.foregroundColor = Color.blue
attributedString.underlineStyle = Text.LineStyle.single
return attributedString
}
var body: some View {
VStack(spacing: 0) {
Text(text)
.padding()
}
}
}
None of this works in SkipUI.
Unresolved reference 'font'.
Unresolved reference 'foregroundColor'.
Unresolved reference 'underlineStyle'.
Also, AttributedStrings support adding attributes to ranges.
struct WelcomeView : View {
var text: AttributedString {
var attributedString = AttributedString("Hello, this part uses a Custom Font!")
let range = attributedString.range(of: "Custom Font")!
attributedString[range].font = Font.custom("Georgia", size: 32)
attributedString[range].foregroundColor = Color.blue
attributedString[range].underlineStyle = Text.LineStyle.single
return attributedString
}
var body: some View {
VStack(spacing: 0) {
Text(text)
.padding()
}
}
}
This doesn't work either.
Unresolved reference 'range'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two AttributedString examples in SkipUI and trace the Text(AttributedString) entry point. Done means whole-string and range-based font, foregroundColor, and underlineStyle attributes compile and work, including range(of:).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100