Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
Change project setup. Add back some tests.
Browse files Browse the repository at this point in the history
The pods are now installed as frameworks. This generates a compile
warning that can be ignored for now. Deploying will require to set the
frameork's target as 'safe API only'.
The test suite is still problematic with Xcode 6.3, so only the
DrinkViewController is available right now.
  • Loading branch information
andreamazz committed Apr 26, 2015
1 parent de186a5 commit 87a2d87
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 68 deletions.
14 changes: 10 additions & 4 deletions BigGulp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
65F295DD1AA3B314003D4016 /* NSUserDefaults-BigGulp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F295DB1AA3B311003D4016 /* NSUserDefaults-BigGulp.swift */; };
65F295E31AA61F4B003D4016 /* Onboarding.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65F295E21AA61F4B003D4016 /* Onboarding.storyboard */; };
696B3059AB57E24FA7EEA307 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9472BDFA39F9529F02380169 /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
7BBBDA1EA024CAEDA92009EA /* Pods_BigGulpTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A01D32D47AD6F4810507097 /* Pods_BigGulpTests.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
D4CE697120972CE291433FD5 /* Pods_BigGulpTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A01D32D47AD6F4810507097 /* Pods_BigGulpTests.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
D8974C0C139A1D0A12CAE27A /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9472BDFA39F9529F02380169 /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -201,6 +202,7 @@
buildActionMask = 2147483647;
files = (
696B3059AB57E24FA7EEA307 /* Pods.framework in Frameworks */,
7BBBDA1EA024CAEDA92009EA /* Pods_BigGulpTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -342,9 +344,9 @@
children = (
65B67E5F1A924BCC000A3CCD /* BigGulp */,
6567DAF31A97A43C00857A43 /* BigGulpToday */,
65B67E771A924BCC000A3CCD /* BigGulpTests */,
6585CFA81AAC9A8300CA27F3 /* BigGulp WatchKit Extension */,
6585CFBA1AAC9A8300CA27F3 /* BigGulp WatchKit App */,
65B67E771A924BCC000A3CCD /* BigGulpTests */,
65B67E5E1A924BCC000A3CCD /* Products */,
BF687DAEDF50F34E88CA7A48 /* Pods */,
67E925FAFF6ADF6DA2BD003B /* Frameworks */,
Expand Down Expand Up @@ -750,7 +752,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BigGulpTests/Pods-BigGulpTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
D3F03390AD26351258934912 /* Embed Pods Frameworks */ = {
Expand Down Expand Up @@ -1105,6 +1107,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEFINES_MODULE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -1160,6 +1163,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEFINES_MODULE = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -1191,12 +1195,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5940FD500B5BF8735B6311F3 /* Pods.debug.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = BigGulp/BigGulp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = NO;
DEFINES_MODULE = YES;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = BigGulp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
Expand All @@ -1212,12 +1217,13 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 6903FDD88E08C7ECB5026E69 /* Pods.release.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = BigGulp/BigGulp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = NO;
DEFINES_MODULE = YES;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = BigGulp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
Expand Down
14 changes: 7 additions & 7 deletions BigGulp/Model/Entry.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import Foundation
import Realm

class Entry: RLMObject {
dynamic var date = Entry.defaultDate()
dynamic var quantity = 0.0
dynamic var percentage = 0.0
dynamic var goal = 0.0
dynamic var gulps = RLMArray(objectClassName: Gulp.className())
public class Entry: RLMObject {
dynamic public var date = Entry.defaultDate()
dynamic public var quantity = 0.0
dynamic public var percentage = 0.0
dynamic public var goal = 0.0
dynamic public var gulps = RLMArray(objectClassName: Gulp.className())

class func defaultDate() -> String {
let dateFormat = NSDateFormatter()
dateFormat.dateFormat = "yyyy-MM-dd"
return dateFormat.stringFromDate(NSDate())
}

override class func primaryKey() -> String {
override public class func primaryKey() -> String {
return "date"
}

Expand Down
8 changes: 4 additions & 4 deletions BigGulp/Model/EntryHandler.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Foundation
import Realm

class EntryHandler: NSObject {
func currentEntry() -> Entry {
public class EntryHandler: NSObject {
public func currentEntry() -> Entry {
let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.it.fancypixel.BigGulp")!
let realmPath = directory.path!.stringByAppendingPathComponent("db.realm")
RLMRealm.setDefaultRealmPath(realmPath)
Expand All @@ -21,12 +21,12 @@ class EntryHandler: NSObject {
}
}

func addGulp(quantity: Double) {
public func addGulp(quantity: Double) {
let entry = currentEntry()
entry.addGulp(quantity, goal: NSUserDefaults.groupUserDefaults().doubleForKey(Settings.Gulp.Goal.key()), realm: RLMRealm.defaultRealm())
}

func removeLastGulp() {
public func removeLastGulp() {
let realm = RLMRealm.defaultRealm()
let entry = currentEntry()
if let gulp = entry.gulps.lastObject() as? Gulp {
Expand Down
6 changes: 3 additions & 3 deletions BigGulp/Onboarding.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="By6-Ql-uIz">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14E7f" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="By6-Ql-uIz">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<customFonts key="customFonts">
Expand All @@ -28,7 +28,7 @@
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="I’m here to help you keeping track of a simple healthy habit: 
drinking water." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dbP-89-LG1">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="I’m here to help you keep track of a simple healthy habit: 
drinking water." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dbP-89-LG1">
<rect key="frame" x="16" y="140" width="288" height="66"/>
<fontDescription key="fontDescription" name="Avenir-Book" family="Avenir" pointSize="16"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand Down
20 changes: 10 additions & 10 deletions BigGulp/Support/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ enum UnitsOfMeasure: Int {
}
}

class Settings {
public class Settings {

enum General: Int {
public enum General: Int {
case UnitOfMeasure, OnboardingShown

func key() -> String {
public func key() -> String {
switch self {
case .UnitOfMeasure:
return "UNIT_OF_MEASURE"
Expand All @@ -37,9 +37,9 @@ class Settings {
}
}

enum Gulp: Int {
public enum Gulp: Int {
case Big, Small, Goal
func key() -> String {
public func key() -> String {
switch self {
case .Big:
return "GULP_BIG"
Expand All @@ -51,9 +51,9 @@ class Settings {
}
}

enum Notification: Int {
public enum Notification: Int {
case On, From, To, Interval
func key() -> String {
public func key() -> String {
switch self {
case .On:
return "NOTIFICATION_ON"
Expand All @@ -67,7 +67,7 @@ class Settings {
}
}

class func registerDefaults() {
public class func registerDefaults() {
let userDefaults = NSUserDefaults.groupUserDefaults()

// The defaults registered with registerDefaults are ignore by the Today Extension. :/
Expand All @@ -85,15 +85,15 @@ class Settings {
userDefaults.synchronize()
}

class func registerDefaultsForLiter() {
public class func registerDefaultsForLiter() {
let userDefaults = NSUserDefaults.groupUserDefaults()
userDefaults.setDouble(0.5, forKey: Gulp.Big.key())
userDefaults.setDouble(0.2, forKey: Gulp.Small.key())
userDefaults.setDouble(2, forKey: Gulp.Goal.key())
userDefaults.synchronize()
}

class func registerDefaultsForOunces() {
public class func registerDefaultsForOunces() {
let userDefaults = NSUserDefaults.groupUserDefaults()
userDefaults.setDouble(16, forKey: Gulp.Big.key())
userDefaults.setDouble(8, forKey: Gulp.Small.key())
Expand Down
3 changes: 2 additions & 1 deletion BigGulp/ViewControllers/DrinkViewController+Animations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import pop
extension DrinkViewController {

func initAnimation() {
[self.smallButton, self.largeButton].map({$0.alpha = 0})
self.smallButton.alpha = 0
self.largeButton.alpha = 0
}

func expandAddButton() {
Expand Down
34 changes: 17 additions & 17 deletions BigGulp/ViewControllers/DrinkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import UICountingLabel
import MMWormhole
import AMPopTip

class DrinkViewController: UIViewController, UIAlertViewDelegate {

@IBOutlet weak var progressMeter: DPMeterView!
@IBOutlet weak var percentageLabel: UICountingLabel!
@IBOutlet weak var addButton: UIButton!
@IBOutlet weak var smallButton: UIButton!
@IBOutlet weak var largeButton: UIButton!
@IBOutlet weak var minusButton: UIButton!
@IBOutlet var entryHandler: EntryHandler!
let userDefaults = NSUserDefaults.groupUserDefaults()
public class DrinkViewController: UIViewController, UIAlertViewDelegate {

@IBOutlet public weak var progressMeter: DPMeterView!
@IBOutlet public weak var percentageLabel: UICountingLabel!
@IBOutlet public weak var addButton: UIButton!
@IBOutlet public weak var smallButton: UIButton!
@IBOutlet public weak var largeButton: UIButton!
@IBOutlet public weak var minusButton: UIButton!
@IBOutlet public var entryHandler: EntryHandler!
public var userDefaults = NSUserDefaults.groupUserDefaults()
var expanded = false
let wormhole = MMWormhole(applicationGroupIdentifier: "group.it.fancypixel.BigGulp", optionalDirectory: "biggulp")

override func viewDidLoad() {
public override func viewDidLoad() {
super.viewDidLoad()

self.title = "Drink!"
Expand All @@ -38,17 +38,17 @@ class DrinkViewController: UIViewController, UIAlertViewDelegate {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateUI", name: UIApplicationDidBecomeActiveNotification, object: nil)
}

override func viewDidLayoutSubviews() {
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.progressMeter.setShape(ProgressMeter.pathFromRect(self.progressMeter.frame))
}

override func viewWillAppear(animated: Bool) {
public override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
updateUI()
}

override func viewDidAppear(animated: Bool) {
public override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
}

Expand All @@ -60,7 +60,7 @@ class DrinkViewController: UIViewController, UIAlertViewDelegate {

func updateUI() {
self.percentageLabel.countFromCurrentValueTo(Float(ceil(self.entryHandler.currentEntry().percentage)))
self.progressMeter.setProgress(CGFloat(self.entryHandler.currentEntry().percentage / 100.0), duration: 2)
self.progressMeter.setProgress(CGFloat(self.entryHandler.currentEntry().percentage / 100.0), duration: 1.5)
}

@IBAction func addButtonAction(sender: UIButton) {
Expand All @@ -71,7 +71,7 @@ class DrinkViewController: UIViewController, UIAlertViewDelegate {
}
}

@IBAction func selectionButtonAction(sender: UIButton) {
@IBAction public func selectionButtonAction(sender: UIButton) {
contractAddButton()
if (!self.userDefaults.boolForKey("UNDO_HINT")) {
self.userDefaults.setBool(true, forKey: "UNDO_HINT")
Expand All @@ -93,7 +93,7 @@ class DrinkViewController: UIViewController, UIAlertViewDelegate {
alert.show()
}

func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
public func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
if (buttonIndex > 0) {
self.entryHandler.removeLastGulp()
updateUI()
Expand Down
Loading

0 comments on commit 87a2d87

Please sign in to comment.