ViewControllerGraph
class ViewControllerGraph : UIViewController
The UIViewController subclass for the top half of the app’s UI. It controls the bifocal display utilising the SwiftCharts library, referenced in the documentation.
-
DatePicker used to change and display date
Declaration
Swift
let picker: UIDatePicker -
Initializes the app to today
Declaration
Swift
var today: Date -
Declares Notifications
Declaration
Swift
let nc: NotificationCenter -
Array storing date and time info needed for plot. To be updated with real-time data.
Declaration
Swift
var rawData: [String] -
Array storing past glucose measurements. To be updated with real-time data from wearables.
Declaration
Swift
var rawValues: [Double]
-
Outlet function for if the UISwipeGestureRecognizer detects a right swipe. It then proceeds to update the date by subtracting a day from the current viewed date and updates the bifocal display and creates a notification to synchronize the app.
Declaration
Swift
@IBAction func rightGesture(_ sender: UISwipeGestureRecognizer) -
Outlet function for if the UISwipeGestureRecognizer detects a left swipe. It then proceeds to update the date by adding a day from the current viewed date and updates the bifocal display and creates a notification to synchronize the app.
Declaration
Swift
@IBAction func leftGesture(_ sender: UISwipeGestureRecognizer) -
This function is an override of the same function in the superclass which is called after the view has loaded. It calls the functions responsible for rotating the sideView containers, creating the DatePicker, update any settings and add the notification listeners.
Declaration
Swift
override func viewDidLoad()Return Value
Null
-
Loads data from arrays into core data on first launch for test purposes
Declaration
Swift
func loadData()Return Value
Null
-
Rotates the sideView Containers by (+/-)45degrees about the y axis to give the impression of perspective.
Declaration
Swift
func sideTransforms()Return Value
Null
-
Notifications for when events are added
Declaration
Swift
func addNotifications() -
Called when a notification is received after food, exercise or insulin has been added to Core Data. It reloads the chart data and displays it.
Declaration
Swift
@objc private func dataUpdated() -
Registers settings bundle. Creates a Notification Listener to detect when a change has been made to the Settings.
Declaration
Swift
func settingPreferences() -
Detects which changes that have been made to the Settings and apply them to the UI.
Declaration
Swift
@objc func defaultsChanged() -
Function called when a Notification is detected upon the date being changed. Used to synchronize the app.
Declaration
Swift
@objc func setDay(notification: Notification) -
Creates a Notification used to synchronize the Date throughout the app.
Declaration
Swift
func updateDay() -
Re-initializes the chart and sideViews with the new data corresponding to the updated Date.
Declaration
Swift
private func updateViews() -
Takes the date as argument and converts it to the format ‘weekday day month, year’, then places it in the DatePicker.
- - Parameter date: Date to be transformed
Declaration
Swift
func formatWeekday(date: Date) -
Create a date picker and formats today’s date as required and displays it.
Declaration
Swift
func createDatePicker() -
Function called after the user has finished with the DatePicker and synchronizes the date used for the chart with the viewController.
Declaration
Swift
@objc func donePressed() -
Calculates the minimum, maximum and mean average for daily glucose measurements and updates the CustomView’s member data.
Declaration
Swift
private func calcRanges(Arr: [Double], view: CustomView)Parameters
ArrDouble Array, Glucose measurements for a day.
viewCustomView, to be updated with calculated values.
-
Frame settings for chart area and axis.
Declaration
Swift
fileprivate lazy var chartSettings: ChartSettings { get set } -
Plots glucose, meals, exercise, insulin and predicted glucose data in Layers to create the chart featured in the Bifocal Display. Draws popups and attach messages to them based on Core Data. Change of dates gets passed in to update chart.
Declaration
Swift
private func initChart()
View on GitHub
ViewControllerGraph Class Reference