Skip to content

Commit

Permalink
[Changed] Replace UIKitForMac to macCatalyst to reflect the changes i…
Browse files Browse the repository at this point in the history
…n beta 4

[Changed] Replace .color() with .foregroundColor() to reflect the changes in beta 4
  • Loading branch information
ethanhuang13 committed Jul 18, 2019
1 parent 02a9f88 commit 9f50538
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.3.0] - 2019-07-18
- [Changed] Replace UIKitForMac to macCatalyst to reflect the changes in beta 4
- [Changed] Replace .color() with .foregroundColor() to reflect the changes in beta 4

## [0.2.0] - 2019-07-12
- [Added] Static components
- [Changed] Rename AttrText's typealias to AText
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ Now, with **NSAttributedStringBuilder**, we can use SwiftUI-like syntax to decla
let attributedString = NSAttributedString {
AText("Hello world")
.font(.systemFont(ofSize: 24))
.color(.red)
.foregroundColor(.red)
LineBreak()
AText("with Swift")
.font(.systemFont(ofSize: 20))
.color(.orange)
.foregroundColor(.orange)
}

```

## Requirements
iOS 13, macOS 10.15, tvOS 13, or watchOS 13, because it uses Swift 5.1 features like [Function Builder](https://forums.swift.org/t/function-builders/25167).
Xcode 11 beta 4, iOS 13, macOS 10.15, tvOS 13, or watchOS 13, because it uses Swift 5.1 features like [Function Builder](https://forums.swift.org/t/function-builders/25167).

## Installation
Please use **Swift Package Manager** to install.
Expand Down
4 changes: 2 additions & 2 deletions Sources/NSAttributedStringBuilder/Components/Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension Component {
attributes([.font: font])
}

public func color(_ color: Color) -> Component {
public func foregroundColor(_ color: Color) -> Component {
attributes([.foregroundColor: color])
}

Expand Down Expand Up @@ -222,7 +222,7 @@ extension Component {
return self.paragraphStyle(paragraphStyle)
}

#if canImport(AppKit) && !targetEnvironment(UIKitForMac)
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
public func textBlocks(_ textBlocks: [NSTextBlock]) -> Component {
let paragraphStyle = getMutableParagraphStyle()
paragraphStyle.textBlocks = textBlocks
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion SwiftUISampleApp/AttributedTextSample/AttributedText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct AttributedText_Previews : PreviewProvider {
.backgroundColor(.red)
.baselineOffset(10)
.font(.systemFont(ofSize: 20))
.color(.yellow)
.foregroundColor(.yellow)
.expansion(1)
.kerning(3)
.ligature(.none)
Expand Down
18 changes: 10 additions & 8 deletions SwiftUISampleApp/AttributedTextSample/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import SwiftUI
import NSAttributedStringBuilder
import SwiftUI

let image = UIImage(named: "Swift_logo_color_rgb.jpg")!

struct ContentView : View {
var body: some View {
VStack {
VStack(alignment: .leading) {
Text("Text Title")
.font(.largeTitle)
Text("Text Subtitle")
.font(.headline)
Text("Text Link")
.font(.body)
.underline()
.color(.blue)
.foregroundColor(.blue)
Image(uiImage: image)
.padding(.bottom)

Spacer()

// UILabel: UIViewRepresentable
// UITextView: UIViewRepresentable
AttributedText {
ImageAttachment(UIImage(named: "Swift_logo_color_rgb.jpg")!)
AText("AttributedText Title")
.font(.preferredFont(forTextStyle: .largeTitle))
LineBreak()
Expand All @@ -26,8 +27,9 @@ struct ContentView : View {
LineBreak()
Link("Attributed Link", url: URL(string: "https://www.apple.com")!)
.font(.preferredFont(forTextStyle: .body))
LineBreak()
ImageAttachment(image)
}
.background(Color.gray)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class ComponentBasicModifierTests: XCTestCase {
let sut = NSAttributedString {
AText("Hello world")
.font(.systemFont(ofSize: 20))
.color(.yellow)
.foregroundColor(.yellow)
LineBreak()
AText("Second line")
.font(.systemFont(ofSize: 24))
Expand Down Expand Up @@ -362,7 +362,7 @@ final class ComponentBasicModifierTests: XCTestCase {
.backgroundColor(.red)
.baselineOffset(10)
.font(.systemFont(ofSize: 20))
.color(.yellow)
.foregroundColor(.yellow)
.expansion(1)
.kerning(3)
.ligature(.none)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ final class ComponentParagraphSylteModifierTests: XCTestCase {
XCTAssertTrue(sut.isEqual(testData))
}

#if canImport(AppKit) && !targetEnvironment(UIKitForMac)
#if canImport(AppKit) && !targetEnvironment(macCatalyst)

func testModifyTextBlocks() {
let textBlock = NSTextBlock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class NSAttributedStringBuilderTests: XCTestCase {

let sut = NSAttributedString {
AText("Here is a link to ")
.color(.brown)
.foregroundColor(.brown)
Link("Apple", url: URL(string: "https://www.apple.com")!)
}

Expand Down

0 comments on commit 9f50538

Please sign in to comment.