Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ extension _ViewInputs {

// MARK: - _DefaultForegroundStyleModifier

extension View {
nonisolated package func defaultForegroundStyle<S>(_ style: S?) -> some View where S: ShapeStyle {
modifier(_DefaultForegroundStyleModifier(style: style))
}
}

struct _DefaultForegroundStyleModifier<Style>: PrimitiveViewModifier, ViewInputsModifier where Style: ShapeStyle {
var style: Style?

Expand Down
16 changes: 16 additions & 0 deletions Sources/OpenSwiftUICore/Shape/ShapeStyle/Material.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ public struct Material: Sendable {
extension Material: ShapeStyle {
// FIXME

package static let ultraThin = Material(id: .ultraThin)

package static let thin = Material(id: .thin)

package static let regular = Material(id: .regular)

package static let thick = Material(id: .thick)
Expand All @@ -211,6 +215,18 @@ private struct BackgroundMaterialKey: EnvironmentKey {
}

extension EnvironmentValues {
/// The material underneath the current view.
///
/// This value is `nil` if the current background isn't one of the standard
/// materials. If you set a material, the standard content styles enable
/// their vibrant rendering modes.
///
/// You set this value by calling one of the background modifiers that takes
/// a ``ShapeStyle``, like ``View/background(_:ignoresSafeAreaEdges:)``
/// or ``View/background(_:in:fillStyle:)``, and passing in a
/// ``Material``. You can also set the value manually, using
/// `nil` to disable vibrant rendering, or a ``Material`` instance to
/// enable the vibrancy style associated with the specified material.
public var backgroundMaterial: Material? {
get { self[BackgroundMaterialKey.self] }
set { self[BackgroundMaterialKey.self] = newValue }
Expand Down
Loading