//
//  InterfaceController.swift
//  Project37 WatchKit Extension
//
//  Created by TwoStraws on 25/08/2016.
//  Copyright © 2016 Paul Hudson. All rights reserved.
//

import Foundation
import WatchKit
import WatchConnectivity


class InterfaceController: WKInterfaceController, WCSessionDelegate {
	@IBOutlet var welcomeText: WKInterfaceLabel!
	@IBOutlet var hideButton: WKInterfaceButton!

    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
        
        // Configure interface objects here.
    }

    override func willActivate() {
        // This method is called when watch view controller is about to be visible to user
        super.willActivate()

		if WCSession.isSupported() {
			let session = WCSession.default()
			session.delegate = self
			session.activate()
		}
    }

    override func didDeactivate() {
        // This method is called when watch view controller is no longer visible
        super.didDeactivate()
    }

	@IBAction func hideWelcomeText() {
		welcomeText.setHidden(true)
		hideButton.setHidden(true)
	}

	func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {

	}

	func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
		WKInterfaceDevice().play(.click)
	}
}
