SwiftcordApp / Swiftcord

A fully native Discord client for macOS built 100% in Swift!
https://swiftcordapp.github.io/Swiftcord/
GNU General Public License v3.0
1.85k stars 84 forks source link

Added a Username Copy Button #149

Closed ReactaDev closed 1 year ago

ReactaDev commented 1 year ago

Summery

A Button to directly copy user and discrim from the mini profile page.

How it works

Uses pasteboard to copy to clipboard, grabs the "user.username" and "user.discriminator" and interpolates it with a "#" to form a string "Username#1234" that gets copied to the clipboard.

Code that was added

let pasteboard = NSPasteboard.general

Button(action: { pasteboard.declareTypes([.string], owner: nil) pasteboard.setString("\(user.username)#\(user.discriminator)", forType: .string) }, label: { Image(systemName: "square.on.square") }) .buttonStyle(.plain) .padding() .frame(width: 20, height: 20)

All in all, a very simple ease of life change.

Examples

image
cryptoAlgorithm commented 1 year ago

Great first contribution! It would be great if you could include screenshots of how this button would look (editing your OP would suffice) to make evaluating this PR quicker. Thanks!

ReactaDev commented 1 year ago

Great first contribution! It would be great if you could include screenshots of how this button would look (editing your OP would suffice) to make evaluating this PR quicker. Thanks!

Upated! Sorry about that!

cryptoAlgorithm commented 1 year ago

Ok, looks good! Looks like the only thing that's left is to resolve these lint warnings before this PR can be merged!

cryptoAlgorithm commented 1 year ago

A little tip: I suggest enabling the Automatically trim trailing whitespace and Including whitespace-only lines options in Xcode's settings to automatically remove any trailing whitespace.

Screenshot 2023-05-12 at 11 05 38 PM
ReactaDev commented 1 year ago

Ahh I will fix that. Its a bad habit I have with code formating

ReactaDev commented 1 year ago

A little tip: I suggest enabling the Automatically trim trailing whitespace and Including whitespace-only lines options in Xcode's settings to automatically remove any trailing whitespace.

Screenshot 2023-05-12 at 11 05 38 PM

Ohh I will enable that right now! Thank you! I have spent way to long debugging those.