Rewrite UIKit to SwiftUI

Hi, I'm in the process of updating my dilution calculator app to be fully done in SwiftUI. I'm trying to rewrite the old part of UIKit to SwiftUI. Can I get some help on how to do this?

Here is the code form UIKit:

@IBAction func button(_ sender: Any) {
    self.ContainerSizeTextField.resignFirstResponder()
    self.DilutionRatioTextField.resignFirstResponder()
    
    let firstValue = Double(ContainerSizeTextField.text ?? "0") ?? 0.0  
    let secondValue = Double(DilutionRatioTextField.text ?? "0") ?? 0.0
    let thirdValue = Double(1)
    
    let outputValue = Double(secondValue + thirdValue)
        var outputValue1: Double = 0
        if outputValue > 0.00000001 || outputValue < -0.0000000001 { 
            outputValue1 = Double(firstValue / outputValue)
        }
        let outputValue2 = Double(firstValue - outputValue1)
    
    let c:String = String(format:"%.1f", outputValue1)
    let d:String = String(format:"%.1f", outputValue2)
    
    TotalProductLabel.text = " \(c)"
    TotalWaterLabel.text = " \(d)"
Answered by fredos86 in 718480022

I able to find a solution myself. Thanks.

If you are new to SwiftUI it might be best to invest some time understanding the fundamentals of SwiftUI. It is different from UIKit, if you invest time up front you would save time on the long run. WWDC has some great content for SwiftUI, you could start with https://developer.apple.com/wwdc20/10119 and https://developer.apple.com/wwdc20/10040. Once you are done with it you can view other links under the videos.

Accepted Answer

I able to find a solution myself. Thanks.

Rewrite UIKit to SwiftUI
 
 
Q