-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProductViewController.m
executable file
·270 lines (270 loc) · 8.83 KB
/
ProductViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
////
//// ProductViewController.m
//// NavCtrl
////
//// Created by Aditya Narayan on 10/22/13.
//// Copyright (c) 2013 Aditya Narayan. All rights reserved.
////
//
//#import "detailViewController.h"
//#import "ProductViewController.h"
//#import "EditproductViewController.h"
//
//@interface ProductViewController ()
//
//@end
//
//@implementation ProductViewController
//
//- (id)initWithStyle:(UITableViewStyle)style
//{
// self = [super initWithStyle:style];
// if (self) {
// // Custom initialization
// }
// return self;
//}
//
//- (void)viewDidLoad
//{
// [super viewDidLoad];
//
// UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc]
// initWithTarget:self action:@selector(handleLongPress:)];
// lpgr.minimumPressDuration = 2.0; //seconds
// [self.tableView addGestureRecognizer:lpgr];
// [lpgr release];
//
// UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// [button addTarget:self
// action:@selector(pushToProductViewEditor)
// forControlEvents:UIControlEventTouchUpInside];
// [button setTitle:@"AddProduct" forState:UIControlStateNormal];
// button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
// button.backgroundColor = [UIColor blueColor];
// [self.view addSubview:button];
//
// UIBarButtonItem *saveChanges = [[UIBarButtonItem alloc]
// initWithTitle:@"Save Changes"
// style:UIBarButtonItemStyleBordered
// target:self
// action:@selector(saveChanges)];
// UIBarButtonItem *undo = [[UIBarButtonItem alloc]
// initWithTitle:@"Undo"
// style:UIBarButtonItemStyleBordered
// target:self
// action:@selector(undoLastAction)];
// UIBarButtonItem *redo = [[UIBarButtonItem alloc]
// initWithTitle:@"redo"
// style:UIBarButtonItemStyleBordered
// target:self
// action:@selector(redoLastUndo)];
//
// UIBarButtonItem *undoAllChanges = [[UIBarButtonItem alloc]
// initWithTitle:@"Undo All Changes"
// style:UIBarButtonItemStyleBordered
// target:self
// action:@selector(rollbackAllChanges)];
//
//
//
//
//
//
// //Centers the bottom tool bar.
// UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
// [self setToolbarItems:[NSArray arrayWithObjects:undo,flexibleSpace, saveChanges, flexibleSpace , redo,flexibleSpace, undoAllChanges, nil]];
// [flexibleSpace release];
//
// [self.navigationController setToolbarHidden:NO];
//
//
//
// // 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)rollbackAllChanges{
// [[DAO sharedDao]rollbackAllChangesProducts:self.currentCompany];
// [self.tableView reloadData];
//}
//
//-(void)redoLastUndo{
// [[DAO sharedDao]redoLastUndoforProductWithCurrentCompany:self.currentCompany];
// [self.tableView reloadData];
//}
//-(void)undoLastAction{
// [[DAO sharedDao]undoLastActionProductWithcurrentCompny:self.currentCompany];
// [self.tableView reloadData];
//}
//
//-(void)saveChanges{
// [[DAO sharedDao]saveChanges];
//}
//
//
//-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
//{ //push to the companyeditview controller
//
// CGPoint p = [gestureRecognizer locationInView:self.tableView];
//
// NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p];
// if (indexPath == nil) {
// NSLog(@"long press on table view but not on a row");
// }
// else if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
// NSLog(@"long press on table view at row %ld", (long)indexPath.row);
//
//
// EditproductViewController *productEdit = [[[EditproductViewController alloc]init]autorelease];
// Products *prod = self.currentCompany.products[indexPath.row];
// productEdit.productPassedIn = prod;
//
//
//
// productEdit.productNameString = prod.name;
// productEdit.logoString = prod.logo;
// productEdit.webLinkString = prod.url;
//
//
// [self.navigationController pushViewController:productEdit animated:YES];
//
//// [productEdit release];
// }
//
//}
//
//
//-(void)pushToProductViewEditor{
//
// EditproductViewController *productEdit = [[EditproductViewController alloc]init];
// productEdit.productsArray = self.currentCompany.products;
// productEdit.currentCompanyIdentificaion = self.currentCompany.id;
//
// [self.navigationController pushViewController:productEdit animated:YES];
//
//
// [productEdit release];
//
//}
//
//- (void)viewWillAppear:(BOOL)animated {
//
// [super viewWillAppear:animated];
//
//
// [self.tableView reloadData];
//}
//
//- (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.
// return 1;
//}
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
// // Return the number of rows in the section.
// return [self.currentCompany.products count];
//}
////Added to not have empty rows.
//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
//{
// UIView *view = [[[UIView alloc] init] autorelease];
//
// return view;
//}
//
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
// static NSString *CellIdentifier = @"Cell";
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// if (cell == nil) {
// cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
// }
// // Configure the cell...
// cell.textLabel.text = [[self.currentCompany.products objectAtIndex:[indexPath row] ]name];
//
// cell.imageView.image = [UIImage imageNamed:[[self.currentCompany.products objectAtIndex:[indexPath row]]logo]];
//
// return cell;
// [cell release];
//}
//
///*
//// 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
//{
//
// NSString *prodName = [self.currentCompany.products[indexPath.row]name];
//
// [[DAO sharedDao] deleteProductData:prodName];
//
// [self.currentCompany.products removeObjectAtIndex:indexPath.row];
//
// [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
//
// [self.tableView reloadData];
//
//}
//
//
///*
//// 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 - Table view delegate
//
//// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//// Create the next view controller.
//
// detailViewController *webviewController = [[detailViewController alloc] init];
//
//
// webviewController.currentProduct = self.currentCompany.products[indexPath.row];
//
// // Push the view controller.
// [self.navigationController pushViewController:webviewController animated:YES];
// [webviewController release];
//}
//@end