From 911e7faebe78fd090bf39ae2c0e9e94fb2ffaef6 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 25 Oct 2026 01:23:39 +0800 Subject: [PATCH 1/9] feat: update Link implementation --- .../Button/WidgetLinkButtonStyle.swift | 16 ++ .../OpenSwiftUI/View/Control/Link/Link.swift | 145 ++++++++++++++---- .../View/Control/LinkTests.swift | 79 ++++++++++ 3 files changed, 211 insertions(+), 29 deletions(-) create mode 100644 Sources/OpenSwiftUI/View/Control/Button/WidgetLinkButtonStyle.swift create mode 100644 Tests/OpenSwiftUITests/View/Control/LinkTests.swift diff --git a/Sources/OpenSwiftUI/View/Control/Button/WidgetLinkButtonStyle.swift b/Sources/OpenSwiftUI/View/Control/Button/WidgetLinkButtonStyle.swift new file mode 100644 index 000000000..a1f3e6b44 --- /dev/null +++ b/Sources/OpenSwiftUI/View/Control/Button/WidgetLinkButtonStyle.swift @@ -0,0 +1,16 @@ +// +// WidgetLinkButtonStyle.swift +// OpenSwiftUI +// +// Audited for 6.5.4 +// Status: Complete + +import OpenSwiftUICore + +struct WidgetLinkButtonStyle: ButtonStyle { + func makeBody(configuration: Configuration) -> some View { + configuration.label + .modifier(OpacityButtonHighlightModifier(highlighted: configuration.isPressed)) + .contentShape(Rectangle()) + } +} diff --git a/Sources/OpenSwiftUI/View/Control/Link/Link.swift b/Sources/OpenSwiftUI/View/Control/Link/Link.swift index 36e05451c..da246e2ab 100644 --- a/Sources/OpenSwiftUI/View/Control/Link/Link.swift +++ b/Sources/OpenSwiftUI/View/Control/Link/Link.swift @@ -2,10 +2,11 @@ // Link.swift // OpenSwiftUI // -// Audited for 3.5.2 -// Status: Blocked by Text and Accessibility +// Audited for 6.5.4 +// Status: Complete public import Foundation +@_spi(Private) public import OpenSwiftUICore /// A control for navigating to a URL. /// @@ -34,50 +35,136 @@ public import Foundation /// As with other views, you can style links using standard view modifiers /// depending on the view type of the link's label. For example, a ``Text`` /// label could be modified with a custom ``View/font(_:)`` or -/// ``View/foregroundColor(_:)`` to customize the appearance of the link in +/// ``View/foregroundStyle(_:)`` to customize the appearance of the link in /// your app's UI. +@available(OpenSwiftUI_v2_0, *) public struct Link