Skip to content

Commit 4d015f8

Browse files
committed
chore: simplify copy-paste logic for addresses in device view
Signed-off-by: Tommy van der Vorst <tommy@pixelspark.nl>
1 parent 9136cc1 commit 4d015f8

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

Sushitrain/DeviceView.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,8 @@ struct DeviceView: View {
172172
if !lastAddress.isEmpty {
173173
Section("Current addresses") {
174174
Label(lastAddress, systemImage: "network").contextMenu {
175-
Button(action: {
176-
#if os(iOS)
177-
UIPasteboard.general.string = lastAddress
178-
#endif
179-
180-
#if os(macOS)
181-
let pasteboard = NSPasteboard.general
182-
pasteboard.clearContents()
183-
pasteboard.prepareForNewContents()
184-
pasteboard.setString(
185-
lastAddress, forType: .string)
186-
#endif
187-
}) {
188-
Text("Copy to clipboard")
189-
Image(systemName: "doc.on.doc")
175+
Button("Copy to clipboard", systemImage: "doc.on.doc") {
176+
writeTextToPasteboard(lastAddress)
190177
}
191178
}
192179
}

0 commit comments

Comments
 (0)