Today's Menu  Portugal
journal and plan nutrition
U3MenuChoicesTableView.m
Go to the documentation of this file.
1 //
2 // U3MenuChoicesTableView.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 4/12/17.
6 // Copyright © 2017 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
11 #import "Z5DataController.h"
12 #import "U3MenuTableDelegate.h"
13 #import "Z3DateTimeFocusView.h"
14 #import "Z6ContainedView.h"
16 
17 #import "Meal+CoreDataClass.h"
53 @implementation U3MenuChoicesTableView
54 {
55  // one of givenMeals or givenMenuItems
56  // will be valid, the other null
57  NSMutableArray<Meal *> *givenMeals;
58  NSMutableArray<MenuItem *> *givenMenuItems;
59  id<U3MenuTableDelegate> givenContainer;
60  NSIndexPath *swipedMenuIndexPath;
61  UIView<Z6ContainedView> *tableMenuHead;
62  UIView<Z6ContainedView> *tableMenuTail;
64 
65  NSMutableArray <id<Z6ContainedView>> *sectionHeaderViews;
66  NSMutableArray <MenuItem *> *todaysMealItems;
67 
69 }
70 
71 float menuHeaderHeight = 44.0f;
72 float menuFooterHeight = 0.0f;
73 float sectionHeaderHeight = 32.0f;
74 float sectionFooterHeight = 0.0; // 32.0f;
75 
76 - (id) initWithFrame:(CGRect)frame
77  andParameters:(NSArray<NSDictionary *> *)components
78  andMenuItems:(NSArray<MenuItem *> *)menuitems
79  inContainer:(id<U3MenuTableDelegate, U3ParameterTableDelegate>)container
80 {
81  NSLog(@"U3MenuChoicesTableView.init-A: components: %lu", (unsigned long)[components count]);
82 
83  // encountered at 'Bravo'
84  // assert(nil);
85 
86  self = [super initWithFrame:frame
87  andComponents:components
88  inContainer:container];
89 
90  [self setBackgroundColor:[[Z5DataController sharedInstance] roseColor]];
91 
92  if (0 < [menuitems count]) {
93  givenMenuItems = [[NSMutableArray alloc] initWithArray:menuitems];
94  } else {
95  givenMenuItems = [[NSMutableArray alloc] init];
96  }
97  givenContainer = container;
98 
99  [self setDelegate:self];
100  self.dataSource = self;
101 
102  [self setScrollEnabled:YES];
103  [self initRemoveGesture];
104 
105  isInitialSectionCollapsed = YES; // changed 2/15/18
106  displayFooterOnly = NO;
107 
108  return self;
109 }
110 
114 - (id) initWithFrame:(CGRect)frame
115  andMenus:(NSArray<Meal *> *)meals
116  inContainer:(id<U3MenuTableDelegate, U3ParameterTableDelegate>)container
117 {
118  NSUInteger mealCount = [meals count];
119  NSLog(@"U3MenuChoicesTableView.init-B: meal count: %lu", (unsigned long)mealCount);
120 
121  self = [super initWithFrame:frame
122  andComponents:nil
123  inContainer:container];
124 
125  [self setBackgroundColor:[[Z5DataController sharedInstance] deepRoseColor]];
126 
127  // TODO: RESTART HERE - end of Sunday 10/15 work.
128  // in the alternate intializer to menu-post-view, I put menu-items
129  // on the givenMenuItems array, I should have made dictionary entries
130  // and put those on the array, with the name of the menu item
131  // tagged 'component-name.
132  givenMeals = [[NSMutableArray alloc] initWithArray:meals];
133 
134  [self logMenus];
135 
136  float tableWidth = self.frame.size.width;
137  NSLog(@"U3MenuChoicesTableView.initWithFrame:Menus:Container: tableWidth: %3.2f", tableWidth);
138  CGRect sectionHeaderFrame = CGRectMake(0, 0, tableWidth, sectionHeaderHeight);
139  sectionHeaderViews = [[NSMutableArray alloc] init];
140 
141  for (int j = 0; j < mealCount; j++) {
142  Z3DateTimeFocusView *mealSectionHeaderView = [[Z3DateTimeFocusView alloc] initWithFrame:sectionHeaderFrame andDelegate:self];
143  [mealSectionHeaderView setLabelCaption:@"geronimo"];
144  [sectionHeaderViews addObject:mealSectionHeaderView];
145  }
146 
147  givenContainer = container;
148 
149  [self setDelegate:self];
150  self.dataSource = self;
151 
152  // [self setGivenParameters:[[NSMutableArray alloc] initWithArray:components]];
153  // [self setGivenContainer:container];
154 
155  [self setScrollEnabled:YES];
156  [self initRemoveGesture];
157 
159 
160  return self;
161 }
162 
163 - (id) initWithFrame:(CGRect)frame
164  andComponents:(NSArray<NSDictionary *> *)components
165  inContainer:(id<U3MenuTableDelegate, U3ParameterTableDelegate>)container
166 {
167  self = [super initWithFrame:frame andComponents:components inContainer:container];
168 
169  NSLog(@"U3MenuChoicesTableView.init-C: encountered on todays-menu select");
170  // assert(nil);
171 
172  [self setBackgroundColor:[UIColor colorWithRed:177.0/256 green:206.0/256 blue:131.0/256 alpha:0.4]];
173 
174  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
175  givenMenuItems = [[NSMutableArray alloc] initWithArray:[localData todaysMenuItems]];
176 
177  float tableWidth = self.frame.size.width;
178  CGRect sectionHeaderFrame = CGRectMake(0, 0, tableWidth, sectionHeaderHeight);
179  sectionHeaderViews = [[NSMutableArray alloc] init];
180  Z3DateTimeFocusView *mealSectionHeaderView = [[Z3DateTimeFocusView alloc] initWithFrame:sectionHeaderFrame andDelegate:self];
181  [sectionHeaderViews addObject:mealSectionHeaderView];
182 
183  givenContainer = container;
184 
185  [self setDelegate:self];
186  self.dataSource = self;
187 
188  [self setScrollEnabled:YES];
189  [self initRemoveGesture];
190 
192 
193  return self;
194 }
195 - (void) appearingNow
196 {
197  // LOGGING ONLY --- logging only
198  // NSLog(@"U3MenuChoicesTableView.appearingNow: tableMenuHead:%@ tableMenuTail:%@ tableHead:%@, tableTail:%@", tableMenuHead, tableMenuTail, [self tableHeaderView], [self tableFooterView]);
200  NSLog(@"U3MenuChoicesTableView.appearingNow: initial section collapsed");
201  } else {
202  NSLog(@"U3MenuChoicesTableView.appearingNow: initial section up");
204  }
205 
206 }
207 - (void) logMenus
208 {
209  // LOGGING ONLY --- logging only
210  for (Meal *m in givenMeals) {
211  NSSet *items = [m containedItem];
212  if (nil != items) {
213  NSSortDescriptor *modelDescriptor = [NSSortDescriptor
214  sortDescriptorWithKey:@"name"
215  ascending:YES
216  selector:@selector(caseInsensitiveCompare:)];
217  NSArray<NSSortDescriptor *> *descriptors = @[modelDescriptor];
218  NSArray *itemsAray = [items sortedArrayUsingDescriptors:descriptors];
219  NSLog(@"U3MenuChoicesTableView.logMenu: meal consumed: %@", [m consumeDate]);
220  for (MenuItem *mi in itemsAray) {
221  NSLog(@"U3MenuChoicesTableView.logMenu: menuItem: %@", [mi name]);
222  }
223  } else {
224  NSLog(@"U3MenuChoicesTableView.logMenu: snap meal, caption: %@", m.caption);
225  }
226  }
227  // end -- logging only
228 }
229 
230 - (NSMutableArray<MenuItem *> *) givenMenuItems
231 {
232  return givenMenuItems;
233 }
234 
235 - (void) showFooterOnly:(Boolean) flag
236 {
237  displayFooterOnly = flag;
238 }
239 
244 {
245  float ret = [super getViewHeightReqmt];
246  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: super height: %3.2f", ret);
247  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
248  NSArray<MenuItem *> *developingMeal = [localData todaysMenuItems];
249  // returns nil during rating
250  // NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: .. developingMeal: %@", developingMeal);
251  if (givenMeals) {
252  NSUInteger nMeals = [givenMeals count];
253  float sectionHeaderHgt = 0;
254  if ([sectionHeaderViews count] > 0) {
255  Z3DateTimeFocusView *retx = (Z3DateTimeFocusView *)[sectionHeaderViews objectAtIndex:0];
256  sectionHeaderHgt = [retx heightRequirement];
257  }
258 
259  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: number of Meals: %ld sectionHeaderHgt: %3.2f", (unsigned long)nMeals, sectionHeaderHgt);
260  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: menuHeaderHeight: %3.2f menuFooterHeight: %3.2f", menuHeaderHeight, menuFooterHeight);
261 
262  if (0 < nMeals) {
263  ret += menuHeaderHeight;
264  for (Meal *meal in givenMeals) {
265  NSInteger n_menuItem = [[meal containedItem] count];
266  ret += sectionHeaderHgt;
267  ret += n_menuItem * 40.0f;
268  }
269  ret += menuFooterHeight;
270  }
271  } else if (developingMeal) {
272  // view the ordered meal
273  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: view the ordered meal (A)");
274  NSInteger menuCount = [developingMeal count];
275  if (0 < menuCount) {
276  float menuHeight = (menuHeaderHeight
277  + menuCount * 40
278  + menuFooterHeight);
279  ret += menuHeight;
280  }
281  } else if (displayFooterOnly) {
282  // view the footer rating view only
283  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: view the ordered footer rating view only");
284  ret += menuFooterHeight;
285  // [self setViewForMenuHead:nil];
286  // [self setTableHeaderView:nil];
287  } else {
288  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: view the ordered meal (B)");
289  // display-footer-only = NO
290  // given-meals and developing-meal, both = NO
291  // -- encountered at Bravo
292  // assert(nil);
293  // NSInteger menuCount = [developingMeal count];
294  // view the ordered meal
295  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
296  NSInteger todaysMeItCount = [[[localData todaysMeal] containedItem] count];
297  Meal *meItMeal = [localData todaysMeal];
298  NSSet *meItMealContents = [meItMeal containedItem];
299  NSLog(@" .. meItMeal: %@", meItMeal);
300  NSLog(@" .. meItContents: %@", meItMealContents);
301  NSLog(@" .. todaysMeItCount: %ld", (long)todaysMeItCount);
302  if (0 < todaysMeItCount) {
303  float menuHeight = (menuHeaderHeight
304  + todaysMeItCount * 40
305  + menuFooterHeight);
306  ret += menuHeight;
307  }
308  }
309  NSLog(@"U3MenuChoicesTableView.getViewHeightReqmt: final height: %3.2f header: %3.2f footer: %3.2f", ret, menuHeaderHeight, menuFooterHeight);
310  return ret;
311 }
312 
314 {
315  // assert(nil);
316  [self update:nil];
317  [self setViewForHead:nil];
318  [self setViewForTail:nil];
319 }
320 
321 - (void) updateMenu:(NSArray<MenuItem *> *)menuItems
322 {
323  for (MenuItem *item in menuItems) {
324  NSLog(@"U3MenuChoicesTableView.updateMenu: menu-item: %@", [item name]);
325  }
326  [givenMenuItems removeAllObjects];
327  [givenMenuItems addObjectsFromArray:menuItems];
328  NSLog(@"U3MenuChoicesTableView.updateMenu: nutrition controller input, givenMenuItems: %@", givenMenuItems);
329 
330  [givenContainer resizeMenuItemFrame];
331 
332  [self reloadData];
333  NSLog(@"U3MenuChoicesTableView.updateMenu: end, givenMenuItems: %@", givenMenuItems);
334 }
335 
336 - (void) setViewForMenuHead: (UIView <Z6ContainedView> *)headView
337 {
338  tableMenuHead = headView;
339  menuHeaderHeight = [headView heightRequirement];
340  NSLog(@"U3MenuChoicesTableView.setViewForHead: menuHeaderHeight: %3.2f",menuHeaderHeight);
341 }
342 
343 - (void) setViewForMenuTail: (UIView <Z6ContainedView> *) tailView
344 {
345  tableMenuTail = tailView;
346  menuFooterHeight = [tailView heightRequirement];
347  NSLog(@"U3MenuChoicesTableView.setViewForMenuTail: menuFooterHeight: %3.2f", menuFooterHeight);
348 }
349 
351 {
352  UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeMenu:)];
353  gesture.direction = UISwipeGestureRecognizerDirectionRight;
354  [self addGestureRecognizer:gesture];
355 }
356 
357 -(void)didSwipeMenu:(UIGestureRecognizer *)gestureRecognizer {
358 
359  if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
360  CGPoint swipeLocation = [gestureRecognizer locationInView:self];
361  swipedMenuIndexPath = [self indexPathForRowAtPoint:swipeLocation];
362  UITableViewCell* swipedCell = [self cellForRowAtIndexPath:swipedMenuIndexPath];
363  NSLog(@"U3MenuChoicesTableView.didSwipeMenu: cell row: %ld", (long)[swipedMenuIndexPath row]);
364  [swipedCell setBackgroundColor:[UIColor orangeColor]];
365 
366  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
367  NSInteger nRow = [swipedMenuIndexPath row];
368  if ((0<=nRow) && ([[localData todaysMenuItems] count] > nRow)) {
369  [[localData todaysMenuItems] removeObjectAtIndex:nRow];
370  }
371 
372  [self updateMenu:[localData todaysMenuItems]];
373  [self reloadData];
374  }
375 }
376 
380 //- (void) didTapClearFooter
381 //{
382 // Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
383 // [localData clearTodaysMenuItems];
384 // NSArray *todays = [localData todaysMenuItems];
385 // [self updateMenu:todays];
386 // [self reloadData];
387 //
388 // [self setNeedsDisplay];
389 //}
390 #pragma mark - UIDateTimeFocusDelegate
391 
392 -(void) clickAction
393 {
394  NSLog(@"U3MenuChoicesTableView.clickAction");
395 }
396 
397 #pragma mark - UITableViewDelegate
398 - (void)tableView:(UITableView *)tableView
399 didSelectRowAtIndexPath:(NSIndexPath *)indexPath
400 {
401  NSLog(@"U3menuChoicesTableView.didSelectRowAtIndexPath: %ld", (long)indexPath.row);
402 
403  if (0 == [indexPath section]) {
404  [super tableView:tableView didSelectRowAtIndexPath:indexPath];
405  } else {
406  NSLog(@"U3MenuChoicesTableView.didSelectRowAtIndexPath: %ld", (long)indexPath.row);
407  }
408 }
409 #pragma mark - UITableViewDataSource
410 
411 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
412 {
413  NSInteger ret;
414  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
415  if (givenMeals) {
416  // this view is used to show developing menu, and menus for
417  // a particular (historical) day. 'givenMeals' is set
418  // for display of a day's several meals.
419  ret = 1 + [givenMeals count]; // collapsed parameters section, and meals
420  // TODO TOTEST - when displaying multiple meals in sections 2, 3, ...
421  // do not show parameters is section 1.
422  // isInitialSectionCollapsed = YES;
423  } else {
424  // determine if a return from check-consumed
425  ret = 2;
426  isInitialSectionCollapsed = NO; // (un-)changed 2/15/18
427  if ((0 < [givenMeals count]) || (0 < [givenMenuItems count])) {
428  NSLog(@"U3MenuChoicesTableView.numberOfSectionsInTableView: meals or items available");
429  }
430  }
431 
432  Meal* todaysMeal = [localData todaysMeal];
433  [todaysMealItems removeAllObjects];
434  if (todaysMeal) {
435  for (MenuItem *mItem in [todaysMeal containedItem]) {
436  [todaysMealItems addObject:mItem];
437  }
438  NSLog(@"U3MenuChoicesTableView.numberOfSectionsInTableView: mItem count: %ld", (unsigned long)[todaysMealItems count]);
439  } else if (0 < [givenMenuItems count]) {
440  for (MenuItem *menuItem in givenMenuItems) {
441  [todaysMealItems addObject:menuItem];
442  }
443  } else {
444  NSLog(@"U3MenuChoicesTableView.numberOfSectionsInTableView: nil todaysMeal");
446  // ret = 1;
447  }
448 
449  NSLog(@"U3MenuChoicesTableView.numberOfSectionsInTableView: %ld", (long)ret);
450  // NSLog(@"U3MenuChoicesTableView.numberOfSectionsInTableView: givenMenuItems: %@", givenMenuItems);
451 
452  return ret;
453 }
454 
455 - (NSInteger)tableView:(UITableView *)tableView
456  numberOfRowsInSection:(NSInteger)section
457 {
458  NSInteger ret = 0;
459 
460  if (0 == section) {
462  ret = 0;
463  } else {
464  ret = [super tableView:tableView numberOfRowsInSection:section];
465  }
466  } else {
467  NSInteger mealNumber = section - 1;
468  if (givenMeals && (mealNumber < [givenMeals count])) {
469  // NSLog(@"U3MenuChoicesTableView.numberOfRowsInSection: meal count: %ld", [givenMeals count]);
470  Meal *meal = [givenMeals objectAtIndex:mealNumber];
471  switch([self categorizeMealOrigin:meal]) {
472  case ORIGIN_UNKNOWN: {
473  NSLog(@"U3MenuChoicesTableView.numberOfRowsInSection: meal ORIGIN_UNKNOWN");
474  break;
475  }
477  {
478  NSLog(@"U3MenuChoicesTableView.numberOfRowsInSection: meal COLLECTION_MENUITEMS");
479  NSSet *items = [meal containedItem];
480  ret = [items count];
481  break;
482  }
483  case IMPORT_SPEC: {
484  NSLog(@"U3MenuChoicesTableView.numberOfRowsInSection: meal IMPORT_SPEC");
485  break;
486  }
487  case PHOTO_MEAL: {
488  // meal record is a name and a photo
489  NSLog(@"U3MenuChoicesTableView.numberOfRowsInSection: meal PHOTO_MEAL");
490  ret = 1;
491  break;
492  }
493  }
494  } else {
495  // todays meal is no longer an array of menu-items, but a true meal
496  ret = [givenMenuItems count];
497 
498  // TODO: possible trouble, this block should be displaying
499  // meal items from previous meals.
500 
501  // this gets called at "Today's Menu" pick off the main screen
502  // assert(nil);
503  }
504  }
505  // NSLog(@"U3MenuChoicesTableView.numberOfRowsInSection: section# %ld, rows: %ld", (long) section, (long)ret);
506  return ret;
507 }
508 
509 - (MealOriginatePathEnum) categorizeMealOrigin: (Meal *)meal
510 {
512 
513  NSSet *items = [meal containedItem];
514  BOOL snapFlag = ((nil != meal.caption) && (nil != meal.photo));
515  NSLog(@"U3MenuChoicesTableView.categorizeMealOrigin: caption: %@", meal.caption);
516  if (0 < [items count]) {
517  ret = COLLECTION_MENUITEMS;
518  } else if (snapFlag) {
519  ret = PHOTO_MEAL;
520  } else if (nil != meal.randomkey){
521  ret = IMPORT_SPEC;
522  }
523 
524  return ret;
525 }
526 - (UITableViewCell *)tableView:(UITableView *)tableView
527  cellForRowAtIndexPath:(NSIndexPath *)indexPath
528 {
529  UITableViewCell *cell = nil;
530  if (0 == [indexPath section]) {
531  cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
532  } else {
533  cell = [tableView dequeueReusableCellWithIdentifier:@"item-todays-menu"];
534  if (cell == nil) {
535  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
536  reuseIdentifier:@"item-todays-menu"];
537  cell.contentView.autoresizingMask
538  = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
539  }
540  [cell setBackgroundColor:[Z5LocalDataController menuContentsBackground]];
541 
542  if (givenMeals) {
543  NSLog(@"U3MenuChoicesTableView.(givenMeals)cellForRowAtIndexPath: %@", indexPath);
544  NSInteger mealNumber = [indexPath section] - 1;
545  Meal *sectionMeal = [givenMeals objectAtIndex:mealNumber];
546  switch([self categorizeMealOrigin:sectionMeal]) {
547  case ORIGIN_UNKNOWN: {
548  NSLog(@"U3MenuChoicesTableView.(givenMeals)cellForRowAtIndexPath: meal ORIGIN_UNKNOWN");
549  break;
550  }
552  {
553  NSSet *items = [sectionMeal containedItem];
554  NSSortDescriptor *modelDescriptor = [NSSortDescriptor
555  sortDescriptorWithKey:@"name"
556  ascending:YES
557  selector:@selector(caseInsensitiveCompare:)];
558  NSArray<NSSortDescriptor *> *descriptors = @[modelDescriptor];
559  NSArray *itemsAray = [items sortedArrayUsingDescriptors:descriptors];
560 
561  if ([indexPath row] < [itemsAray count]) {
562  MenuItem *rowMenuItem = [itemsAray objectAtIndex:[indexPath row]];
563  [Z5DataController labelizeCell:cell withText:rowMenuItem.name inColor:[UIColor brownColor] andDetail:nil];
564  } else {
565  [Z5DataController labelizeCell:cell withText:@"missing data" inColor:[UIColor brownColor] andDetail:nil];
566  }
567  break;
568  }
569  case IMPORT_SPEC: {
570  NSLog(@"U3MenuChoicesTableView.(givenMeals)cellForRowAtIndexPath: meal IMPORT_SPEC");
571  break;
572  }
573  case PHOTO_MEAL: {
574  // meal record is a name and a photo
575  NSLog(@"U3MenuChoicesTableView.(givenMeals)cellForRowAtIndexPath: meal PHOTO_MEAL");
576  // [Z5DataController labelizeCell:cell withText:sectionMeal.caption inColor:[UIColor wheatColor] andDetail:nil];
577 // [Z5DataController labelizeCell:cell withText:sectionMeal.caption image:[sectionMeal photo] inColor:[UIColor wheatColor] andDetail:@"no detail yet"];
578 
579  break;
580  }
581  }
582 
583  } else if (givenMenuItems) {
584  if ([indexPath row] < [givenMenuItems count]) {
585  MenuItem *rowMenuItem = [givenMenuItems objectAtIndex:[indexPath row]];
586  [Z5DataController labelizeCell:cell withText:rowMenuItem.name inColor:[UIColor brownColor] andDetail:nil];
587  }
588  } else {
589  NSLog(@"U3MenuChoicesTableView.(NOT givenMeals)cellForRowAtIndexPath: %@", indexPath);
590  [Z5DataController labelizeCell:cell withText:@"no data" inColor:[UIColor orangeColor] andDetail:nil];
591  }
592 
593  return cell;
594  }
595  return cell;
596 }
597 
598 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
599 {
600  float ret = 0.0;
601  if (0 == section) {
602  ret = [super tableView:tableView heightForHeaderInSection:section];
603  } else {
604  if (givenMeals) {
605  NSInteger menuN = section - 1;
606  Z3DateTimeFocusView *retx = (Z3DateTimeFocusView *)[sectionHeaderViews objectAtIndex:menuN];
607  ret = [retx heightRequirement];
608  } else if (givenMenuItems) {
609  ret = [tableMenuHead heightRequirement];
610  }
611  }
612  return ret;
613 }
614 
615 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
616 {
617  UIView *ret = nil;
618  NSLog(@"U3MenuChoicesTableView.viewForHeaderInSection: %ld", (long)section);
619  if (0 == section) {
620  ret = [super tableView:tableView viewForHeaderInSection:section];
621  } else {
622  if (givenMeals) {
623  NSInteger menuN = section - 1;
624  Meal *sectionMeal = [givenMeals objectAtIndex:menuN];
625  NSDateFormatter *mDateFormatter = [[NSDateFormatter alloc] init];
626  [mDateFormatter setDateStyle:NSDateFormatterNoStyle];
627  [mDateFormatter setTimeStyle:NSDateFormatterMediumStyle];
628  NSString *daytime = [mDateFormatter stringFromDate:[sectionMeal consumeDate]];
629  Z3DateTimeFocusView *retx = (Z3DateTimeFocusView *)[sectionHeaderViews objectAtIndex:menuN];
630  [retx setLabelCaption:daytime];
631  CGRect dummp = CGRectMake(2.0, 2.0, 300.0, 26.0);
632  [retx appear:dummp];
633  ret = retx;
634 
635  NSLog(@"U3MenuChoicesTableView.view~ %@ ~ForHeaderInSection: %ld, one of given-meals", ret, (long)section);
636 
637  } else if (givenMenuItems) {
638 
639  if (0 < [givenMenuItems count]) {
640  ret = tableMenuHead;
641  // NSLog(@"U3MenuChoicesTableView.view~ %@ ~ForHeaderInSection: %ld, from local-data-todays", ret, section);
642 
643 
644  } else {
645  // NSLog(@"U3MenuChoicesTableView.viewForHeaderInSection: nothing");
646 
647  }
648  }
649  }
650  return ret;
651 }
652 
653 - (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
654 {
655  float ret = 0.0f;
656  if (0 == section) {
657  ret = [super tableView:tableView heightForFooterInSection:section];
658  } else {
659  ret = [tableMenuTail heightRequirement];
660  }
661  return ret;
662 }
663 
664 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
665 {
666  UIView *ret = nil;
667  if (0 == section) {
668  ret = [super tableView:tableView viewForFooterInSection:section];
669  } else {
670  ret = tableMenuTail;
671  }
672  return ret;
673 }
674 
675 - (void) setInitialSectionCollapsed:(Boolean)flag
676 {
678  [self setNeedsDisplay];
679 }
680 
682 {
684 }
685 /*
686 // Only override drawRect: if you perform custom drawing.
687 // An empty implementation adversely affects performance during animation.
688 - (void)drawRect:(CGRect)rect {
689  // Drawing code
690 }
691 */
692 
694  // TODO: <#code#>
695 }
696 
698  // TODO: <#code#>
699 }
700 
702  // TODO: <#code#>
703 }
704 
706  // TODO: <#code#>
707 }
708 
709 
710 @end
UIView< Z6ContainedView > * tableMenuTail
CGFloat tableView:heightForFooterInSection:(UITableView *tableView, [heightForFooterInSection] NSInteger section)
Boolean isInitialSectionCollapsed
float sectionHeaderHeight
NSMutableArray< id< Z6ContainedView > > * sectionHeaderViews
id initWithFrame:andComponents:inContainer:(CGRect frame, [andComponents] NSArray *components, [inContainer] id< U3ParameterTableDelegate > container)
void setViewForHead:(UIView *headView)
MenuItem * menuItem
UIView< Z6ContainedView > * tableMenuHead
instancetype sharedInstance()
Boolean displayFooterOnly
float menuHeaderHeight
UIView * tableView:viewForHeaderInSection:(UITableView *tableView, [viewForHeaderInSection] NSInteger section)
NSString * randomkey
id< U3ParameterTableDelegate > givenContainer
NSMutableArray< MenuItem * > * todaysMealItems
void update:(NSArray< NSDictionary * > *components)
id< U3MenuTableDelegate > givenContainer
NSIndexPath * swipedMenuIndexPath
float menuFooterHeight
UITableViewCell * tableView:cellForRowAtIndexPath:(UITableView *tableView, [cellForRowAtIndexPath] NSIndexPath *indexPath)
CGFloat tableView:heightForHeaderInSection:(UITableView *tableView, [heightForHeaderInSection] NSInteger section)
NSDate * consumeDate
void appear:(CGRect bound)
Singleton interface to both core and remote data sources.
UIView * tableView:viewForFooterInSection:(UITableView *tableView, [viewForFooterInSection] NSInteger section)
NSMutableArray< MenuItem * > * givenMenuItems()
float sectionFooterHeight
NSString * caption
void setViewForTail:(UIView< Z6ContainedView > *tailView)
NSData * photo
void updateMenu:(NSArray< MenuItem * > *menuItems)
NSMutableArray< MenuItem * > * givenMenuItems
NSDateFormatter * mDateFormatter
NSInteger tableView:numberOfRowsInSection:(UITableView *tableView, [numberOfRowsInSection] NSInteger section)
NSSet< MenuItem * > * containedItem
NSMutableArray< MenuItem * > * todaysMenuItems
void labelizeCell:withText:inColor:andDetail:(UITableViewCell *targCell, [withText] NSString *txt, [inColor] UIColor *color, [andDetail] NSString *detailTxt)
void tableView:didSelectRowAtIndexPath:(UITableView *tableView, [didSelectRowAtIndexPath] NSIndexPath *indexPath)