feat: 🚧 Starting conversion from any base to another

This commit is contained in:
Louis Gallet 2023-11-08 17:20:14 +01:00
parent a6d602b726
commit 2571fb29a3
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY
4 changed files with 22 additions and 11 deletions

View File

@ -302,7 +302,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter; PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
@ -336,7 +336,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter; PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "B687202D-EECB-4F94-B02D-B86448789ACD"
type = "1"
version = "2.0">
</Bucket>

View File

@ -18,16 +18,18 @@ struct AnyBaseConverter: View {
TextField("Enter the source base for the number", text: $sourceBasedNumber) TextField("Enter the source base for the number", text: $sourceBasedNumber)
.keyboardType(.numberPad) .keyboardType(.numberPad)
} }
Section(header: Text("Number to convert")) {
TextField("Enter the number that you want to convert",
text: $basedNumber)
.keyboardType(.numberPad)
}
Section(header: Text("Destination base")) { Section(header: Text("Destination base")) {
TextField("Enter the arrival base", TextField("Enter the arrival base",
text: $destinationBasedNumber) text: $destinationBasedNumber)
.keyboardType(.numberPad) .keyboardType(.numberPad)
} }
Section(header: Text("Number to convert")) {
TextField("Enter the number that you want to convert",
text: $basedNumber)
.keyboardType(.numberPad)
}
Section(header: Text("Result")) { Section(header: Text("Result")) {
Text("Your number in base \(destinationBasedNumber): \(resultConversion)") Text("Your number in base \(destinationBasedNumber): \(resultConversion)")
} }
@ -35,10 +37,12 @@ struct AnyBaseConverter: View {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
} }
} }
.onChange(of: $basedNumber, $sourceBasedNumber) { newValue in resultConversion = convertFromAnyBaseToAnyBase(basedNumber, fromBase: Int(sourceBasedNumber)!, toBase: Int(destinationBasedNumber))!} .onChange(of: basedNumber) { newValue in
// .onChange(of: $sourceBasedNumber) { newValue in if (!(destinationBasedNumber == "" || sourceBasedNumber == "")) {
// $destinationBasedNumber = convertToHex(newValue) resultConversion = convertFromAnyBaseToAnyBase(basedNumber, fromBase: Int(sourceBasedNumber)!, toBase: Int(destinationBasedNumber) ?? 0)
// } }
}
} }
} }

View File

@ -14,6 +14,7 @@ struct ContentView: View {
content: { content: {
BinaryConverter().tabItem { Image(systemName: "2.square.fill") ; Text("Binary") }.tag(0) BinaryConverter().tabItem { Image(systemName: "2.square.fill") ; Text("Binary") }.tag(0)
HexaConverter().tabItem { Image(systemName: "16.square.fill") ; Text("Hexa") }.tag(1) HexaConverter().tabItem { Image(systemName: "16.square.fill") ; Text("Hexa") }.tag(1)
AnyBaseConverter().tabItem { Image(systemName: "number.square.fill") ; Text("Any base") }.tag(2)
}) })
} }