Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.0
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down Expand Up @@ -29,7 +29,7 @@ let package = Package(

.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),

.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "601.0.1"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import LiveViewNativeStylesheet
import LiveViewNativeCore
import CoreText

extension Calendar {
@ASTDecodable("Calendar")
Expand Down Expand Up @@ -238,6 +239,24 @@ public extension AttributedString.Resolvable {
}
}

@available(iOS 26.0, macOS 26.0, tvOS 26.0, watchOS 26.0, *)
extension AttributedString.LineHeight {
@ASTDecodable("LineHeight")
public enum Resolvable: StylesheetResolvable, @preconcurrency Decodable {
case __constant(AttributedString.LineHeight)
}
}

@available(iOS 26.0, macOS 26.0, tvOS 26.0, watchOS 26.0, *)
public extension AttributedString.LineHeight.Resolvable {
@MainActor func resolve<R: RootRegistry>(on element: ElementNode, in context: LiveContext<R>) -> AttributedString.LineHeight {
switch self {
case let .__constant(value):
return value
}
}
}

public struct StylesheetResolvableLocalizedError: @preconcurrency Decodable, StylesheetResolvable, LocalizedError, @preconcurrency AttributeDecodable {
public let errorDescription: String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,40 @@ extension Double {
}
}
}

extension Float {
public enum Resolvable: StylesheetResolvable, @preconcurrency Decodable {
case __constant(Float)
case reference(AttributeReference<Float>)

@ASTDecodable("Float")
enum Member: @preconcurrency Decodable {
case infinity
case pi
}

public init(from decoder: any Decoder) throws {
let container = try decoder.singleValueContainer()

if let member = try? container.decode(Member.self) {
switch member {
case .infinity:
self = .__constant(.infinity)
case .pi:
self = .__constant(.pi)
}
} else {
self = .reference(try container.decode(AttributeReference<Float>.self))
}
}

public func resolve<R>(on element: ElementNode, in context: LiveContext<R>) -> Float where R : RootRegistry {
switch self {
case let .__constant(constant):
return constant
case let .reference(reference):
return reference.resolve(on: element, in: context)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//
// AttributedTextFormattingDefinition.swift
// LiveViewNative
//
// Created by Carson Katri on 6/10/25.
//
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ public extension NamedCoordinateSpace.Resolvable {
}
}
}

enum StylesheetResolvableCoordinateSpaceProtocol: StylesheetResolvable, AttributeDecodable, @preconcurrency Decodable {
case local

@MainActor func resolve<R: RootRegistry>(on element: ElementNode, in context: LiveContext<R>) -> CoordinateSpace {
switch self {
case .local:
return .local
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//
// RoundedRectangularShape.swift
// LiveViewNative
//
// Created by Carson.Katri on 9/9/25.
//

import SwiftUI
import LiveViewNativeCore
import LiveViewNativeStylesheet

@ASTDecodable("RoundedRectangularShape")
@available(iOS 26.0, macOS 26.0, tvOS 26.0, watchOS 26.0, *)
enum StylesheetResolvableRoundedRectangularShape: InsettableShape, RoundedRectangularShape, StylesheetResolvable, @preconcurrency Decodable, AttributeDecodable {
typealias InsetShape = StylesheetResolvableRoundedRectangularShape

case _resolved(any SwiftUI.RoundedRectangularShape)

case rect
case _rectCornerSize(cornerSize: CGSize.Resolvable, style: RoundedCornerStyle.Resolvable)
static func rect(cornerSize: CGSize.Resolvable, style: RoundedCornerStyle.Resolvable = .__constant(.continuous)) -> Self {
._rectCornerSize(cornerSize: cornerSize, style: style)
}
case _rectCornerRadius(cornerRadius: CGFloat.Resolvable, style: RoundedCornerStyle.Resolvable)
static func rect(cornerRadius: CGFloat.Resolvable, style: RoundedCornerStyle.Resolvable = .__constant(.continuous)) -> Self {
._rectCornerRadius(cornerRadius: cornerRadius, style: style)
}
case _rectCornerRadii(cornerRadii: RectangleCornerRadii.Resolvable, style: RoundedCornerStyle.Resolvable)
static func rect(cornerRadii: RectangleCornerRadii.Resolvable, style: RoundedCornerStyle.Resolvable = .__constant(.continuous)) -> Self {
._rectCornerRadii(cornerRadii: cornerRadii, style: style)
}
case _rectRadius(
topLeadingRadius: CGFloat.Resolvable,
bottomLeadingRadius: CGFloat.Resolvable,
bottomTrailingRadius: CGFloat.Resolvable,
topTrailingRadius: CGFloat.Resolvable,
style: RoundedCornerStyle.Resolvable
)
static func rect(
topLeadingRadius: CGFloat.Resolvable = .__constant(0),
bottomLeadingRadius: CGFloat.Resolvable = .__constant(0),
bottomTrailingRadius: CGFloat.Resolvable = .__constant(0),
topTrailingRadius: CGFloat.Resolvable = .__constant(0),
style: RoundedCornerStyle.Resolvable = .__constant(.continuous)
) -> Self {
._rectRadius(
topLeadingRadius: topLeadingRadius,
bottomLeadingRadius: bottomLeadingRadius,
bottomTrailingRadius: bottomTrailingRadius,
topTrailingRadius: topTrailingRadius,
style: style
)
}

case capsule
case _capsule(style: RoundedCornerStyle.Resolvable)
static func capsule(style: RoundedCornerStyle.Resolvable) -> Self {
._capsule(style: style)
}

case circle
}

@available(iOS 26.0, macOS 26.0, tvOS 26.0, watchOS 26.0, *)
extension StylesheetResolvableRoundedRectangularShape {
nonisolated func path(in rect: CGRect) -> Path {
switch self {
case let ._resolved(shape):
return shape.path(in: rect)
default:
fatalError()
}
}

nonisolated func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize {
switch self {
case let ._resolved(shape):
return shape.sizeThatFits(proposal)
default:
fatalError()
}
}

func corners(in size: CGSize?) -> Self.Corners? {
switch self {
case let ._resolved(shape):
return shape.corners(in: size)
default:
fatalError()
}
}

nonisolated func inset(by amount: CGFloat) -> StylesheetResolvableRoundedRectangularShape {
switch self {
case let ._resolved(shape):
return ._resolved(shape.inset(by: amount) as! any RoundedRectangularShape)
default:
fatalError()
}
}
}

@available(iOS 26.0, macOS 26.0, tvOS 26.0, watchOS 26.0, *)
extension StylesheetResolvableRoundedRectangularShape {
@MainActor
func resolve<R>(on element: ElementNode, in context: LiveContext<R>) -> Self where R : RootRegistry {
switch self {
case ._resolved(let roundedRectangularShape):
return self
case .rect:
return ._resolved(Rectangle())
case ._rectCornerSize(let cornerSize, let style):
return ._resolved(RoundedRectangle(cornerSize: cornerSize.resolve(on: element, in: context), style: style.resolve(on: element, in: context)))
case ._rectCornerRadius(let cornerRadius, let style):
return ._resolved(RoundedRectangle(cornerRadius: cornerRadius.resolve(on: element, in: context), style: style.resolve(on: element, in: context)))
case ._rectCornerRadii(let cornerRadii, let style):
return ._resolved(UnevenRoundedRectangle(cornerRadii: cornerRadii.resolve(on: element, in: context), style: style.resolve(on: element, in: context)))
case ._rectRadius(let topLeadingRadius, let bottomLeadingRadius, let bottomTrailingRadius, let topTrailingRadius, let style):
return ._resolved(UnevenRoundedRectangle(
topLeadingRadius: topLeadingRadius.resolve(on: element, in: context),
bottomLeadingRadius: bottomLeadingRadius.resolve(on: element, in: context),
bottomTrailingRadius: bottomTrailingRadius.resolve(on: element, in: context),
topTrailingRadius: topTrailingRadius.resolve(on: element, in: context),
style: style.resolve(on: element, in: context)
))
case .capsule:
return ._resolved(Capsule())
case ._capsule(let style):
return ._resolved(Capsule(style: style.resolve(on: element, in: context)))
case .circle:
return ._resolved(Circle())
}
}
}

@available(iOS 26.0, macOS 26.0, tvOS 26.0, watchOS 26.0, *)
extension StylesheetResolvableRoundedRectangularShape {
init(from attribute: LiveViewNativeCore.Attribute?, on element: ElementNode) throws {
throw AttributeDecodingError.badValue(Self.self)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ enum StylesheetResolvablePrimitiveButtonStyle: @preconcurrency PrimitiveButtonSt
case link
#endif
case plain

case glass
}

extension StylesheetResolvablePrimitiveButtonStyle {
Expand Down Expand Up @@ -87,6 +89,12 @@ extension StylesheetResolvablePrimitiveButtonStyle {
#endif
case .plain:
SwiftUI.Button(configuration).buttonStyle(.plain)
case .glass:
if #available(iOS 26, macOS 26, tvOS 26, visionOS 26, watchOS 26, *) {
SwiftUI.Button(configuration).buttonStyle(.glass)
} else {
SwiftUI.Button(configuration).buttonStyle(.automatic)
}
}
}
}
Expand Down Expand Up @@ -118,6 +126,8 @@ extension StylesheetResolvablePrimitiveButtonStyle: @preconcurrency AttributeDec
#endif
case "plain":
self = .plain
case "glass":
self = .glass
default:
throw AttributeDecodingError.badValue(Self.self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,3 +621,21 @@ extension ShadowStyle {
}
}
}

@available(iOS 26.0, *)
extension Color.ResolvedHDR {
public enum Resolvable: StylesheetResolvable, @preconcurrency Decodable {
case __constant(SwiftUI.Color.ResolvedHDR)

public init(from decoder: any Decoder) throws {
fatalError()
}

public func resolve<R>(on element: ElementNode, in context: LiveContext<R>) -> Color.ResolvedHDR where R : RootRegistry {
switch self {
case let .__constant(resolvedHDR):
return resolvedHDR
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// TextSelection.swift
// LiveViewNative
//
// Created by Carson.Katri on 9/9/25.
//

import SwiftUI
import LiveViewNativeCore

@available(iOS 18.0, macOS 15.0, tvOS 18.0, watchOS 11.0, visionOS 2.0, *)
extension TextSelection: @retroactive Codable, AttributeDecodable {
public init(from decoder: any Decoder) throws {
fatalError("not supported")
}

public func encode(to encoder: any Encoder) throws {
fatalError("not supported")
}

public init(from attribute: LiveViewNativeCore.Attribute?, on element: ElementNode) throws {
fatalError()
}
}
6 changes: 3 additions & 3 deletions Sources/LiveViewNative/Views/Toolbars/ToolbarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import LiveViewNativeCore
struct ToolbarItem<Root: RootRegistry>: ToolbarContent {
/// The position of this item in the toolbar.
@_documentation(visibility: public)
private var placement: ToolbarItemPlacement = .automatic
private var placement: _ToolbarItemPlacement = .automatic

init(element: ElementNode) {
self._liveElement = .init(element: element)
Expand All @@ -83,7 +83,7 @@ struct ToolbarItem<Root: RootRegistry>: ToolbarContent {
@_documentation(visibility: public)
@LiveElement
struct CustomizableToolbarItem<Root: RootRegistry>: CustomizableToolbarContent {
var placement: ToolbarItemPlacement = .automatic
var placement: _ToolbarItemPlacement = .automatic

/// The unique ID for this customizable item.
@_documentation(visibility: public)
Expand Down Expand Up @@ -131,7 +131,7 @@ struct CustomizableToolbarItem<Root: RootRegistry>: CustomizableToolbarContent {

/// The positioning of a toolbar item.
@_documentation(visibility: public)
enum ToolbarItemPlacement: String, AttributeDecodable {
enum _ToolbarItemPlacement: String, AttributeDecodable {
@_documentation(visibility: public)
case automatic
@_documentation(visibility: public)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import SwiftUI
struct ToolbarItemGroup<Root: RootRegistry>: ToolbarContent {
/// The position of this group in the toolbar.
@_documentation(visibility: public)
private var placement: ToolbarItemPlacement = .automatic
private var placement: _ToolbarItemPlacement = .automatic

init(element: ElementNode) {
self._liveElement = .init(element: element)
Expand Down
Loading