dropbox integrated with table view

This commit is contained in:
Kilian Hofmann 2016-03-31 19:30:10 +02:00
parent a52c8bb5b4
commit 37b2619277
7 changed files with 150 additions and 74 deletions

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
</Bucket>

View File

@ -7,10 +7,12 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
538D4E6DD1FC94B931B43D52 /* libPods-FMC Planner 2UITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 168D3CE5E84BDA0F157A7CF7 /* libPods-FMC Planner 2UITests.a */; };
7724A561D957642263D75813 /* libPods-FMC Planner 2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 02FB9097A522461BE8F904D4 /* libPods-FMC Planner 2.a */; };
E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */; }; E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */; };
E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */; }; E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */; };
E22E0B561CAD655D00B71EE5 /* libPods-FMC Planner 2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E22E0B551CAD655D00B71EE5 /* libPods-FMC Planner 2.a */; };
E22E0B581CAD656700B71EE5 /* libPods-FMC Planner 2UITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E22E0B571CAD656700B71EE5 /* libPods-FMC Planner 2UITests.a */; };
E22E0B591CAD656B00B71EE5 /* libPods-FMC Planner 2Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E22E0B531CAD655200B71EE5 /* libPods-FMC Planner 2Tests.a */; };
E22E0B5B1CAD657000B71EE5 /* libSWTableViewCell.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E22E0B5A1CAD657000B71EE5 /* libSWTableViewCell.a */; };
E22EE9D11C9DB7B3001F5BC0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D01C9DB7B3001F5BC0 /* main.m */; }; E22EE9D11C9DB7B3001F5BC0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D01C9DB7B3001F5BC0 /* main.m */; };
E22EE9D41C9DB7B3001F5BC0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D31C9DB7B3001F5BC0 /* AppDelegate.m */; }; E22EE9D41C9DB7B3001F5BC0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D31C9DB7B3001F5BC0 /* AppDelegate.m */; };
E22EE9D71C9DB7B3001F5BC0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D61C9DB7B3001F5BC0 /* ViewController.m */; }; E22EE9D71C9DB7B3001F5BC0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9D61C9DB7B3001F5BC0 /* ViewController.m */; };
@ -29,7 +31,6 @@
E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */ = {isa = PBXBuildFile; fileRef = E2A927151CA30CEE00606E07 /* SharedDeclerations.m */; }; E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */ = {isa = PBXBuildFile; fileRef = E2A927151CA30CEE00606E07 /* SharedDeclerations.m */; };
E2B694BC1CAC0C56007B28EF /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2B694BB1CAC0C56007B28EF /* Security.framework */; }; E2B694BC1CAC0C56007B28EF /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2B694BB1CAC0C56007B28EF /* Security.framework */; };
E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */ = {isa = PBXBuildFile; fileRef = E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */; }; E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */ = {isa = PBXBuildFile; fileRef = E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */; };
FBF6796DA6BFEFE056737798 /* libPods-FMC Planner 2Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5BF6A3B18A12DDBE49807 /* libPods-FMC Planner 2Tests.a */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -50,8 +51,6 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
02FB9097A522461BE8F904D4 /* libPods-FMC Planner 2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FMC Planner 2.a"; sourceTree = BUILT_PRODUCTS_DIR; };
168D3CE5E84BDA0F157A7CF7 /* libPods-FMC Planner 2UITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FMC Planner 2UITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
3A4DEEC164570A675464527C /* Pods-FMC Planner 2UITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2UITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2UITests/Pods-FMC Planner 2UITests.debug.xcconfig"; sourceTree = "<group>"; }; 3A4DEEC164570A675464527C /* Pods-FMC Planner 2UITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2UITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2UITests/Pods-FMC Planner 2UITests.debug.xcconfig"; sourceTree = "<group>"; };
49ECBB2A9C708150C7EF0B6D /* Pods-FMC Planner 2.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2.release.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2/Pods-FMC Planner 2.release.xcconfig"; sourceTree = "<group>"; }; 49ECBB2A9C708150C7EF0B6D /* Pods-FMC Planner 2.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2.release.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2/Pods-FMC Planner 2.release.xcconfig"; sourceTree = "<group>"; };
64A5F6E611B5803249E6DC1F /* Pods-FMC Planner 2Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2Tests/Pods-FMC Planner 2Tests.release.xcconfig"; sourceTree = "<group>"; }; 64A5F6E611B5803249E6DC1F /* Pods-FMC Planner 2Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FMC Planner 2Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-FMC Planner 2Tests/Pods-FMC Planner 2Tests.release.xcconfig"; sourceTree = "<group>"; };
@ -62,6 +61,10 @@
E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerKeyboard.m; sourceTree = "<group>"; }; E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerKeyboard.m; sourceTree = "<group>"; };
E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerScreen.h; sourceTree = "<group>"; }; E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerScreen.h; sourceTree = "<group>"; };
E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerScreen.m; sourceTree = "<group>"; }; E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerScreen.m; sourceTree = "<group>"; };
E22E0B531CAD655200B71EE5 /* libPods-FMC Planner 2Tests.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-FMC Planner 2Tests.a"; path = "../../../Library/Developer/Xcode/DerivedData/FMC_PLanner_2-fsspigtxwcyaejgcrewjeasvcrcv/Build/Products/Debug-iphonesimulator/libPods-FMC Planner 2Tests.a"; sourceTree = "<group>"; };
E22E0B551CAD655D00B71EE5 /* libPods-FMC Planner 2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-FMC Planner 2.a"; path = "../../../Library/Developer/Xcode/DerivedData/FMC_PLanner_2-fsspigtxwcyaejgcrewjeasvcrcv/Build/Products/Debug-iphonesimulator/libPods-FMC Planner 2.a"; sourceTree = "<group>"; };
E22E0B571CAD656700B71EE5 /* libPods-FMC Planner 2UITests.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libPods-FMC Planner 2UITests.a"; path = "../../../Library/Developer/Xcode/DerivedData/FMC_PLanner_2-fsspigtxwcyaejgcrewjeasvcrcv/Build/Products/Debug-iphonesimulator/libPods-FMC Planner 2UITests.a"; sourceTree = "<group>"; };
E22E0B5A1CAD657000B71EE5 /* libSWTableViewCell.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSWTableViewCell.a; path = "../../../Library/Developer/Xcode/DerivedData/FMC_PLanner_2-fsspigtxwcyaejgcrewjeasvcrcv/Build/Products/Debug-iphonesimulator/SWTableViewCell/libSWTableViewCell.a"; sourceTree = "<group>"; };
E22EE9CC1C9DB7B3001F5BC0 /* FMC Planner 2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FMC Planner 2.app"; sourceTree = BUILT_PRODUCTS_DIR; }; E22EE9CC1C9DB7B3001F5BC0 /* FMC Planner 2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FMC Planner 2.app"; sourceTree = BUILT_PRODUCTS_DIR; };
E22EE9D01C9DB7B3001F5BC0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; E22EE9D01C9DB7B3001F5BC0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E22EE9D21C9DB7B3001F5BC0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; E22EE9D21C9DB7B3001F5BC0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -92,7 +95,6 @@
E2A927151CA30CEE00606E07 /* SharedDeclerations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharedDeclerations.m; sourceTree = "<group>"; }; E2A927151CA30CEE00606E07 /* SharedDeclerations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharedDeclerations.m; sourceTree = "<group>"; };
E2B694BB1CAC0C56007B28EF /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; E2B694BB1CAC0C56007B28EF /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PERF INIT.plist"; sourceTree = "<group>"; }; E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PERF INIT.plist"; sourceTree = "<group>"; };
EAA5BF6A3B18A12DDBE49807 /* libPods-FMC Planner 2Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FMC Planner 2Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -100,9 +102,12 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
E22E0B5B1CAD657000B71EE5 /* libSWTableViewCell.a in Frameworks */,
E22E0B591CAD656B00B71EE5 /* libPods-FMC Planner 2Tests.a in Frameworks */,
E22E0B581CAD656700B71EE5 /* libPods-FMC Planner 2UITests.a in Frameworks */,
E22E0B561CAD655D00B71EE5 /* libPods-FMC Planner 2.a in Frameworks */,
E2B694BC1CAC0C56007B28EF /* Security.framework in Frameworks */, E2B694BC1CAC0C56007B28EF /* Security.framework in Frameworks */,
E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */, E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */,
7724A561D957642263D75813 /* libPods-FMC Planner 2.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -110,7 +115,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
FBF6796DA6BFEFE056737798 /* libPods-FMC Planner 2Tests.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -118,7 +122,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
538D4E6DD1FC94B931B43D52 /* libPods-FMC Planner 2UITests.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -141,9 +144,10 @@
C605C480B46761595F28A6B2 /* Frameworks */ = { C605C480B46761595F28A6B2 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
02FB9097A522461BE8F904D4 /* libPods-FMC Planner 2.a */, E22E0B5A1CAD657000B71EE5 /* libSWTableViewCell.a */,
EAA5BF6A3B18A12DDBE49807 /* libPods-FMC Planner 2Tests.a */, E22E0B571CAD656700B71EE5 /* libPods-FMC Planner 2UITests.a */,
168D3CE5E84BDA0F157A7CF7 /* libPods-FMC Planner 2UITests.a */, E22E0B551CAD655D00B71EE5 /* libPods-FMC Planner 2.a */,
E22E0B531CAD655200B71EE5 /* libPods-FMC Planner 2Tests.a */,
); );
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@ -2,22 +2,4 @@
<Bucket <Bucket
type = "1" type = "1"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/TableViewController.m"
timestampString = "481124660.630831"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "93"
endingLineNumber = "93"
landmarkName = "-tableView:editingStyleForRowAtIndexPath:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>

View File

@ -171,7 +171,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes> <prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="GLu-S8-RZg"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="GLu-S8-RZg" customClass="SWTableViewCell">
<rect key="frame" x="0.0" y="92" width="320" height="44"/> <rect key="frame" x="0.0" y="92" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GLu-S8-RZg" id="r83-TH-eMI"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GLu-S8-RZg" id="r83-TH-eMI">

View File

@ -9,10 +9,11 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "SharedDeclerations.h" #import "SharedDeclerations.h"
#import "ViewController.h" #import "ViewController.h"
#import <SWTableViewCell/SWTableViewCell.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class ViewController; @class ViewController;
@interface TableViewController : UITableViewController @interface TableViewController : UITableViewController <SWTableViewCellDelegate>
#pragma mark - Refrence to other views in app #pragma mark - Refrence to other views in app
@ -21,5 +22,6 @@
#pragma mark - Table view data source #pragma mark - Table view data source
@property (strong, nonatomic) NSMutableArray *dataSource; @property (strong, nonatomic) NSMutableArray *dataSource;
@property (strong, nonatomic) NSMutableArray *markList;
@end @end

View File

@ -10,6 +10,8 @@
@implementation TableViewController @implementation TableViewController
DropboxV2ObjC *dbClient = nil;
#pragma mark - View management and navigation #pragma mark - View management and navigation
- (void)viewDidLoad - (void)viewDidLoad
@ -22,7 +24,13 @@
// Uncomment the following line to display an Edit button in the navigation // Uncomment the following line to display an Edit button in the navigation
// bar for this view controller. // bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem; // self.navigationItem.rightBarButtonItem = self.editButtonItem;
if ([self.title isEqualToString:@"Manage"]) { self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
_markList = [[NSMutableArray alloc] init];
dbClient =
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
if ([self.title isEqualToString:@"Manage"] ||
[self.title isEqualToString:@"Upload"]) {
NSArray *temp = [[NSFileManager defaultManager] NSArray *temp = [[NSFileManager defaultManager]
contentsOfDirectoryAtPath:[SharedDeclerations savePathForFile:@""] contentsOfDirectoryAtPath:[SharedDeclerations savePathForFile:@""]
error:nil]; error:nil];
@ -33,9 +41,6 @@
@"."]] mutableCopy]; @"."]] mutableCopy];
} }
if ([self.title isEqualToString:@"Download"]) { if ([self.title isEqualToString:@"Download"]) {
DropboxV2ObjC *dbClient =
((AppDelegate *)[UIApplication sharedApplication].delegate)
.dbClient;
[dbClient [dbClient
contentsOfPath:nil contentsOfPath:nil
completion:^(NSArray *data) { completion:^(NSArray *data) {
@ -71,11 +76,11 @@
- (UITableViewCell *)tableView:(UITableView *)tableView - (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
UITableViewCell *cell = SWTableViewCell *cell = (SWTableViewCell *)[tableView
[tableView dequeueReusableCellWithIdentifier:@"Cell" dequeueReusableCellWithIdentifier:@"Cell"];
forIndexPath:indexPath];
if ([self.title isEqualToString:@"Manage"]) { if ([self.title isEqualToString:@"Manage"] ||
[self.title isEqualToString:@"Upload"]) {
NSDictionary *data = [[NSDictionary alloc] NSDictionary *data = [[NSDictionary alloc]
initWithContentsOfFile:[SharedDeclerations initWithContentsOfFile:[SharedDeclerations
savePathForFile:_dataSource[indexPath savePathForFile:_dataSource[indexPath
@ -85,42 +90,14 @@
if ([self.title isEqualToString:@"Download"]) { if ([self.title isEqualToString:@"Download"]) {
cell.textLabel.text = _dataSource[indexPath.row]; cell.textLabel.text = _dataSource[indexPath.row];
} }
return cell;
}
#pragma mark - Table view editing action
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Detemine if it's in editing mode
if ([self.title isEqualToString:@"Manage"]) { if ([self.title isEqualToString:@"Manage"]) {
return UITableViewCellEditingStyleDelete; cell.rightUtilityButtons = [self rightButtons];
} }
else {
return UITableViewCellEditingStyleNone; cell.leftUtilityButtons = [self leftButtonsNormal];
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[[NSFileManager defaultManager]
removeItemAtPath:[SharedDeclerations
savePathForFile:_dataSource[indexPath.row]]
error:nil];
[_dataSource removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into
// the
// array, and add a new row to the table view
} }
cell.delegate = self;
return cell;
} }
#pragma mark - Table view cell selection action #pragma mark - Table view cell selection action
@ -137,6 +114,112 @@
.textLabel.text]; .textLabel.text];
}]; }];
} }
else {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
}
#pragma mark - Helper methods
/**
* AKA Delete button
*/
- (NSArray *)rightButtons
{
NSMutableArray *array = [[NSMutableArray alloc] init];
[array sw_addUtilityButtonWithColor:[UIColor colorWithRed:1.0f
green:0.231f
blue:0.188
alpha:1.0f]
title:@"Delete"];
return array;
}
/**
* AKA Mark button white
*/
- (NSArray *)leftButtonsNormal
{
NSMutableArray *array = [[NSMutableArray alloc] init];
[array sw_addUtilityButtonWithColor:[UIColor colorWithRed:0.78f
green:0.78f
blue:0.8f
alpha:1.0]
title:@"Mark"];
return array;
}
/**
* AKA Mark button green
*/
- (NSArray *)leftButtonsSelected
{
NSMutableArray *array = [[NSMutableArray alloc] init];
[array sw_addUtilityButtonWithColor:[UIColor colorWithRed:0.07
green:0.75f
blue:0.16f
alpha:1.0]
title:@"Unmark"];
return array;
}
- (void)finishSelection
{
if ([self.title isEqualToString:@"Download"]) {
[dbClient downloadFromDropbox:_markList];
[self.navigationController popViewControllerAnimated:YES];
}
if ([self.title isEqualToString:@"Upload"]) {
[dbClient uploadToDropbox:_markList];
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - SWTableViewDelegate
- (void)swipeableTableViewCell:(SWTableViewCell *)cell
didTriggerLeftUtilityButtonWithIndex:(NSInteger)index
{
if ([((UIButton *)cell.leftUtilityButtons[index])
.titleLabel.text isEqualToString:@"Mark"]) {
[_markList addObject:cell.textLabel.text];
cell.leftUtilityButtons = [self leftButtonsSelected];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[cell hideUtilityButtonsAnimated:YES];
}
else if ([((UIButton *)cell.leftUtilityButtons[index])
.titleLabel.text isEqualToString:@"Unmark"]) {
[_markList removeObject:cell.textLabel.text];
cell.leftUtilityButtons = [self leftButtonsNormal];
cell.accessoryType = UITableViewCellAccessoryNone;
[cell hideUtilityButtonsAnimated:YES];
}
if (_markList.count > 0 && self.navigationItem.rightBarButtonItem == nil) {
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Ok"
style:UIBarButtonItemStyleDone
target:self
action:@selector(finishSelection)];
}
else if (_markList.count == 0) {
self.navigationItem.rightBarButtonItem = nil;
}
}
- (void)swipeableTableViewCell:(SWTableViewCell *)cell
didTriggerRightUtilityButtonWithIndex:(NSInteger)index
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
[[NSFileManager defaultManager]
removeItemAtPath:[SharedDeclerations
savePathForFile:_dataSource[indexPath.row]]
error:nil];
[_dataSource removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationFade];
} }
@end @end

View File

@ -53,7 +53,7 @@
#pragma mark - Dropbox Button #pragma mark - Dropbox Button
// Standard action (hence set), dnamically set and unset // Standard action (hence set), dynamically set and unset
- (IBAction)dbConnect:(UIButton *)sender - (IBAction)dbConnect:(UIButton *)sender
{ {
UIViewController *webController = [[UIViewController alloc] init]; UIViewController *webController = [[UIViewController alloc] init];