Skip to content

Commit

Permalink
2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
backslash112 committed Mar 14, 2015
1 parent 6f80756 commit d931c8a
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 12 deletions.
107 changes: 103 additions & 4 deletions WorkAndRest/ViewControllers/NewTaskViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class NewTaskViewController: BaseViewController, TaskTitleViewControllerDelegate
// MARK: - Properties

@IBOutlet var startButton: UIButton!
@IBOutlet var startNowButton: UIButton!
@IBOutlet var startLaterButton: UIButton!
// @IBOutlet var startNowButton: UIButton!
// @IBOutlet var startLaterButton: UIButton!
@IBOutlet var timeSelector: TimeSelectorView!
@IBOutlet var taskTitleView: TaskTitleView!
@IBOutlet var completionCycleView: CompletionCycleView!
Expand All @@ -30,6 +30,7 @@ class NewTaskViewController: BaseViewController, TaskTitleViewControllerDelegate
var delegate: NewTaskViewControllerDelegate?
var minutes = GlobalConstants.DEFAULT_MINUTES
var number = GlobalConstants.DEFAULT_NUMBER
var startView: UIView?

// MARK: - Lifecycle

Expand Down Expand Up @@ -76,7 +77,15 @@ class NewTaskViewController: BaseViewController, TaskTitleViewControllerDelegate
// MARK: - Events

@IBAction func startButtonClick(sender: AnyObject) {
self.performSegueWithIdentifier("StartSegue", sender: nil)
if WARDevice.isiOS7() {
self.startView = self.getStartView()
let tap = UITapGestureRecognizer(target: self, action: "cancel:")
self.startView!.addGestureRecognizer(tap)
self.hideStartView(self.startView!, animated: false)
self.showStartView(self.startView!, animated: true)
} else {
self.performSegueWithIdentifier("StartSegue", sender: nil)
}
}

// MARK: - ItemDetailViewControllerDelegate
Expand Down Expand Up @@ -111,7 +120,7 @@ class NewTaskViewController: BaseViewController, TaskTitleViewControllerDelegate

// MARK: - StartViewControllerDelegate

func startViewController(sender: StartViewController, didSelectItem type: StartType) {
func startViewController(sender: StartViewController?, didSelectItem type: StartType) {
switch type {
case .Now, .Later:
if self.taskItem == nil {
Expand Down Expand Up @@ -279,4 +288,94 @@ class NewTaskViewController: BaseViewController, TaskTitleViewControllerDelegate
self.adapteDifferentScreenSize()
super.updateViewConstraints()
}

// MARK: - Methods

func getStartView() -> UIView {
self.navigationController?.setNavigationBarHidden(true, animated: true)

let bgView = UIView()
bgView.backgroundColor = UIColor.clearColor()
let toolBar = UIToolbar()
toolBar.autoresizingMask = self.view.autoresizingMask
bgView.insertSubview(toolBar, atIndex: 0)
self.view.addSubview(bgView)

let startNowButton = UIButton()
let startLaterButton = UIButton()
startNowButton.frame = CGRectMake(0, 0, 98, 99)
startLaterButton.frame = CGRectMake(0, 0, 98, 99)
startNowButton.setImage(UIImage(named: NSLocalizedString("Start Now", comment: "")), forState: UIControlState.Normal)
startLaterButton.setImage(UIImage(named: NSLocalizedString("Start Later", comment: "")), forState: UIControlState.Normal)

startNowButton.addTarget(self, action: "startNowButtonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
startLaterButton.addTarget(self, action: "startLaterButtonClicked:", forControlEvents: UIControlEvents.TouchUpInside)

bgView.addSubview(startNowButton)
bgView.addSubview(startLaterButton)

startNowButton.mas_makeConstraints { (make) -> Void in
make.centerX.equalTo()(bgView.mas_centerX)
make.centerY.equalTo()(bgView.mas_centerY).offset()(-76.5)
return ()
}

startLaterButton.mas_makeConstraints { (make) -> Void in
make.centerX.equalTo()(bgView.mas_centerX)
make.centerY.equalTo()(bgView.mas_centerY).offset()(88.5)
return ()
}

return bgView

}

func updateView(view: UIView, newFrame: CGRect, withDuration duration: NSTimeInterval, animated: Bool) {
if animated {
UIView.animateWithDuration(duration, animations: { () -> Void in
view.frame = newFrame
})
} else {
view.frame = newFrame
}
}

func showStartView(view: UIView, animated: Bool) {
let frame = self.view.frame
self.updateView(view, newFrame: frame, withDuration: 0.1, animated: animated)
}

func hideStartView(view: UIView, animated: Bool) {
var frame = self.view.frame
frame.origin.y += frame.size.height
self.updateView(view, newFrame: frame, withDuration: 0.3, animated: animated)
}

func cancel(sender: AnyClass?) {
self.hideStartView(self.startView!, animated: true)
self.navigationController?.setNavigationBarHidden(false, animated: true)
}

func startNowButtonClicked(sender: UIButton!) {
self.cancel(nil)
self.startViewController(nil, didSelectItem: StartType.Now)
self.dismissViewControllerAnimated(true, completion: nil)
}

func startLaterButtonClicked(sender: UIButton!) {
self.cancel(nil)
self.startViewController(nil, didSelectItem: StartType.Later)
self.dismissViewControllerAnimated(true, completion: nil)
}
}











2 changes: 1 addition & 1 deletion WorkAndRest/ViewControllers/StartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum StartType {
case Now, Later, Cancel
}
protocol StartViewControllerDelegate {
func startViewController(sender: StartViewController, didSelectItem item: StartType)
func startViewController(sender: StartViewController?, didSelectItem item: StartType)
}

class StartViewController: UIViewController, UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning {
Expand Down
8 changes: 4 additions & 4 deletions WorkAndRest/Views/CompletionCycleView.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CompletionCycleView" customModule="WorkAndRest" customModuleProvider="target">
Expand Down Expand Up @@ -56,9 +56,9 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Completion Cycle" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bfe-x8-OFU">
<rect key="frame" x="135" y="65" width="100" height="15"/>
<rect key="frame" x="85" y="65" width="200" height="15"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="ari-tc-wO4"/>
<constraint firstAttribute="width" constant="200" id="ari-tc-wO4"/>
<constraint firstAttribute="height" constant="15" id="pgI-Kv-Exp"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
Expand Down
4 changes: 2 additions & 2 deletions WorkAndRest/WorkAndRest-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.1</string>
<string>2.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.0.1</string>
<string>2.0.2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
2 changes: 1 addition & 1 deletion WorkAndRest/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"Nov" = "11月";
"Dec" = "12月";

"CompletionCycleText" = "预计所需番茄时间";
"CompletionCycleText" = "预计所需番茄时间数";


"Start Now" = "start_now_cn";
Expand Down

0 comments on commit d931c8a

Please sign in to comment.