Today's Menu  Portugal
journal and plan nutrition
Instance Methods | Protected Types | Properties | List of all members
U3MenuChoicesTableView Class Reference

#import <U3MenuChoicesTableView.h>

Inheritance diagram for U3MenuChoicesTableView:
Inheritance graph
[legend]
Collaboration diagram for U3MenuChoicesTableView:
Collaboration graph
[legend]

Instance Methods

(id) - initWithFrame:andParameters:andMenuItems:inContainer:
 
(id) - initWithFrame:andMenus:inContainer:
 
(id) - initWithFrame:andComponents:inContainer:
 
(NSMutableArray< MenuItem * > *) - givenMenuItems
 
(void) - clearParameters
 
(void) - updateMenu:
 
(void) - setViewForMenuHead:
 
(void) - setViewForMenuTail:
 
(void) - setInitialSectionCollapsed:
 
(Boolean) - isInitialSectionCollapsed
 
(void) - showFooterOnly:
 
(void) - appearingNow
 
(void) - logMenus [implementation]
 
(float) - getViewHeightReqmt [implementation]
 
(void) - initRemoveGesture [implementation]
 
(void) - didSwipeMenu: [implementation]
 
(void) - clickAction [implementation]
 
(void) - tableView:didSelectRowAtIndexPath: [implementation]
 
(NSInteger) - numberOfSectionsInTableView: [implementation]
 
(NSInteger) - tableView:numberOfRowsInSection: [implementation]
 
(MealOriginatePathEnum- categorizeMealOrigin: [implementation]
 
(UITableViewCell *) - tableView:cellForRowAtIndexPath: [implementation]
 
(CGFloat) - tableView:heightForHeaderInSection: [implementation]
 
(UIView *) - tableView:viewForHeaderInSection: [implementation]
 
(CGFloat) - tableView:heightForFooterInSection: [implementation]
 
(UIView *) - tableView:viewForFooterInSection: [implementation]
 
(void) - didTapBravoFooter [implementation]
 
(void) - didTapClearFooter [implementation]
 
(void) - didTapConsumedFooter [implementation]
 
(void) - didTapSkippedFooter [implementation]
 
- Instance Methods inherited from U3ParameterTableView
(id) - initWithFrame:andComponents:inContainer:
 
(void) - addParameter:
 
(void) - updateParameter:
 
(NSInteger) - isListedAlready:
 
(void) - update:
 
(void) - scrollInitially
 
(void) - scrollForControlPanel
 
(void) - scrollForInstructionPanel
 
(NSUInteger) - parameterCount
 
(void) - setViewForHead:
 
(void) - setViewForTail:
 
(id) - initWithFrame:andComponents:inContainer: [implementation]
 
(void) - setViewForHead: [implementation]
 

Protected Types

enum  MealOriginatePathEnum { ORIGIN_UNKNOWN, COLLECTION_MENUITEMS, IMPORT_SPEC, PHOTO_MEAL }
 

Properties

NSDateFormatter * mDateFormatter
 
- Properties inherited from U3ParameterTableView
NSMutableArray< NSDictionary * > * givenParameters
 
id< U3ParameterTableDelegate > givenContainer
 

Detailed Description

Introduction

Screen Flow

dot_inline_dotgraph_4.png

Pick date on calendar

Definition at line 15 of file U3MenuChoicesTableView.h.

Member Enumeration Documentation

◆ MealOriginatePathEnum

- (enum) MealOriginatePathEnum
protected

Method Documentation

◆ appearingNow()

- (void) appearingNow

Definition at line 195 of file U3MenuChoicesTableView.m.

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");
203  [self scrollForInstructionPanel];
204  }
205 
206 }

◆ categorizeMealOrigin:()

- (MealOriginatePathEnum) categorizeMealOrigin: (Meal *)  meal
implementation

Definition at line 509 of file U3MenuChoicesTableView.m.

509  : (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 }
NSString * randomkey
NSString * caption
NSData * photo
NSSet< MenuItem * > * containedItem

◆ clearParameters()

- (void) clearParameters

Definition at line 313 of file U3MenuChoicesTableView.m.

314 {
315  // assert(nil);
316  [self update:nil];
317  [self setViewForHead:nil];
318  [self setViewForTail:nil];
319 }

◆ clickAction()

- (void) clickAction
implementation

This relates to entries in section-1 and above, menus. Move to MenuView

Definition at line 392 of file U3MenuChoicesTableView.m.

393 {
394  NSLog(@"U3MenuChoicesTableView.clickAction");
395 }

◆ didSwipeMenu:()

- (void) didSwipeMenu: (UIGestureRecognizer *)  gestureRecognizer
implementation

Definition at line 357 of file U3MenuChoicesTableView.m.

357  :(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 }
instancetype sharedInstance()
NSIndexPath * swipedMenuIndexPath
Singleton interface to both core and remote data sources.
NSMutableArray< MenuItem * > * todaysMenuItems

◆ didTapBravoFooter()

- (void) didTapBravoFooter
implementation

Definition at line 693 of file U3MenuChoicesTableView.m.

693  {
694  // TODO: <#code#>
695 }

◆ didTapClearFooter()

- (void) didTapClearFooter
implementation

Definition at line 697 of file U3MenuChoicesTableView.m.

697  {
698  // TODO: <#code#>
699 }

◆ didTapConsumedFooter()

- (void) didTapConsumedFooter
implementation

Definition at line 701 of file U3MenuChoicesTableView.m.

701  {
702  // TODO: <#code#>
703 }

◆ didTapSkippedFooter()

- (void) didTapSkippedFooter
implementation

Definition at line 705 of file U3MenuChoicesTableView.m.

705  {
706  // TODO: <#code#>
707 }

◆ getViewHeightReqmt()

- (float) getViewHeightReqmt
implementation

Next work - track where extra space on top comes from

Reimplemented from U3ParameterTableView.

Definition at line 243 of file U3MenuChoicesTableView.m.

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 }
NSMutableArray< id< Z6ContainedView > > * sectionHeaderViews
instancetype sharedInstance()
Boolean displayFooterOnly
float menuHeaderHeight
float menuFooterHeight
Singleton interface to both core and remote data sources.
NSSet< MenuItem * > * containedItem
NSMutableArray< MenuItem * > * todaysMenuItems

◆ givenMenuItems()

- (NSMutableArray< MenuItem * > *) givenMenuItems

Definition at line 230 of file U3MenuChoicesTableView.m.

231 {
232  return givenMenuItems;
233 }
NSMutableArray< MenuItem * > * givenMenuItems()

◆ initRemoveGesture()

- (void) initRemoveGesture
implementation

Definition at line 350 of file U3MenuChoicesTableView.m.

351 {
352  UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeMenu:)];
353  gesture.direction = UISwipeGestureRecognizerDirectionRight;
354  [self addGestureRecognizer:gesture];
355 }

◆ initWithFrame:andComponents:inContainer:()

- (id) initWithFrame: (CGRect)  frame
andComponents: (NSArray<NSDictionary *> *)  components
inContainer: (id<U3MenuTableDelegate, U3ParameterTableDelegate>)  container 

Definition at line 163 of file U3MenuChoicesTableView.m.

163  :(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 }
float sectionHeaderHeight
NSMutableArray< id< Z6ContainedView > > * sectionHeaderViews
instancetype sharedInstance()
id< U3ParameterTableDelegate > givenContainer
Singleton interface to both core and remote data sources.
NSMutableArray< MenuItem * > * givenMenuItems()
NSMutableArray< MenuItem * > * todaysMenuItems

◆ initWithFrame:andMenus:inContainer:()

- (id) initWithFrame: (CGRect)  frame
andMenus: (NSArray<Meal *> *)  meals
inContainer: (id<U3MenuTableDelegate, U3ParameterTableDelegate>)  container 

this is the entry point for picks from the calendar screen

Definition at line 114 of file U3MenuChoicesTableView.m.

114  :(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 }
float sectionHeaderHeight
NSMutableArray< id< Z6ContainedView > > * sectionHeaderViews
instancetype sharedInstance()
id< U3ParameterTableDelegate > givenContainer
Singleton interface to both core and remote data sources.

◆ initWithFrame:andParameters:andMenuItems:inContainer:()

- (id) initWithFrame: (CGRect)  frame
andParameters: (NSArray<NSDictionary *> *)  components
andMenuItems: (NSArray<MenuItem *> *)  menuitems
inContainer: (id<U3MenuTableDelegate, U3ParameterTableDelegate>)  container 

Definition at line 76 of file U3MenuChoicesTableView.m.

76  :(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 }
instancetype sharedInstance()
Boolean displayFooterOnly
id< U3ParameterTableDelegate > givenContainer
Singleton interface to both core and remote data sources.
NSMutableArray< MenuItem * > * givenMenuItems()

◆ isInitialSectionCollapsed()

- (Boolean) isInitialSectionCollapsed

Definition at line 681 of file U3MenuChoicesTableView.m.

682 {
684 }

◆ logMenus()

- (void) logMenus
implementation

Definition at line 207 of file U3MenuChoicesTableView.m.

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 }

◆ numberOfSectionsInTableView:()

- (NSInteger) numberOfSectionsInTableView: (UITableView *)  tableView
implementation

Reimplemented from U3ParameterTableView.

Definition at line 411 of file U3MenuChoicesTableView.m.

411  :(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 }
MenuItem * menuItem
instancetype sharedInstance()
NSMutableArray< MenuItem * > * todaysMealItems
Singleton interface to both core and remote data sources.
NSMutableArray< MenuItem * > * givenMenuItems()

◆ setInitialSectionCollapsed:()

- (void) setInitialSectionCollapsed: (Boolean)  flag

Definition at line 675 of file U3MenuChoicesTableView.m.

675  :(Boolean)flag
676 {
678  [self setNeedsDisplay];
679 }

◆ setViewForMenuHead:()

- (void) setViewForMenuHead: (UIView <Z6ContainedView> *)  headView

Definition at line 336 of file U3MenuChoicesTableView.m.

336  : (UIView <Z6ContainedView> *)headView
337 {
338  tableMenuHead = headView;
339  menuHeaderHeight = [headView heightRequirement];
340  NSLog(@"U3MenuChoicesTableView.setViewForHead: menuHeaderHeight: %3.2f",menuHeaderHeight);
341 }
UIView< Z6ContainedView > * tableMenuHead
float menuHeaderHeight

◆ setViewForMenuTail:()

- (void) setViewForMenuTail: (UIView <Z6ContainedView> *)  tailView

Definition at line 343 of file U3MenuChoicesTableView.m.

343  : (UIView <Z6ContainedView> *) tailView
344 {
345  tableMenuTail = tailView;
346  menuFooterHeight = [tailView heightRequirement];
347  NSLog(@"U3MenuChoicesTableView.setViewForMenuTail: menuFooterHeight: %3.2f", menuFooterHeight);
348 }
UIView< Z6ContainedView > * tableMenuTail
float menuFooterHeight

◆ showFooterOnly:()

- (void) showFooterOnly: (Boolean)  flag

Definition at line 235 of file U3MenuChoicesTableView.m.

235  :(Boolean) flag
236 {
237  displayFooterOnly = flag;
238 }
Boolean displayFooterOnly

◆ tableView:cellForRowAtIndexPath:()

- (UITableViewCell *) tableView: (UITableView *)  tableView
cellForRowAtIndexPath: (NSIndexPath *)  indexPath 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 526 of file U3MenuChoicesTableView.m.

526  :(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 }
Singleton interface to both core and remote data sources.
NSMutableArray< MenuItem * > * givenMenuItems()
void labelizeCell:withText:inColor:andDetail:(UITableViewCell *targCell, [withText] NSString *txt, [inColor] UIColor *color, [andDetail] NSString *detailTxt)

◆ tableView:didSelectRowAtIndexPath:()

- (void) tableView: (UITableView *)  tableView
didSelectRowAtIndexPath: (NSIndexPath *)  indexPath 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 398 of file U3MenuChoicesTableView.m.

398  :(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 }

◆ tableView:heightForFooterInSection:()

- (CGFloat) tableView: (UITableView *)  tableView
heightForFooterInSection: (NSInteger)  section 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 653 of file U3MenuChoicesTableView.m.

653  :(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 }

◆ tableView:heightForHeaderInSection:()

- (CGFloat) tableView: (UITableView *)  tableView
heightForHeaderInSection: (NSInteger)  section 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 598 of file U3MenuChoicesTableView.m.

598  :(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 }
NSMutableArray< id< Z6ContainedView > > * sectionHeaderViews
NSMutableArray< MenuItem * > * givenMenuItems()

◆ tableView:numberOfRowsInSection:()

- (NSInteger) tableView: (UITableView *)  tableView
numberOfRowsInSection: (NSInteger)  section 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 455 of file U3MenuChoicesTableView.m.

455  :(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 }

◆ tableView:viewForFooterInSection:()

- (UIView *) tableView: (UITableView *)  tableView
viewForFooterInSection: (NSInteger)  section 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 664 of file U3MenuChoicesTableView.m.

664  :(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 }
UIView< Z6ContainedView > * tableMenuTail

◆ tableView:viewForHeaderInSection:()

- (UIView *) tableView: (UITableView *)  tableView
viewForHeaderInSection: (NSInteger)  section 
implementation

Reimplemented from U3ParameterTableView.

Definition at line 615 of file U3MenuChoicesTableView.m.

615  :(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 }
NSMutableArray< id< Z6ContainedView > > * sectionHeaderViews
UIView< Z6ContainedView > * tableMenuHead
NSDate * consumeDate
void appear:(CGRect bound)
NSMutableArray< MenuItem * > * givenMenuItems()
NSDateFormatter * mDateFormatter

◆ updateMenu:()

- (void) updateMenu: (NSArray<MenuItem *> *)  menuItems

Definition at line 321 of file U3MenuChoicesTableView.m.

321  :(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 }
NSMutableArray< MenuItem * > * givenMenuItems()

Property Documentation

◆ mDateFormatter

- (NSDateFormatter*) mDateFormatter
readwritenonatomicstrong

Definition at line 17 of file U3MenuChoicesTableView.h.


The documentation for this class was generated from the following files: