Challenge
- build an app that handles unit conversions
- users will select an input unit and an output unit
- then enter a value, and see the output of the conversion.
- Which units you choose are down to you, but you could choose one of these:
- Temperature conversion: users choose Celsius, Fahrenheit, or Kelvin.
- Length conversion: users choose meters, kilometers, feet, yards, or miles.
- Time conversion: users choose seconds, minutes, hours, or days.
- Volume conversion: users choose milliliters, liters, cups, pints, or gallons.
- If you were going for length conversion you might have:
- A segmented control for meters, kilometers, feet, yard, or miles, for the input unit.
- A second segmented control for meters, kilometers, feet, yard, or miles, for the output unit.
- A text field where users enter a number.
- A text view showing the result of the conversion.
Tips
- First, and most importantly: keep it simple!
- Second, a better idea is to convert the user’s input to a single base unit, then convert from there to the target unit.
- Third, as we have three user values here – their input number, their input unit, and their output unit.
- You need to have three
@State properties to store them all
- one
TextField
- two pickers
- one text view to show your output
- You can break your form up into sections if you want, but it’s not required.