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

#import <Y4MenuPostViewController.h>

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

Instance Methods

(void) - viewDidLoad [implementation]
 
(void) - viewDidAppear: [implementation]
 
(void) - viewWillAppear: [implementation]
 
(void) - updateTodaysMenuView: [implementation]
 
(void) - updateMenuSeriesView: [implementation]
 
(void) - orientUI [implementation]
 
(void) - clickAction [implementation]
 
(void) - updatedParameterArray: [implementation]
 
(float) - resizeParameterFrame [implementation]
 
(void) - didSelectParameterRow: [implementation]
 
(NSDate *) - dateForHeader [implementation]
 
(Boolean) - hasFooter [implementation]
 
(void) - updatedMenuItemArray: [implementation]
 
(float) - resizeMenuItemFrame [implementation]
 
(void) - didSelectMenuItemRow: [implementation]
 
(void) - didTapBravoFooter [implementation]
 
(void) - didTapNetworkFooter [implementation]
 
(void) - didTapConsumedFooter [implementation]
 
(NSArray< NSDictionary *> *) - parametersOfMeals: [implementation]
 
(NSMutableArray< NSDictionary *> *) - addParameters:toRunningTotal: [implementation]
 
(void) - didTapRatingControl: [implementation]
 
(void) - didTapCheckFooter [implementation]
 
(void) - popOut [implementation]
 
(void) - didTapSkippedFooter [implementation]
 
(void) - healthQuantityTypeData:success: [implementation]
 
(void) - updateToAuthorizationOK [implementation]
 
(void) - didSwipeMenu: [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 

Properties

< U3ParameterTableDelegate, U3MenuTableDelegate, Z5HealthConnectionProtocol, Z3MenuConsumedDelegate, Z3DateTimeFocusDelegate, Z6MenuJournalDelegate > NSArray< Meal * > * postedMeals
 
NSDate * postingDate
 

Detailed Description

Menu Post View Controller

dot_structureY4MenuPostView.png
dot_structureY4MenuPostView.png

msc_initializationB2CalendarSeq
Menu Post Association

Definition at line 18 of file Y4MenuPostViewController.h.

Method Documentation

◆ addParameters:toRunningTotal:()

- (NSMutableArray< NSDictionary * > *) addParameters: (NSDictionary *)  itemParameters
toRunningTotal: (NSMutableArray<NSDictionary *> *)  runningTotal 
implementation

Definition at line 559 of file Y4MenuPostViewController.m.

559  :(NSDictionary *) itemParameters toRunningTotal:(NSMutableArray<NSDictionary *> *) runningTotal
560 {
561  NSString *parameterName = [itemParameters objectForKey:[Z5LocalDataController componentNameKey]];
562  // Look for an entry in the array of running total with the component-name
563  // equal the component-name in the input Distionary. If found, add value and
564  // set record, return. If not found, create a dictionary element and add it to
565  // the running total array-of-parameter-dictionaries, retrun that. Expect running-total
566  // to possibly be empty, but not nil. Same for the itemParameters' argument to
567  // be added to the running-total
568  assert(runningTotal);
569  assert(itemParameters);
570  for (NSDictionary *paramDictionary in runningTotal) {
571  NSString *runningRecordName = [paramDictionary objectForKey:[Z5LocalDataController componentNameKey]];
572  if ([runningRecordName isEqualToString:parameterName]) {
573  NSNumber *enterParameterValue = [itemParameters objectForKey:[Z5LocalDataController componentValueKey]];
574  float enterParameterValueF = [enterParameterValue floatValue];
575  NSNumber *runningParameterValue = [paramDictionary objectForKey:[Z5LocalDataController componentValueKey]];
576  float runningParameterValueF = [runningParameterValue floatValue];
577 
578  // (@"MenuPostViewController.addParameters: enter: %@ running %@", enterParameterValue, runningParameterValue);
579 
580  float newRunningValueF = enterParameterValueF + runningParameterValueF;
581  NSNumber *newRunningValue = [NSNumber numberWithFloat:newRunningValueF];
582  [paramDictionary setValue:newRunningValue forKey:[Z5LocalDataController componentValueKey]];
583  }
584  }
585  return runningTotal;
586 }

◆ clickAction()

- (void) clickAction
implementation

Definition at line 309 of file Y4MenuPostViewController.m.

310 {
311  NSLog(@"MenuPostController.clickAction");
312 }

◆ dateForHeader()

- (NSDate *) dateForHeader
implementation

Definition at line 362 of file Y4MenuPostViewController.m.

363 {
364  NSDate *headerDate;
365  switch (menuType) {
366  case Current_Menu:
367  headerDate = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
368  break;
369 
370  case Calendar_Menu:
371  headerDate = _postingDate;
372  break;
373 
374  default:
375  break;
376  }
377  NSDateComponents *components = [[NSCalendar currentCalendar]
378  components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay
379  fromDate:headerDate];
380  NSDate *dayBegin = [[NSCalendar currentCalendar] dateFromComponents:components];
381  return dayBegin;
382 }
MenuType menuType

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 660 of file Y4MenuPostViewController.m.

660  {
661  [super didReceiveMemoryWarning];
662  // Dispose of any resources that can be recreated.
663 }

◆ didSelectMenuItemRow:()

- (void) didSelectMenuItemRow: (NSIndexPath *)  index
implementation

Definition at line 411 of file Y4MenuPostViewController.m.

411  :(NSIndexPath *) index
412 {
413  Meal *meal = [_postedMeals objectAtIndex:[index section]];
414  NSSortDescriptor *modelDescriptor = [NSSortDescriptor
415  sortDescriptorWithKey:@"name"
416  ascending:YES
417  selector:@selector(caseInsensitiveCompare:)];
418  NSArray *descriptors = @[modelDescriptor];
419  NSArray *itemsArray = [meal.containedItem sortedArrayUsingDescriptors:descriptors];
420  MenuItem *mi = [itemsArray objectAtIndex:[index row]];
421 
422  U7UsdaParamEntryViewController *recipeView =
423  [[U7UsdaParamEntryViewController alloc] initWithMenuItem:mi];
424  [self.navigationController pushViewController:recipeView animated:YES];
425 
426 }

◆ didSelectParameterRow:()

- (void) didSelectParameterRow: (NSIndexPath *)  index
implementation

Definition at line 351 of file Y4MenuPostViewController.m.

351  :(NSIndexPath *) index
352 {
353  NSLog(@"MenuPostViewController.didSelectParameterRow");
354  assert(nil); // boom
355 }

◆ didSwipeMenu:()

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

Definition at line 639 of file Y4MenuPostViewController.m.

639  :(UIGestureRecognizer *)gestureRecognizer {
640 
641  if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
642  // CGPoint swipeLocation = [gestureRecognizer locationInView:proposedMenuTableView];
643  // swipedMenuIndexPath = [proposedMenuTableView indexPathForRowAtPoint:swipeLocation];
644  // UITableViewCell* swipedCell = [proposedMenuTableView cellForRowAtIndexPath:swipedMenuIndexPath];
645  // NSLog(@"MenuPostViewController.didSwipeMenu: cell row: %ld", (long)[swipedMenuIndexPath row]);
646  // [swipedCell setBackgroundColor:[UIColor orangeColor]];
647  //
648  // Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
649  // NSInteger nRow = [swipedMenuIndexPath row];
650  // if ((0<=nRow) && ([[localData todaysMenuItems] count] > nRow)) {
651  // [[localData todaysMenuItems] removeObjectAtIndex:nRow];
652  // }
653  //
654  // [proposedMenuTableView updateSingle:[localData todaysMenuItems]];
655  // [proposedMenuTableView reloadData];
656  }
657 }

◆ didTapBravoFooter()

- (void) didTapBravoFooter
implementation

Definition at line 429 of file Y4MenuPostViewController.m.

430 {
431  NSLog(@"MenuPostController.didTapBravoFooter");
432 }

◆ didTapCheckFooter()

- (void) didTapCheckFooter
implementation

Definition at line 593 of file Y4MenuPostViewController.m.

594 {
595  NSLog(@"MenuPostController.didTapCheckFooter");
596  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
597 
598 
599  NSDate *mealConsumeDate = [menuJournalView getMealJournalDate];
600  [localData todaysMealConsumed:mealConsumeDate forDelegate:self];
601 
602  [localData initializeTodaysMeal];
603 
604  [menuChoicesTableView update:[localData todaysMenuComponents]];
605  [menuChoicesTableView reloadData];
606 
607  [self popOut];
608 }
NSArray< NSDictionary * > * todaysMenuComponents()
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
void todaysMealConsumed:forDelegate:(NSDate *date, [forDelegate] id< Z5HealthConnectionProtocol > jingo)

◆ didTapConsumedFooter()

- (void) didTapConsumedFooter
implementation

If the menu-type is Current-menu: this routine will add the meal defined by the current menu components into a new data base meal, with a date of now. the routine will first put all the parameters for all the components in health data if it's authorized. Context and the meal are save If the menu-type is Calendar-menu: this routine will have an array of meals, to put up a table one meal per section, and a parameter information table. Means will be provided to determine what the parameter information covers, a particular meal or the whole day.

Definition at line 450 of file Y4MenuPostViewController.m.

451 {
452  // log 'consumed' or 'finished' tap
453  // NSLog(@"MenuPostController.didTapConsumedFooter");
454  switch (menuType) {
455  case Current_Menu:
456  {
457  NSLog(@"MenuPostViewController.didTapConsumedFooter: Current_Menu");
458  }
459  break;
460  case Calendar_Menu:
461  {
462  NSLog(@"MenuPostViewController.didTapConsumedFooter: Calendar_Menu");
463  }
464  break;
465  }
466 
467  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
468 
469  float tableWidth = self.view.bounds.size.width;
470 
471  switch (menuType) {
472  case Current_Menu:
473  {
474  // add parameters of all components, eventually accounting for portion size, to health kit.
475  /*
476  [localData goHealthData:[localData todaysMenuComponents] forDelegate:self];
477 
478  NSArray<Meal *> *dailyMeal = [localData findOrCreateMealWithDate: [localData toLocalTime:rightNow]];
479  Meal *meal = [dailyMeal lastObject];
480  NSArray<MenuItem *> *todaysMenuItems = [localData todaysMenuItems];
481  meal.containedItem = [NSSet setWithArray:todaysMenuItems];
482  */
483  menuStatusView = nil;
484  menuJournalViewFrameHeight = 200; // TODO -- ??
485  CGRect menuJournalFrame = CGRectMake(0.0, navbarBottomEdge + 2.0, tableWidth - 8.0, menuJournalViewFrameHeight);
486  menuJournalView = [[Z3MenuJournalView alloc] initWithDelegate:self];
487  menuJournalViewFrameHeight = [menuJournalView heightRequirement];
488  menuJournalFrame = CGRectMake(0.0, 0.0, tableWidth - 8.0, menuJournalViewFrameHeight);
489  [menuJournalView setFrame:menuJournalFrame];
490  [menuChoicesTableView setViewForMenuHead:nil];
491  [menuChoicesTableView setViewForMenuTail:menuJournalView];
492  [menuJournalView appear:menuJournalFrame];
493 
494  // clear out menu-items
495  [menuChoicesTableView.givenMenuItems removeAllObjects];
496  [menuChoicesTableView showFooterOnly:YES];
497 
498  [menuChoicesTableView reloadData];
499  [self resizeParameterFrame];
500  // emptied table, this doesn't work
501  // [menuChoicesTableView scrollForInstructionPanel];
502  }
503  break;
504 
505  case Calendar_Menu:
506  {
507  // get the meals for the date. If there are none start an array.
508  NSArray<Meal *> *mealsToday;
509  NSDate *rightNow = [NSDate dateWithTimeIntervalSinceNow:0];
510  mealsToday = [localData findMealsWithDate:[localData toLocalTime:rightNow]];
511 
512  // [menuChoicesTableView initTableHeadFoot];
513  [menuChoicesTableView setViewForMenuTail:nil];
514  NSArray<NSDictionary *> *totalParams = [self parametersOfMeals:mealsToday];
515 
516  // TODO: Hey!! continue here
517  NSLog(@"HEY: Y4MenuPostViewController.didTapConsumedFooter: meal count: %ld", [totalParams count]);
518 
519 
520  [menuChoicesTableView update:totalParams];
521  [menuChoicesTableView reloadData];
522  }
523  break;
524 
525  default:
526  break;
527  }
528 }
MenuType menuType
Z3MenuConsumedView * menuStatusView
instancetype sharedInstance()
NSArray< Meal * > * findMealsWithDate:(NSDate *findDate)
Z3MenuJournalView * menuJournalView
Singleton interface to both core and remote data sources.
float menuJournalViewFrameHeight
float navbarBottomEdge
NSDate * toLocalTime:(NSDate *grenwich)

◆ didTapNetworkFooter()

- (void) didTapNetworkFooter
implementation

Definition at line 434 of file Y4MenuPostViewController.m.

435 {
436  NSLog(@"MenuPostController.didTapNetworkFooter");
437 }

◆ didTapRatingControl:()

- (void) didTapRatingControl: (float)  rating
implementation

Definition at line 587 of file Y4MenuPostViewController.m.

587  :(float) rating
588 {
589  NSLog(@"MenuPostController.didTapRatingControl: %3.2f", rating);
590  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
591  [localData todaysMealRated:rating];
592 }
instancetype sharedInstance()
void todaysMealRated:(float rating)
Singleton interface to both core and remote data sources.

◆ didTapSkippedFooter()

- (void) didTapSkippedFooter
implementation

Definition at line 613 of file Y4MenuPostViewController.m.

614 {
615  NSLog(@"MenuPostViewController.didTapSkippedFooter");
616  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
617 
618  [localData todaysMealSkipped];
619 
620  // [self popOut];
621  [[self navigationController] popViewControllerAnimated:YES];
622 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ hasFooter()

- (Boolean) hasFooter
implementation

Definition at line 383 of file Y4MenuPostViewController.m.

384 {
385  Boolean ret;
386  switch (menuType) {
387  case Current_Menu:
388  ret = YES;
389  break;
390 
391  case Calendar_Menu:
392  ret = NO;
393  break;
394 
395  default:
396  ret = NO;
397  break;
398  }
399  return ret;
400 }
MenuType menuType

◆ healthQuantityTypeData:success:()

- (void) healthQuantityTypeData: (HKQuantityType *)  quantityType
success: (Boolean)  flag 
implementation

Definition at line 624 of file Y4MenuPostViewController.m.

624  : (HKQuantityType *)quantityType success: (Boolean) flag
625 {
626  NSLog(@"MenuPostViewController:healthQuantityTypeDate: NO-OP success: %@", (flag?@"yes":@"no"));
627 }

◆ orientUI()

- (void) orientUI
implementation

Definition at line 273 of file Y4MenuPostViewController.m.

273  {
274  /*
275  CGRect totalFrame = self.view.frame;
276  float portalHeight = 0.0;
277  float calculatedPortalHeight = 0.0;
278  float yNext = 0.0;
279  */
280 
281  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
282  switch (orientation)
283  {
284  case UIDeviceOrientationPortrait:
285  case UIDeviceOrientationFaceUp:
286  {
287  [menuChoicesTableView scrollInitially];
288 
289  // [proposedMenuTableView scrollInitially];
290  }
291  break;
292  case UIDeviceOrientationLandscapeLeft:
293  case UIDeviceOrientationLandscapeRight:
294  {
295  }
296  break;
297  case UIDeviceOrientationUnknown:
298  {
299  NSLog(@"MenuPostViewController.orientUI: orientation unknown");
300  }
301  break;
302  default:
303  {
304  NSLog(@"MenuPostViewController.orientUI: other: %ld", (long)orientation);
305  }
306  } // END - switch
307 }

◆ parametersOfMeals:()

- (NSArray< NSDictionary * > *) parametersOfMeals: (NSArray<Meal *> *)  meals
implementation

Definition at line 529 of file Y4MenuPostViewController.m.

529  :(NSArray<Meal *> *)meals
530 {
531  NSMutableArray *buildRet = [[NSMutableArray alloc] init];
532  for (Meal *meal in meals) {
533  NSSet<MenuItem *> *mealItems = [meal containedItem];
534  for (MenuItem *mealMenuItem in mealItems) {
535  NSString *theNumbers = [mealMenuItem usdaNumbers];
536  if (theNumbers != nil) {
537  NSError *jsonError;
538  NSData *objectData = [theNumbers dataUsingEncoding:NSUTF8StringEncoding];
539  NSDictionary *menuItemUsdaNumbers = [NSJSONSerialization JSONObjectWithData:objectData
540  options:NSJSONReadingMutableContainers
541  error:&jsonError];
542  if (jsonError) {
543  NSLog(@"MenuPostViewController.parametersOfMeals: ERR: %@", jsonError);
544  } else {
545  NSLog(@"MenuPostViewController.parametersOfMeals: json: %@", menuItemUsdaNumbers);
546  // _nutritionComponents = [usdaNumbersJsonInitial mutableArrayValueForKey:@"usdaNumbers"];
547  NSString *componentName = [menuItemUsdaNumbers objectForKey:[Z5LocalDataController componentNameKey]];
548  NSLog(@"MenuPostViewController.parametersOfMeals: componentName: %@", componentName);
549 
550  buildRet = [self addParameters:menuItemUsdaNumbers toRunningTotal:buildRet];
551  }
552  }
553  }
554 
555  }
556  NSArray<NSDictionary *> *ret = [NSArray arrayWithArray:buildRet];
557  return ret;
558 }

◆ popOut()

- (void) popOut
implementation

Definition at line 609 of file Y4MenuPostViewController.m.

609  {
610  NSLog(@"MenuPostViewController.popOut: pop view off stack");
611  [[self navigationController] popToRootViewControllerAnimated:YES];
612 }

◆ resizeMenuItemFrame()

- (float) resizeMenuItemFrame
implementation

Definition at line 405 of file Y4MenuPostViewController.m.

406 {
407  float menuItemListPanelHeight = 99;
408  NSLog(@"MenuPost.resizeMenuItemFrame: menuItemListPanelHeight: %3.2f", menuItemListPanelHeight);
409  return menuItemListPanelHeight;
410 }

◆ resizeParameterFrame()

- (float) resizeParameterFrame
implementation

Definition at line 335 of file Y4MenuPostViewController.m.

336 {
337  CGRect totalFrame = self.view.frame;
338  float leftMargin = 0.02*totalFrame.size.width;
339  // float topMargin = 48;
340  float controlWidth = 0.96*totalFrame.size.width;
341  // float yNext = topMargin + [proposedMenuTableView frame].size.height + 36;
342 
343  float parameterListPanelHeight = [menuChoicesTableView getViewHeightReqmt];
344  CGRect menuItemParametersFrame = CGRectMake(leftMargin, navbarBottomEdge + 6, controlWidth, parameterListPanelHeight);
345  [menuChoicesTableView setFrame:menuItemParametersFrame];
346 
347  NSLog(@"MenuPostController.resizeParameterFrame: height: %3.2f", menuItemParametersFrame.size.height);
348 
349  return parameterListPanelHeight;
350 }
float navbarBottomEdge

◆ updatedMenuItemArray:()

- (void) updatedMenuItemArray: (NSArray *)  menuItemArray
implementation

Definition at line 401 of file Y4MenuPostViewController.m.

401  :(NSArray *)menuItemArray
402 {
403  NSLog(@"MenuPostController.updatedMenuItemArray");
404 }

◆ updatedParameterArray:()

- (void) updatedParameterArray: (NSArray *)  parameterArray
implementation

Definition at line 314 of file Y4MenuPostViewController.m.

314  :(NSArray *)parameterArray
315 {
316  NSLog(@"MenuPostViewController.updatedParameterArray: NO-OP NO-OP");
317  NSLog(@"MenuPostViewController.updatedParameterArray: parameterArryCount: %lu", (unsigned long)[parameterArray count]);
318  for (NSObject *parameterItem in parameterArray) {
319  Class parameterItemClass = [parameterItem class];
320  NSString *className = NSStringFromClass(parameterItemClass);
321  if ([NSStringFromClass(parameterItemClass) containsString:@"Dictionary"]) {
322  NSDictionary *itemDictionary = (NSDictionary *)parameterItem;
323 
324  NSString *itemName = [itemDictionary objectForKey:@"component-type"];
325  NSLog(@"MenuPostViewController.updatedParameterArray: item-name: %@", itemName);
326  } else if ([NSStringFromClass(parameterItemClass) containsString:@"Meal"]) {
327  Meal *itemMeal = (Meal *)parameterItem;
328  NSLog(@"MenuPostViewController.updatedParameterArray: meal-name: %@", [[itemMeal orderDate] description]);
329  } else {
330  NSLog(@"MenuPostViewController.updatedParameterArray: className: %@", className);
331  }
332  }
333 }

◆ updateMenuSeriesView:()

- (void) updateMenuSeriesView: (NSArray<Meal *> *)  postedMeals
implementation

this is the effective entry point for a pick from the calendar View controller.

Definition at line 249 of file Y4MenuPostViewController.m.

249  :(NSArray<Meal *> *)postedMeals
250 {
251  float tableWidth = self.view.bounds.size.width;
252  NSLog(@"MenuPostViewController.updateMenuSeriesView: tableWidth: %3.2f", tableWidth);
253 
254  // TODO: improve sizing
255  CGRect menuTableViewFrame = CGRectMake(4.0, 4.0, tableWidth - 8.0, 32);
256  float dateTimeViewFrameHeight = [[Z3DateTimeFocusView alloc] heightRequirement];
257 
258  // clearly a series of meals from the calendar orderDate
260  NSLog(@"MenuPostViewController.updateMenuSeriesView: clearly a series of meals from the calendar orderDate");
261 
262  CGRect dateTimeViewFrame = CGRectMake(0.0, 0.0, tableWidth - 8.0, dateTimeViewFrameHeight);
263  dateTimeView = [[Z3DateTimeFocusView alloc] initWithFrame:dateTimeViewFrame andDelegate:self];
264 
265  menuChoicesTableView = [[U3MenuChoicesTableView alloc] initWithFrame:menuTableViewFrame andMenus:postedMeals inContainer:self];
266  [menuChoicesTableView setViewForHead:dateTimeView];
267  [menuChoicesTableView setViewForMenuTail:nil];
268  [menuChoicesTableView update:nil];
269 
270  [self.view addSubview:menuChoicesTableView];
271 }
MenuType menuType
< U3ParameterTableDelegate, U3MenuTableDelegate, Z5HealthConnectionProtocol, Z3MenuConsumedDelegate, Z3DateTimeFocusDelegate, Z6MenuJournalDelegate > NSArray< Meal * > * postedMeals
Z3DateTimeFocusView * dateTimeView
U3MenuChoicesTableView * menuChoicesTableView

◆ updateToAuthorizationOK()

- (void) updateToAuthorizationOK
implementation

Definition at line 628 of file Y4MenuPostViewController.m.

629 {
630  NSLog(@"MenuPostViewController.updateToAuthorizationOK");
631 
632  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
633  [menuChoicesTableView update:[localData todaysMenuComponents]];
634  [menuChoicesTableView reloadData];
635 
636 }
NSArray< NSDictionary * > * todaysMenuComponents()
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ updateTodaysMenuView:()

- (void) updateTodaysMenuView: (NSMutableArray<MenuItem *> *)  proposedTodaysMenu
implementation

Troubleshoot extra header space and scrolled to the top instead of the bottom to provide controls ParameterTablView.scrollForInstructionPanel?

Definition at line 203 of file Y4MenuPostViewController.m.

203  :(NSMutableArray<MenuItem *> *)proposedTodaysMenu
204 {
205  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
206  float tableWidth = self.view.bounds.size.width;
207  CGRect menuTableViewFrame = CGRectMake(8.0, 30.0, 320, 30);
208  float dateTimeViewFrameHeight = [[Z3DateTimeFocusView alloc] heightRequirement];
209 
210  // clearly a ordered meal
212  NSLog(@"MenuPostViewController.updateTodaysMenuView: clearly an ordered meal");
213 
214  // compose a menu table with meal components
215  CGRect dateTimeViewFrame = CGRectMake(0.0, 0.0, tableWidth - 8.0, dateTimeViewFrameHeight);
216  dateTimeView = [[Z3DateTimeFocusView alloc] initWithFrame:dateTimeViewFrame andDelegate:self];
217  menuStatusView = [[Z3MenuConsumedView alloc] initWithDelegate:self];
218  menuChoicesTableView = [[U3MenuChoicesTableView alloc] initWithFrame:menuTableViewFrame andParameters:nil andMenuItems:proposedTodaysMenu inContainer:self];
219  [menuChoicesTableView setViewForMenuHead:dateTimeView];
220  [menuChoicesTableView setViewForMenuTail:menuStatusView];
221  [menuChoicesTableView clearParameters];
222  // compose a menu table with meal components
223 
224  [self.view addSubview:menuChoicesTableView];
225 
226  // determine whether any additional authority is required (this would relate to a individual meal consumed
227  NSArray<NSDictionary *> *componentsPresent = [localData todaysMenuComponents];
228  NSMutableSet *needAuthorizationSet = [[NSMutableSet alloc] init];
229  Boolean needsAdditionalAuthority = NO;
230  for (NSDictionary *component in componentsPresent) {
231  NSNumber *authorityStatus = [component objectForKey:[Z5LocalDataController componentAuthorityKey]];
232  if (![authorityStatus boolValue]) {
233  NSString *componentName = [component objectForKey:[Z5LocalDataController componentNameKey]];
234  HKQuantityType *rowQuantityType = [HKObjectType quantityTypeForIdentifier:[@"HKQuantityTypeIdentifierDietary" stringByAppendingString:componentName]];
235  [needAuthorizationSet addObject:rowQuantityType];
236  needsAdditionalAuthority = YES;
237  }
238  }
239  if (needsAdditionalAuthority) {
240  [localData getAddedAuthorizationToShare:needAuthorizationSet forDelegate:self];
241  }
242  // end - determine whether any additional authority it Is required (this would relate to a individual meal proposed)
243 }
void getAddedAuthorizationToShare:forDelegate:(NSSet *writeNutrTypes, [forDelegate] id< Z5HealthConnectionProtocol > requestFrom)
MenuType menuType
NSMutableSet * needAuthorizationSet
Z3MenuConsumedView * menuStatusView
NSArray< NSDictionary * > * todaysMenuComponents()
instancetype sharedInstance()
Z3DateTimeFocusView * dateTimeView
Singleton interface to both core and remote data sources.
U3MenuChoicesTableView * menuChoicesTableView

◆ viewDidAppear:()

- (void) viewDidAppear: (BOOL)  animated
implementation

Definition at line 145 of file Y4MenuPostViewController.m.

145  :(BOOL)animated
146 {
147  [super viewDidAppear:animated];
148  float tableWidth = self.view.bounds.size.width;
149  NSLog(@"MenuPostViewController.viewDidAppear: tableWidth: %3.2f", tableWidth);
150  // TODO: improve sizing
151  // CGRect menuTableViewFrame = CGRectMake(4.0, 4.0, tableWidth - 8.0, 32);
152  float dateTimeViewFrameHeight = [[Z3DateTimeFocusView alloc] heightRequirement];
153 
154  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
155  if (_postedMeals) {
156  // NSLog(@"MenuPostViewController.viewDidAppear: postedMeals count: %ld", (long)[_postedMeals count]);
157 
158  CGRect dateTimeViewFrame = CGRectMake(0.0, 0.0, tableWidth - 8.0, dateTimeViewFrameHeight);
159  [dateTimeView appear:dateTimeViewFrame];
160 
161  NSString *mealTimeDateStamp;
162  if (_postingDate) {
163  NSDateFormatter *mDayFormatter = [[NSDateFormatter alloc] init];
164  [mDayFormatter setDateStyle:NSDateFormatterMediumStyle];
165  [mDayFormatter setTimeStyle:NSDateFormatterNoStyle];
166  mealTimeDateStamp = [mDayFormatter stringFromDate:_postingDate];
167  NSLog(@"MenuPostViewController.viewDidAppear: mealTimeDateStamp: %@", mealTimeDateStamp);
168  } else {
169  mealTimeDateStamp = @"missing posted orderDate";
170  }
171  [dateTimeView setLabelCaption:mealTimeDateStamp];
172  [dateTimeView appear:self.view.bounds];
173  [menuStatusView appear:self.view.bounds];
174  // NSIndexPath *firstIndex = [NSIndexPath indexPathForRow:0 inSection:1];
175  // [menuChoicesTableView scrollToRowAtIndexPath:firstIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];
176  // [menuChoicesTableView scrollForInstructionPanel];
177  [menuChoicesTableView scrollInitially];
178 
179  } else {
180  NSArray<MenuItem *> *showMenu;
181  showMenu = [localData todaysMenuItems];
182 
183  [dateTimeView setLabelCaption:@"requested menu"];
184  [dateTimeView appear:self.view.bounds];
185  [menuStatusView appear:self.view.bounds];
186  }
187 
188  [self orientUI];
189 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
NSMutableArray< MenuItem * > * todaysMenuItems

◆ viewDidLoad()

- (void) viewDidLoad
implementation

this method sorts through initialization data to find out what should be displayed. The options are to display a proposed complete menu (to be consumed), or to post up a series of meals for a given day.

Definition at line 68 of file Y4MenuPostViewController.m.

68  {
69  [super viewDidLoad];
70 
71  // Do any additional setup after loading the view.
72  self.title = @"Y4MenuPostViewController";
73  navbarBottomEdge = self.navigationController.navigationBar.frame.origin.y
74  + self.navigationController.navigationBar.frame.size.height;
75 
76  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
77  CGRect totalFrame = self.view.frame;
78  NSLog(@"Y4MenuPostViewController.viewDidLoad: width: %3.2f", totalFrame.size.width);
79 
80  // LOGGING ONLY --- logging only
81  NSLog(@"MenuPostViewController.viewDidLoad: postingDate: %@", _postingDate);
82  for (Meal *m in _postedMeals) {
83  NSSet *items = [m containedItem];
84  NSSortDescriptor *modelDescriptor = [NSSortDescriptor
85  sortDescriptorWithKey:@"name"
86  ascending:YES
87  selector:@selector(caseInsensitiveCompare:)];
88  NSArray<NSSortDescriptor *> *descriptors = @[modelDescriptor];
89  NSArray *itemsAray = [items sortedArrayUsingDescriptors:descriptors];
90  NSLog(@"MenuPostViewController.viewDidLoad: meal: %@", [m orderDate]);
91  for (MenuItem *mi in itemsAray) {
92  NSLog(@"MenuPostViewController.viewDidLoad: menuItem: %@", [mi name]);
93  }
94  }
95  // end -- logging only
96 
97  // get and scale image for background
98  UIImage *backgrdImage = [UIImage imageNamed:@"stillLifeWithWineAndCheese.png"];
99  CGSize photoSize = [backgrdImage size];
100  float resizeRatio = photoSize.height / totalFrame.size.height;
101  UIImage *resizedImage = [UIImage imageWithCGImage:[backgrdImage CGImage]
102  scale:backgrdImage.scale * resizeRatio
103  orientation:(backgrdImage.imageOrientation) ];
104  UIImageView *backgrd = [[UIImageView alloc] initWithImage:resizedImage];
105  [self.view addSubview:backgrd];
106  // end - get and scale image for background
107 
108  // float dateTimeViewFrameHeight = [[Z3DateTimeFocusView alloc] heightRequirement];
109 
110  // TODO: Fix here - when coming from calendar, and menu being prepared is encountered .....
111  // determine whether you have a proposed meal or a series of meals
112  // the frame will be revised as the table is composed
113  // float tableWidth = self.view.bounds.size.width;
114  // CGRect menuTableViewFrame = CGRectMake(8.0, 30.0, 320, 30);
115  NSMutableArray<MenuItem *> *proposedTodaysMenu = [localData todaysMenuItems];
116  NSLog(@"MenuPostViewController.viewDidLoad: proposedTodaysMenu: %@", proposedTodaysMenu);
117  Meal *proposedTodaysMeal = [localData todaysMeal];
118  if (proposedTodaysMeal) {
119  NSLog(@"MenuPostViewController.viewDidLoad: proposedTodaysMeal: %@ -date: %@", proposedTodaysMeal, [proposedTodaysMeal orderDate]);
120 
121  NSMutableArray *todayItems = [[NSMutableArray alloc] initWithArray:[[proposedTodaysMeal containedItem] allObjects]];
122  [self updateTodaysMenuView:todayItems];
123 
124  } else if ((0 == [proposedTodaysMenu count]) && (nil != _postedMeals)) {
125  [self updateMenuSeriesView:_postedMeals];
126 
127  } else {
128  NSMutableArray<MenuItem *> *todaysMenuItems = [localData todaysMenuItems];
129  if (nil != todaysMenuItems) {
130  [self updateTodaysMenuView:todaysMenuItems];
131  } else {
132  // an unclear result, further resolution required
133  NSLog(@"MenuPostViewController.viewDidLoad: sniffing at history, with meal edit in progress");
134  }
135  }
136 
137  // add a swipe gesture recognition, Add it to to scene
138  UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeMenu:)];
139  gesture.direction = UISwipeGestureRecognizerDirectionRight;
140  // [proposedMenuTableView addGestureRecognizer:gesture];
141 
142  NSLog(@"MenuPostViewController.viewDidLoad: end");
143 
144 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
float navbarBottomEdge
NSSet< MenuItem * > * containedItem
NSMutableArray< MenuItem * > * todaysMenuItems

◆ viewWillAppear:()

- (void) viewWillAppear: (BOOL)  animated
implementation

Log table header/rows/tailers at appearance

Definition at line 194 of file Y4MenuPostViewController.m.

194  :(BOOL)animated
195 {
196  NSLog(@"MenuPostViewController.viewWillAppear");
197  [menuChoicesTableView appearingNow];
198 }

Property Documentation

◆ postedMeals

- (<U3ParameterTableDelegate, U3MenuTableDelegate, Z5HealthConnectionProtocol, Z3MenuConsumedDelegate, Z3DateTimeFocusDelegate, Z6MenuJournalDelegate> NSArray<Meal *>*) postedMeals
readwritenonatomicstrong

Definition at line 26 of file Y4MenuPostViewController.h.

◆ postingDate

- (NSDate*) postingDate
readwritenonatomicstrong

Definition at line 27 of file Y4MenuPostViewController.h.


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