skiptools / skiptools/skip-ui

AttributedString attributes not implemented

Open
#202 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.