Skip to content

Commit

Permalink
Merge pull request #6 from peterentwistle/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
peterentwistle authored Jan 29, 2017
2 parents bc6c2c3 + c4d5744 commit 055cb55
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 78 deletions.
4 changes: 2 additions & 2 deletions Calculator WatchKit App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>107</string>
<string>109</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
4 changes: 2 additions & 2 deletions Calculator WatchKit Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>107</string>
<string>109</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
40 changes: 20 additions & 20 deletions Calculator WatchKit Extension/InterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import WatchKit
import Foundation

enum Operator {
case Addition
case Subtract
case Multiply
case Divide
case addition
case subtract
case multiply
case divide
}

extension String {
Expand Down Expand Up @@ -91,39 +91,39 @@ class InterfaceController: WKInterfaceController {
}

@IBAction func addition() {
selectedOperator = .Addition
selectedOperator = .addition
changeBackgroundColours(additionBtn)
resetDecimal()
}

@IBAction func subtract() {
selectedOperator = .Subtract
selectedOperator = .subtract
changeBackgroundColours(subtractBtn)
resetDecimal()
}

@IBAction func multiply() {
selectedOperator = .Multiply
selectedOperator = .multiply
changeBackgroundColours(multiplyBtn)
resetDecimal()
}

@IBAction func divide() {
selectedOperator = .Divide
selectedOperator = .divide
changeBackgroundColours(divideBtn)
resetDecimal()
}

@IBAction func equals() {
let result: Float
switch selectedOperator! {
case .Addition:
case .addition:
result = firstNum.floatValue + secondNum.floatValue
case .Subtract:
case .subtract:
result = firstNum.floatValue - secondNum.floatValue
case .Multiply:
case .multiply:
result = firstNum.floatValue * secondNum.floatValue
case .Divide:
case .divide:
result = firstNum.floatValue / secondNum.floatValue
}
resultLabel.setText(result.description)
Expand All @@ -147,8 +147,8 @@ class InterfaceController: WKInterfaceController {
}
}

override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
operatorButtons.append(divideBtn)
operatorButtons.append(multiplyBtn)
Expand All @@ -166,7 +166,7 @@ class InterfaceController: WKInterfaceController {
super.didDeactivate()
}

func addToDisplay(s: Character) {
func addToDisplay(_ s: Character) {
if let _ = selectedOperator {
secondNum.append(s)
resultLabel.setText(secondNum)
Expand All @@ -176,7 +176,7 @@ class InterfaceController: WKInterfaceController {
}
}

func changeBackgroundColours(selectedButton: WKInterfaceButton) {
func changeBackgroundColours(_ selectedButton: WKInterfaceButton) {
for button in operatorButtons {
if button == selectedButton {
setButtonBackgroundColourGreen(button)
Expand All @@ -186,12 +186,12 @@ class InterfaceController: WKInterfaceController {
}
}

func setButtonBackgroundColourGreen(button: WKInterfaceButton) {
button.setBackgroundColor(UIColor.greenColor())
func setButtonBackgroundColourGreen(_ button: WKInterfaceButton) {
button.setBackgroundColor(UIColor.green)
}

func resetButtonBackgroundColour(button: WKInterfaceButton) {
button.setBackgroundColor(UIColor.darkGrayColor())
func resetButtonBackgroundColour(_ button: WKInterfaceButton) {
button.setBackgroundColor(UIColor.darkGray)
}

func resetDecimal() {
Expand Down
12 changes: 6 additions & 6 deletions Calculator/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
10 changes: 10 additions & 0 deletions Calculator/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
Expand Down
21 changes: 12 additions & 9 deletions Calculator/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -13,27 +17,26 @@
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Icon" translatesAutoresizingMaskIntoConstraints="NO" id="HRC-wj-9bI">
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="Icon" translatesAutoresizingMaskIntoConstraints="NO" id="HRC-wj-9bI">
<rect key="frame" x="149" y="163" width="303" height="205"/>
<constraints>
<constraint firstAttribute="width" constant="303" id="FN9-cc-2Nh"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TinyWatchCalc" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6JI-CZ-Ys6">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="TinyWatchCalc" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6JI-CZ-Ys6">
<rect key="frame" x="177" y="366" width="246" height="89"/>
<constraints>
<constraint firstAttribute="width" constant="246" id="7P0-dj-1sK"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="black" pointSize="30"/>
<color key="textColor" red="0.0" green="0.55294117649999996" blue="0.69803921570000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.55294117649999996" blue="0.69803921570000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" red="0.84705882349999995" green="0.81960784310000001" blue="0.73725490199999999" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.81960784310000001" blue="0.73725490199999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="6JI-CZ-Ys6" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="FCj-HF-Guj"/>
<constraint firstItem="xb3-aO-Qok" firstAttribute="top" secondItem="HRC-wj-9bI" secondAttribute="bottom" constant="232" id="HbO-9U-RWZ"/>
Expand Down
30 changes: 17 additions & 13 deletions Calculator/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11191" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11156"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -14,26 +15,26 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jaq-Z0-gnE">
<rect key="frame" x="48" y="137" width="505" height="174"/>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jaq-Z0-gnE">
<frame key="frameInset" minX="48" minY="137" width="505" height="174"/>
<constraints>
<constraint firstAttribute="height" constant="174" id="7pW-QS-NLG"/>
</constraints>
<string key="text">Welcome to TinyWatchCalc. This is the iPhone companion app, the watch app should install automatically. If the app does not install you can install it manually in the apple watch app on your iPhone.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Icon" translatesAutoresizingMaskIntoConstraints="NO" id="BoH-rp-cjz">
<rect key="frame" x="160" y="341" width="281" height="181"/>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="Icon" translatesAutoresizingMaskIntoConstraints="NO" id="BoH-rp-cjz">
<frame key="frameInset" minX="160" minY="341" width="281" height="181"/>
<constraints>
<constraint firstAttribute="width" constant="281" id="HCK-AT-t1k"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="juN-Zr-aq3">
<rect key="frame" x="216" y="524" width="169" height="30"/>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="juN-Zr-aq3">
<frame key="frameInset" minX="216" minY="524" width="169" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="169" id="4oa-pK-H7t"/>
<constraint firstAttribute="height" constant="30" id="f9H-eL-0Ye"/>
Expand All @@ -44,17 +45,17 @@
<action selector="copyBtn:" destination="BYZ-38-t0r" eventType="touchUpInside" id="bPu-7d-oou"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TinyWatchCalc" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5yL-rx-2tv">
<rect key="frame" x="184" y="41" width="232" height="36"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="TinyWatchCalc" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5yL-rx-2tv">
<frame key="frameInset" minX="184" minY="41" width="232" height="36"/>
<constraints>
<constraint firstAttribute="height" constant="36" id="ccC-LY-S9J"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="black" pointSize="30"/>
<color key="textColor" red="0.0" green="0.55294117647058827" blue="0.69803921568627447" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.55294117647058827" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.84705882352941175" green="0.81960784313725488" blue="0.73725490196078436" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.84705882352941175" green="0.81960784313725488" blue="0.73725490196078436" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="jaq-Z0-gnE" firstAttribute="top" secondItem="5yL-rx-2tv" secondAttribute="bottom" constant="60" id="4lx-yo-j04"/>
<constraint firstItem="BoH-rp-cjz" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="76j-u5-f0H"/>
Expand All @@ -68,6 +69,9 @@
<constraint firstItem="5yL-rx-2tv" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="21" id="lcs-fe-nJy"/>
</constraints>
</view>
<connections>
<outlet property="copyBtn" destination="juN-Zr-aq3" id="w2G-6C-gMR"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
Expand Down
Loading

0 comments on commit 055cb55

Please sign in to comment.