Skip to content
Permalink
ba4409d748
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
63 lines (53 sloc) 2.04 KB
//
// MainMenuInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 11/21/18.
// Copyright © 2018 Alan Maynard. All rights reserved.
//
import WatchKit
import Foundation
import Alamofire
import SwiftyJSON
class MainMenuInterfaceController: WKInterfaceController {
@IBOutlet weak var accountsButton: WKInterfaceButton!
@IBOutlet weak var wellnessButton: WKInterfaceButton!
var accounts: [Account] = []
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// We should find a better place for this call, just for testing purposes
FetchData.attemptLogin { result, error in
switch result {
case true:
FetchData.getAccountInfo { accounts, error in
guard error == nil else {
NSLog("Account Retrieval Error: %s", error?.localizedDescription ?? "")
return
}
self.accounts = accounts
}
case false:
NSLog("Login Error: %s", error?.localizedDescription ?? "Unknown Error")
}
}
//just here for testing. Should be moved into the accounts controller when that branch is merged
// FetchData.getAccountInfo()
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
if segueIdentifier == "toAccounts" {
// we will probably want to do some setup prior to presenting Accounts
print(accounts.count)
} else if segueIdentifier == "toWellness" {
// we will probably want to do some setup prior to presenting Wellness
}
return nil
}
}