Skip to content

Commit

Permalink
update watch app UI
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiralArm Consulting Ltd committed Feb 2, 2019
1 parent 202db87 commit e1c4065
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 300 deletions.
8 changes: 0 additions & 8 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D020CB721FEF3D200DC71C2 /* SplitController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D020CB621FEF3D200DC71C2 /* SplitController.swift */; };
2D020CB921FEF5A100DC71C2 /* BillController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D020CB821FEF5A100DC71C2 /* BillController.swift */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
2D69490521FDFD9600B94252 /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2D69490321FDFD9600B94252 /* Interface.storyboard */; };
Expand All @@ -18,7 +17,6 @@
2D69491521FDFD9700B94252 /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D69491421FDFD9700B94252 /* ExtensionDelegate.swift */; };
2D69491721FDFD9700B94252 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2D69491621FDFD9700B94252 /* Assets.xcassets */; };
2D69491B21FDFD9700B94252 /* WatchTips.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 2D69490121FDFD9600B94252 /* WatchTips.app */; };
2D69492921FE165500B94252 /* TipController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D69492821FE165500B94252 /* TipController.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -89,7 +87,6 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D020CB621FEF3D200DC71C2 /* SplitController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitController.swift; sourceTree = "<group>"; };
2D020CB821FEF5A100DC71C2 /* BillController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BillController.swift; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
2D69490121FDFD9600B94252 /* WatchTips.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WatchTips.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -101,7 +98,6 @@
2D69491421FDFD9700B94252 /* ExtensionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionDelegate.swift; sourceTree = "<group>"; };
2D69491621FDFD9700B94252 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2D69491821FDFD9700B94252 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2D69492821FE165500B94252 /* TipController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipController.swift; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,10 +149,8 @@
children = (
2D69491221FDFD9700B94252 /* InterfaceController.swift */,
2D69491421FDFD9700B94252 /* ExtensionDelegate.swift */,
2D69492821FE165500B94252 /* TipController.swift */,
2D69491621FDFD9700B94252 /* Assets.xcassets */,
2D69491821FDFD9700B94252 /* Info.plist */,
2D020CB621FEF3D200DC71C2 /* SplitController.swift */,
2D020CB821FEF5A100DC71C2 /* BillController.swift */,
);
path = "WatchTips Extension";
Expand Down Expand Up @@ -406,11 +400,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2D020CB721FEF3D200DC71C2 /* SplitController.swift in Sources */,
2D020CB921FEF5A100DC71C2 /* BillController.swift in Sources */,
2D69491521FDFD9700B94252 /* ExtensionDelegate.swift in Sources */,
2D69491321FDFD9700B94252 /* InterfaceController.swift in Sources */,
2D69492921FE165500B94252 /* TipController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
104 changes: 27 additions & 77 deletions ios/WatchTips Extension/InterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import Foundation
import WatchConnectivity


class InterfaceController: WKInterfaceController, WCSessionDelegate, WKCrownDelegate {
class InterfaceController: WKInterfaceController, WCSessionDelegate {


var tipAmount: Int = 10
var splitBetween: Int = 1
var billTotal = Double(0)
var focusButton: Int = 0
var accumulatedCrownDelta = 0.0

@IBOutlet weak var currentSplit: WKInterfaceButton!
@IBOutlet weak var currentTip: WKInterfaceButton!
@IBOutlet var currentSplit: WKInterfaceLabel!
@IBOutlet var currentTip: WKInterfaceLabel!
@IBOutlet weak var billButton: WKInterfaceButton!
@IBOutlet weak var currentTotal: WKInterfaceLabel!
@IBOutlet weak var costEach: WKInterfaceLabel!
Expand All @@ -33,59 +32,9 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate, WKCrownDele
}



func crownDidBecomeIdle(_ crownSequencer: WKCrownSequencer?) {
accumulatedCrownDelta = 0.0
}

func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
accumulatedCrownDelta += rotationalDelta
let threshold = 0.05

// do nothing if delta is less that threshold
guard abs(accumulatedCrownDelta) > threshold else {
return
}

if focusButton == 1 {
if accumulatedCrownDelta > 0 {
splitBetween += 1
} else {
splitBetween -= 1
}
if splitBetween < 1 {
splitBetween = 1
}
if splitBetween > 50 {
splitBetween = 50
}
}

if focusButton == 2 {
if accumulatedCrownDelta > 0 {
tipAmount += 1
} else {
tipAmount -= 1
}
if tipAmount < 0 {
tipAmount = 0
}
if tipAmount > 100 {
tipAmount = 100
}
}

accumulatedCrownDelta = 0
updateCalc()

}


override func awake(withContext context: Any?) {
super.awake(withContext: context)

// Configure interface objects here.
crownSequencer.delegate = self
updateCalc()
}

Expand All @@ -97,7 +46,6 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate, WKCrownDele
session.delegate = self
session.activate()
}
crownSequencer.focus()
updateCalc()
}

Expand All @@ -106,36 +54,38 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate, WKCrownDele
super.didDeactivate()
}


// chnage how many the bill is split between
@IBAction func showSplitController() {
resetButtonFocus()
currentSplit?.setBackgroundColor(UIColor(red: 0/255, green: 128/255, blue: 255/255, alpha: 1.0))
focusButton = 1
//presentController(withName: "SplitController", context: self)
@IBAction func splitDecrease() {
if(splitBetween > 1){
splitBetween -= 1
}
updateCalc()
}

@IBAction func splitIncrease() {
if(splitBetween < 99){
splitBetween += 1
}
updateCalc()
}

@IBAction func showTipController() {
resetButtonFocus()
currentTip?.setBackgroundColor(UIColor(red: 0/255, green: 128/255, blue: 255/255, alpha: 1.0))
focusButton = 2
//presentController(withName: "TipController", context: self)
@IBAction func tipPercentReduce() {
if(tipAmount>0){
tipAmount -= 1
}
updateCalc()
}

@IBAction func tipPercentIncrease() {
if(tipAmount<100){
tipAmount += 1
}
updateCalc()
}

@IBAction func showBillController() {
resetButtonFocus()
presentController(withName: "BillController", context: self)
}

// reset the focus to the currently selected button
func resetButtonFocus(){
focusButton = 0
currentSplit?.setBackgroundColor(UIColor.darkGray)
currentTip?.setBackgroundColor(UIColor.darkGray)
billButton?.setBackgroundColor(UIColor.darkGray)
}

// Update the actual calculations
func updateCalc(){
Expand All @@ -146,8 +96,8 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate, WKCrownDele
let perPerson = billWithTip / Double(splitBetween)

// update display
currentTip.setTitle("\(tipAmount)%")
currentSplit.setTitle("\(splitBetween)")
currentTip.setText("\(tipAmount)%")
currentSplit.setText("\(splitBetween)")
currentTotal.setText(String(format: "%.2f", billTotal))
withTip.setText(String(format: "%.2f", billWithTip))
costEach.setText(String(format: "%.2f", perPerson))
Expand Down
62 changes: 0 additions & 62 deletions ios/WatchTips Extension/SplitController.swift

This file was deleted.

58 changes: 0 additions & 58 deletions ios/WatchTips Extension/TipController.swift

This file was deleted.

Loading

0 comments on commit e1c4065

Please sign in to comment.