Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Gessner committed Nov 4, 2013
1 parent e7e25d1 commit 4d84a04
Show file tree
Hide file tree
Showing 14 changed files with 668 additions and 214 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
Binary file added Demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
184 changes: 30 additions & 154 deletions JGScrollableTableViewCell Examples.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions JGScrollableTableViewCell Examples/JGAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

#import <UIKit/UIKit.h>

@class JGTextViewController;

@interface JGAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (nonatomic, strong) JGTextViewController *mainViewController;

@end
10 changes: 8 additions & 2 deletions JGScrollableTableViewCell Examples/JGAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@

#import "JGAppDelegate.h"

#import "JGTextViewController.h"

@implementation JGAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];

self.mainViewController = [[JGTextViewController alloc] initWithStyle:UITableViewStylePlain];

self.window.rootViewController = self.mainViewController;

[self.window makeKeyAndVisible];

return YES;
}

Expand Down
13 changes: 13 additions & 0 deletions JGScrollableTableViewCell Examples/JGTextViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// JGTextViewController.h
// JGScrollableTableViewCell Examples
//
// Created by Jonas Gessner on 03.11.13.
// Copyright (c) 2013 Jonas Gessner. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface JGTextViewController : UITableViewController

@end
101 changes: 101 additions & 0 deletions JGScrollableTableViewCell Examples/JGTextViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// JGTextViewController.m
// JGScrollableTableViewCell Examples
//
// Created by Jonas Gessner on 03.11.13.
// Copyright (c) 2013 Jonas Gessner. All rights reserved.
//

#import "JGTextViewController.h"

#import "JGScrollableTableViewCell.h"
#import "JGScrollableTableViewCellAccessoryButton.h"

@interface JGTextViewController () <JGScrollableTableViewCellDelegate> {
NSIndexPath *_openedIndexPath;
}

@end

@implementation JGTextViewController

- (instancetype)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
if (self) {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

[self.tableView registerClass:[JGScrollableTableViewCell class] forCellReuseIdentifier:@"ScrollCell"];
}
return self;
}



#pragma mark - JGScrollableTableViewCellDelegate

- (void)cellDidBeginScrolling:(JGScrollableTableViewCell *)cell {
[JGScrollableTableViewCellManager closeAllCellsWithExceptionOf:cell];
}

- (void)cellDidScroll:(JGScrollableTableViewCell *)cell {
[JGScrollableTableViewCellManager closeAllCellsWithExceptionOf:cell];
}

- (void)cellDidEndScrolling:(JGScrollableTableViewCell *)cell {
if (cell.optionViewVisible) {
_openedIndexPath = [self.tableView indexPathForCell:cell];
}
else {
_openedIndexPath = nil;
}

[JGScrollableTableViewCellManager closeAllCellsWithExceptionOf:cell];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 99;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 70.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *const CellIdentifier = @"ScrollCell";
JGScrollableTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
[cell setScrollViewBackgroundColor:[UIColor colorWithWhite:0.975f alpha:1.0f]];
[cell setScrollViewInsets:UIEdgeInsetsMake(0.0f, 1.0f, 1.0f, 1.0f)];
cell.contentView.backgroundColor = [UIColor colorWithWhite:0.7f alpha:1.0f];

JGScrollableTableViewCellAccessoryButton *optionView = [JGScrollableTableViewCellAccessoryButton button];
[optionView setButtonColor:[UIColor colorWithRed:0.975f green:0.0f blue:0.0f alpha:1.0f] forState:UIControlStateNormal];
[optionView setButtonColor:[UIColor colorWithRed:0.8f green:0.1f blue:0.1f alpha:1.0f] forState:UIControlStateHighlighted];

[optionView setTitle:@"Action" forState:UIControlStateNormal];

optionView.frame = CGRectMake(0.0f, 0.0f, 80.0f, 0.0f); //width is the only frame parameter that needs to be set on the option view

[cell setOptionView:optionView side:JGScrollableTableViewCellSideRight];

cell.scrollDelegate = self;

[cell setOptionViewVisible:[_openedIndexPath isEqual:indexPath]];

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Selected Index Path %@", indexPath);
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Deselected Index Path %@", indexPath);
}

@end

This file was deleted.

This file was deleted.

This file was deleted.

101 changes: 101 additions & 0 deletions JGScrollableTableViewCell/JGScrollableTableViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// JGScrollableTableViewCell.h
// ProTube 2
//
// Created by Jonas Gessner on 03.11.13.
// Copyright (c) 2013 Jonas Gessner. All rights reserved.
//

#import <UIKit/UIKit.h>

@class JGScrollableTableViewCell;

@protocol JGScrollableTableViewCellDelegate <NSObject>

@optional
- (void)cellDidBeginScrolling:(JGScrollableTableViewCell *)cell;
- (void)cellDidScroll:(JGScrollableTableViewCell *)cell;
- (void)cellDidEndScrolling:(JGScrollableTableViewCell *)cell;

@end

typedef NS_ENUM(BOOL, JGScrollableTableViewCellSide) {
JGScrollableTableViewCellSideLeft = NO,
JGScrollableTableViewCellSideRight = YES
};

@interface JGScrollableTableViewCell : UITableViewCell

//scroll view peoperties
/**
Insets the scroll view. Useful for displaying a border around the scroll area (when also setting \c contentView.backgroundColor)
*/
@property (nonatomic, assign) UIEdgeInsets scrollViewInsets;


/**
Sets the background color of the visible scroll area.
*/
- (void)setScrollViewBackgroundColor:(UIColor *)scrollViewBackgroundColor;


/**
An instance conforming to the \c JGScrollableTableViewCellDelegate protocol.
*/
@property (nonatomic, weak) id <JGScrollableTableViewCellDelegate> scrollDelegate;


/**
@warning When the cell is selected or highlighted the scroll view won't be able to scroll. (This shouldn't be a problem anyway)
@return If the user is currently dragging the scroll view.
*/
@property (nonatomic, assign, readonly) BOOL scrolling;


//opened sides
/**
The current state of the option view.
@return If the option view is visible.
*/
@property (nonatomic, assign) BOOL optionViewVisible;


/**
Sets the current state of the option view with an optional animation of 0.3 seconds.
*/
- (void)setOptionViewVisible:(BOOL)optionViewVisible animated:(BOOL)animated;


//views
/**
@return The option view.
*/
@property (nonatomic, strong, readonly) UIView *optionView;


/**
Sets & removes the old option view.
@param view The option view to add. The view's width should be set, all ofther frame paramaters are ignored.
@param side The side on which the view should be placed. Either left or right.
*/
- (void)setOptionView:(UIView *)view side:(JGScrollableTableViewCellSide)side;


/**
Add a view to the scrolling area of the cell.
@param view The view to add.
*/
- (void)addContentView:(UIView *)view;

@end


@interface JGScrollableTableViewCellManager : NSObject

/**
Closes all optin views in \c Cell's UITableView.
@param cell The cell that should not be closed.
*/
+ (void)closeAllCellsWithExceptionOf:(JGScrollableTableViewCell *)cell;

@end
Loading

0 comments on commit 4d84a04

Please sign in to comment.