Make it pretty. add drag to hide or show completed.

This commit is contained in:
Kyle Fang
2013-02-27 12:35:17 +08:00
parent 67e8db2e5d
commit 656deba724
6 changed files with 46 additions and 27 deletions

View File

@@ -10,4 +10,5 @@
@interface GVUserDefaults (Progress)
@property (nonatomic) BOOL firstTimeLaunchApp;
@property (nonatomic) BOOL hideCompleted;
@end

View File

@@ -9,10 +9,11 @@
#import "GVUserDefaults+Progress.h"
@implementation GVUserDefaults (Progress)
@dynamic firstTimeLaunchApp;
@dynamic firstTimeLaunchApp, hideCompleted;
- (NSDictionary *)setupDefaults{
return @{@"firstTimeLaunchApp": @YES};
return @{@"firstTimeLaunchApp": @YES,
@"hideCompleted": @YES};
}
@end

View File

@@ -10,16 +10,19 @@
#import "PPEvenKitManager.h"
#import <SVProgressHUD/SVProgressHUD.h>
#import "UIScrollView+ZGPullDrag.h"
#import <NUI/NUIConverter.h>
#import <NUI/NUIGraphics.h>
#import <NUI/UILabel+NUI.h>
#import "ReminderItemCell.h"
typedef NSUInteger ZGScrollViewStyle;
@interface PPRemindersViewController () <ReminderItemCellDelegate, ZGPullDragViewDelegate>
@property (strong, nonatomic) IBOutlet UIView *pullDownView;
@property (nonatomic, strong) UITableViewCell *placeHolderCell;
@property (nonatomic, strong) UITableViewCell *editingCell;
@property (nonatomic) BOOL isEdingAReminder;
@property (nonatomic) NSArray *remindersDatasource;
@property (nonatomic) CGFloat pullViewShowRadio;
@property (nonatomic) CGFloat xTouchPoint;
@end
@implementation PPRemindersViewController
@@ -36,6 +39,8 @@ static NSString *CellIdentifier = @"ReminderCell";
self.clearsSelectionOnViewWillAppear = NO;
self.navigationController.navigationBarHidden = YES;
self.tableView.backgroundColor = [UIColor blackColor];
[self.tableView registerClass:[ReminderItemCell class] forCellReuseIdentifier:CellIdentifier];
[SVProgressHUD show];
@@ -48,7 +53,13 @@ static NSString *CellIdentifier = @"ReminderCell";
[self.tableView addZGPullView:self.placeHolderCell];
UIView *dragView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.tableView.rowHeight)];
dragView.backgroundColor = [UIColor greenColor];
dragView.backgroundColor = [UIColor clearColor];
UILabel *label = [[UILabel alloc] initWithFrame:dragView.frame];
label.nuiClass = @"WhiteLabel";
[label applyNUI];
label.text = @"Hide Completed";
label.tag = 1;
[dragView addSubview:label];
[self.tableView addZGDragView:dragView];
self.tableView.pullDragDelegate = self;
@@ -85,6 +96,17 @@ static NSString *CellIdentifier = @"ReminderCell";
}
- (void)pullView:(UIView *)pullView Show:(CGFloat)shownPixels ofTotal:(CGFloat)totalPixels{
self.pullViewShowRadio = shownPixels/totalPixels;
CGFloat pullProgress = MAX(0, MIN(1, shownPixels/totalPixels));
pullView.alpha = pullProgress;
}
- (void)dragView:(UIView *)dragView Show:(CGFloat)showPixels ofTotal:(CGFloat)totalPixels{
CGFloat dragProgress = MAX(0, MIN(1, showPixels/totalPixels));
dragView.alpha = dragProgress;
}
- (void)userPullOrDragStoppedWithPullView:(UIView *)pullView dragView:(UIView *)dragView{
NSLog(@"Stopped");
}
@@ -139,25 +161,5 @@ static NSString *CellIdentifier = @"ReminderCell";
[[PPEvenKitManager sharedManager] deleteReminder:reminder];
}
#pragma mark - ScrollView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
[self touchPointUpdate:[touches anyObject]];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesMoved:touches withEvent:event];
[self touchPointUpdate:[touches anyObject]];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesEnded:touches withEvent:event];
[self touchPointUpdate:[touches anyObject]];
}
- (void)touchPointUpdate:(UITouch *)touch{
NSLog(@"AwesomE");
}
@end

View File

@@ -55,6 +55,13 @@ Label {
font-color: @primaryFontColor;
text-auto-fit: false;
}
WhiteLabel {
font-name: @secondaryFontName;
font-size: 20;
font-color: @primaryBackgroundColorBottom;
text-auto-fit: false;
text-align: center;
}
LargeLabel {
font-size: 24;
}

View File

@@ -50,6 +50,16 @@
[super layoutSubviews];
[self sendSubviewToBack:[self viewWithTag:1]];
[self sendSubviewToBack:[self viewWithTag:2]];
CGRect textLabelFrame = self.textLabel.frame;
CGRect detailLableFrame = self.detailTextLabel.frame;
if (textLabelFrame.origin.x+textLabelFrame.size.width > detailLableFrame.origin.x) {
textLabelFrame.size.width = detailLableFrame.origin.x - textLabelFrame.origin.x - 10;
}
self.textLabel.frame = textLabelFrame;
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{

View File

@@ -161,8 +161,6 @@ static char UIScrollViewWasDragging;
}
}
- (void)pullViewHandler:(CGFloat )visiblePixels{
if ([self.pullDragDelegate respondsToSelector:@selector(pullView:Show:ofTotal:)]) {
[self.pullDragDelegate pullView:self.pullView Show:visiblePixels ofTotal:self.pullView.frame.size.height];