ViewControllerMain
class ViewControllerMain : UIViewController
Controls transitions between domains by showing and hiding domain and indicator views. Also controls insulin entry views.
-
Tracks date set by graph and hides insulin entry fields when not on current day
Declaration
Swift
private var currentDay: Date { get set } -
Instantiates Date Picker for insulin time selection
Declaration
Swift
private var insulinTimePicker: UIDatePicker -
Stores whether keyboard is open, to smooth transitions between tabs
Declaration
Swift
private var keyboardOpen: Bool -
Variable to track state of views
Declaration
Swift
private var state: MainViewState { get set }
-
viewDidLoad override to set initial state of: Insulin date entry field, TimePicker instantiation, Observer to act on current graph day changing, Observers to act based on keyboard state
Declaration
Swift
override func viewDidLoad()
-
Updates the currentDay variable with a date provided via notification from ViewControllerGraph
Declaration
Swift
@objc private func updateDay(notification: Notification)
-
Func to set state cases: .food, .exercise, .health or .advice. This hides other embedded views and brings chosen domain to the front
Declaration
Swift
private func updateViews()
-
Sets state to .health, updating the view to display the health domain
Declaration
Swift
@IBAction private func healthButton(_ sender: UIButton) -
Sets state to .food, updating the view to display the food domain. If keyboard is open when set (only possible from Exercise domain), it is dismissed and state change is delayed to smooth the transition
Declaration
Swift
@IBAction private func foodButton(_ sender: UIButton) -
Sets state to .exercise, updating the view to display the exercise domain. If keyboard is open when set (only possible from Food domain), it is dismissed and state change is delayed to smooth the transition
Declaration
Swift
@IBAction private func exerciseButton(_ sender: UIButton) -
Sets state to .advice, updating the view to display the advice domain
Declaration
Swift
@IBAction private func adviceButton(_ sender: UIButton)
-
Insulin clock icon: Toggles a text field with a time picker to enter time of insulin dose
Declaration
Swift
@IBAction private func glucoseClockButton(_ sender: Any) -
Insulin button (blood symbol): Toggles visibility of insulin text field and insulin clock icon. When closed, if a value has been entered it will be added to the database. If no time value was entered, the current time will be used.
Declaration
Swift
@IBAction private func glucoseButton(_ sender: Any) -
Insulin Time picker
Declaration
Swift
private func createInsulinTimePicker()
-
Opens phone settings
Declaration
Swift
@IBAction func settingsPopup(_ sender: Any)
View on GitHub
ViewControllerMain Class Reference