feat: Add contextual menu for copy-paste

This commit is contained in:
Louis Gallet 2023-11-08 17:52:58 +01:00
parent 2571fb29a3
commit 80a0bf1bd5
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY
4 changed files with 29 additions and 4 deletions

View File

@ -13,8 +13,8 @@
2CCE3EA32AF678B300BB0ED3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */; };
2CCE3EA62AF678B300BB0ED3 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */; };
2CCE3EAD2AF67A9000BB0ED3 /* UtilsFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */; };
2CCE3EAF2AF67BA900BB0ED3 /* BinaryConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */; };
2CCE3EB12AF67CFD00BB0ED3 /* HexaConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */; };
2CEC5C712AFBF09800A6DEB3 /* BinaryConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEC5C702AFBF09800A6DEB3 /* BinaryConverter.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -25,8 +25,8 @@
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilsFunctions.swift; sourceTree = "<group>"; };
2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryConverter.swift; sourceTree = "<group>"; };
2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexaConverter.swift; sourceTree = "<group>"; };
2CEC5C702AFBF09800A6DEB3 /* BinaryConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryConverter.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -62,7 +62,7 @@
2CCE3E9E2AF678B200BB0ED3 /* BinaryConverterApp.swift */,
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */,
2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */,
2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */,
2CEC5C702AFBF09800A6DEB3 /* BinaryConverter.swift */,
2C53DAA52AF866B200EB233F /* AnyBaseConverter.swift */,
2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */,
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */,
@ -150,9 +150,9 @@
buildActionMask = 2147483647;
files = (
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */,
2CCE3EAF2AF67BA900BB0ED3 /* BinaryConverter.swift in Sources */,
2C53DAA62AF866B200EB233F /* AnyBaseConverter.swift in Sources */,
2CCE3EAD2AF67A9000BB0ED3 /* UtilsFunctions.swift in Sources */,
2CEC5C712AFBF09800A6DEB3 /* BinaryConverter.swift in Sources */,
2CCE3EB12AF67CFD00BB0ED3 /* HexaConverter.swift in Sources */,
2CCE3E9F2AF678B200BB0ED3 /* BinaryConverterApp.swift in Sources */,
);

View File

@ -32,6 +32,14 @@ struct AnyBaseConverter: View {
Section(header: Text("Result")) {
Text("Your number in base \(destinationBasedNumber): \(resultConversion)")
.contextMenu(ContextMenu(menuItems: {
Button(action: {
let pasteboard = UIPasteboard.general
pasteboard.string = resultConversion
}, label: {
Label("Copy value", systemImage: "doc.on.doc")
})
}))
}
Button("Dismiss Keyboard") {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)

View File

@ -18,6 +18,14 @@ struct BinaryConverter: View {
}
Section(header: Text("Base 2")) {
Text("Your number in base 2: \(binaryNumber)")
.contextMenu(ContextMenu(menuItems: {
Button(action: {
let pasteboard = UIPasteboard.general
pasteboard.string = binaryNumber
}, label: {
Label("Copy value", systemImage: "doc.on.doc")
})
}))
}
Button("Dismiss Keyboard") {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)

View File

@ -18,6 +18,15 @@ struct HexaConverter: View {
}
Section(header: Text("Base 16")) {
Text("Your number in base 16: \(HexadecimalNumber)")
.contextMenu(ContextMenu(menuItems: {
Button(action: {
let pasteboard = UIPasteboard.general
pasteboard.string = HexadecimalNumber
}, label: {
Label("Copy value", systemImage: "doc.on.doc")
})
}))
}
Button("Dismiss Keyboard") {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)