diff --git a/BinaryConverter.xcodeproj/project.pbxproj b/BinaryConverter.xcodeproj/project.pbxproj index 6dec7d8..1a69a75 100644 --- a/BinaryConverter.xcodeproj/project.pbxproj +++ b/BinaryConverter.xcodeproj/project.pbxproj @@ -302,7 +302,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -336,7 +336,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = fr.louisgallet.BinaryConverter; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; diff --git a/BinaryConverter.xcodeproj/xcuserdata/louisgallet.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/BinaryConverter.xcodeproj/xcuserdata/louisgallet.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..d934828 --- /dev/null +++ b/BinaryConverter.xcodeproj/xcuserdata/louisgallet.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/BinaryConverter/AnyBaseConverter.swift b/BinaryConverter/AnyBaseConverter.swift index 2a7a9a4..ad2e0dc 100644 --- a/BinaryConverter/AnyBaseConverter.swift +++ b/BinaryConverter/AnyBaseConverter.swift @@ -18,16 +18,18 @@ struct AnyBaseConverter: View { TextField("Enter the source base for the number", text: $sourceBasedNumber) .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")) { TextField("Enter the arrival base", text: $destinationBasedNumber) .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")) { 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) } } - .onChange(of: $basedNumber, $sourceBasedNumber) { newValue in resultConversion = convertFromAnyBaseToAnyBase(basedNumber, fromBase: Int(sourceBasedNumber)!, toBase: Int(destinationBasedNumber))!} -// .onChange(of: $sourceBasedNumber) { newValue in -// $destinationBasedNumber = convertToHex(newValue) -// } + .onChange(of: basedNumber) { newValue in + if (!(destinationBasedNumber == "" || sourceBasedNumber == "")) { + resultConversion = convertFromAnyBaseToAnyBase(basedNumber, fromBase: Int(sourceBasedNumber)!, toBase: Int(destinationBasedNumber) ?? 0) + } + + } } } diff --git a/BinaryConverter/ContentView.swift b/BinaryConverter/ContentView.swift index 5c8080b..b65e100 100644 --- a/BinaryConverter/ContentView.swift +++ b/BinaryConverter/ContentView.swift @@ -14,6 +14,7 @@ struct ContentView: View { content: { BinaryConverter().tabItem { Image(systemName: "2.square.fill") ; Text("Binary") }.tag(0) HexaConverter().tabItem { Image(systemName: "16.square.fill") ; Text("Hexa") }.tag(1) + AnyBaseConverter().tabItem { Image(systemName: "number.square.fill") ; Text("Any base") }.tag(2) }) }