Add a few more things
This commit is contained in:
parent
e6c3489e66
commit
b54dcad16e
@ -22,7 +22,13 @@
|
|||||||
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||||
<items>
|
<items>
|
||||||
<navigationItem title="FitKit" id="2jc-hB-lMj"/>
|
<navigationItem title="FitKit" id="2jc-hB-lMj">
|
||||||
|
<barButtonItem key="rightBarButtonItem" title="Log Out" id="A20-nJ-4HO">
|
||||||
|
<connections>
|
||||||
|
<action selector="logOut:" destination="BYZ-38-t0r" id="ohP-Rh-eHV"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
</navigationItem>
|
||||||
</items>
|
</items>
|
||||||
</navigationBar>
|
</navigationBar>
|
||||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Logged In" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CoH-cd-flw">
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Logged In" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CoH-cd-flw">
|
||||||
@ -39,6 +45,14 @@
|
|||||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||||
</textView>
|
</textView>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qBL-XQ-4jZ">
|
||||||
|
<rect key="frame" x="170" y="617" width="34" height="30"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<state key="normal" title="Sync"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="syncNow:" destination="BYZ-38-t0r" eventType="touchUpInside" id="50A-vo-aNS"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
<accessibility key="accessibilityConfiguration">
|
<accessibility key="accessibilityConfiguration">
|
||||||
@ -47,6 +61,7 @@
|
|||||||
<viewLayoutGuide key="safeArea" id="OGN-ry-fYp"/>
|
<viewLayoutGuide key="safeArea" id="OGN-ry-fYp"/>
|
||||||
</view>
|
</view>
|
||||||
<connections>
|
<connections>
|
||||||
|
<outlet property="logInButton" destination="A20-nJ-4HO" id="wg9-Si-CdO"/>
|
||||||
<outlet property="loggedIn" destination="CoH-cd-flw" id="SUh-wA-KNF"/>
|
<outlet property="loggedIn" destination="CoH-cd-flw" id="SUh-wA-KNF"/>
|
||||||
<outlet property="outputText" destination="IdY-jU-MBP" id="yl5-f9-Gws"/>
|
<outlet property="outputText" destination="IdY-jU-MBP" id="yl5-f9-Gws"/>
|
||||||
</connections>
|
</connections>
|
||||||
|
@ -14,6 +14,7 @@ class ViewController: UIViewController {
|
|||||||
|
|
||||||
@IBOutlet var loggedIn: UILabel!
|
@IBOutlet var loggedIn: UILabel!
|
||||||
@IBOutlet var outputText: UITextView!
|
@IBOutlet var outputText: UITextView!
|
||||||
|
@IBOutlet var logInButton: UIBarButtonItem!
|
||||||
let client = FitbitClient()
|
let client = FitbitClient()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@ -35,14 +36,23 @@ class ViewController: UIViewController {
|
|||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if self.client.isAuthorized() {
|
if self.client.isAuthorized() {
|
||||||
self.loggedIn.text = "Logged In"
|
self.loggedIn.text = "Logged In"
|
||||||
//self.loginButton.currentTitle = "Log Out"
|
self.logInButton.title = "Log Out"
|
||||||
} else {
|
} else {
|
||||||
self.loggedIn.text = "Not Logged In"
|
self.loggedIn.text = "Not Logged In"
|
||||||
//self.loginButton.currentTitle = "Log In"
|
self.logInButton.title = "Log In"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func logOut(_ sender: Any) {
|
||||||
|
NSLog("Log out!!!")
|
||||||
|
self.client.clearCredential()
|
||||||
|
self.updateAuthorizedLabel()
|
||||||
|
}
|
||||||
|
@IBAction func syncNow(_ sender: Any) {
|
||||||
|
NSLog("Sync button tapped")
|
||||||
|
self.syncWeights()
|
||||||
|
}
|
||||||
/// Ensure that the client is authorized and then continue
|
/// Ensure that the client is authorized and then continue
|
||||||
fileprivate func ensureAuthorized(callback: @escaping (Bool) -> Void) {
|
fileprivate func ensureAuthorized(callback: @escaping (Bool) -> Void) {
|
||||||
// If already authroized, we can short circuit
|
// If already authroized, we can short circuit
|
||||||
|
Loading…
Reference in New Issue
Block a user