Thread 👇
We place these together in a VStack (vertical stack) to get them to vertically stack on top of one another.
We’ll place two HStacks (horizontal stacks) inside of a single VStack so to do this.
- Introduce a variable called “spacing” (we’ll use this later to control spacing & padding)
- Add a background color to our containing VStack
To do this, we’ll use an onTapGesture on our VStack to toggle “isExpanded” on and off. We’ll also make each text label visible if expanded.
This is as simple as wrapping our “isExpanded” toggle inside of withAnimation. We’ll also adjust our “spacing” variable we introduced earlier to grow or shrink depending on if we’re expanded to give the widget some breathing room.
- Introduce a “wifiEnabled” variable
- Wrap our WiFi VStack inside of a Button so that we can toggle wifiEnabled on or off.
- Make the background of the WiFi circle blue if enabled.
This is just a small example of placing the focus on layout and style and letting SwiftUI do the rest automagically ✨
Please reach out if I can help clarify anything or with any questions!