Permalink
Browse files

Merged all components into repository

  • Loading branch information...
1 parent cdcb82c commit 203250ab50dc663ded63555456f5d63bff420a93 @keeshux committed Nov 7, 2011
Showing with 12,990 additions and 13 deletions.
  1. +4 −0 .gitignore
  2. +60 −0 Classes/KSAdvancedPicker/KSAdvancedPicker.h
  3. +182 −0 Classes/KSAdvancedPicker/KSAdvancedPicker.m
  4. +2 −5 { → Classes}/KSCheckView/KSCheckView.h
  5. +18 −7 { → Classes}/KSCheckView/KSCheckView.m
  6. +29 −0 Classes/KSEditEnder/KSEditEnder.h
  7. +57 −0 Classes/KSEditEnder/KSEditEnder.m
  8. +44 −0 Classes/KSProgressDownloader/KSProgressDownloader.h
  9. +171 −0 Classes/KSProgressDownloader/KSProgressDownloader.m
  10. +46 −0 Classes/KSSheetView/KSSheetView.h
  11. +115 −0 Classes/KSSheetView/KSSheetView.m
  12. +623 −0 Demo/ComponentsDemo.xcodeproj/project.pbxproj
  13. +16 −0 Demo/ComponentsDemo/AppDelegate.h
  14. +69 −0 Demo/ComponentsDemo/AppDelegate.m
  15. +51 −0 Demo/ComponentsDemo/ComponentsDemo-Info.plist
  16. +14 −0 Demo/ComponentsDemo/ComponentsDemo-Prefix.pch
  17. +16 −0 Demo/ComponentsDemo/Tests/KSAdvancedPicker/VC_KSAdvancedPicker.h
  18. +120 −0 Demo/ComponentsDemo/Tests/KSAdvancedPicker/VC_KSAdvancedPicker.m
  19. +14 −0 Demo/ComponentsDemo/Tests/KSCheckView/VC_KSCheckView.h
  20. +56 −0 Demo/ComponentsDemo/Tests/KSCheckView/VC_KSCheckView.m
  21. +17 −0 Demo/ComponentsDemo/Tests/KSEditEnder/VC_KSEditEnder.h
  22. +90 −0 Demo/ComponentsDemo/Tests/KSEditEnder/VC_KSEditEnder.m
  23. +16 −0 Demo/ComponentsDemo/Tests/KSProgressDownloader/VC_KSProgressDownloader.h
  24. +75 −0 Demo/ComponentsDemo/Tests/KSProgressDownloader/VC_KSProgressDownloader.m
  25. +14 −0 Demo/ComponentsDemo/Tests/KSSheetView/VC_KSSheetView.h
  26. +59 −0 Demo/ComponentsDemo/Tests/KSSheetView/VC_KSSheetView.m
  27. +16 −0 Demo/ComponentsDemo/ViewController.h
  28. +98 −0 Demo/ComponentsDemo/ViewController.m
  29. +2 −0 Demo/ComponentsDemo/en.lproj/InfoPlist.strings
  30. +169 −0 Demo/ComponentsDemo/en.lproj/ViewController_iPad.xib
  31. +168 −0 Demo/ComponentsDemo/en.lproj/ViewController_iPhone.xib
  32. +245 −0 Demo/ComponentsDemo/en.lproj/Window_iPad.xib
  33. +242 −0 Demo/ComponentsDemo/en.lproj/Window_iPhone.xib
  34. +18 −0 Demo/ComponentsDemo/main.m
  35. +194 −0 External/Reachability/Reachability.h
  36. +814 −0 External/Reachability/Reachability.m
  37. +35 −0 External/asi-http-request/ASIAuthenticationDialog.h
  38. +487 −0 External/asi-http-request/ASIAuthenticationDialog.m
  39. +103 −0 External/asi-http-request/ASICacheDelegate.h
  40. +42 −0 External/asi-http-request/ASIDataCompressor.h
  41. +219 −0 External/asi-http-request/ASIDataCompressor.m
  42. +41 −0 External/asi-http-request/ASIDataDecompressor.h
  43. +218 −0 External/asi-http-request/ASIDataDecompressor.m
  44. +46 −0 External/asi-http-request/ASIDownloadCache.h
  45. +514 −0 External/asi-http-request/ASIDownloadCache.m
  46. +76 −0 External/asi-http-request/ASIFormDataRequest.h
  47. +362 −0 External/asi-http-request/ASIFormDataRequest.m
  48. +1,004 −0 External/asi-http-request/ASIHTTPRequest.h
  49. +5,119 −0 External/asi-http-request/ASIHTTPRequest.m
  50. +43 −0 External/asi-http-request/ASIHTTPRequestConfig.h
  51. +35 −0 External/asi-http-request/ASIHTTPRequestDelegate.h
  52. +26 −0 External/asi-http-request/ASIInputStream.h
  53. +138 −0 External/asi-http-request/ASIInputStream.m
  54. +108 −0 External/asi-http-request/ASINetworkQueue.h
  55. +343 −0 External/asi-http-request/ASINetworkQueue.m
  56. +38 −0 External/asi-http-request/ASIProgressDelegate.h
  57. +28 −0 External/asi-http-request/LICENSE
  58. +0 −1 README
  59. +21 −0 README.md
View
@@ -1,3 +1,7 @@
.DS_Store
*.swp
*.o
+*.class
+Demo/ComponentsDemo.xcodeproj/project.xcworkspace
+Demo/ComponentsDemo.xcodeproj/xcuserdata
+comment
@@ -0,0 +1,60 @@
+/*
+ * KSAdvancedPicker.h
+ *
+ * Copyright 2011 Davide De Rosa
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <UIKit/UIKit.h>
+
+@protocol KSAdvancedPickerDelegate;
+
+@interface KSAdvancedPicker : UIView<UITableViewDataSource, UITableViewDelegate> {
+}
+
+@property (nonatomic, readonly) UITableView *table;
+@property (nonatomic, readonly) NSInteger selectedRowIndex;
+@property (nonatomic, assign) id<KSAdvancedPickerDelegate> delegate;
+
+- (id) initWithFrame:(CGRect)frame delegate:(id<KSAdvancedPickerDelegate>)aDelegate;
+
+- (void) scrollToRowAtIndex:(NSInteger)rowIndex animated:(BOOL)animated;
+- (void) reloadData;
+
+@end
+
+@protocol KSAdvancedPickerDelegate<NSObject>
+
+// row view
+- (NSInteger) numberOfRowsInAdvancedPicker:(KSAdvancedPicker *)picker;
+- (UITableViewCell *) advancedPicker:(KSAdvancedPicker *)picker tableView:(UITableView *)tableView cellForRowAtIndex:(NSInteger)rowIndex;
+
+@optional
+
+// row height
+- (CGFloat) heightForRowInAdvancedPicker:(KSAdvancedPicker *)picker;
+
+// selected row
+- (void) advancedPicker:(KSAdvancedPicker *)picker didSelectRowAtIndex:(NSInteger)rowIndex;
+
+// table background view (checked in the same order)
+- (UIView *) backgroundViewForAdvancedPicker:(KSAdvancedPicker *)picker;
+- (UIColor *) backgroundColorForAdvancedPicker:(KSAdvancedPicker *)picker;
+
+// selector view (checked in the same order)
+- (UIView *) viewForAdvancedPickerSelector:(KSAdvancedPicker *)picker;
+- (UIColor *) viewColorForAdvancedPickerSelector:(KSAdvancedPicker *)picker;
+
+@end
@@ -0,0 +1,182 @@
+/*
+ * KSAdvancedPicker.m
+ *
+ * Copyright 2011 Davide De Rosa
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import "KSAdvancedPicker.h"
+
+@interface KSAdvancedPicker ()
+
+@property (nonatomic, retain) UIView *selector;
+
+- (void) alignToRowBoundary;
+
+@end
+
+@implementation KSAdvancedPicker
+
+// public
+@synthesize table;
+@synthesize selectedRowIndex;
+@synthesize delegate;
+
+// private
+@synthesize selector;
+
+- (id) initWithFrame:(CGRect)frame delegate:(id<KSAdvancedPickerDelegate>)aDelegate
+{
+ if ((self = [super initWithFrame:frame])) {
+ delegate = aDelegate;
+
+ // custom row height?
+ CGFloat rowHeight;
+ if ([delegate respondsToSelector:@selector(heightForRowInAdvancedPicker:)]) {
+ rowHeight = [delegate heightForRowInAdvancedPicker:self];
+ } else {
+ rowHeight = 44;
+ }
+
+ // distance from center
+ const CGFloat centralRowOffset = (frame.size.height - rowHeight) / 2;
+
+ // picker content
+ table = [[UITableView alloc] initWithFrame:self.bounds];
+ table.rowHeight = rowHeight;
+ table.contentInset = UIEdgeInsetsMake(centralRowOffset, 0, centralRowOffset, 0);
+ table.separatorStyle = UITableViewCellSeparatorStyleNone;
+ table.showsVerticalScrollIndicator = NO;
+ table.allowsSelection = NO;
+
+ // custom background?
+ if ([delegate respondsToSelector:@selector(backgroundViewForAdvancedPicker:)]) {
+ table.backgroundView = [delegate backgroundViewForAdvancedPicker:self];
+ } else if ([delegate respondsToSelector:@selector(backgroundColorForAdvancedPicker:)]) {
+ table.backgroundColor = [delegate backgroundColorForAdvancedPicker:self];
+ } else {
+ table.backgroundColor = [UIColor whiteColor];
+ }
+
+ table.dataSource = self;
+ table.delegate = self;
+ [self addSubview:table];
+
+ // custom selector?
+ if ([delegate respondsToSelector:@selector(viewForAdvancedPickerSelector:)]) {
+ self.selector = [delegate viewForAdvancedPickerSelector:self];
+ } else if ([delegate respondsToSelector:@selector(viewColorForAdvancedPickerSelector:)]) {
+ selector = [[UIView alloc] init];
+ selector.backgroundColor = [delegate viewColorForAdvancedPickerSelector:self];
+ } else {
+ selector = [[UIView alloc] init];
+ selector.backgroundColor = [UIColor blueColor];
+ selector.alpha = 0.5;
+ }
+
+ // ignore user input on selector
+ selector.userInteractionEnabled = NO;
+
+ // override selector frame
+ CGRect selectorFrame;
+ selectorFrame.origin.x = 0;
+ selectorFrame.origin.y = centralRowOffset;
+ selectorFrame.size.width = frame.size.width;
+ selectorFrame.size.height = rowHeight;
+ selector.frame = selectorFrame;
+
+ [self addSubview:selector];
+
+// NSLog(@"self.frame = %@", NSStringFromCGRect(self.frame));
+// NSLog(@"table.frame = %@", NSStringFromCGRect(table.frame));
+// NSLog(@"selector.frame = %@", NSStringFromCGRect(selector.frame));
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ self.delegate = nil;
+ [table release];
+ self.selector = nil;
+
+ [super dealloc];
+}
+
+- (void) scrollToRowAtIndex:(NSInteger)rowIndex animated:(BOOL)animated
+{
+ selectedRowIndex = rowIndex;
+
+ const CGPoint alignedOffset = CGPointMake(0, rowIndex * table.rowHeight - table.contentInset.top);
+ [table setContentOffset:alignedOffset animated:animated];
+
+ if ([delegate respondsToSelector:@selector(advancedPicker:didSelectRowAtIndex:)]) {
+ [delegate advancedPicker:self didSelectRowAtIndex:rowIndex];
+ }
+}
+
+- (void) reloadData
+{
+ [table reloadData];
+}
+
+#pragma mark - UITableViewDataSource
+
+- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 1;
+}
+
+- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return [delegate numberOfRowsInAdvancedPicker:self];
+}
+
+- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ return [delegate advancedPicker:self tableView:tableView cellForRowAtIndex:indexPath.row];
+}
+
+#pragma mark - UIScrollViewDelegate
+
+- (void) scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
+{
+ if (!decelerate) {
+ [self alignToRowBoundary];
+ }
+}
+
+- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
+{
+ [self alignToRowBoundary];
+}
+
+#pragma mark - Private methods
+
+- (void) alignToRowBoundary
+{
+// NSLog(@"contentOffset = %@", NSStringFromCGPoint(table.contentOffset));
+// NSLog(@"rowHeight = %f", table.rowHeight);
+
+ const CGPoint relativeOffset = CGPointMake(0, table.contentOffset.y + table.contentInset.top);
+// NSLog(@"relativeOffset = %@", NSStringFromCGPoint(relativeOffset));
+
+ const NSUInteger rowIndex = round(relativeOffset.y / table.rowHeight);
+// NSLog(@"rowIndex = %d", rowIndex);
+
+ [self scrollToRowAtIndex:rowIndex animated:YES];
+}
+
+@end
@@ -19,15 +19,12 @@
#import <UIKit/UIKit.h>
-@interface KSCheckView : UIView {
+@interface KSCheckView : UIControl {
CGFloat width;
CGMutablePathRef path;
-
- BOOL enabled;
- UIColor *color;
}
-@property (nonatomic, assign) BOOL enabled;
+@property (nonatomic, assign) BOOL checked;
@property (nonatomic, retain) UIColor *color;
@end
@@ -21,33 +21,39 @@
@implementation KSCheckView
-@synthesize enabled;
+@synthesize checked;
@synthesize color;
-- (id) initWithCoder:(NSCoder *)aDecoder
+- (id) initWithFrame:(CGRect)frame
{
- if ((self = [super initWithCoder:aDecoder])) {
+ if ((self = [super initWithFrame:frame])) {
width = self.frame.size.width / 8.0;
path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, width, self.frame.size.height / 2);
CGPathAddLineToPoint(path, NULL, self.frame.size.width * 0.4, self.frame.size.height - width);
CGPathAddLineToPoint(path, NULL, self.frame.size.width - width, width);
+
+ self.backgroundColor = [UIColor whiteColor];
+ self.color = [UIColor blackColor];
+
+ // toggle action
+ [self addTarget:self action:@selector(toggle) forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
- (void) dealloc
{
CGPathRelease(path);
- [color release];
+ self.color = nil;
[super dealloc];
}
-- (void) setEnabled:(BOOL)aEnabled
+- (void) setChecked:(BOOL)aChecked
{
- enabled = aEnabled;
+ checked = aChecked;
[self setNeedsDisplay];
}
@@ -60,7 +66,7 @@ - (void) drawRect:(CGRect)rect
CGContextFillRect(context, rect);
// check mark
- if (enabled) {
+ if (checked) {
CGContextSetStrokeColorWithColor(context, color.CGColor);
CGContextSetShouldAntialias(context, YES);
CGContextSetLineCap(context, kCGLineCapRound);
@@ -72,4 +78,9 @@ - (void) drawRect:(CGRect)rect
}
}
+- (void) toggle
+{
+ self.checked = !checked;
+}
+
@end
@@ -0,0 +1,29 @@
+/*
+ * KSEditEnder.h
+ *
+ * Copyright 2011 Davide De Rosa
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+@interface KSEditEnder : UIControl
+
+@property (nonatomic, assign) BOOL force;
+
++ (id) enderWithView:(UIView *)view;
+- (id) initWithView:(UIView *)view;
+
+@end
Oops, something went wrong.

0 comments on commit 203250a

Please sign in to comment.