Skip to content

Commit d42e5a6

Browse files
committed
Adjust icon placement and background size to Liquid Glass spacing
1 parent c7cce3e commit d42e5a6

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Sources/LinksKit/Styles/TitleAndIconBadgeLabelStyle.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ public struct TitleAndIconBadgeLabelStyle: LabelStyle {
77
/// The color of the icon badge.
88
let color: Color
99

10+
private var isPreLiquidGlass: Bool {
11+
if #available(iOS 26, macOS 26, tvOS 26, visionOS 26, watchOS 26, *) {
12+
return false
13+
} else {
14+
return true
15+
}
16+
}
17+
1018
/// Creates a view representing the body of a label.
1119
///
1220
/// - Parameter configuration: The properties of the label.
@@ -15,15 +23,16 @@ public struct TitleAndIconBadgeLabelStyle: LabelStyle {
1523
/// This method creates a horizontal stack with a colored badge containing the icon, followed by the title. The badge size adjusts to match the height of the label.
1624
public func makeBody(configuration: Configuration) -> some View {
1725
GeometryReader { proxy in
18-
HStack {
26+
HStack(spacing: self.isPreLiquidGlass ? 8 : 15) {
1927
Group {
20-
RoundedRectangle(cornerRadius: 8)
28+
RoundedRectangle(cornerRadius: self.isPreLiquidGlass ? 8 : 6)
29+
.scale(self.isPreLiquidGlass ? 1 : 1.3)
2130
.fill(self.color)
2231
.overlay(configuration.icon.foregroundStyle(.white).font(.body))
23-
.padding(4)
32+
.padding(self.isPreLiquidGlass ? 4 : 0)
2433
}
2534
.frame(width: proxy.size.height, height: proxy.size.height)
26-
.padding(.leading, -8)
35+
.padding(.leading, self.isPreLiquidGlass ? -8 : 0)
2736

2837
configuration.title
2938
}

Sources/LinksKit/Styles/TitleAndTrailingIconBadgeLabelStyle.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ public struct TitleAndTrailingIconBadgeLabelStyle: LabelStyle {
88
/// The color of the icon badge.
99
let color: Color
1010

11+
private var isPreLiquidGlass: Bool {
12+
if #available(iOS 26, macOS 26, tvOS 26, visionOS 26, watchOS 26, *) {
13+
return false
14+
} else {
15+
return true
16+
}
17+
}
18+
1119
/// Creates a view representing the body of a label.
1220
///
1321
/// - Parameter configuration: The properties of the label.
@@ -23,13 +31,14 @@ public struct TitleAndTrailingIconBadgeLabelStyle: LabelStyle {
2331
Spacer()
2432

2533
Group {
26-
RoundedRectangle(cornerRadius: 8)
34+
RoundedRectangle(cornerRadius: self.isPreLiquidGlass ? 8 : 6)
35+
.scale(self.isPreLiquidGlass ? 1 : 1.3)
2736
.fill(self.color)
2837
.overlay(configuration.icon.foregroundStyle(.white).font(.body))
29-
.padding(4)
38+
.padding(self.isPreLiquidGlass ? 4 : 0)
3039
}
3140
.frame(width: proxy.size.height, height: proxy.size.height)
32-
.padding(.trailing, -8)
41+
.padding(.trailing, self.isPreLiquidGlass ? -8 : 0)
3342
}
3443
}
3544
}

0 commit comments

Comments
 (0)