Skip to content

Commit

Permalink
Fix concurrency breaking code
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Dec 18, 2024
1 parent eb6c5b2 commit 15656e5
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 274 deletions.
24 changes: 23 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@ SwiftUIKit makes its best effort to honor semver, but breaking changes can occur



## 5.0.1

This patch updates `LinkText` to work with Swift 6, after a post 5.0 Swift concurrency change made it stop compiling.

However, since the complexity of the old `LinkText` implementation couldn't be ported to strict concurrency, the new implementation has breaking changes, and uses plain Markdown for its rendering, which reduces the capability of the component.

As a positive side-effect of this change, `LinkText` can now be used on all platforms.

### ✨ Features

* `LinkText` can now be used on all platforms.

### 💡 Behavior changes

* `TextFieldClearButton` now performs some actions as `MainActor`.

### 🚨 Breaking Changes

* `LinkText` has been reimplemented in Markdown, and has fewer capabilities than before.



## 5.0

This verison makes SwiftUIKit use Swift 6.
This version makes SwiftUIKit use Swift 6.

Due to the strict concurrency enforcement, this involves some breaking changes.

Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftUIKit/Data/Collection+RawRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import SwiftUI
/// to disappear. For instance, JSON encoding a `Color` will
/// not include any information about alternate color values
/// for light and dark mode, high constrasts, etc.
extension Array: RawRepresentable where Element: Codable {
extension Array: @retroactive RawRepresentable where Element: Codable {

public init?(rawValue: String) {
guard
Expand All @@ -44,7 +44,7 @@ extension Array: RawRepresentable where Element: Codable {
/// to disappear. For instance, JSON encoding a `Color` will
/// not include any information about alternate color values
/// for light and dark mode, high constrasts, etc.
extension Dictionary: RawRepresentable where Key: Codable, Value: Codable {
extension Dictionary: @retroactive RawRepresentable where Key: Codable, Value: Codable {

public init?(rawValue: String) {
guard
Expand Down
43 changes: 23 additions & 20 deletions Sources/SwiftUIKit/Text/LinkText+Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,49 @@
// Original: https://stackoverflow.com/questions/73133551
//

#if os(iOS) || os(macOS) || os(watchOS)
import SwiftUI

public extension LinkText {

/// This style can be applied to a ``LinkText`` and will
/// apply to all links within the view.
///
/// There are some built-in styles like ``standard`` and
/// ``plain``. You can also create your own.
/// This style can be applied by using the view modifier
/// ``SwiftUICore/View/linkTextStyle(_:)``.
///
/// To style colors, plain texts in a ``LinkText`` apply
/// the currently applied `.foregroundColor` while links
/// use the currently applied `.accentColor`. The entire
/// component will also use other native modifiers, like
/// `.lineSpacing`.
/// To style link color, line heights, etc. just use the
/// standard SwiftUI view modifiers. A link will use the
/// `.accentColor` while texts use the `.foregroundStyle`.
struct Style {

public init(
fontWeight: Font.Weight = .regular,
underline: Bool = true
bold: Bool = false,
italic: Bool = false
) {
self.fontWeight = fontWeight
self.underline = underline
self.bold = bold
self.italic = italic
}

public var fontWeight: Font.Weight
public var underline: Bool
public var bold: Bool
public var italic: Bool
}
}

public extension LinkText.Style {

/// The standard link text style.
/// The standard, plain link text style.
static var standard: Self { .init() }

/// A plain link text style that doesn't underline links.
static var plain: Self { .init(underline: false) }

/// A bold link style.
static var bold: Self { .init(bold: true) }

/// A bold, italic link style.
static var boldItalic: Self {
.init(bold: true, italic: true)
}

/// An italic link style.
static var italic: Self { .init(italic: true) }
}

public extension View {
Expand Down Expand Up @@ -75,5 +80,3 @@ public extension EnvironmentValues {
set { self [LinkText.Style.Key.self] = newValue }
}
}

#endif
Loading

0 comments on commit 15656e5

Please sign in to comment.