mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Swipe to delete implemented
This commit is contained in:
parent
b494b71dbc
commit
d740f801c6
|
@ -19,7 +19,6 @@ typedef enum : NSUInteger {
|
||||||
@class InboxTableViewCell;
|
@class InboxTableViewCell;
|
||||||
@protocol TableViewCellDelegate <NSObject>
|
@protocol TableViewCellDelegate <NSObject>
|
||||||
|
|
||||||
- (void)tableViewCellTappedDelete:(InboxTableViewCell *)cell;
|
|
||||||
- (void)tableViewCellTappedArchive:(InboxTableViewCell *)cell;
|
- (void)tableViewCellTappedArchive:(InboxTableViewCell *)cell;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#define DELETE_IMAGE_VIEW_WIDTH 19.0f
|
#define DELETE_IMAGE_VIEW_WIDTH 19.0f
|
||||||
#define TIME_LABEL_SIZE 11
|
#define TIME_LABEL_SIZE 11
|
||||||
#define DATE_LABEL_SIZE 13
|
#define DATE_LABEL_SIZE 13
|
||||||
|
#define SWIPE_ARCHIVE_OFFSET -50
|
||||||
|
|
||||||
@implementation InboxTableViewCell
|
@implementation InboxTableViewCell
|
||||||
|
|
||||||
|
@ -195,39 +195,17 @@
|
||||||
_archiveImageView.bounds.size.height);
|
_archiveImageView.bounds.size.height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollView.contentOffset.x > CGRectGetWidth(_archiveView.frame)*2) {
|
|
||||||
_deleteImageView.image = [_deleteImageView.image jsq_imageMaskedWithColor:[UIColor ows_redColor]];
|
|
||||||
_deleteImageView.bounds = CGRectMake(_deleteImageView.bounds.origin.x,
|
|
||||||
_deleteImageView.bounds.origin.y,
|
|
||||||
DELETE_IMAGE_VIEW_WIDTH,
|
|
||||||
_deleteImageView.bounds.size.height);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
_deleteImageView.image = [_deleteImageView.image jsq_imageMaskedWithColor:[UIColor ows_darkGrayColor]];
|
|
||||||
double ratio = _scrollView.contentOffset.x / (CGRectGetWidth(_deleteView.frame)*2);
|
|
||||||
double newWidth = DELETE_IMAGE_VIEW_WIDTH/2.0f + (DELETE_IMAGE_VIEW_WIDTH * ratio)/2.0f;
|
|
||||||
|
|
||||||
_deleteImageView.bounds = CGRectMake(_deleteImageView.bounds.origin.x,
|
|
||||||
_deleteImageView.bounds.origin.y,
|
|
||||||
(CGFloat)newWidth,
|
|
||||||
_deleteImageView.bounds.size.height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
|
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
|
||||||
withVelocity:(CGPoint)velocity
|
withVelocity:(CGPoint)velocity
|
||||||
targetContentOffset:(inout CGPoint *)targetContentOffset {
|
targetContentOffset:(inout CGPoint *)targetContentOffset {
|
||||||
|
|
||||||
if (_scrollView.contentOffset.x < 0) {
|
if (_scrollView.contentOffset.x < SWIPE_ARCHIVE_OFFSET) {
|
||||||
|
// archive the thread
|
||||||
[_delegate tableViewCellTappedArchive:self];
|
[_delegate tableViewCellTappedArchive:self];
|
||||||
} else {
|
} else {
|
||||||
*targetContentOffset = CGPointMake(CGRectGetWidth(_archiveView.frame), 0);
|
// don't do anything
|
||||||
}
|
|
||||||
|
|
||||||
if (scrollView.contentOffset.x > CGRectGetWidth(_archiveView.frame)/4) {
|
|
||||||
[_delegate tableViewCellTappedDelete:self];
|
|
||||||
} else {
|
|
||||||
*targetContentOffset = CGPointMake(CGRectGetWidth(_archiveView.frame), 0);
|
*targetContentOffset = CGPointMake(CGRectGetWidth(_archiveView.frame), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - Table view data source
|
#pragma mark - Table View Data Source
|
||||||
|
|
||||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||||
return (NSInteger)[self.threadMappings numberOfSections];
|
return (NSInteger)[self.threadMappings numberOfSections];
|
||||||
|
@ -168,8 +168,8 @@ static NSString* const kShowSignupFlowSegue = @"showSignupFlow";
|
||||||
|
|
||||||
#pragma mark - HomeFeedTableViewCellDelegate
|
#pragma mark - HomeFeedTableViewCellDelegate
|
||||||
|
|
||||||
- (void)tableViewCellTappedDelete:(InboxTableViewCell*)cell {
|
- (void)tableViewCellTappedDelete:(NSIndexPath*)indexPath {
|
||||||
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
|
//NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
|
||||||
TSThread *thread = [self threadForIndexPath:indexPath];
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
||||||
if([thread isKindOfClass:[TSGroupThread class]]) {
|
if([thread isKindOfClass:[TSGroupThread class]]) {
|
||||||
DDLogDebug(@"leaving the group");
|
DDLogDebug(@"leaving the group");
|
||||||
|
|
Loading…
Reference in a new issue