-
Notifications
You must be signed in to change notification settings - Fork 0
What each Swift file does
The root SwiftUI view is defined here. It calls another view which is inside a user module. Keeping all the Swift files in a user module has the benefit that all the code is available amongst these files without having to modify file access levels. The view you call from root has to be marked as Public as well as its initialiser and body.
These files do most of the work for you. Define some buttons in an array of type Buttons. Call CreateButtonsFromArray in a HStack or VStack for example and pass in this array. The buttons will be created for you. When you press them they will send the commands defined in the array.
This defines the serverIPAddress - make sure it matches the IP address of the computer hosting the Python server DirectInputServer. The class TCPClient creates a connection to the server so the Playground can communicate to the server. Every time a message is sent it is sent with sharedTCPClient of which only one instance is created.
It's easier to define data in one place and use separate code to define presentation. Arrays of buttons are used and their properties are defined here.
Array of buttons that will be used with CreateButtonsFromArray to create a keyboard number pad.
Arrays of buttons that will be used with CreateButtonsFromArray to create stacks of buttons.
Defines every keystroke that can be sent
This view defines a SwiftUI button and its properties that can be modified.
A row that displays the Server IP address and a button to gracefully stop the connection.
Pass an array of type buttons to this struct and for each array item a SwiftUI button will be created.
This view provides the presentation for the first tab.
This row shows messages sent to DirectInputServer.
Call NumPad() in a containing view and a number pad on a keyboard will be created.
This view provides the presentation for the second tab.
This is called from the PlaygroundPage and creates a TabView. Here you can define how many tabs, their icons and tab names. For each tab you can define its content.