shlist

share and manage lists between multiple people
Log | Files | Refs

commit 4a2a9cab63507ecf85396eeaede743381c37e9a9
parent 7f75b01c64d2f180fe9d689ee8721a09f7cc7476
Author: Kyle Milz <kmilz@coverity.com>
Date:   Mon, 29 Jun 2015 15:27:47 -0600

ios: start fleshing out list detail view

Diffstat:
Mios-ng/shlist.xcodeproj/project.pbxproj | 14++++++++++++++
Mios-ng/shlist/Base.lproj/Main.storyboard | 25++++++++++++++++++++-----
Aios-ng/shlist/ListDetailTableViewController.h | 7+++++++
Aios-ng/shlist/ListDetailTableViewController.m | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aios-ng/shlist/ListItem.h | 9+++++++++
Aios-ng/shlist/ListItem.m | 6++++++
Mios-ng/shlist/SharedListsTableViewController.m | 27+++++++++++++++------------
7 files changed, 194 insertions(+), 17 deletions(-)

diff --git a/ios-ng/shlist.xcodeproj/project.pbxproj b/ios-ng/shlist.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 27C70F301B33F4FA00DADEB3 /* SharedListsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F2F1B33F4FA00DADEB3 /* SharedListsTableViewController.m */; }; 27C70F321B3650CB00DADEB3 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 27C70F311B3650CB00DADEB3 /* libsqlite3.dylib */; }; 27C70F351B36513200DADEB3 /* DBManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F341B36513200DADEB3 /* DBManager.m */; }; + BF7776B91B38928D00526CB0 /* ListDetailTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7776B81B38928D00526CB0 /* ListDetailTableViewController.m */; }; + BF7776BC1B38D0DB00526CB0 /* ListItem.m in Sources */ = {isa = PBXBuildFile; fileRef = BF7776BB1B38D0DB00526CB0 /* ListItem.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -54,6 +56,10 @@ 27C70F311B3650CB00DADEB3 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; 27C70F331B36513200DADEB3 /* DBManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBManager.h; sourceTree = "<group>"; }; 27C70F341B36513200DADEB3 /* DBManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBManager.m; sourceTree = "<group>"; }; + BF7776B71B38928D00526CB0 /* ListDetailTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListDetailTableViewController.h; sourceTree = "<group>"; }; + BF7776B81B38928D00526CB0 /* ListDetailTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListDetailTableViewController.m; sourceTree = "<group>"; }; + BF7776BA1B38D0DB00526CB0 /* ListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListItem.h; sourceTree = "<group>"; }; + BF7776BB1B38D0DB00526CB0 /* ListItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListItem.m; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -104,6 +110,10 @@ 27C70F061B32AF8000DADEB3 /* AppDelegate.h */, 27C70F071B32AF8000DADEB3 /* AppDelegate.m */, 27C70F0C1B32AF8000DADEB3 /* Main.storyboard */, + BF7776B71B38928D00526CB0 /* ListDetailTableViewController.h */, + BF7776B81B38928D00526CB0 /* ListDetailTableViewController.m */, + BF7776BA1B38D0DB00526CB0 /* ListItem.h */, + BF7776BB1B38D0DB00526CB0 /* ListItem.m */, 27C70F2E1B33F4FA00DADEB3 /* SharedListsTableViewController.h */, 27C70F2F1B33F4FA00DADEB3 /* SharedListsTableViewController.m */, 27C70F2B1B33F3C300DADEB3 /* NewListViewController.h */, @@ -244,7 +254,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + BF7776B91B38928D00526CB0 /* ListDetailTableViewController.m in Sources */, 27C70F351B36513200DADEB3 /* DBManager.m in Sources */, + BF7776BC1B38D0DB00526CB0 /* ListItem.m in Sources */, 27C70F0B1B32AF8000DADEB3 /* Server.m in Sources */, 27C70F2A1B33D1C900DADEB3 /* SharedList.m in Sources */, 27C70F2D1B33F3C300DADEB3 /* NewListViewController.m in Sources */, @@ -455,6 +467,7 @@ 27C70F241B32AF8000DADEB3 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 27C70F251B32AF8000DADEB3 /* Build configuration list for PBXNativeTarget "shlistTests" */ = { isa = XCConfigurationList; @@ -463,6 +476,7 @@ 27C70F271B32AF8000DADEB3 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ios-ng/shlist/Base.lproj/Main.storyboard b/ios-ng/shlist/Base.lproj/Main.storyboard @@ -1,24 +1,38 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="0GJ-5e-Vr4"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="0GJ-5e-Vr4"> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/> <capability name="Constraints to layout margins" minToolsVersion="6.0"/> </dependencies> <scenes> - <!--Table View Controller--> + <!--List Detail--> <scene sceneID="NFJ-ye-dsA"> <objects> - <tableViewController id="pMK-tA-j4s" sceneMemberID="viewController"> + <tableViewController title="List Detail" id="pMK-tA-j4s" customClass="ListDetailTableViewController" sceneMemberID="viewController"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="dCf-l7-AN3"> <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <prototypes> - <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="s1K-8G-gXq"> + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ListDetailPrototypeCell" textLabel="rxW-Ue-XrL" detailTextLabel="Q7z-lr-GKp" style="IBUITableViewCellStyleValue1" id="s1K-8G-gXq"> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="s1K-8G-gXq" id="H4s-wq-8Lq"> <autoresizingMask key="autoresizingMask"/> + <subviews> + <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="rxW-Ue-XrL"> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="system" pointSize="16"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Q7z-lr-GKp"> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="system" pointSize="16"/> + <color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/> + <nil key="highlightedColor"/> + </label> + </subviews> </tableViewCellContentView> </tableViewCell> </prototypes> @@ -73,6 +87,7 @@ </tableView> <toolbarItems/> <navigationItem key="navigationItem" title="Shared Lists" id="uhM-V6-aB7"> + <barButtonItem key="leftBarButtonItem" systemItem="edit" id="XHh-J3-UVD"/> <barButtonItem key="rightBarButtonItem" systemItem="add" id="hNc-gt-QbU"> <connections> <segue destination="zuT-Jr-cfg" kind="presentation" id="Tbe-NZ-dy8"/> diff --git a/ios-ng/shlist/ListDetailTableViewController.h b/ios-ng/shlist/ListDetailTableViewController.h @@ -0,0 +1,7 @@ +#import <UIKit/UIKit.h> + +@interface ListDetailTableViewController : UITableViewController + +@property NSMutableArray *list_items; + +@end diff --git a/ios-ng/shlist/ListDetailTableViewController.m b/ios-ng/shlist/ListDetailTableViewController.m @@ -0,0 +1,123 @@ +#import "ListDetailTableViewController.h" +#import "ListItem.h" + +@interface ListDetailTableViewController () + +- (void)load_initial_data; + +@end + +@implementation ListDetailTableViewController + +- (void)load_initial_data +{ + NSLog(@"ListDetailTableViewController::load_initial_data()"); + + ListItem *item1 = [[ListItem alloc] init]; + item1.name = @"Axe"; + item1.owner = @"Kyle"; + [self.list_items addObject:item1]; + + ListItem *item2 = [[ListItem alloc] init]; + item2.name = @"Camp Stove"; + item2.owner = @"<none>"; + [self.list_items addObject:item2]; + + ListItem *item3 = [[ListItem alloc] init]; + item3.name = @"Tent"; + item3.owner = @"David"; + [self.list_items addObject:item3]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.leftBarButtonItem = self.editButtonItem; + + self.list_items = [[NSMutableArray alloc] init]; + [self load_initial_data]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [self.list_items count]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListDetailPrototypeCell" forIndexPath:indexPath]; + + NSLog(@"ListDetailTableViewController::cellForRowAtIndexPath()"); + + // Configure the cell... + + ListItem *item = [self.list_items objectAtIndex:indexPath.row]; + cell.textLabel.text = item.name; + cell.detailTextLabel.text = item.owner; + + return cell; +} + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// 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 + [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 + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/ios-ng/shlist/ListItem.h b/ios-ng/shlist/ListItem.h @@ -0,0 +1,8 @@ +#import <Foundation/Foundation.h> + +@interface ListItem : NSObject + +@property NSString *name; +@property NSString *owner; + +@end +\ No newline at end of file diff --git a/ios-ng/shlist/ListItem.m b/ios-ng/shlist/ListItem.m @@ -0,0 +1,5 @@ +#import "ListItem.h" + +@implementation ListItem + +@end +\ No newline at end of file diff --git a/ios-ng/shlist/SharedListsTableViewController.m b/ios-ng/shlist/SharedListsTableViewController.m @@ -13,7 +13,7 @@ // load local shared list data from db // sync with server and check if there's any updates - NSLog(@"Loading initial data"); + NSLog(@"SharedListsTableViewController::load_initial_data()"); SharedList *list1 = [[SharedList alloc] init]; list1.list_name = @"Camping"; @@ -27,7 +27,8 @@ } -- (IBAction)unwindToList:(UIStoryboardSegue *)segue { +- (IBAction)unwindToList:(UIStoryboardSegue *)segue +{ NewListViewController *source = [segue sourceViewController]; SharedList *list = source.shared_list; @@ -39,41 +40,43 @@ NSLog(@"unwindToList(): done"); } -- (void)viewDidLoad { +- (void)viewDidLoad +{ [super viewDidLoad]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; + self.navigationItem.leftBarButtonItem = self.editButtonItem; self.shared_lists = [[NSMutableArray alloc] init]; [self load_initial_data]; } -- (void)didReceiveMemoryWarning { +- (void)didReceiveMemoryWarning +{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - // Return the number of sections. +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ return 1; } -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - // Return the number of rows in the section. +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ return [self.shared_lists count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SharedListPrototypeCell" forIndexPath:indexPath]; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SharedListPrototypeCell"]; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SharedListPrototypeCell" forIndexPath:indexPath]; + // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SharedListPrototypeCell"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"SharedListPrototypeCell"]; @@ -88,7 +91,7 @@ SharedList *shared_list = [self.shared_lists objectAtIndex:indexPath.row]; cell.textLabel.text = shared_list.list_name; cell.detailTextLabel.text = shared_list.list_members; - + return cell; }