Skip to content

Commit

Permalink
1. Task redux with order and upcoming cells
Browse files Browse the repository at this point in the history
  • Loading branch information
Syerram committed Jan 22, 2015
1 parent 4969407 commit ce52608
Show file tree
Hide file tree
Showing 16 changed files with 368 additions and 109 deletions.
24 changes: 23 additions & 1 deletion asphalos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
9B9BED8F1A70930A001847DD /* ListOn.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED8B1A70930A001847DD /* ListOn.png */; };
9B9BED901A70930A001847DD /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED8C1A70930A001847DD /* [email protected] */; };
9B9BED911A70930A001847DD /* List.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED8D1A70930A001847DD /* List.png */; };
9B9BED931A713FD0001847DD /* TaskViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B9BED921A713FD0001847DD /* TaskViewCell.swift */; };
9B9BED961A7141A5001847DD /* Task_Icon_Unselected.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED941A7141A5001847DD /* Task_Icon_Unselected.png */; };
9B9BED971A7141A5001847DD /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED951A7141A5001847DD /* [email protected] */; };
9B9BED9A1A7141B8001847DD /* Task_Icon_Selected.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED981A7141B8001847DD /* Task_Icon_Selected.png */; };
9B9BED9B1A7141B8001847DD /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 9B9BED991A7141B8001847DD /* [email protected] */; };
9BB825501A662B0B004129E2 /* TaskerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BB8254F1A662B0B004129E2 /* TaskerController.swift */; };
9BB825551A66DAFE004129E2 /* Vault.png in Resources */ = {isa = PBXBuildFile; fileRef = 9BB825511A66DAFE004129E2 /* Vault.png */; };
9BB825561A66DAFE004129E2 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 9BB825521A66DAFE004129E2 /* [email protected] */; };
Expand Down Expand Up @@ -156,6 +161,12 @@
9B9BED8B1A70930A001847DD /* ListOn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ListOn.png; sourceTree = "<group>"; };
9B9BED8C1A70930A001847DD /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
9B9BED8D1A70930A001847DD /* List.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = List.png; sourceTree = "<group>"; };
9B9BED921A713FD0001847DD /* TaskViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaskViewCell.swift; sourceTree = "<group>"; };
9B9BED941A7141A5001847DD /* Task_Icon_Unselected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Task_Icon_Unselected.png; sourceTree = "<group>"; };
9B9BED951A7141A5001847DD /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
9B9BED981A7141B8001847DD /* Task_Icon_Selected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Task_Icon_Selected.png; sourceTree = "<group>"; };
9B9BED991A7141B8001847DD /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
9B9BED9C1A715325001847DD /* asphalos 3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "asphalos 3.xcdatamodel"; sourceTree = "<group>"; };
9BB8254F1A662B0B004129E2 /* TaskerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaskerController.swift; sourceTree = "<group>"; };
9BB825511A66DAFE004129E2 /* Vault.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Vault.png; sourceTree = "<group>"; };
9BB825521A66DAFE004129E2 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -197,6 +208,10 @@
9B0B3ABF1A58F5B4003222B9 /* Images */ = {
isa = PBXGroup;
children = (
9B9BED981A7141B8001847DD /* Task_Icon_Selected.png */,
9B9BED991A7141B8001847DD /* [email protected] */,
9B9BED941A7141A5001847DD /* Task_Icon_Unselected.png */,
9B9BED951A7141A5001847DD /* [email protected] */,
9B9BED8A1A70930A001847DD /* [email protected] */,
9B9BED8B1A70930A001847DD /* ListOn.png */,
9B9BED8C1A70930A001847DD /* [email protected] */,
Expand Down Expand Up @@ -463,6 +478,7 @@
9BB8254E1A662AE5004129E2 /* Tasker */ = {
isa = PBXGroup;
children = (
9B9BED921A713FD0001847DD /* TaskViewCell.swift */,
9BB8254F1A662B0B004129E2 /* TaskerController.swift */,
9BB825591A66DB38004129E2 /* TaskEditController.swift */,
9B9BED731A687349001847DD /* TaskDetailController.swift */,
Expand Down Expand Up @@ -551,12 +567,14 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9B9BED9B1A7141B8001847DD /* [email protected] in Resources */,
9BF4DC6B1A662015006088F2 /* [email protected] in Resources */,
9BB825561A66DAFE004129E2 /* [email protected] in Resources */,
9BF4DC6A1A662015006088F2 /* TickSelected.png in Resources */,
9B2A16461A535193002E5AE4 /* Montserrat-Bold.ttf in Resources */,
9BB825601A66E3F0004129E2 /* BackwardWhite.png in Resources */,
9BB825551A66DAFE004129E2 /* Vault.png in Resources */,
9B9BED971A7141A5001847DD /* [email protected] in Resources */,
9BF4DC631A661FFB006088F2 /* VaultSelected.png in Resources */,
9BB8255F1A66E3F0004129E2 /* [email protected] in Resources */,
9BF4DC621A661FFB006088F2 /* [email protected] in Resources */,
Expand All @@ -570,9 +588,11 @@
9BB825581A66DAFE004129E2 /* [email protected] in Resources */,
9B9BED8E1A70930A001847DD /* [email protected] in Resources */,
9B2A15841A534547002E5AE4 /* LaunchScreen.xib in Resources */,
9B9BED9A1A7141B8001847DD /* Task_Icon_Selected.png in Resources */,
9BB825611A66E3F0004129E2 /* [email protected] in Resources */,
9B9BED8F1A70930A001847DD /* ListOn.png in Resources */,
9B2A15811A534547002E5AE4 /* Images.xcassets in Resources */,
9B9BED961A7141A5001847DD /* Task_Icon_Unselected.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -634,6 +654,7 @@
9B2A15E71A534848002E5AE4 /* FormSegmentedControlCell.swift in Sources */,
9B2A15E61A534848002E5AE4 /* FormPickerCell.swift in Sources */,
9B2A15B71A5346F8002E5AE4 /* CategoriesController.swift in Sources */,
9B9BED931A713FD0001847DD /* TaskViewCell.swift in Sources */,
9B2A15C61A534738002E5AE4 /* MasterPasswordController.swift in Sources */,
9B2A15ED1A534848002E5AE4 /* FormMultiLineLabelCell.swift in Sources */,
9B2A15F21A534857002E5AE4 /* FormBaseCell.swift in Sources */,
Expand Down Expand Up @@ -847,9 +868,10 @@
isa = XCVersionGroup;
children = (
9B9BED751A68B3AC001847DD /* asphalos 2.xcdatamodel */,
9B9BED9C1A715325001847DD /* asphalos 3.xcdatamodel */,
9B2A15791A534547002E5AE4 /* asphalos.xcdatamodel */,
);
currentVersion = 9B9BED751A68B3AC001847DD /* asphalos 2.xcdatamodel */;
currentVersion = 9B9BED9C1A715325001847DD /* asphalos 3.xcdatamodel */;
path = asphalos.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
36 changes: 36 additions & 0 deletions asphalos/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ extension UIView {
return image
}

class func colorizeImage(image:UIImage, withColor color:UIColor) -> UIImage {
var rect:CGRect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, false, image.scale);
var c:CGContextRef = UIGraphicsGetCurrentContext();
image.drawInRect(rect)
CGContextSetFillColorWithColor(c, color.CGColor);
CGContextSetBlendMode(c, kCGBlendModeSourceAtop);
CGContextFillRect(c, rect);

var result:UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}

class func delay(delay:Double, callback:() -> ()) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC))),
dispatch_get_main_queue(), callback)
}

}

extension UIImageView {
Expand Down Expand Up @@ -104,6 +123,11 @@ extension UILabel {
var newSize:CGSize = textView.sizeThatFits(CGSizeMake(width, CGFloat(MAXFLOAT)))
return newSize.height
}

class func getHeight(text:String, font:UIFont, width:CGFloat, height:CGFloat) -> CGFloat {
let size = (text as NSString).boundingRectWithSize(CGSizeMake(width, height), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName:font], context: nil)
return size.height
}
}

extension UIViewController {
Expand Down Expand Up @@ -307,4 +331,16 @@ extension SFSwiftNotification {
}
return notifyView
}
}

extension NSDate {

func isBefore(date:NSDate) -> Bool {
return self.compare(date) == NSComparisonResult.OrderedAscending
}

func isLater(date:NSDate) -> Bool {
return self.compare(date) == NSComparisonResult.OrderedDescending
}

}
22 changes: 8 additions & 14 deletions asphalos/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<string>Montserrat-Regular</string>
<string>Montserrat-Regular</string>
<string>Montserrat-Regular</string>
<string>Montserrat-Regular</string>
</mutableArray>
</customFonts>
<scenes>
Expand Down Expand Up @@ -258,7 +257,7 @@
<color key="textColor" red="0.53725490200000003" green="0.53725490200000003" blue="0.53725490200000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="C7F-dl-6r8">
<view tag="6" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="C7F-dl-6r8">
<rect key="frame" x="88" y="0.0" width="1" height="69"/>
<color key="backgroundColor" red="0.7843137255" green="0.78039215689999997" blue="0.80000000000000004" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
Expand Down Expand Up @@ -472,18 +471,12 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Qvo-yk-ggR" id="nFD-dk-aov">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="startTime" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qbh-Q1-Stk">
<rect key="frame" x="18" y="13" width="67" height="18"/>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="length" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qbh-Q1-Stk">
<rect key="frame" x="18" y="8" width="70" height="58"/>
<fontDescription key="fontDescription" name="Montserrat-Regular" family="Montserrat" pointSize="14"/>
<color key="textColor" red="0.53725490196078429" green="0.53725490196078429" blue="0.53725490196078429" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="endTime" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A1X-er-PvL">
<rect key="frame" x="18" y="43" width="63" height="18"/>
<fontDescription key="fontDescription" name="Montserrat-Regular" family="Montserrat" pointSize="14"/>
<color key="textColor" red="0.53725490200000003" green="0.53725490200000003" blue="0.53725490200000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kec-m2-xE8">
<rect key="frame" x="98" y="0.0" width="1" height="74"/>
<color key="backgroundColor" red="0.78431372549019607" green="0.7803921568627451" blue="0.80000000000000004" alpha="1" colorSpace="calibratedRGB"/>
Expand All @@ -497,7 +490,7 @@
</mask>
</variation>
</view>
<label opaque="NO" userInteractionEnabled="NO" tag="3" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="task" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wNK-Sp-sWD">
<label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="task" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wNK-Sp-sWD">
<rect key="frame" x="114" y="26" width="38" height="22"/>
<fontDescription key="fontDescription" name="Montserrat-Regular" family="Montserrat" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
Expand All @@ -507,18 +500,19 @@
<constraints>
<constraint firstItem="wNK-Sp-sWD" firstAttribute="leading" secondItem="Kec-m2-xE8" secondAttribute="trailing" constant="15" id="5A4-0k-Zdv"/>
<constraint firstAttribute="centerY" secondItem="wNK-Sp-sWD" secondAttribute="centerY" id="5os-JX-UcD"/>
<constraint firstAttribute="centerY" secondItem="Qbh-Q1-Stk" secondAttribute="centerY" constant="15" id="6BV-B5-m0x"/>
<constraint firstAttribute="centerY" secondItem="Qbh-Q1-Stk" secondAttribute="centerY" id="6BV-B5-m0x"/>
<constraint firstAttribute="centerY" secondItem="Kec-m2-xE8" secondAttribute="centerY" id="AEI-OB-EtZ"/>
<constraint firstAttribute="bottomMargin" secondItem="Kec-m2-xE8" secondAttribute="bottom" constant="-8" id="Gbt-5Z-TmL"/>
<constraint firstItem="Kec-m2-xE8" firstAttribute="leading" secondItem="nFD-dk-aov" secondAttribute="leadingMargin" constant="90" id="IkR-du-3AR"/>
<constraint firstItem="Qbh-Q1-Stk" firstAttribute="top" secondItem="nFD-dk-aov" secondAttribute="topMargin" id="JKZ-v4-t2s"/>
<constraint firstItem="Kec-m2-xE8" firstAttribute="leading" secondItem="nFD-dk-aov" secondAttribute="leadingMargin" constant="90" id="PK9-aa-vFT"/>
<constraint firstAttribute="centerY" secondItem="A1X-er-PvL" secondAttribute="centerY" constant="-15" id="UrH-Ax-nYC"/>
<constraint firstItem="Kec-m2-xE8" firstAttribute="leading" secondItem="Qbh-Q1-Stk" secondAttribute="trailing" constant="20" id="aih-U8-gcJ"/>
<constraint firstItem="Qbh-Q1-Stk" firstAttribute="leading" secondItem="nFD-dk-aov" secondAttribute="leadingMargin" constant="10" id="b6w-Wy-8Tn"/>
<constraint firstItem="wNK-Sp-sWD" firstAttribute="leading" secondItem="nFD-dk-aov" secondAttribute="leadingMargin" constant="125" id="bzh-ee-BR1"/>
<constraint firstItem="A1X-er-PvL" firstAttribute="leading" secondItem="nFD-dk-aov" secondAttribute="leadingMargin" constant="10" id="elD-k2-EWf"/>
<constraint firstItem="Kec-m2-xE8" firstAttribute="top" secondItem="nFD-dk-aov" secondAttribute="topMargin" constant="-8" id="hAb-3i-cia"/>
<constraint firstItem="Kec-m2-xE8" firstAttribute="leading" secondItem="Qbh-Q1-Stk" secondAttribute="trailing" constant="10" id="vXH-c4-ZhE"/>
<constraint firstAttribute="centerX" secondItem="Kec-m2-xE8" secondAttribute="centerX" constant="204.5" id="veZ-09-4hF"/>
<constraint firstItem="Qbh-Q1-Stk" firstAttribute="bottom" secondItem="nFD-dk-aov" secondAttribute="bottomMargin" id="xZS-Fo-lEj"/>
</constraints>
<variation key="default">
<mask key="constraints">
Expand Down
2 changes: 1 addition & 1 deletion asphalos/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* TODO
* Design like Timeful with hours on the left
* when navigating to +, we need to know what slot is available (including break time). Use 9AM as starting coordinate

* Check if end date is today first before changing its day or hours

## Enhancements
1. Use timeful style of times on the left
Expand Down
17 changes: 12 additions & 5 deletions asphalos/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,28 @@ class Task: NSManagedObject {
@NSManaged var info: String
@NSManaged var completed: NSNumber
@NSManaged var actual: NSNumber

@NSManaged var order: NSNumber

///MARK: Non managed
var endTime:NSDate {
var lengthFormatted:String {
get {
var interval:NSTimeInterval = Double(length) * 60.00
return self.startDate.dateByAddingTimeInterval(interval)
var hours = self.length.integerValue / 60
var mins = self.length.integerValue % 60
if hours > 0 {
return "\(hours) hrs and \(mins) mins"
} else {
return "\(mins) mins"
}
}
}

///Swap the task timings with each other
class func SwapTimes(source:Task, destination:Task) {
class func SwapOrder(source:Task, destination:Task) {
var startDate = destination.startDate
destination.startDate = source.startDate
source.startDate = startDate
(destination.order, source.order) = (source.order, destination.order)

Task.save()
}

Expand Down
Loading

0 comments on commit ce52608

Please sign in to comment.