commit d2d5ced7e3e226a8e7c6756b05c7e072b6c888da
parent b5e684bd4504f5fb005b58bd2e46455d2afafa19
Author: Kyle Milz <kyle@Kyles-MacBook-Pro.local>
Date: Tue, 22 Sep 2015 18:36:49 -0600
ios: polish the ui some more
- rename and expand on edit item screen, hook ui elements to code
- additional/better logging
- added various fields to data structures
Diffstat:
13 files changed, 314 insertions(+), 293 deletions(-)
diff --git a/ios-ng/EditItemTableViewController.h b/ios-ng/EditItemTableViewController.h
@@ -0,0 +1,12 @@
+#import <UIKit/UIKit.h>
+#import "DataStructures.h"
+
+@interface EditItemTableViewController : UITableViewController
+
+@property SharedList *list;
+@property ListItem *item;
+
+- (void) set_item:(ListItem *)item for_list:(SharedList *)list;
+- (void) set_edit_or_new:(NSString *)edit_or_new;
+
+@end
diff --git a/ios-ng/EditItemTableViewController.m b/ios-ng/EditItemTableViewController.m
@@ -0,0 +1,131 @@
+#import "EditItemTableViewController.h"
+#import "Network.h"
+
+@interface EditItemTableViewController () {
+ Network *network_connection;
+}
+
+@property (weak, nonatomic) IBOutlet UIBarButtonItem *save_button;
+
+@property (weak, nonatomic) IBOutlet UILabel *item_name;
+@property (weak, nonatomic) IBOutlet UILabel *quantity_label;
+@property (weak, nonatomic) IBOutlet UISwitch *shared_sw;
+
+@property (weak, nonatomic) IBOutlet UILabel *owner_label;
+@property (weak, nonatomic) IBOutlet UILabel *price_label;
+
+
+@end
+
+@implementation EditItemTableViewController
+
+// called when shared switch is toggled
+- (IBAction)shared_switch:(id)sender
+{
+ NSIndexSet *index_set = [NSIndexSet indexSetWithIndex:1];
+
+ if (_item.shared) {
+ _item.shared = false;
+ // XXX: send network request with list id, item id, and this device id
+ [self.tableView deleteSections:index_set withRowAnimation:UITableViewRowAnimationMiddle];
+ } else {
+ _item.shared = true;
+ // XXX: send item commit network request with list id, item id, and this device id
+ [self.tableView insertSections:index_set withRowAnimation:UITableViewRowAnimationMiddle];
+ }
+}
+
+- (void) set_item:(ListItem *)item for_list:(SharedList *)list;
+{
+ _list = list;
+ _item = item;
+}
+
+- (void) set_edit_or_new:(NSString *)edit_or_new;
+{
+ self.title = edit_or_new;
+}
+
+- (void) viewDidLoad
+{
+ [super viewDidLoad];
+ network_connection = [Network shared_network_connection];
+
+ [_shared_sw setOn:_item.shared animated:YES];
+ [_item_name setText:_item.name];
+ [_quantity_label setText:[NSString stringWithFormat:@"%i", _item.quantity]];
+
+ if (_item.committed)
+ _owner_label.text = _item.owner;
+ else
+ _owner_label.text = @"";
+
+ [_price_label setText:@"$26.99"];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ if (_item.shared)
+ return 2;
+ else
+ return 1;
+}
+
+// fill in the static table view cells with information
+- (UITableViewCell *)tableView:(UITableView *)tableView
+ cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
+
+ if ([indexPath section] == 1) {
+ /*
+ if ([indexPath row] == 0) {
+ UILabel *owner = (UILabel *)[cell viewWithTag:1];
+
+ if (_item.committed)
+ owner.text = _item.owner;
+ else
+ owner.text = @"";
+ }
+ */
+ }
+
+ return cell;
+}
+
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
+{
+ if (sender != self.save_button)
+ return;
+
+ // save item, item_id could be incrementing unique integer
+ // device_id:list_id:item_id:name:quantity:owner:committed:complete
+ NSMutableArray *string_array = [[NSMutableArray alloc] init];
+ [string_array addObject:_item.name];
+ [string_array addObject:[NSString stringWithFormat:@"%i", _item.quantity]];
+
+ if (_item.shared)
+ [string_array addObject:_item.owner];
+ else
+ [string_array addObject:@""];
+
+ [string_array addObject:[NSString stringWithFormat:@"%i", _item.committed]];
+ [string_array addObject:[NSString stringWithFormat:@"%i", _item.completed]];
+
+ NSMutableData *buffer = [[NSMutableData alloc] init];
+ [buffer appendData:_list.id];
+ [buffer appendData:[[string_array componentsJoinedByString:@":"] dataUsingEncoding:NSUTF8StringEncoding]];
+
+ // the list item that was just edited will be updated when a response comes
+ [network_connection send_message:7 contents:buffer];
+
+ NSLog(@"debug: %@: %@: saving", _list.name, _item.name);
+}
+
+@end
diff --git a/ios-ng/NewItemTableViewController.h b/ios-ng/NewItemTableViewController.h
@@ -1,8 +0,0 @@
-#import <UIKit/UIKit.h>
-#import "DataStructures.h"
-
-@interface NewItemTableViewController : UITableViewController
-
-@property ListItem *shared_list;
-
-@end
diff --git a/ios-ng/NewItemTableViewController.m b/ios-ng/NewItemTableViewController.m
@@ -1,155 +0,0 @@
-#import "NewItemTableViewController.h"
-
-@interface NewItemTableViewController ()
-
-
-@property (weak, nonatomic) IBOutlet UILabel *item_name;
-@property (weak, nonatomic) IBOutlet UISwitch *purchase_switch;
-@property (weak, nonatomic) IBOutlet UISwitch *shared_sw;
-
-@end
-
-@implementation NewItemTableViewController
-
-// called when shared switch is toggled
-- (IBAction)shared_switch:(id)sender
-{
- NSIndexSet *index_set = [NSIndexSet indexSetWithIndex:1];
-
- if ([self.tableView numberOfSections] == 1)
- [self.tableView insertSections:index_set withRowAnimation:UITableViewRowAnimationMiddle];
- else
- [self.tableView deleteSections:index_set withRowAnimation:UITableViewRowAnimationMiddle];
-
- // hide/unhide the shared status group
- // [self.tableView reloadData];
-}
-
-- (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;
-}
-
-- (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
-}
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-{
- // get the shared switch state to see if the shared properties should
- // be shown
- // NSIndexPath *index_path = [NSIndexPath indexPathForRow:1 inSection:0];
-
- // UITableViewCell *cell = [super tableView:tableView
- // cellForRowAtIndexPath:index_path];
-
- // UISwitch *shared_switch = (UISwitch *)[cell viewWithTag:1];
-
-
- if (_shared_sw.isOn)
- return 2;
- else
- return 1;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView
- numberOfRowsInSection:(NSInteger)section
-{
- // NSLog(@"info: reloading rows in table view");
-
- if (section == 0)
- return 3;
- else if (section == 1)
- return 2;
-
- return 0;
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView
- cellForRowAtIndexPath:(NSIndexPath *)indexPath
-{
- //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
-
- // Configure the cell...
-
- //return cell;
-
- UITableViewCell *cell = [super tableView:tableView
- cellForRowAtIndexPath:indexPath];
- // cell.accessoryType = UITableViewCellAccessoryNone;
-
- // NSUInteger section = [indexPath section];
- // NSUInteger row = [indexPath row];
-
- /*
- switch (section)
- {
- case SECTION_SPEED:
- if (row == self.speed)
- {
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- }
- break;
-
- case SECTION_VOLUME:
- if (row == self.volume)
- {
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- }
- break;
- }
- */
- 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.xcodeproj/project.pbxproj b/ios-ng/shlist.xcodeproj/project.pbxproj
@@ -7,7 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
- 27AAC22C1B50ABAF00D99171 /* NewItemTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27AAC22B1B50ABAF00D99171 /* NewItemTableViewController.m */; };
+ 27AAC22C1B50ABAF00D99171 /* EditItemTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27AAC22B1B50ABAF00D99171 /* EditItemTableViewController.m */; };
27B03A021B43B8660054B6D2 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27B03A001B43B8660054B6D2 /* AddressBook.framework */; };
27C70F051B32AF8000DADEB3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F041B32AF8000DADEB3 /* main.m */; };
27C70F081B32AF8000DADEB3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C70F071B32AF8000DADEB3 /* AppDelegate.m */; };
@@ -38,8 +38,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
- 27AAC22A1B50ABAF00D99171 /* NewItemTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NewItemTableViewController.h; path = ../NewItemTableViewController.h; sourceTree = "<group>"; };
- 27AAC22B1B50ABAF00D99171 /* NewItemTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NewItemTableViewController.m; path = ../NewItemTableViewController.m; sourceTree = "<group>"; };
+ 27AAC22A1B50ABAF00D99171 /* EditItemTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EditItemTableViewController.h; path = ../EditItemTableViewController.h; sourceTree = "<group>"; };
+ 27AAC22B1B50ABAF00D99171 /* EditItemTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EditItemTableViewController.m; path = ../EditItemTableViewController.m; sourceTree = "<group>"; };
27B03A001B43B8660054B6D2 /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
27C70EFF1B32AF8000DADEB3 /* shlist.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = shlist.app; sourceTree = BUILT_PRODUCTS_DIR; };
27C70F031B32AF8000DADEB3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -122,20 +122,20 @@
27C70F281B33CE2500DADEB3 /* DataStructures.h */,
27C70F291B33D1C900DADEB3 /* DataStructures.m */,
27DCC9DD1B8A98D400207340 /* dollar103-2.png */,
+ 27AAC22A1B50ABAF00D99171 /* EditItemTableViewController.h */,
+ 27AAC22B1B50ABAF00D99171 /* EditItemTableViewController.m */,
+ 27D83D281BAFC99D0029F54B /* EditTableViewController.h */,
+ 27D83D291BAFC99D0029F54B /* EditTableViewController.m */,
27C70F0F1B32AF8000DADEB3 /* Images.xcassets */,
27DCC9E71B9EB4E800207340 /* information15-3.png */,
27C70F111B32AF8000DADEB3 /* LaunchScreen.xib */,
BF7776B71B38928D00526CB0 /* ListTableViewController.h */,
BF7776B81B38928D00526CB0 /* ListTableViewController.m */,
27C70F0C1B32AF8000DADEB3 /* Main.storyboard */,
- 27D83D281BAFC99D0029F54B /* EditTableViewController.h */,
- 27D83D291BAFC99D0029F54B /* EditTableViewController.m */,
27C70F2E1B33F4FA00DADEB3 /* MainTableViewController.h */,
27C70F2F1B33F4FA00DADEB3 /* MainTableViewController.m */,
27C70F091B32AF8000DADEB3 /* Network.h */,
27C70F0A1B32AF8000DADEB3 /* Network.m */,
- 27AAC22A1B50ABAF00D99171 /* NewItemTableViewController.h */,
- 27AAC22B1B50ABAF00D99171 /* NewItemTableViewController.m */,
27C70F2B1B33F3C300DADEB3 /* NewListTableViewController.h */,
27C70F2C1B33F3C300DADEB3 /* NewListTableViewController.m */,
27C70F021B32AF8000DADEB3 /* Supporting Files */,
@@ -273,7 +273,7 @@
buildActionMask = 2147483647;
files = (
BF7776B91B38928D00526CB0 /* ListTableViewController.m in Sources */,
- 27AAC22C1B50ABAF00D99171 /* NewItemTableViewController.m in Sources */,
+ 27AAC22C1B50ABAF00D99171 /* EditItemTableViewController.m in Sources */,
27C70F0B1B32AF8000DADEB3 /* Network.m in Sources */,
27D805731BA2649D00867494 /* ContactsTableViewController.m in Sources */,
27C70F2A1B33D1C900DADEB3 /* DataStructures.m in Sources */,
diff --git a/ios-ng/shlist/Base.lproj/Main.storyboard b/ios-ng/shlist/Base.lproj/Main.storyboard
@@ -20,14 +20,11 @@
<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" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="btC-Lf-VTy">
- <rect key="frame" x="16" y="11" width="46" height="21"/>
- <fontDescription key="fontDescription" type="system" pointSize="17"/>
- <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
- <nil key="highlightedColor"/>
- </label>
<switch opaque="NO" tag="5" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="n1B-AB-bme">
<rect key="frame" x="535" y="6" width="51" height="31"/>
+ <connections>
+ <action selector="commit_toggled:" destination="pMK-tA-j4s" eventType="valueChanged" id="bxZ-F2-qdI"/>
+ </connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" tag="4" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Owner" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0TP-dF-f2P">
<rect key="frame" x="476" y="11" width="51" height="21"/>
@@ -36,25 +33,31 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" tag="3" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Quantity" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="upb-uA-yH2">
- <rect key="frame" x="70" y="13" width="55" height="17"/>
- <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <rect key="frame" x="66" y="11" width="65" height="21"/>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
+ <label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="btC-Lf-VTy">
+ <rect key="frame" x="16" y="11" width="46" height="21"/>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
+ <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+ <nil key="highlightedColor"/>
+ </label>
</subviews>
<constraints>
- <constraint firstItem="btC-Lf-VTy" firstAttribute="leading" secondItem="H4s-wq-8Lq" secondAttribute="leadingMargin" constant="8" id="5to-9N-ciC"/>
- <constraint firstItem="upb-uA-yH2" firstAttribute="leading" secondItem="btC-Lf-VTy" secondAttribute="trailing" constant="8" id="7aj-Mf-7or"/>
<constraint firstAttribute="centerY" secondItem="upb-uA-yH2" secondAttribute="centerY" id="MWW-iY-71k"/>
<constraint firstItem="n1B-AB-bme" firstAttribute="trailing" secondItem="H4s-wq-8Lq" secondAttribute="trailingMargin" constant="-8" id="VG7-8h-1wm"/>
<constraint firstAttribute="centerY" secondItem="btC-Lf-VTy" secondAttribute="centerY" id="Yg4-lg-cMN"/>
<constraint firstAttribute="centerY" secondItem="0TP-dF-f2P" secondAttribute="centerY" id="chu-HH-HQT"/>
<constraint firstAttribute="centerY" secondItem="n1B-AB-bme" secondAttribute="centerY" id="cyz-Nv-ZRW"/>
+ <constraint firstItem="btC-Lf-VTy" firstAttribute="leading" secondItem="H4s-wq-8Lq" secondAttribute="leadingMargin" constant="8" id="nYb-Lh-toQ"/>
<constraint firstItem="n1B-AB-bme" firstAttribute="leading" secondItem="0TP-dF-f2P" secondAttribute="trailing" constant="8" id="rYF-Sw-Bsg"/>
+ <constraint firstItem="upb-uA-yH2" firstAttribute="leading" secondItem="btC-Lf-VTy" secondAttribute="trailing" constant="4" id="s9P-VC-4MI"/>
</constraints>
</tableViewCellContentView>
<connections>
- <segue destination="KAJ-Ph-mEk" kind="presentation" id="Z5g-ao-bLA"/>
+ <segue destination="KAJ-Ph-mEk" kind="presentation" identifier="edit item segue" id="Z5g-ao-bLA"/>
</connections>
</tableViewCell>
</prototypes>
@@ -67,19 +70,19 @@
<navigationItem key="navigationItem" title="Title" id="66A-da-3AW">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="iiv-LM-IOO">
<connections>
- <segue destination="KAJ-Ph-mEk" kind="presentation" id="jZG-FG-nAX"/>
+ <segue destination="KAJ-Ph-mEk" kind="presentation" identifier="add item segue" id="jZG-FG-nAX"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="H64-xB-1er" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="2168" y="-638"/>
+ <point key="canvasLocation" x="2168" y="-628"/>
</scene>
- <!--Add Item-->
+ <!--Edit Item-->
<scene sceneID="OeV-vW-TVD">
<objects>
- <tableViewController title="Add Item" id="8Gi-Gc-mRg" customClass="NewItemTableViewController" sceneMemberID="viewController">
+ <tableViewController title="Edit Item" id="8Gi-Gc-mRg" customClass="EditItemTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="sGb-Al-WmL">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -92,13 +95,13 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hpv-Jh-N2Z" id="bBG-J9-Qvq">
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GRs-CY-ps2">
- <rect key="frame" x="8" y="11" width="46" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GRs-CY-ps2">
+ <rect key="frame" x="16" y="11" width="46" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<item name>" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RxZ-xc-Qog">
+ <label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<item name>" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RxZ-xc-Qog">
<rect key="frame" x="458" y="11" width="101" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
@@ -108,28 +111,35 @@
<constraints>
<constraint firstItem="RxZ-xc-Qog" firstAttribute="trailing" secondItem="bBG-J9-Qvq" secondAttribute="trailingMargin" id="Eg4-rr-HNe"/>
<constraint firstAttribute="centerY" secondItem="RxZ-xc-Qog" secondAttribute="centerY" id="J7h-Uo-2Vv"/>
+ <constraint firstAttribute="centerY" secondItem="GRs-CY-ps2" secondAttribute="centerY" id="TXF-WC-Vov"/>
+ <constraint firstItem="GRs-CY-ps2" firstAttribute="leading" secondItem="bBG-J9-Qvq" secondAttribute="leadingMargin" constant="8" id="wJB-ao-RGm"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
- <tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="EtU-pb-OGN">
+ <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="TH5-mM-xLA">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
- <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="EtU-pb-OGN" id="rFW-W4-rEL">
+ <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TH5-mM-xLA" id="V8L-jF-w5s">
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="ZG9-yz-YFh">
- <rect key="frame" x="543" y="6" width="51" height="31"/>
- </switch>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Purchase" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uxj-my-Z2Y">
- <rect key="frame" x="8" y="11" width="72" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Quantity" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YUn-bk-b71">
+ <rect key="frame" x="16" y="11" width="65" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
- <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="euC-mD-mH7">
+ <rect key="frame" x="574" y="11" width="10" height="21"/>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
+ <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
- <constraint firstAttribute="centerY" secondItem="ZG9-yz-YFh" secondAttribute="centerY" id="80p-g3-bEH"/>
- <constraint firstItem="ZG9-yz-YFh" firstAttribute="trailing" secondItem="rFW-W4-rEL" secondAttribute="trailingMargin" id="vZc-93-inJ"/>
+ <constraint firstItem="YUn-bk-b71" firstAttribute="leading" secondItem="V8L-jF-w5s" secondAttribute="leadingMargin" constant="8" id="2Kd-Y9-ts0"/>
+ <constraint firstAttribute="trailingMargin" secondItem="euC-mD-mH7" secondAttribute="trailing" constant="8" id="DhZ-y0-7xK"/>
+ <constraint firstAttribute="centerY" secondItem="YUn-bk-b71" secondAttribute="centerY" id="mzx-tl-wdn"/>
+ <constraint firstAttribute="centerY" secondItem="euC-mD-mH7" secondAttribute="centerY" id="pfb-yv-Ae2"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
@@ -138,21 +148,23 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="40G-4d-KXw" id="xcB-Zu-7Yt">
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Shared" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MsQ-Iq-XOk">
- <rect key="frame" x="8" y="11" width="55" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Shared" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MsQ-Iq-XOk">
+ <rect key="frame" x="16" y="11" width="55" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" tag="1" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="xy3-L7-YrZ">
- <rect key="frame" x="543" y="6" width="51" height="31"/>
+ <rect key="frame" x="535" y="6" width="51" height="31"/>
<connections>
<action selector="shared_switch:" destination="8Gi-Gc-mRg" eventType="valueChanged" id="Add-PE-NRp"/>
</connections>
</switch>
</subviews>
<constraints>
- <constraint firstItem="xy3-L7-YrZ" firstAttribute="trailing" secondItem="xcB-Zu-7Yt" secondAttribute="trailingMargin" id="JoL-Hq-y2d"/>
+ <constraint firstItem="MsQ-Iq-XOk" firstAttribute="leading" secondItem="xcB-Zu-7Yt" secondAttribute="leadingMargin" constant="8" id="AkM-8d-yzx"/>
+ <constraint firstAttribute="centerY" secondItem="MsQ-Iq-XOk" secondAttribute="centerY" id="EFU-w6-pPU"/>
+ <constraint firstItem="xy3-L7-YrZ" firstAttribute="trailing" secondItem="xcB-Zu-7Yt" secondAttribute="trailingMargin" constant="-8" id="JoL-Hq-y2d"/>
<constraint firstAttribute="centerY" secondItem="xy3-L7-YrZ" secondAttribute="centerY" id="yuO-MF-KCL"/>
</constraints>
</tableViewCellContentView>
@@ -166,22 +178,24 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="CLf-ge-Fs1" id="bPK-KB-4tb">
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Owner" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T4L-tN-tX4">
- <rect key="frame" x="8" y="11" width="51" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Owner" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T4L-tN-tX4">
+ <rect key="frame" x="16" y="11" width="51" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<persons name>" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y92-Cj-Q4R">
- <rect key="frame" x="462" y="11" width="130" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Nobody" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y92-Cj-Q4R">
+ <rect key="frame" x="523" y="11" width="61" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
+ <constraint firstAttribute="centerY" secondItem="T4L-tN-tX4" secondAttribute="centerY" id="GEh-N7-Mx3"/>
<constraint firstAttribute="centerY" secondItem="Y92-Cj-Q4R" secondAttribute="centerY" id="aQV-Ex-gn9"/>
- <constraint firstItem="Y92-Cj-Q4R" firstAttribute="trailing" secondItem="bPK-KB-4tb" secondAttribute="trailingMargin" id="yHe-aI-QkZ"/>
+ <constraint firstItem="T4L-tN-tX4" firstAttribute="leading" secondItem="bPK-KB-4tb" secondAttribute="leadingMargin" constant="8" id="bwC-VG-kcs"/>
+ <constraint firstItem="Y92-Cj-Q4R" firstAttribute="trailing" secondItem="bPK-KB-4tb" secondAttribute="trailingMargin" constant="-8" id="yHe-aI-QkZ"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
@@ -190,21 +204,23 @@
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aur-Cc-cv0" id="l74-H8-N2N">
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Cost" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Boa-7b-ddO">
- <rect key="frame" x="8" y="11" width="37" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Cost" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Boa-7b-ddO">
+ <rect key="frame" x="16" y="11" width="37" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<cost>" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QhL-xd-rVc">
- <rect key="frame" x="538" y="11" width="54" height="21"/>
+ <label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="$21.99" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QhL-xd-rVc">
+ <rect key="frame" x="531" y="11" width="53" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
- <constraint firstItem="QhL-xd-rVc" firstAttribute="trailing" secondItem="l74-H8-N2N" secondAttribute="trailingMargin" id="bNe-Ou-GSy"/>
+ <constraint firstItem="Boa-7b-ddO" firstAttribute="leading" secondItem="l74-H8-N2N" secondAttribute="leadingMargin" constant="8" id="H8D-9z-Lmo"/>
+ <constraint firstAttribute="centerY" secondItem="Boa-7b-ddO" secondAttribute="centerY" id="N88-au-rdg"/>
+ <constraint firstItem="QhL-xd-rVc" firstAttribute="trailing" secondItem="l74-H8-N2N" secondAttribute="trailingMargin" constant="-8" id="bNe-Ou-GSy"/>
<constraint firstAttribute="centerY" secondItem="QhL-xd-rVc" secondAttribute="centerY" id="sZa-du-szj"/>
</constraints>
</tableViewCellContentView>
@@ -231,7 +247,10 @@
</navigationItem>
<connections>
<outlet property="item_name" destination="RxZ-xc-Qog" id="nxl-In-G7u"/>
- <outlet property="purchase_switch" destination="ZG9-yz-YFh" id="5ir-Mo-Mkl"/>
+ <outlet property="owner_label" destination="Y92-Cj-Q4R" id="VkB-vs-TZU"/>
+ <outlet property="price_label" destination="QhL-xd-rVc" id="uLO-C8-jdW"/>
+ <outlet property="quantity_label" destination="euC-mD-mH7" id="R9f-fy-Aul"/>
+ <outlet property="save_button" destination="911-15-WDf" id="Nhm-2D-fHs"/>
<outlet property="shared_sw" destination="xy3-L7-YrZ" id="lDX-FU-p1a"/>
</connections>
</tableViewController>
@@ -347,7 +366,7 @@
</subviews>
</tableViewCellContentView>
<connections>
- <segue destination="uyw-yd-pcJ" kind="show" id="HBi-RJ-djr"/>
+ <segue destination="uyw-yd-pcJ" kind="show" identifier="add shared list name edit" id="HBi-RJ-djr"/>
</connections>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" id="Eio-uC-eIV">
@@ -701,7 +720,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AR0-99-D0J" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
- <point key="canvasLocation" x="3016" y="-638"/>
+ <point key="canvasLocation" x="3024" y="-628"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="9uD-bo-9f6">
diff --git a/ios-ng/shlist/DataStructures.h b/ios-ng/shlist/DataStructures.h
@@ -10,6 +10,7 @@
@property NSString *name;
@property NSData *id;
@property NSArray *members_phone_nums;
+@property bool deadline;
@property NSDate *date;
@property int items_ready;
@property int items_total;
@@ -24,8 +25,9 @@
@property int modifier;
@property NSString *name;
@property int quantity;
+@property bool shared;
@property NSString *owner;
@property bool committed;
-@property int completed;
+@property bool completed;
@end
\ No newline at end of file
diff --git a/ios-ng/shlist/ListTableViewController.m b/ios-ng/shlist/ListTableViewController.m
@@ -1,11 +1,14 @@
+#import "EditItemTableViewController.h"
#import "ListTableViewController.h"
+
#import "DataStructures.h"
#import "Network.h"
-@interface ListTableViewController ()
+@interface ListTableViewController () {
+ Network *network_connection;
+}
- (void)load_initial_data;
-@property (strong, nonatomic) Network *server;
@end
@@ -17,6 +20,7 @@
item.name = @"Cheese Pizza";
item.owner = @"Dave";
item.committed = 1;
+ item.shared = 1;
[self.list_items addObject:item];
item = [[ListItem alloc] init];
@@ -24,6 +28,7 @@
item.name = @"Camp stove";
item.owner = @"Steve";
item.committed = 1;
+ item.shared = 1;
[self.list_items addObject:item];
item = [[ListItem alloc] init];
@@ -31,6 +36,7 @@
item.quantity = 10;
item.owner = @"";
item.committed = 0;
+ item.shared = 1;
[self.list_items addObject:item];
item = [[ListItem alloc] init];
@@ -38,6 +44,7 @@
item.quantity = 1;
item.owner = @"You";
item.committed = 1;
+ item.shared = 1;
[self.list_items addObject:item];
item = [[ListItem alloc] init];
@@ -45,6 +52,7 @@
item.quantity = 1;
item.owner = @"";
item.committed = 0;
+ item.shared = 1;
[self.list_items addObject:item];
item = [[ListItem alloc] init];
@@ -52,15 +60,18 @@
item.quantity = 1;
item.owner = @"Greg";
item.committed = 1;
+ item.shared = 1;
[self.list_items addObject:item];
item = [[ListItem alloc] init];
item.name = @"Deoderant";
+ item.shared = 0;
[self.private_items addObject:item];
item = [[ListItem alloc] init];
item.name = @"Toothbrush";
+ item.shared = 0;
[self.private_items addObject:item];
item = [[ListItem alloc] init];
@@ -102,6 +113,8 @@
_list_items = [[NSMutableArray alloc] init];
_private_items = [[NSMutableArray alloc] init];
+
+ network_connection = [Network shared_network_connection];
[self load_initial_data];
}
@@ -111,8 +124,16 @@
// Dispose of any resources that can be recreated.
}
-- (IBAction)unwindToList:(UIStoryboardSegue *)segue {
+- (IBAction)commit_toggled:(id)sender
+{
+ NSIndexPath *path = [self.tableView indexPathForCell:sender];
+
+ NSLog(@"debug: toggled commit at %@", path);
+}
+// called when previous segue's are unwinding
+- (IBAction)unwindToList:(UIStoryboardSegue *)segue
+{
}
- (void) setMetadata:(SharedList *)metadata
@@ -193,6 +214,9 @@
[commit_switch setEnabled:NO];
}
}
+
+ commit_switch.hidden = false;
+ owner.hidden = false;
}
else if ([indexPath section] == 1) {
// "private items" section
@@ -202,13 +226,15 @@
owner.hidden = true;
commit_switch.hidden = true;
}
+ else
+ return nil;
item_name.text = item.name;
if (item.quantity > 1)
- quantity.text = [NSString stringWithFormat:@"(x%d)", item.quantity];
+ quantity.text = [NSString stringWithFormat:@"x%d", item.quantity];
else
- quantity.hidden = true;
+ quantity.text = @"";
return cell;
}
@@ -221,7 +247,10 @@
// Override to support editing the table view.
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+- (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];
@@ -230,29 +259,38 @@
}
}
-
-/*
-// 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.
+- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
+{
+ // This guys answer here saved my ass once
+ // http://stackoverflow.com/questions/9727549/unrecognized-selector-sent-to-instance-using-storyboards
+
+ // I like the two line version from above but it gives warnings :(
+ EditItemTableViewController *tvc = (EditItemTableViewController *)[[segue destinationViewController] topViewController];
+
+ if ([[segue identifier] isEqualToString:@"edit item segue"]) {
+ // NSIndexPath *path = [self.tableView indexPathForSelectedRow];
+
+ NSIndexPath *path = [self.tableView indexPathForCell:sender];
+ ListItem *item;
+ if ([path section] == 0)
+ item = [self.list_items objectAtIndex:[path row]];
+ else if ([path section] == 1)
+ item = [self.private_items objectAtIndex:[path row]];
+ else
+ // segue from unknown section
+ return;
+
+ // make sure incoming view controller knows about itself
+ [tvc set_item:item for_list:_list_metadata];
+ [tvc set_edit_or_new:@"Edit Item"];
+
+ NSLog(@"debug: %@: edit item segue", _list_metadata.name);
+ }
+ else if ([[segue identifier] isEqualToString:@"add item segue"]) {
+ [tvc set_edit_or_new:@"Add Item"];
+ NSLog(@"debug: %@: add item segue", _list_metadata.name);
+ }
}
-*/
@end
\ No newline at end of file
diff --git a/ios-ng/shlist/MainTableViewController.m b/ios-ng/shlist/MainTableViewController.m
@@ -158,16 +158,6 @@ clickedButtonAtIndex:(NSInteger)buttonIndex
// new list dialogue has been saved
- (IBAction) unwindToList:(UIStoryboardSegue *)segue
{
- NewListTableViewController *source = [segue sourceViewController];
- SharedList *list = source.shared_list;
-
- if (list == nil) {
- return;
- }
-
- // good to save
- NSData *payload = [list.name dataUsingEncoding:NSUTF8StringEncoding];
- [network_connection send_message:1 contents:payload];
}
- (void) finished_new_list_request:(SharedList *) shlist
@@ -423,37 +413,28 @@ clickedButtonAtIndex:(NSInteger)buttonIndex
return @"Leave";
}
-// In a storyboard-based application, you will often want to do a little preparation before navigation
+// tell incoming controllers about their environment
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
-
if ([[segue identifier] isEqualToString:@"show list segue"]) {
+ // a shared list was selected, transfer into detailed view
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
-
SharedList *list = [self.shared_lists objectAtIndex:[path row]];
- // only list detail table view controller has this method
+ // make sure incoming view controller knows about itself
[segue.destinationViewController setMetadata:list];
- // has to be done before issuing network request
- network_connection->shlist_ldvc = segue.destinationViewController;
-
// send update list items message
+ network_connection->shlist_ldvc = segue.destinationViewController;
[network_connection send_message:6 contents:list.id];
}
- // DetailObject *detail = [self detailForIndexPath:path];ß
-
- // ListDetailTableViewController *list_detail_tvc = [segue destinationViewController];
- // list_detail_tvc.navigationItem.title = @"Test Title";
- NSLog(@"preparing for segue");
+ // DetailObject *detail = [self detailForIndexPath:path];
+ NSLog(@"info: main: preparing for segue");
}
// prevent segues from occurring when non member lists are selected
-// this isn't needed if we use 2 different prototype cells
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
diff --git a/ios-ng/shlist/Network.h b/ios-ng/shlist/Network.h
@@ -11,7 +11,6 @@
@public
MainTableViewController *shlist_tvc;
ListTableViewController *shlist_ldvc;
-
}
- (void) connect;
diff --git a/ios-ng/shlist/Network.m b/ios-ng/shlist/Network.m
@@ -137,8 +137,7 @@
[self connect];
NSMutableData *msg = [NSMutableData data];
- [self info:@"network: send_message: msg type %i, %i bytes payload",
- send_msg_type, [payload length]];
+
uint16_t msg_type_network = htons(send_msg_type);
[msg appendBytes:&msg_type_network length:2];
@@ -162,6 +161,9 @@
[msg appendData:payload];
}
+ [self info:@"network: send_message: type %i, %i bytes",
+ send_msg_type, [msg length]];
+
if ([outputShlistStream write:[msg bytes] maxLength:[msg length]] == -1) {
[self warn:@"network: write error occurred, trying reconnect"];
if (connected)
diff --git a/ios-ng/shlist/NewListTableViewController.h b/ios-ng/shlist/NewListTableViewController.h
@@ -3,6 +3,5 @@
@interface NewListTableViewController : UITableViewController
-@property SharedList *shared_list;
@end
diff --git a/ios-ng/shlist/NewListTableViewController.m b/ios-ng/shlist/NewListTableViewController.m
@@ -1,15 +1,16 @@
#import "NewListTableViewController.h"
#import "EditTableViewController.h"
+#import "Network.h"
@interface NewListTableViewController () {
- int num_sections;
+ Network *network_connection;
}
@property (weak, nonatomic) IBOutlet UIBarButtonItem *saveButton;
@property (weak, nonatomic) IBOutlet UISwitch *deadline_switch;
@property (weak, nonatomic) IBOutlet UILabel *list_name;
-@property (weak, nonatomic) IBOutlet UITextField *textField;
+// @property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UIDatePicker *datePicker;
@end
@@ -37,8 +38,7 @@
// Do any additional setup after loading the view.
_list_name.text = @"New List";
-
- num_sections = 1;
+ network_connection = [Network shared_network_connection];
}
- (void) didReceiveMemoryWarning {
@@ -48,39 +48,40 @@
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
- if (_deadline_switch.isOn) {
+ if (_deadline_switch.isOn)
return 2;
- } else {
+ else
return 1;
- }
- // default with deadline turned off
- return num_sections;
+ return 0;
}
-#pragma mark - Navigation
-
// preparation before navigation
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"edit name segue"]) {
- NSLog(@"info: new list: edit name segue");
+ // segue forwards to name editor
+ NSLog(@"debug: %@: editing name", _list_name.text);
// EditTableViewController *edit = [segue destinationViewController];
// edit.list_name.text = @"New List";
return;
}
+ // jump backwards to previous view controller
if (sender != self.saveButton)
return;
- // if (self.textField.text.length > 0) {
- self.shared_list = [[SharedList alloc] init];
- self.shared_list.name = self.list_name.text;
- // self.shared_list.list_date = self.datePicker.date;
- // self.shared_list.members = @"You";
+ SharedList *shared_list = [[SharedList alloc] init];
+
+ // saving, copy form fields into shared list object
+ shared_list.name = _list_name.text;
+ shared_list.deadline = _deadline_switch.isOn;
+ // _shared_list.filters = ???
+
+ NSLog(@"debug: %@: saving", shared_list.name);
- NSLog(@"NewListViewController::prepareForSegue(): %@", self.textField.text);
- // }
+ NSData *payload = [shared_list.name dataUsingEncoding:NSUTF8StringEncoding];
+ [network_connection send_message:1 contents:payload];
}
@end
\ No newline at end of file