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

#import <U7UsdaParamEntryViewController.h>

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

Instance Methods

(id) - initWithMenuItem:
 
(void) - scrollForControlPanel
 
(void) - updatedParameterArray:
 
(void) - viewDidLoad [implementation]
 
(void) - viewDidAppear: [implementation]
 
(void) - viewWillAppear: [implementation]
 
(void) - viewWillDisappear: [implementation]
 
(void) - captureNutritionComponents [implementation]
 
(void) - checkWithHealthKit [implementation]
 
(NSSet *) - produceSetWith: [implementation]
 
(void) - placeButtons [implementation]
 
(float) - viewWidth [implementation]
 
(float) - parameterViewHeight [implementation]
 
(float) - parameterViewHeight2 [implementation]
 
(void) - didSwipe: [implementation]
 
(void) - healthQuantityTypeData:success: [implementation]
 
(void) - updateToAuthorizationOK [implementation]
 
(CGRect) - screenBound [implementation]
 
(void) - didSelectParameterRow: [implementation]
 
(float) - resizeParameterFrame [implementation]
 
(float) - manageParameterViewFrame [implementation]
 
(void) - configureToState: [implementation]
 
(void) - clickRemoveButton [implementation]
 
(void) - addParameter: [implementation]
 
(void) - needsRedisplay [implementation]
 
(NSDictionary *) - selectedParameterList [implementation]
 
(TotalEditStateEnum- getTotalEditState [implementation]
 
(void) - showUpdatedHeaderFooter [implementation]
 
(void) - fireRecipeCheck [implementation]
 
(void) - addMenuItemOnToday: [implementation]
 
(NSInteger) - numberOfComponentsInPickerView: [implementation]
 
(NSInteger) - pickerView:numberOfRowsInComponent: [implementation]
 
(UIView *) - createParameterValueEntryViewWithFrame:caption: [implementation]
 
(NSString *) - stringForPickerRow99: [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 

Properties

NSMutableArray * nutritionComponents
 
MenuItemfocusMenuItem [implementation]
 

Detailed Description

Definition at line 17 of file U7UsdaParamEntryViewController.h.

Method Documentation

◆ addMenuItemOnToday:()

- (void) addMenuItemOnToday: (UIButton *)  sender
implementation

Definition at line 475 of file U7UsdaParamEntryViewController.m.

475  :(UIButton *)sender
476 {
477  // TODO: do
478 }

◆ addParameter:()

- (void) addParameter: (NSDictionary *)  newComponentSpecDict
implementation

Definition at line 423 of file U7UsdaParamEntryViewController.m.

423  : (NSDictionary *)newComponentSpecDict
424 {
425  NSString *specDictName = [newComponentSpecDict objectForKey:[Z5LocalDataController componentNameKey]];
426  if (0 <= [parameterTableView isListedAlready:specDictName]) {
427  NSLog(@"USDAparameterView.addParameter: RESTART HERE: %@ already listed", specDictName);
428  [parameterTableView updateParameter:newComponentSpecDict];
429  } else {
430  [parameterTableView addParameter:newComponentSpecDict];
431  }
432 
433  // put revised data in local data
434  [self captureNutritionComponents];
435 }
U3ParameterTableView * parameterTableView
NSMutableDictionary * newComponentSpecDict

◆ captureNutritionComponents()

- (void) captureNutritionComponents
implementation

Definition at line 193 of file U7UsdaParamEntryViewController.m.

194 {
195  // capture parameters to json string
196 // An object that may be converted to JSON must have the following properties:
197 // The top level object is an NSArray or NSDictionary.
198 // All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull.
199 // All dictionary keys are instances of NSString.
200 // Numbers are not NaN or infinity.
201 
202 
203  NSString *jsonReturn = @"{ \"usdaNumbers\" : [";
204  for (NSDictionary *nutritCompo in _nutritionComponents) {
205  NSString *nuroidAddition = [[NSString alloc] initWithFormat:@" { \"%@\" : \"%@\" , \"%@\" : \"%@\" } , ", [Z5LocalDataController componentNameKey], [nutritCompo objectForKey:[Z5LocalDataController componentNameKey]], [Z5LocalDataController componentValueKey], [nutritCompo objectForKey:[Z5LocalDataController componentValueKey]]];
206  jsonReturn = [jsonReturn stringByAppendingString:nuroidAddition];
207  }
208  jsonReturn = [jsonReturn stringByAppendingString:@"] }"];
209  NSLog(@"USDAparameterEntry.viewWillDisappear: jsonReturn: %@", jsonReturn);
210 
211  NSData *jsonReturnData = [jsonReturn dataUsingEncoding:NSUTF8StringEncoding];
212  NSError *err;
213  NSObject *jsonSerialized = [NSJSONSerialization JSONObjectWithData:jsonReturnData options:NSJSONReadingAllowFragments error:&err];
214  if (jsonSerialized) {
215  NSString *jsonSerializedClass = NSStringFromClass([jsonSerialized class]);
216  NSLog(@"USDAparameterEntry.viewWillDisappear: valid data, top class: %@", jsonSerializedClass);
217  if (([jsonSerializedClass isEqualToString:@"__NSCFDictionary"])
218  || ([jsonSerializedClass isEqualToString:@"__NSSingleEntryDictionaryI"])){
219  NSDictionary *jsonSerializedDict = (NSDictionary *)jsonSerialized;
220  NSObject *uNums = [jsonSerializedDict objectForKey:@"usdaNumbers"];
221  NSString *uNumsClass = NSStringFromClass([uNums class]);
222  NSLog(@"USDAparameterEntry.viewWillDisappear: uNumsClass: %@", uNumsClass);
223  // NSArray *jsonSerializedArray = (NSArray *)uNums;
224 
225  if ([NSJSONSerialization isValidJSONObject:jsonSerialized]) {
226  NSLog(@"USDAparameterEntry.viewWillDissappear: json is valid");
227  }
228  NSString *jsonString = [[NSString alloc] initWithData:jsonReturnData encoding:NSUTF8StringEncoding];
229 
230  NSLog(@"USDAparameterEntry.viewWillDissappear: ---> jsonString: %@", jsonString);
231  NSLog(@"USDAparameterEntry.viewWillDissappear: jsonSerializedDict: %@", [jsonSerializedDict descriptionWithLocale:nil]);
232 
233  [self.focusMenuItem setUsdaNumbers:jsonString];
234  } else if ([jsonSerializedClass isEqualToString:@"__NSSingleEntryDictionaryI"]) {
235  NSDictionary *jsonSerializedDict = (NSDictionary *)jsonSerialized;
236  NSObject *uNums = [jsonSerializedDict objectForKey:@"usdaNumbers"];
237  NSString *uNumsClass = NSStringFromClass([uNums class]);
238  NSLog(@"USDAparameterEntry.viewWillDisappear: single-entry dictionary: uNumsClass: %@", uNumsClass);
239  } else {
240  NSLog(@"USDAparameterEntry.viewWillDissappear: jsonSerializedClass: %@", jsonSerializedClass);
241  }
242  } else {
243  NSLog(@"USDAparameterEntry.viewWillDisappear: invalid data");
244  }
245  // store json string in data-base menu-item.usda-numbers
246  [[[Z5DataController sharedInstance] localDataController] saveContext];
247 
248 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ checkWithHealthKit()

- (void) checkWithHealthKit
implementation

Definition at line 250 of file U7UsdaParamEntryViewController.m.

251 {
252  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
253  NSSet *forAuthorizationCheck = [self produceSetWith: _nutritionComponents];
254  [localData getAddedAuthorizationToShare:forAuthorizationCheck forDelegate:self];
255 }
void getAddedAuthorizationToShare:forDelegate:(NSSet *writeNutrTypes, [forDelegate] id< Z5HealthConnectionProtocol > requestFrom)
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ clickRemoveButton()

- (void) clickRemoveButton
implementation

Definition at line 408 of file U7UsdaParamEntryViewController.m.

409 {
410  NSLog(@"USDAparameterEntry: clickRemoveButton");
411  [editTotalView showRemoveOption:NO];
412 
413  NSLog(@"USDAparameterEntry.clickRemoveButton: remove %@", swipedIndexPath);
414  NSInteger tRow = [swipedIndexPath row];
415  [_nutritionComponents removeObjectAtIndex:tRow];
416  [parameterTableView update:_nutritionComponents];
417  [self placeButtons];
418 
419  // put revised data in local data
420  [self captureNutritionComponents];
421 }
NSIndexPath * swipedIndexPath

◆ configureToState:()

- (void) configureToState: (TotalEditStateEnum state
implementation

Definition at line 400 of file U7UsdaParamEntryViewController.m.

400  :(TotalEditStateEnum) state
401 {
402  // TODO: do
403 }
TotalEditStateEnum

◆ createParameterValueEntryViewWithFrame:caption:()

- (UIView *) createParameterValueEntryViewWithFrame: (CGRect)  frame
caption: (NSString *)  nutrCaption 
implementation

add to USDA dictionary at this point

the same cancel button target for quitting adding a parameter, or for quitting editting a parameter.

Definition at line 652 of file U7UsdaParamEntryViewController.m.

652  : (CGRect) frame caption: (NSString *) nutrCaption
653 {
654  CGRect parameterNameRect = CGRectMake(0, 0, 90, 38);
655  CGRect parameterValueRect = CGRectMake(90, 0, 70, 38);
656  UIView* ret = [[UIView alloc] initWithFrame:frame];
657  [ret setBackgroundColor:[UIColor blueColor]];
658 
659  UILabel *parameterType = [[UILabel alloc] initWithFrame:parameterNameRect];
660  [parameterType setBackgroundColor:[UIColor grayColor]];
661  [parameterType setText:nutrCaption];
662  [ret addSubview:parameterType];
663 
664  UITextField *parameterValue = [[UITextField alloc] initWithFrame:parameterValueRect];
665  [parameterValue setBackgroundColor:[UIColor lightGrayColor]];
666  [ret addSubview:parameterValue];
667 
668  return ret;
669 }

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 697 of file U7UsdaParamEntryViewController.m.

697  {
698  [super didReceiveMemoryWarning];
699  // Dispose of any resources that can be recreated.
700 }

◆ didSelectParameterRow:()

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

Definition at line 348 of file U7UsdaParamEntryViewController.m.

348  : (NSIndexPath *)iPath
349 {
350  editParameterIndexRow = [iPath row];
351 
352  [editTotalView configureToState:PICK_QUANTITY];
353  [self resizeParameterFrame];
354 }
NSInteger editParameterIndexRow

◆ didSwipe:()

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

Definition at line 313 of file U7UsdaParamEntryViewController.m.

313  :(UIGestureRecognizer *)gestureRecognizer {
314 
315  if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
316  CGPoint swipeLocation = [gestureRecognizer locationInView:parameterTableView];
317  swipedIndexPath = [parameterTableView indexPathForRowAtPoint:swipeLocation];
318  UITableViewCell* swipedCell = [parameterTableView cellForRowAtIndexPath:swipedIndexPath];
319  NSLog(@"USDAparameterEntry.didSwipe: cell: %@", [swipedCell description]);
320  [swipedCell setBackgroundColor:[UIColor orangeColor]];
321 
322  [editTotalView showRemoveOption:YES];
323  [parameterTableView scrollForControlPanel];
324  }
325 }
NSIndexPath * swipedIndexPath

◆ fireRecipeCheck()

- (void) fireRecipeCheck
implementation

Definition at line 471 of file U7UsdaParamEntryViewController.m.

472 {
473  // TODO: do
474 }

◆ getTotalEditState()

- (TotalEditStateEnum) getTotalEditState
implementation

Definition at line 456 of file U7UsdaParamEntryViewController.m.

456  {
457  // <*code*>
458  NSLog(@"USDAParameterEntryViewController.getTotalEditState: returns INITIAL_STATE");
459  return INITIAL_STATE;
460 }

◆ healthQuantityTypeData:success:()

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

Definition at line 328 of file U7UsdaParamEntryViewController.m.

328  : (HKQuantityType *)quantityType success: (Boolean) flag
329 {
330  NSLog(@"USDAparameterEntry.healthQuantityTypeData");
331 }

◆ initWithMenuItem:()

- (id) initWithMenuItem: (MenuItem *)  menuItem

Definition at line 53 of file U7UsdaParamEntryViewController.m.

53  :(MenuItem *)menuItem
54 {
55  self = [super init];
56  self.focusMenuItem = menuItem;
57  focusGallery = [self.focusMenuItem.galleryNumber integerValue];
58  self.title = @"Update Menu Item";
59  NSString *theNumbers = self.focusMenuItem.usdaNumbers;
60  NSLog(@"USDAparameterEntry.initWithItem: USDA #: %@", theNumbers);
61 
62  if (theNumbers) {
63  NSError *jsonError;
64  NSData *objectData = [theNumbers dataUsingEncoding:NSUTF8StringEncoding];
65  usdaNumbersJsonInitial = [NSJSONSerialization JSONObjectWithData:objectData
66  options:NSJSONReadingMutableContainers
67  error:&jsonError];
68  if (jsonError) {
69  NSLog(@"USDAparameterEntry.initWithItem: ERR: %@", jsonError);
70  } else {
71  NSLog(@"USDAparameterEntry.initWithItem: json: %@", usdaNumbersJsonInitial);
72  _nutritionComponents = [usdaNumbersJsonInitial mutableArrayValueForKey:@"usdaNumbers"];
73  }
74  }
75  if (!_nutritionComponents) {
76  _nutritionComponents = [[NSMutableArray alloc] init];
77  }
78 
79  [[[Z5DataController sharedInstance] localDataController] establishNutritionParameters];
80  return self;
81 }
NSInteger focusGallery
MenuItem * menuItem
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
NSDictionary * usdaNumbersJsonInitial

◆ manageParameterViewFrame()

- (float) manageParameterViewFrame
implementation

Definition at line 370 of file U7UsdaParamEntryViewController.m.

371 {
372  float parameterPanelHgt = [self parameterViewHeight] - 6;
373  if (parameterPanelHgt < 0) parameterPanelHgt = 0;
374  CGRect totalFrame = self.view.frame;
375  float parameterPanelHgtLimit = totalFrame.size.height - topOfPage.floatValue - 8;
376  if (parameterPanelHgt > parameterPanelHgtLimit) {
377  NSLog(@"USDAparamEntryController.manageParameterViewFrame: limit vertical from %3.2f to %3.2f", parameterPanelHgt, parameterPanelHgtLimit);
378  parameterPanelHgt = parameterPanelHgtLimit;
379  }
380  parameterViewFrame = CGRectMake([sideMarginWidth floatValue],
381  [topOfPage floatValue]
382  + 6,
383  [featuresWidth floatValue], parameterPanelHgt);
384  [parameterTableView setFrame:parameterViewFrame];
385  [parameterTableView reloadData];
386  if ([parameterTableView parameterCount] > 0) {
387  NSIndexPath *addIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
388  [parameterTableView scrollToRowAtIndexPath:addIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
389  }
390  NSLog(@"USDAparameterView.manageParameterViewFrame: %3.2f/%3.2f %3.2f/%3.2f", parameterViewFrame.origin.x, parameterViewFrame.origin.y, parameterViewFrame.size.width, parameterViewFrame.size.height);
391 
392  return parameterPanelHgt;
393 }
U3ParameterTableView * parameterTableView
NSNumber * sideMarginWidth
NSNumber * featuresWidth
NSNumber * topOfPage

◆ needsRedisplay()

- (void) needsRedisplay
implementation

Definition at line 437 of file U7UsdaParamEntryViewController.m.

438 {
439  [self.view setNeedsDisplay];
440 }

◆ numberOfComponentsInPickerView:()

- (NSInteger) numberOfComponentsInPickerView: (UIPickerView *)  pickerView
implementation

Definition at line 483 of file U7UsdaParamEntryViewController.m.

483  :(UIPickerView *)pickerView
484 {
485  assert (nil);
486  return 0;
487 }

◆ parameterViewHeight()

- (float) parameterViewHeight
implementation

This method provides the overall vertical size of the nutrition components table.

Definition at line 291 of file U7UsdaParamEntryViewController.m.

292 {
293  return [menuItemView heightRequirement]
294  + [_nutritionComponents count] * 42
295  + [editTotalView heightRequirement]
296  + 12.0;
297 }
Z6ParamEditTotalView * editTotalView

◆ parameterViewHeight2()

- (float) parameterViewHeight2
implementation

Definition at line 298 of file U7UsdaParamEntryViewController.m.

299 {
300  float parameterFramePerCentHeightMax = 0.26;
301  CGRect totalFrame = self.view.frame;
302  float paramLineHgtPerCent = 46.0 / totalFrame.size.height;
303 
304  // NSLog(@"USDAparameterEntry.parameterViewHeight: nutrComp count: %ld",(long) [nutritionComponents count]);
305 
306  float suggestedParamHeightPerCent = paramLineHgtPerCent * [_nutritionComponents count];
307  if (parameterFramePerCentHeightMax < suggestedParamHeightPerCent) {
308  suggestedParamHeightPerCent = parameterFramePerCentHeightMax;
309  }
310  float parameterViewHeight = totalFrame.size.height * suggestedParamHeightPerCent;
311  return parameterViewHeight;
312 }
float parameterViewHeight()

◆ pickerView:numberOfRowsInComponent:()

- (NSInteger) pickerView: (UIPickerView *)  pickerView
numberOfRowsInComponent: (NSInteger)  component 
implementation

Definition at line 488 of file U7UsdaParamEntryViewController.m.

488  :(UIPickerView *)pickerView
489 numberOfRowsInComponent:(NSInteger)component
490 {
491  assert(nil);
492  return 0;
493 }

◆ placeButtons()

- (void) placeButtons
implementation

Definition at line 268 of file U7UsdaParamEntryViewController.m.

269 {
270  CGRect totalFrame = self.view.frame;
271  CGRect topNavigationFrame = [[[self navigationController] navigationBar] frame];
272  float topOfPageFloat = topNavigationFrame.origin.y + topNavigationFrame.size.height;
273  topOfPage = [[NSNumber alloc] initWithFloat:topOfPageFloat];
274  float featuresWidthFloat = totalFrame.size.width * 0.84;
275  featuresWidth = [[NSNumber alloc] initWithFloat:featuresWidthFloat];
276  float sideMarginWidthFloat = totalFrame.size.width * 0.08;
277  sideMarginWidth = [[NSNumber alloc] initWithFloat:sideMarginWidthFloat];
278 
279 // float newParameterPickerHeight = totalFrame.size.height * 0.20 ;
280 // float topOfPageF = [topOfPage floatValue];
281 //
282 // float parameterViewHeight = [self parameterViewHeight];
283 }
NSNumber * sideMarginWidth
NSNumber * featuresWidth
float featuresWidthFloat
float sideMarginWidthFloat
NSNumber * topOfPage

◆ produceSetWith:()

- (NSSet *) produceSetWith: (NSArray *)  nutrComp
implementation

Definition at line 256 of file U7UsdaParamEntryViewController.m.

256  :(NSArray *)nutrComp
257 {
258  NSMutableSet *ret = [[NSMutableSet alloc] init];
259  for (NSDictionary *entry in nutrComp) {
260  NSLog(@"USDAparameterEntry.produceSetWith: entry: %@", entry);
261  NSString *caption = [entry objectForKey:[Z5LocalDataController componentNameKey]];
262  HKQuantityType *rowQuantityType = [HKObjectType quantityTypeForIdentifier:[@"HKQuantityTypeIdentifierDietary" stringByAppendingString:caption]];
263  [ret addObject:rowQuantityType];
264  }
265  return ret;
266 }

◆ resizeParameterFrame()

- (float) resizeParameterFrame
implementation

Definition at line 355 of file U7UsdaParamEntryViewController.m.

356 {
357  return [self manageParameterViewFrame];
358 }

◆ screenBound()

- (CGRect) screenBound
implementation

Definition at line 342 of file U7UsdaParamEntryViewController.m.

343 {
344  return parameterViewFrame;
345 }

◆ scrollForControlPanel()

- (void) scrollForControlPanel

Definition at line 404 of file U7UsdaParamEntryViewController.m.

405 {
406  [parameterTableView scrollForControlPanel];
407 }

◆ selectedParameterList()

- (NSDictionary *) selectedParameterList
implementation

Definition at line 441 of file U7UsdaParamEntryViewController.m.

442 {
443  NSDictionary *selectParameters;
444  if ((0 < [_nutritionComponents count]) && (0 <= editParameterIndexRow)) {
445  if ([_nutritionComponents count] > editParameterIndexRow) {
446  selectParameters = [_nutritionComponents objectAtIndex:editParameterIndexRow];
447  } else {
448  NSLog(@"USDAparameterEntry.selectedParameterList: editParameterIndexRow: %ld nutritionComponents count: %lu", (long)editParameterIndexRow, (unsigned long)[_nutritionComponents count] );
449  }
450  } else {
451  selectParameters = [[NSDictionary alloc] init];
452  }
453  return selectParameters;
454 }
NSInteger editParameterIndexRow

◆ showUpdatedHeaderFooter()

- (void) showUpdatedHeaderFooter
implementation

Definition at line 461 of file U7UsdaParamEntryViewController.m.

462 {
463  // [parameterTableView reloadData];
464  // [self.view setNeedsDisplay];
465  [parameterTableView setViewForTail:editTotalView];
466  [self manageParameterViewFrame];
467 }

◆ stringForPickerRow99:()

- (NSString *) stringForPickerRow99: (NSInteger)  row
implementation

Definition at line 671 of file U7UsdaParamEntryViewController.m.

671  : (NSInteger) row
672 {
673  NSString *ret;
674  if ((row >= 0) && (row < [[[[Z5DataController sharedInstance] localDataController] availableNutritionParamArray] count])) {
675 
676  // get nutrition component code
677  NSString *rowQuantityTypeClue = [[[[Z5DataController sharedInstance] localDataController] availableNutritionParamArray] objectAtIndex:row];
678 
679  // convert to QuantityType
680  HKQuantityType *rowQuantityType = [HKObjectType quantityTypeForIdentifier:rowQuantityTypeClue];
681 
682  // convert back to a string
683  NSString *rowQuanTypeString = [rowQuantityType description];
684  // NSLog(@"USDAparameterEntry.stringForPickerRow: rowQuantityType: %@", rowQuanTypeString);
685 
686  // pick out last portion of nutrition component code
687  NSString *protoCaption = [rowQuanTypeString substringFromIndex:31]; // length 'HKQuantityTypeIdentifierDietary' = 31
688  ret = protoCaption;
689  } else {
690  ret = @"-?-";
691  }
692 
693  return ret;
694 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ updatedParameterArray:()

- (void) updatedParameterArray: (NSArray *)  parameterArray

Definition at line 359 of file U7UsdaParamEntryViewController.m.

359  :(NSArray *)parameterArray;
360 {
361  [_nutritionComponents removeAllObjects];
362  [_nutritionComponents addObjectsFromArray:parameterArray];
363 
364  // [parameterTableView update:nutritionComponents];
365  // NSLog(@"USDAparameterView.updatedParameterArray: nutritionComponents: %@", nutritionComponents);
366 
367  [self manageParameterViewFrame];
368 }

◆ updateToAuthorizationOK()

- (void) updateToAuthorizationOK
implementation

Definition at line 332 of file U7UsdaParamEntryViewController.m.

333 {
334  NSLog(@"USDAparameterEntry.updateToAuthorizationOK");
335  [parameterTableView update:_nutritionComponents];
336  NSLog(@"USDAparameterEntry.healthQuantityTypeData: nutritionComponents: %@", _nutritionComponents);
337  [parameterTableView reloadData];
338 }

◆ viewDidAppear:()

- (void) viewDidAppear: (BOOL)  animated
implementation

Definition at line 150 of file U7UsdaParamEntryViewController.m.

150  :(BOOL)animated
151 {
152  [super viewDidAppear:animated];
153 
155 
156  // animate section 0 header and footer views
157  [menuItemView appear:parameterTableView.bounds];
158  [editTotalView appear:self.view.bounds];
159  // end - animate section 0 header and footer views
160 }
NSInteger editParameterIndexRow

◆ viewDidLoad()

- (void) viewDidLoad
implementation

This method constructs the image, in the final some will be moved off to [self orientUI] to accomodate rotation. The screen establishes widths and some vertical limits: topOfPage just under navigation bar galleryIdHeight vertical for gallery-id (eg. home, restaurant, burger stand menuItemNameHeight vertical for item title (focus-key*item) imageHeight height of screen devoted to image presentation A background image is put up (wheat field, red barn)

Definition at line 93 of file U7UsdaParamEntryViewController.m.

93  {
94  [super viewDidLoad];
95  // Do any additional setup after loading the view.
96  [self.view setBackgroundColor:[UIColor colorWithHue:0.17 saturation:0.5 brightness:0.7 alpha:1.0]];
97 
98  // topOfPage, imageHeight, featuresWidth,
99  // and sideMarginWidth are class vars
100  CGRect totalFrame = self.view.frame;
101  CGRect topNavigationFrame = [[[self navigationController] navigationBar] frame];
102  // CGSize buttonSize = CGSizeMake(totalFrame.size.width * 0.42, 40.0);
103 
104  float topOfPageFloat = topNavigationFrame.origin.y + topNavigationFrame.size.height;
105  topOfPage = [[NSNumber alloc] initWithFloat:topOfPageFloat];
106  float featuresWidthFloat = totalFrame.size.width * 0.84;
107  featuresWidth = [[NSNumber alloc] initWithFloat:featuresWidthFloat];
108  float sideMarginWidthFloat = totalFrame.size.width * 0.08;
109  sideMarginWidth = [[NSNumber alloc] initWithFloat:sideMarginWidthFloat];
110 
111  // get and scale image for background
112  UIImage *backgrdImage = [UIImage imageNamed:@"red_barn_field.png"];
113  CGSize photoSize = [backgrdImage size];
114  float resizeRatio = photoSize.height / totalFrame.size.height;
115  UIImage *resizedImage = [UIImage imageWithCGImage:[backgrdImage CGImage]
116  scale:backgrdImage.scale * resizeRatio
117  orientation:(backgrdImage.imageOrientation) ];
118  UIImageView *backgrd = [[UIImageView alloc] initWithImage:resizedImage];
119  [self.view addSubview:backgrd];
120  // end - get and scale image for background
121 
122  // create section 0 header and footer views
123  menuItemView = [[Z6MenuItemFocusView alloc] initWithMenuItem:_focusMenuItem andDelegate: self];
124  editTotalView = [[Z6ParamEditTotalView alloc] initWithDelegate: self];
125  // end - create section 0 header and footer views
126 
127  parameterViewFrame = CGRectMake(sideMarginWidthFloat,
128  topOfPageFloat + 6,
130  [self parameterViewHeight]);
131  parameterTableView = [[U3ParameterTableView alloc] initWithFrame:parameterViewFrame
132  andComponents:_nutritionComponents
133  inContainer:self];
134  UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
135  gesture.direction = UISwipeGestureRecognizerDirectionRight;
136  [parameterTableView addGestureRecognizer:gesture];
137 
138  [parameterTableView setViewForHead:menuItemView];
139  [parameterTableView setViewForTail:editTotalView];
140 
141  [self.view addSubview:parameterTableView];
142 
143  UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"HealthKit"
144  style:UIBarButtonItemStylePlain
145  target:self
146  action:@selector(checkWithHealthKit)];
147  self.navigationItem.rightBarButtonItem = anotherButton;
148  self.navigationItem.rightBarButtonItem.enabled = YES;
149 }
U3ParameterTableView * parameterTableView
NSNumber * sideMarginWidth
float parameterViewHeight()
Z6ParamEditTotalView * editTotalView
NSNumber * featuresWidth
float featuresWidthFloat
Z6MenuItemFocusView * menuItemView
float sideMarginWidthFloat
NSNumber * topOfPage

◆ viewWidth()

- (float) viewWidth
implementation

Definition at line 284 of file U7UsdaParamEntryViewController.m.

285 {
286  return self.view.frame.size.width;
287 }

◆ viewWillAppear:()

- (void) viewWillAppear: (BOOL)  animated
implementation

Definition at line 161 of file U7UsdaParamEntryViewController.m.

161  :(BOOL)animated
162 {
163  // capture parameters to json string
164  NSLog(@"USDAparameterEntry.viewWillAppear: usdaNumbers: %@", [self.focusMenuItem usdaNumbers]);
165 
166  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
167  NSError *error;
168  NSData *data = [[self.focusMenuItem usdaNumbers] dataUsingEncoding:NSUTF8StringEncoding];
169  if (data) {
170  NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data
171  options:kNilOptions
172  error:&error];
173  if (error) {
174  NSLog(@"USDAparameterEntry.viewWillAppear: error: %@", error);
175  } else {
176  NSLog(@"USDAparameterEntry.viewWillAppear: jsonResponse: %@", jsonResponse);
177  NSArray<NSDictionary *> *parameters = [jsonResponse mutableArrayValueForKey:@"usdaNumbers"];
178  NSArray<NSDictionary *> *parametersWithAuth = [localData annotateAuthority:parameters];
179  [parameterTableView update:parametersWithAuth];
180  [parameterTableView reloadData];
181  }
182  }
183  [editTotalView appear:parameterViewFrame];
184 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
NSMutableArray * annotateAuthority:(NSArray *componentArray)

◆ viewWillDisappear:()

- (void) viewWillDisappear: (BOOL)  animated
implementation

Definition at line 185 of file U7UsdaParamEntryViewController.m.

185  :(BOOL)animated
186 {
187  NSLog(@"USDAparameterEntry.viewWillDisappear: usdaNumbers: %@", [self.focusMenuItem usdaNumbers]);
188  NSLog(@"USDAparameterEntry.viewWillDisappear: nutritionComponents: %@", _nutritionComponents);
189 
190  [self captureNutritionComponents];
191 }

Property Documentation

◆ focusMenuItem

- (MenuItem*) focusMenuItem
readwritenonatomicstrongimplementation

Definition at line 24 of file U7UsdaParamEntryViewController.m.

◆ nutritionComponents

- (NSMutableArray*) nutritionComponents
readwritenonatomicstrong

Definition at line 20 of file U7UsdaParamEntryViewController.h.


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