Today's Menu  Portugal
journal and plan nutrition
V3GalleryEditTableViewController.m
Go to the documentation of this file.
1 //
2 // V3GalleryEditTableViewController.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 12/7/16.
6 // Copyright © 2016 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
10 #import "Z5DataController.h"
14 
16 
17 @end
18 
122 @implementation V3GalleryEditTableViewController
123 {
124  // these items will be listed, and editted. At end of
125  // screen, will all be re-indexed to new order.
126  NSMutableArray<MenuItem *> *menuItems;
127  NSMutableArray<Meal *> *snapMeals;
128 
129  UIColor *keylimePie;
131  Boolean editModeBool;
132 // int tableRowImageHeight;
133 // float tableHeaderHeight;
134  NSDateFormatter *mDateFormatter;
135 }
140 
141 - (void)viewDidLoad {
142  [super viewDidLoad];
143 
144  self.title = @"Kitchen";
145 
146  _focusGallery = [NSNumber numberWithInteger:1];
147 
148  [mDateFormatter setDateStyle:NSDateFormatterNoStyle];
149  [mDateFormatter setTimeStyle:NSDateFormatterMediumStyle];
150 
151 
152  // fetch, scale, and add a subview background image
153  UIImage *backgrdImage = [UIImage imageNamed:@"szmaniasKitchen.png"];
154  CGSize photoSize = [backgrdImage size];
155  CGRect totalFrame = self.view.frame;
156  galleryEditOverallSize = totalFrame.size;
157  float resizeRatio = photoSize.height / totalFrame.size.height;
158  UIImage *resizedImage = [UIImage imageWithCGImage:[backgrdImage CGImage]
159  scale:backgrdImage.scale * resizeRatio
160  orientation:(backgrdImage.imageOrientation) ];
161  UIImageView *backgrd = [[UIImageView alloc] initWithImage:resizedImage];
162  [self.view addSubview:backgrd];
163  // end - fetch, scale, and add a subview background image
164 
165  CGRect topNavigationFrame = [[[self navigationController]
166  navigationBar] frame];
167  kitchenTableViewTop = topNavigationFrame.origin.y + topNavigationFrame.size.height + 4.0 + 60.0;
169  CGRect tableViewFrame = CGRectMake(4.0, kitchenTableViewTop, galleryEditOverallSize.width - 8.0, kitchenTableViewHeight);
170 
171  galleryEditTableView = [[V3KitchenTableView alloc] initWithFrame: tableViewFrame andDelegate:self];
172 
173  keylimePie = [UIColor keylimePieColor];
174  [galleryEditTableView setBackgroundColor:keylimePie];
175  [self.view addSubview:galleryEditTableView];
176 
177  cellBackgroundColor = [UIColor colorWithRed:0.8f green:1.0f blue:1.0f alpha:1.0f];
178 
179  editModeBool = NO;
180 
181  self.navigationItem.rightBarButtonItem = self.editButtonItem;
182 
183  // Uncomment the following line to preserve selection between presentations.
184  // self.clearsSelectionOnViewWillAppear = NO;
185 }
186 
187 - (void) viewWillAppear:(BOOL)animated
188 {
189  [super viewWillAppear:animated];
190 
191  [galleryEditTableView appear:self.view.bounds];
192  [galleryEditTableView reloadData];
193 
194  [self sizeKitchenTable];
195 }
197 {
198  kitchenTableViewHeight = [galleryEditTableView heightRequirement];
199  CGRect tableViewFrame = CGRectMake(4.0, kitchenTableViewTop, galleryEditOverallSize.width - 8.0, kitchenTableViewHeight);
200  [galleryEditTableView setFrame:tableViewFrame];
201 }
202 - (void) viewWillDisappear:(BOOL)animated
203 {
204  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
205 
206  NSRange initRange = NSMakeRange(10, 0);
207  [localData initGalleryPositionsRange:initRange];
208  for (MenuItem *mItem in menuItems) {
209  [mItem setGalleryPositionNo:[NSNumber numberWithInteger:[localData getNextGalleryPositionIdx]]];
210  }
211  [localData saveContext];
212 }
213 
214 #pragma mark - V3KitchenTableProtocol
215 - (void) itemSelected:(MenuItem *)selectedMenuItem
216 {
217  U7UsdaParamEntryViewController *recipeView =
218  [[U7UsdaParamEntryViewController alloc] initWithMenuItem:selectedMenuItem];
219  [self.navigationController pushViewController:recipeView animated:YES];
220 }
222 {
223  NSLog(@"V3GalleryEditTableViewController.clickPlusButton");
225  [[self navigationController] pushViewController:vc3 animated:YES];
226 }
227 
229  return [_focusGallery integerValue];
230 }
231 
232 
234  [super didReceiveMemoryWarning];
235  // Dispose of any resources that can be recreated.
236 }
237 
239 {
241  [self setEditing:editModeBool];
242  if (!editModeBool) {
243  // editting complete, update database
244 
245  }
246 }
247 
248 #pragma mark - Stubs
249 
250 
251 
252 - (NSInteger)numberOfComponentsInPickerView:(nonnull UIPickerView *)pickerView {
253  NSLog(@"V3GalleryEditTableViewController.numberOfComponentsInPickerView: should not be data source");
254  return 1;
255 }
256 
257 - (NSInteger)pickerView:(nonnull UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
258  NSLog(@"V3GalleryEditTableViewController.numberOfRowsInComponent: should not be data source");
259  return 3;
260 
261 }
262 
263 @end
instancetype sharedInstance()
void initGalleryPositionsRange:(NSRange fetchAllRange)
Singleton interface to both core and remote data sources.
void appear:(CGRect bound)