Skip to content
Open
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
20 changes: 14 additions & 6 deletions resources/ios/NativeUIChipRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct NativeUIChipRenderer: View {
.modifier(ChipBackgroundModifier(
fillColor: bg,
borderColor: border,
selected: isSelected,
glassEnabled: glassEnabled,
glassInteractive: glassInteractive,
glassClear: glassClear,
Expand Down Expand Up @@ -117,6 +118,9 @@ struct NativeUIChipRenderer: View {
private struct ChipBackgroundModifier: ViewModifier {
let fillColor: Color
let borderColor: Color
/// A selected glass chip takes its fill as a glass tint: its text is
/// the on-primary colour, which an untinted plate can't carry.
let selected: Bool
let glassEnabled: Bool
let glassInteractive: Bool
let glassClear: Bool
Expand All @@ -131,14 +135,18 @@ private struct ChipBackgroundModifier: ViewModifier {
)

if glassEnabled, #available(iOS 26.0, *) {
if glassClear {
bordered.glassEffect(.clear.interactive(glassInteractive), in: shape)
} else {
bordered.glassEffect(.regular.interactive(glassInteractive), in: shape)
}
let glass: Glass = glassClear ? .clear : .regular
bordered.glassEffect(
(selected ? glass.tint(fillColor) : glass).interactive(glassInteractive),
in: shape
)
} else if glassEnabled {
bordered.background(
shape.fill(glassClear ? AnyShapeStyle(.ultraThinMaterial) : AnyShapeStyle(.regularMaterial))
shape.fill(
selected
? AnyShapeStyle(fillColor)
: (glassClear ? AnyShapeStyle(.ultraThinMaterial) : AnyShapeStyle(.regularMaterial))
)
)
} else if hasUserBg {
// User bg wins — paint nothing here, NodeStyleModifier already
Expand Down
Loading