Skip to content

Commit e30fdaa

Browse files
committed
Add Copy Indicator
1 parent 6f1c85c commit e30fdaa

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

CodeEdit/Features/About/Views/AboutDefaultView.swift

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ struct AboutDefaultView: View {
2727
@Environment(\.colorScheme)
2828
var colorScheme
2929

30+
@State private var didCopyVersion = false
31+
@State private var isHoveringVersion = false
32+
3033
private static var licenseURL = URL(string: "https://github.com/CodeEditApp/CodeEdit/blob/main/LICENSE.md")!
3134

3235
let smallTitlebarHeight: CGFloat = 28
@@ -52,9 +55,39 @@ struct AboutDefaultView: View {
5255
weight: .bold
5356
))
5457
Text("Version \(appVersion)\(appVersionPostfix) (\(appBuild))")
55-
.textSelection(.enabled)
56-
.foregroundColor(Color(.tertiaryLabelColor))
58+
.textSelection(.disabled)
5759
.font(.body)
60+
.onTapGesture {
61+
// Create a string suitable for pasting into a bug report
62+
let macOSVersion = ProcessInfo.processInfo.operatingSystemVersion.semverString
63+
NSPasteboard.general.clearContents()
64+
NSPasteboard.general.setString(
65+
"CodeEdit: \(appVersion) (\(appBuild))\nmacOS: \(macOSVersion)",
66+
forType: .string
67+
)
68+
didCopyVersion.toggle()
69+
}
70+
.background(alignment: .leading) {
71+
if isHoveringVersion {
72+
if #available(macOS 14.0, *) {
73+
Image(systemName: "document.on.document.fill")
74+
.font(.caption)
75+
.offset(x: -16, y: 0)
76+
.transition(.opacity)
77+
.symbolEffect(
78+
.bounce.down.wholeSymbol,
79+
options: .nonRepeating.speed(1.8),
80+
value: didCopyVersion
81+
)
82+
} else {
83+
Image(systemName: "document.on.document.fill")
84+
.font(.caption)
85+
.offset(x: -16, y: 0)
86+
.transition(.opacity)
87+
}
88+
}
89+
}
90+
.foregroundColor(Color(.tertiaryLabelColor))
5891
.blendMode(colorScheme == .dark ? .plusLighter : .plusDarker)
5992
.padding(.top, 4)
6093
.matchedGeometryEffect(
@@ -65,14 +98,10 @@ struct AboutDefaultView: View {
6598
)
6699
.blur(radius: aboutMode == .about ? 0 : 10)
67100
.opacity(aboutMode == .about ? 1 : 0)
68-
.onTapGesture {
69-
// Create a string suitable for pasting into a bug report
70-
let macOSVersion = ProcessInfo.processInfo.operatingSystemVersion.semverString
71-
NSPasteboard.general.clearContents()
72-
NSPasteboard.general.setString(
73-
"CodeEdit: \(appVersion) (\(appBuild))\nmacOS: \(macOSVersion)",
74-
forType: .string
75-
)
101+
.onHover { hovering in
102+
withAnimation(.easeInOut(duration: 0.1)) {
103+
isHoveringVersion = hovering
104+
}
76105
}
77106
}
78107
.padding(.horizontal)

0 commit comments

Comments
 (0)