Skip to content

Commit f7bd7e4

Browse files
committed
Minor updates
1 parent a592b64 commit f7bd7e4

File tree

6 files changed

+81
-48
lines changed

6 files changed

+81
-48
lines changed

Demo/What's New?.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/What's New?/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct ContentView : View {
2020
}
2121

2222
// Mini (Toolbar / List only)
23-
#Preview("Invisible") {
23+
#Preview("Mini") {
2424
@Previewable @State var showNew: Bool = false
2525
List {
2626
Section(header: Text("Compatible with Toolbar / List")) {
@@ -30,7 +30,7 @@ struct ContentView : View {
3030
}
3131

3232
#Preview("Invisible") {
33-
@Previewable @State var showNew: Bool = false
33+
@Previewable @State var showNew: Bool = true
3434
SwiftNEW(show: $showNew, size: .constant("invisible"))
3535
}
3636

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
dependencies: [
2424
.package(url: "https://github.com/1998code/SwiftVBKit.git", .upToNextMinor(from: "1.4.0")),
2525
.package(url: "https://github.com/omaralbeik/Drops.git", .upToNextMinor(from: "1.7.0")),
26-
.package(url: "https://github.com/1998code/SwiftGlass.git", .upToNextMinor(from: "1.8.0"))
26+
.package(url: "https://github.com/1998code/SwiftGlass.git", .upToNextMinor(from: "1.9.9"))
2727
],
2828
targets: [
2929
.target(

Sources/SwiftNEW/SwiftNEW.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public struct SwiftNEW: View {
4141
align: Binding<HorizontalAlignment>? = .constant(.center),
4242
color: Binding<Color>? = .constant(Color.accentColor),
4343
size: Binding<String>? = .constant("simple"),
44-
labelColor: Binding<Color>? = .constant(Color(UIColor.systemBackground)),
44+
labelColor: Binding<Color>? = .constant(Color.primary),
4545
label: Binding<String>? = .constant("Show Release Note"),
4646
labelImage: Binding<String>? = .constant("arrow.up.circle.fill"),
4747
history: Binding<Bool>? = .constant(true),
@@ -54,7 +54,7 @@ public struct SwiftNEW: View {
5454
_align = align ?? .constant(.center)
5555
_color = color ?? .constant(Color.accentColor)
5656
_size = size ?? .constant("simple")
57-
_labelColor = labelColor ?? .constant(Color(UIColor.systemBackground))
57+
_labelColor = labelColor ?? .constant(Color.primary)
5858
_label = label ?? .constant("Show Release Note")
5959
_labelImage = labelImage ?? .constant("arrow.up.circle.fill")
6060
_history = history ?? .constant(true)
@@ -70,7 +70,7 @@ public struct SwiftNEW: View {
7070
align: Binding<HorizontalAlignment>? = .constant(.center),
7171
color: Binding<Color>? = .constant(Color.accentColor),
7272
size: Binding<String>? = .constant("simple"),
73-
labelColor: Binding<Color>? = .constant(Color(NSColor.windowBackgroundColor)),
73+
labelColor: Binding<Color>? = .constant(Color.primary),
7474
label: Binding<String>? = .constant("Show Release Note"),
7575
labelImage: Binding<String>? = .constant("arrow.up.circle.fill"),
7676
history: Binding<Bool>? = .constant(true),
@@ -83,7 +83,7 @@ public struct SwiftNEW: View {
8383
_align = align ?? .constant(.center)
8484
_color = color ?? .constant(Color.accentColor)
8585
_size = size ?? .constant("simple")
86-
_labelColor = labelColor ?? .constant(Color(NSColor.windowBackgroundColor))
86+
_labelColor = labelColor ?? .constant(Color.primary)
8787
_label = label ?? .constant("Show Release Note")
8888
_labelImage = labelImage ?? .constant("arrow.up.circle.fill")
8989
_history = history ?? .constant(true)
@@ -99,7 +99,7 @@ public struct SwiftNEW: View {
9999
align: Binding<HorizontalAlignment>? = .constant(.center),
100100
color: Binding<Color>? = .constant(Color.accentColor),
101101
size: Binding<String>? = .constant("simple"),
102-
labelColor: Binding<Color>? = .constant(Color.white),
102+
labelColor: Binding<Color>? = .constant(Color.primary),
103103
label: Binding<String>? = .constant("Show Release Note"),
104104
labelImage: Binding<String>? = .constant("arrow.up.circle.fill"),
105105
history: Binding<Bool>? = .constant(true),
@@ -112,7 +112,7 @@ public struct SwiftNEW: View {
112112
_align = align ?? .constant(.center)
113113
_color = color ?? .constant(Color.accentColor)
114114
_size = size ?? .constant("simple")
115-
_labelColor = labelColor ?? .constant(Color.white)
115+
_labelColor = labelColor ?? .constant(Color.primary)
116116
_label = label ?? .constant("Show Release Note")
117117
_labelImage = labelImage ?? .constant("arrow.up.circle.fill")
118118
_history = history ?? .constant(true)

Sources/SwiftNEW/Views/Sheets/HistorySheet.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ extension SwiftNEW {
2626
ForEach(items, id: \.self) { item in
2727
ZStack {
2828
color.opacity(0.25)
29-
Text(item.version).bold().font(.title2).foregroundColor(color)
29+
Text(item.version).bold().font(.title2)
30+
.foregroundColor(labelColor)
3031
}.glass(radius: 15, shadowColor: color)
3132
.frame(width: 75, height: 30)
3233
.cornerRadius(15)

Sources/SwiftNEW/Views/SwiftNEW+View.swift

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,86 @@ import Drops
1717
extension SwiftNEW {
1818
public var body: some View {
1919
Button(action: {
20+
#if os(iOS)
2021
if showDrop {
21-
#if os(iOS)
2222
drop()
23-
#endif
2423
} else {
2524
show = true
2625
}
26+
#else
27+
show = true
28+
#endif
2729
}) {
28-
if size == "mini" {
29-
Label(label, systemImage: labelImage)
30-
}
31-
else if size == "normal" || size == "simple" {
32-
Label(label, systemImage: labelImage)
33-
#if !os(tvOS)
34-
.frame(width: 300, height: 50)
35-
#else
36-
.frame(width: 400, height: 50)
37-
#endif
38-
#if os(iOS) && !os(visionOS)
39-
.foregroundColor(labelColor)
40-
.background(color)
41-
.cornerRadius(15)
42-
#endif
43-
}
30+
Label(label, systemImage: labelImage)
31+
.frame(
32+
width: size == "mini" ? nil : (size == "invisible" ? 0 : platformWidth),
33+
height: size == "mini" ? nil : (size == "invisible" ? 0 : 50)
34+
)
35+
#if os(iOS) && !os(visionOS)
36+
.foregroundColor(labelColor)
37+
.background(size != "mini" && size != "invisible" ? color : Color.clear)
38+
.cornerRadius(15)
39+
#endif
4440
}
4541
.opacity(size == "invisible" ? 0 : 1)
4642
.glass(shadowColor: color)
4743
.sheet(isPresented: $show) {
48-
ZStack {
49-
if mesh {
50-
MeshView(color: $color)
51-
}
52-
if specialEffect == "Christmas" {
53-
SnowfallView()
44+
sheetContent
45+
}
46+
}
47+
48+
private var platformWidth: CGFloat {
49+
#if os(tvOS)
50+
400
51+
#else
52+
300
53+
#endif
54+
}
55+
56+
private var sheetContent: some View {
57+
ZStack {
58+
if mesh {
59+
MeshView(color: $color)
60+
}
61+
if specialEffect == "Christmas" {
62+
SnowfallView()
63+
}
64+
sheetCurrent
65+
.sheet(isPresented: $historySheet) {
66+
historySheetContent
5467
}
55-
sheetCurrent
56-
.sheet(isPresented: $historySheet) {
57-
if #available(iOS 16.4, tvOS 16.4, *) {
58-
sheetHistory
59-
.presentationBackground(.thinMaterial)
60-
} else {
61-
sheetHistory
62-
}
63-
}
64-
#if os(visionOS)
65-
.padding()
66-
#endif
68+
#if os(visionOS)
69+
.padding()
70+
#endif
71+
}
72+
.background(.ultraThinMaterial)
73+
.modifier(PresentationBackgroundModifier())
74+
}
75+
76+
private var historySheetContent: some View {
77+
ZStack {
78+
if mesh {
79+
MeshView(color: $color)
6780
}
81+
if specialEffect == "Christmas" {
82+
SnowfallView()
83+
}
84+
sheetHistory
85+
#if os(visionOS)
86+
.padding()
87+
#endif
88+
}
89+
.background(.ultraThinMaterial)
90+
.modifier(PresentationBackgroundModifier())
91+
}
92+
}
93+
94+
private struct PresentationBackgroundModifier: ViewModifier {
95+
func body(content: Content) -> some View {
96+
if #available(iOS 16.4, tvOS 16.4, *) {
97+
content.presentationBackground(.thinMaterial)
98+
} else {
99+
content
68100
}
69101
}
70102
}

0 commit comments

Comments
 (0)