ContentView - marleysudbury/swiftui-calculator GitHub Wiki
This file contains the single view of the app that the user directly accesses. This view is made up of the other views contained within the app.
This file contents can be broken down like so:
- The
ContentView
structurebuttonSize: CGFloat = 75.0
a constant property used to specify the size of the CalcButtonsspacing: CGFloat = 10.0
a constant property used to specify the space between CalcButtons@EnvironmentObject var appData: DataStoreXD
which is our global data storevar body: some View
which is the ContentView screen itselfVStack
with the background colourbg
CalcScreen
which hasappData.value
passed as a parameter, and horizontal padding.Keyboard
which hasbuttonSize
andspacing
passed as parameters, which are class properties of this screen.
- The
DataStoreXD
class, which can be accessed from any view@Published var value: String
stores the value on the screen@Published var decimal: Bool
stores if the value has a decimal part@Published var cache: String
stores a previous value@Published var ac: Bool
AC button says 'AC' iftrue
, 'C' iffalse
@Published var active: Dictionary<String, Bool>
for each operation button, is it active?init()
initialises the object
- The preview structure
- An instance of
ContentView()
- An instance of