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

#import <Z6ParamValueEditView.h>

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

Instance Methods

(instancetype) - initWithDelegate:
 
(void) - specializePickerView:
 
(NSDictionary *) - originateParameter
 
(void) - initializeSelection
 
(void) - showPickerViewNot:
 
(HKQuantityType *) - pickQuantityType [implementation]
 
(HKUnit *) - pickQuantityUnit [implementation]
 
(void) - originate [implementation]
 
(HKQuantity *) - produceQuantityValue [implementation]
 
(float) - heightRequirement [implementation]
 
(void) - appear: [implementation]
 
(CGFloat) - pickerView:rowHeightForComponent: [implementation]
 
(CGFloat) - pickerView:widthForComponent: [implementation]
 
(NSAttributedString *) - pickerView:attributedTitleForRow:forComponent: [implementation]
 
(UIView *) - pickerView:viewForRow:forComponent:reusingView: [implementation]
 
(NSInteger) - isListedAlready: [implementation]
 
(void) - setupDimensionWheel [implementation]
 
(HKUnit *) - unitForQuantityType: [implementation]
 
(void) - establishPick: [implementation]
 
(void) - pickerView:didSelectRow:inComponent: [implementation]
 
(NSInteger) - numberOfComponentsInPickerView: [implementation]
 
(NSInteger) - pickerView:numberOfRowsInComponent: [implementation]
 
(void) - setPickerType:scalar:andUnit: [implementation]
 
(NSString *) - stringForPickerRow: [implementation]
 

Detailed Description

Definition at line 13 of file Z6ParamValueEditView.h.

Method Documentation

◆ appear:()

- (void) appear: (CGRect)  bound
implementation

Definition at line 237 of file Z6ParamValueEditView.m.

237  :(CGRect)bound
238 {
239  // NSLog(@"Z6ParamValueEditView.appear: newParameterPickerHeight: %3.2f", newParameterPickerHeight);
240  switch ([delegate getTotalEditState]) {
241  case INITIAL_STATE:
242  {
243  }
244  break;
245  case PICK_COMPONENT:
246  {
247  }
248  break;
249  case PICK_QUANTITY:
250  {
251  // next line is inadequate, consider when parameter
252  // added subsequent to initial add. Name inside dictionary
253  // should be new parameter, or selected parameter GENERally
254  // from component-0
255  NSInteger huh = [newParameterPicker selectedRowInComponent:0];
256  NSString *component0parameter = [self stringForPickerRow:huh];
257  NSDictionary *tryThisDict = [[NSDictionary alloc] initWithObjectsAndKeys:component0parameter, [Z5LocalDataController componentNameKey] , nil];
258  NSDictionary *editParameterDictionary = [delegate selectedParameterList];
259  if (editParameterDictionary && ([editParameterDictionary count] > 0)) {
260  [self specializePickerView:editParameterDictionary];
261  } else {
262  [self specializePickerView:tryThisDict];
263  }
264  }
265  break;
266  }
267  CGRect pickerFrame = CGRectMake(2.0, 2.0, bound.size.width - 4.0, newParameterPickerHeight);
268  [newParameterPicker setFrame:pickerFrame];
269  [newParameterPicker showsSelectionIndicator];
270 }
float newParameterPickerHeight
id< U7ParamEditControlDelegate > delegate

◆ establishPick:()

- (void) establishPick: (NSInteger)  row
implementation

this method takes the name of the selected nutrition parameter and uses it as a key to get the component amount specification. With the specification, its sets the current value in the picker, and informs the delegate tht it should show options to use the picker settting, or cancel the picker operation.

Definition at line 468 of file Z6ParamValueEditView.m.

468  : (NSInteger)row
469 {
470  NSString *pickedCaption = [self stringForPickerRow:row];
471  NSInteger valueComponentIndex = 1;
472  [newParameterPicker reloadComponent:valueComponentIndex];
473  valueComponentIndex = 2;
474  [newParameterPicker reloadComponent:valueComponentIndex];
475  valueComponentIndex = 3;
476  [newParameterPicker reloadComponent:valueComponentIndex];
477  valueComponentIndex = 4;
478  [newParameterPicker reloadComponent:valueComponentIndex];
479 
480  newComponentSpecDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:pickedCaption, [Z5LocalDataController componentNameKey], nil];
481 
482  // TODO [editControlbarView showPickOptions];
483 
484  pickQuantityType = [HKObjectType quantityTypeForIdentifier:[[[[Z5DataController sharedInstance] localDataController] availableNutritionParamArray] objectAtIndex:row]];
485  pickQuantityUnit = [self unitForQuantityType:pickQuantityType];
486  NSLog(@"Z6ParamValueEditView.didSelectRow: pickQuantityUnit: %@", pickQuantityUnit);
487 
488 }
instancetype sharedInstance()
NSMutableDictionary * newComponentSpecDict
Singleton interface to both core and remote data sources.
HKQuantityType * pickQuantityType

◆ heightRequirement()

- (float) heightRequirement
implementation

Definition at line 230 of file Z6ParamValueEditView.m.

231 {
232  return newParameterPickerHeight + 4;
233 }
float newParameterPickerHeight

◆ initializeSelection()

- (void) initializeSelection

After the value-editor has been used, it returns to what it was editting when it specializes for the next entry, this is an attempt to initiaizes the thing after it has been used.

Definition at line 103 of file Z6ParamValueEditView.m.

104 {
106 }
Boolean editParameterSelected

◆ initWithDelegate:()

- (instancetype) initWithDelegate: (id<Z6ParamValueEditDelegate>)  dele

This method sets the delegate and fills the object with method 'originate', which creates the frame for the picker, and adds the picker to the view.

Definition at line 44 of file Z6ParamValueEditView.m.

44  : (id<Z6ParamValueEditDelegate>) dele {
45  self = [super init];
46  if (self) {
47  delegate = dele;
48  [self originate];
49  }
50  return self;
51 }
id< U7ParamEditControlDelegate > delegate

◆ isListedAlready:()

- (NSInteger) isListedAlready: (NSString *)  pickedCaption
implementation

Definition at line 395 of file Z6ParamValueEditView.m.

395  : (NSString *)pickedCaption
396 {
397  NSInteger ret = -1;
398  int parameterIndex = 0;
399  for (NSDictionary *item in nutritionComponents) {
400  NSString *componentType = [item objectForKey:[Z5LocalDataController componentNameKey]];
401  NSString *compoTypeClass = NSStringFromClass([componentType class]);
402 
403  if ([compoTypeClass isEqualToString:@"NSTaggedPointerString"]) {
404  //U7UsdaParamEntryViewController.m:690:45: Use of undeclared identifier 'NSTaggedPointerString', even with UIKit.
405  // NSTaggedPointerString *tpStr = (NSTaggedPointerString *)componentType;
406  if ([componentType isEqualToString:pickedCaption]) {
407  NSLog(@"Z6ParamValueEditView.isListedAlready: UNEXPECTED: %@", componentType);
408  ret = parameterIndex;
409  }
410  break;
411  } else if (![compoTypeClass isEqualToString:@"NSString"]) {
412  NSLog(@"Z6ParamValueEditView.isListedAlready: odd-bal compo-class: %@", compoTypeClass);
413  } else if ([componentType isEqualToString:pickedCaption]) {
414  // if component is listed, eventually set the picker view
415  // to the quantity-sample data
416  ret = parameterIndex;
417  break;
418  }
419  parameterIndex++;
420  }
421  return ret;
422 }
NSMutableArray * nutritionComponents

◆ numberOfComponentsInPickerView:()

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

Definition at line 538 of file Z6ParamValueEditView.m.

538  :(UIPickerView *)pickerView
539 {
540  NSInteger ret = 0;
541  if ( editParameterSelected ) {
542  ret = 5;
543  } else {
544  ret = 1;
545  }
546  return ret;
547 }
Boolean editParameterSelected

◆ originate()

- (void) originate
implementation

Definition at line 52 of file Z6ParamValueEditView.m.

53 {
54  // [self setBackgroundColor:[UIColor cyanColor]];
55 
56  sideMarginWidth = 2.0;
57  topOfPickerFrame= 2.0;
62  pickerWheel4Titles = nil;
63  massUnitsArray = [[NSArray alloc] initWithObjects: @"ug", @"mg", @"g", @"kg", nil];
64  energyUnitsArray = [[NSArray alloc] initWithObjects: @"cal", @"kcal", nil];
65 
66  CGRect totalFrame = delegate.screenBound;
67  featuresWidth = 260;
68  // newParameterPickerHeight = totalFrame.size.height * 0.20 ;
69  featuresWidth = totalFrame.size.width - 4.0;
70 
71  CGRect newParameterFrame = CGRectMake(2.0, 2.0, 400.0, 350.0);
72  newParameterPicker = [[UIPickerView alloc] initWithFrame:newParameterFrame];
73  [newParameterPicker setDelegate:self];
74  [newParameterPicker setDataSource:self];
75  [newParameterPicker setBackgroundColor:[UIColor colorWithWhite:0.76 alpha:1.0]];
76  [self addSubview:newParameterPicker];
77 }
NSMutableArray * pickerWheel4Titles
float newParameterPickerHeight
Boolean editParameterSelected
float featuresWidth
float topOfPickerFrame
NSArray * massUnitsArray
id< U7ParamEditControlDelegate > delegate
NSArray * energyUnitsArray
float sideMarginWidth
CGRect newParameterPickerFrame
NSInteger editNutritionParameter
UIPickerView * newParameterPicker

◆ originateParameter()

- (NSDictionary *) originateParameter

Definition at line 204 of file Z6ParamValueEditView.m.

205 {
206  HKQuantity *acceptQuantity = [self produceQuantityValue];
207  [newComponentSpecDict setObject:acceptQuantity forKey:[Z5LocalDataController componentValueKey]];
208 
209  // https://developer.apple.com/library/ios/documentation/HealthKit/Reference/HealthKit_Constants/index.html#//apple_ref/doc/constant_group/Nutrition_Identifiers
210  // HKQuantityType *acceptedQuantityType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDietarySodium];
211  // [acceptedQuantityType.canonicalUnit]
212 
213  NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
214  HKQuantitySample *acceptedSample = [HKQuantitySample quantitySampleWithType:pickQuantityType
215  quantity:acceptQuantity
216  startDate:now
217  endDate:now];
218  [newComponentSpecDict setObject:acceptedSample forKey:[Z5LocalDataController componentSampleKey]];
219 
220  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
221  NSNumber *typeAuthorization = [localData checkTypeAuthorization:pickQuantityType];
222  [newComponentSpecDict setObject:typeAuthorization forKey:[Z5LocalDataController componentAuthorityKey]];
223  return newComponentSpecDict;
224 }
instancetype sharedInstance()
NSMutableDictionary * newComponentSpecDict
NSNumber * checkTypeAuthorization:(HKQuantityType *quantityType)
Singleton interface to both core and remote data sources.

◆ pickerView:attributedTitleForRow:forComponent:()

- (NSAttributedString *) pickerView: (UIPickerView *)  pickerView
attributedTitleForRow: (NSInteger)  row
forComponent: (NSInteger)  component 
implementation

Definition at line 319 of file Z6ParamValueEditView.m.

319  :(UIPickerView *)pickerView
320  attributedTitleForRow:(NSInteger)row
321  forComponent:(NSInteger)component
322 {
323  NSString *ret;
324 
325  if (0 == component) {
326  ret = [self stringForPickerRow:row];
327  // NSLog(@"/Z6ParamValueEditView.titleForRow: %ld: %@", row, ret);
328  } else if (1 == component) {
329  ret = [[NSString alloc] initWithFormat:@"%ld", (long)row];
330  } else if (2 == component) {
331  ret = [[NSString alloc] initWithFormat:@"%ld", (long)row];
332  } else if (3 == component) {
333  ret = [[NSString alloc] initWithFormat:@"%ld", (long)row];
334  } else if (4 == component) {
335  // ret = [self parameterDimensionForRow:row];
336  if ([pickerWheel4Titles count] > row) {
337  ret = [pickerWheel4Titles objectAtIndex:row];
338  } else {
339  ret = @"w?5";
340  }
341  } else {
342  NSLog(@"Z6ParamValueEditView.titleForRow: unknown component: %ld", (long)component);
343  }
344 
345  UIFont *herefont = [UIFont fontWithName:@"Helvetica-Bold" size:16];
346  NSDictionary *attribs = @{
347  NSForegroundColorAttributeName: [UIColor blackColor],
348  NSFontAttributeName: herefont
349  };
350  NSMutableAttributedString *attributedText =
351  [[NSMutableAttributedString alloc] initWithString:ret
352  attributes:attribs];
353  return attributedText;
354 }
NSMutableArray * pickerWheel4Titles

◆ pickerView:didSelectRow:inComponent:()

- (void) pickerView: (UIPickerView *)  pickerView
didSelectRow: (NSInteger)  row
inComponent: (NSInteger)  component 
implementation

Definition at line 489 of file Z6ParamValueEditView.m.

489  :(UIPickerView *)pickerView
490  didSelectRow:(NSInteger)row
491  inComponent:(NSInteger)component
492 {
493  NSLog(@"Z6ParamValueEditView.didSelectPickerRow: component: %ld", (long)component);
494  newParameterIndex = row;
495  switch (component) {
496  case 0:
497  {
498  // set the HKQuantityType with result
499  NSString *pickedCaption = [self stringForPickerRow:row];
500  NSLog(@"Z6ParamValueEditView.didSelectPickerRow: %ld %@", (long)row, pickedCaption);
501  int parameterIndex = (int)[self isListedAlready:pickedCaption];
502  // see if the quantity-type is already listed
503  if (0 <= parameterIndex) {
504  // TODO set scrolling
505  // NSIndexPath *paramComponentPath = [NSIndexPath indexPathForRow:parameterIndex inSection:0];
506  // [parameterTableView selectRowAtIndexPath:paramComponentPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
507  // NSLog(@"Z6ParamValueEditView.didSelectPickerRow: picking component row: %d", parameterIndex);
508  } else {
509  // if processing reaches this point, quantity-type not listed
510  if (editParameterSelected ) {
511  [self establishPick:row];
512  [self setupDimensionWheel];
513  } else {
515  NSLog(@"Z6ParamValueEditView.didSelectRow: reload all components at pick");
516  [pickerView reloadAllComponents];
517  NSLog(@"Z6ParamValueEditView.didSelectRow: END -- reload all components at pick");
518  }
520  }
521  }
522 
523  break;
524  case 1:
525  case 2:
526  case 3:
527  case 4:
528  {
529  NSLog(@"Z6ParamValueEditView.didSelectRow: component: %ld", (long)component);
530  }
531  break;
532  default:
533  break;
534  }
535 }
Boolean editParameterSelected
NSInteger newParameterIndex
NSInteger editNutritionParameter

◆ pickerView:numberOfRowsInComponent:()

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

Definition at line 548 of file Z6ParamValueEditView.m.

548  :(UIPickerView *)pickerView
549 numberOfRowsInComponent:(NSInteger)component
550 {
551  NSInteger ret = 0;
552  switch(component) {
553  case 0:
554  {
555  NSArray<HKQuantityType *> *typesApprovedToWrite = [[[Z5DataController sharedInstance] localDataController] allHkTypes];
556  ret = [typesApprovedToWrite count];
557  }
558  break;
559  case 1:
560  case 2:
561  case 3:
562  {
563  if ( !editParameterSelected ) {
564  ret = 0;
565  } else {
566  ret = 10;
567  }
568  }
569  break;
570 
571  case 4:
572  {
573  if ( !editParameterSelected ) {
574  ret = 0;
575  } else {
576  if (pickQuantityType) {
577  HKUnit *massUnit = [HKUnit unitFromString:@"g"];
578  HKUnit *energyUnit = [HKUnit unitFromString:@"cal"];
579  if ([pickQuantityType isCompatibleWithUnit:massUnit]) {
580  ret = 4;
581  } else if ([pickQuantityType isCompatibleWithUnit:energyUnit]) {
582  ret = 2;
583  }
584  } else {
585  ret = 4;
586  NSLog(@"Z6ParamValueEditView.numberOfRowsInComponent: NULL pickQuantityType");
587  }
588  }
589  }
590  break;
591 
592  default:
593  ret = 0;
594  }
595  return ret;
596 }
Boolean editParameterSelected
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
HKQuantityType * pickQuantityType

◆ pickerView:rowHeightForComponent:()

- (CGFloat) pickerView: (UIPickerView *)  pickerView
rowHeightForComponent: (NSInteger)  component 
implementation

the picker view is an

Definition at line 276 of file Z6ParamValueEditView.m.

276  :(UIPickerView *)pickerView
277 rowHeightForComponent:(NSInteger)component
278 {
279  CGFloat ret;
280  ret = 30.0;
281  return ret;
282 }

◆ pickerView:viewForRow:forComponent:reusingView:()

- (UIView *) pickerView: (UIPickerView *)  pickerView
viewForRow: (NSInteger)  row
forComponent: (NSInteger)  component
reusingView: (UIView *)  view 
implementation

Definition at line 355 of file Z6ParamValueEditView.m.

355  :(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
356 {
357  // create attributed string
358  NSString *ret;
359 
360  if (0 == component) {
361  ret = [self stringForPickerRow:row];
362  NSLog(@"Z6ParamValueEditView.titleForRow: %ld: %@", (long)row, ret);
363  } else if (1 == component) {
364  ret = [[NSString alloc] initWithFormat:@"%ld", (long)row];
365  } else if (2 == component) {
366  ret = [[NSString alloc] initWithFormat:@"%ld", (long)row];
367  } else if (3 == component) {
368  ret = [[NSString alloc] initWithFormat:@"%ld", (long)row];
369  } else if (4 == component) {
370  // ret = [self parameterDimensionForRow:row];
371  if ([pickerWheel4Titles count] > row) {
372  ret = [pickerWheel4Titles objectAtIndex:row];
373  } else {
374  ret = @"x?v";
375  }
376  } else {
377  NSLog(@"Z6ParamValueEditView.titleForRow: unknown component: %ld", (long)component);
378  }
379 
380  UIFont *herefont = [UIFont fontWithName:@"Helvetica-Bold" size:20];
381  NSDictionary *attribs = @{
382  NSForegroundColorAttributeName: [UIColor blackColor],
383  NSFontAttributeName: herefont
384  };
385  NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:ret attributes:attribs];
386 
387  // add the string to a label's attributedText property
388  UILabel *labelView = [[UILabel alloc] init];
389  [labelView setTextAlignment:NSTextAlignmentCenter];
390  labelView.attributedText = attributedString;
391 
392  // return the label
393  return labelView;
394 }
NSMutableArray * pickerWheel4Titles

◆ pickerView:widthForComponent:()

- (CGFloat) pickerView: (UIPickerView *)  pickerView
widthForComponent: (NSInteger)  component 
implementation

Definition at line 286 of file Z6ParamValueEditView.m.

286  :(UIPickerView *)pickerView widthForComponent:(NSInteger)component
287 {
288  CGFloat ret;
289  switch (component) {
290  case 0:
291  {
292  if ( editParameterSelected ) {
293  ret = 100.0;
294  } else {
295  ret = 300;
296  }
297  }
298  break;
299 
300  case 1:
301  case 2:
302  case 3:
303  ret = 22.0;
304  break;
305 
306  case 4:
307  ret = 70.0f;
308  break;
309 
310  default:
311  ret=0;
312  break;
313  }
314 
315  // NSLog(@"Z6ParamValueEditView.widthForComponent: %3.2f", ret);
316  return ret;
317 }
Boolean editParameterSelected

◆ pickQuantityType()

- (HKQuantityType *) pickQuantityType
implementation

Definition at line 29 of file Z6ParamValueEditView.m.

◆ pickQuantityUnit()

- (HKUnit *) pickQuantityUnit
implementation

Definition at line 30 of file Z6ParamValueEditView.m.

◆ produceQuantityValue()

- (HKQuantity *) produceQuantityValue
implementation

Definition at line 164 of file Z6ParamValueEditView.m.

165 {
166  // amount
167  NSInteger hundreds = [newParameterPicker selectedRowInComponent:1];
168  NSInteger tens = [newParameterPicker selectedRowInComponent:2];
169  NSInteger ones = [newParameterPicker selectedRowInComponent:3];
170  double inputValue = 100*hundreds + 10*tens + ones;
171  double nutritionAmount = inputValue; // = pickerValue;
172  // END -- amount
173 
174  // units
175  NSUInteger unitIndex = [newParameterPicker selectedRowInComponent:4];
176  // NSString *units = [pickerWheel4Titles objectAtIndex:unitIndex];
177  HKUnit *massUnit = [HKUnit unitFromString:@"g"];
178  HKUnit *energyUnit = [HKUnit unitFromString:@"cal"];
179  HKMetricPrefix metricPrefix;
180  HKQuantity *acceptQuantity;
181  if ([pickQuantityType isCompatibleWithUnit:massUnit]) {
182  metricPrefix = massUnitsMetricPrefixArray[unitIndex];
183  HKUnit *prefixGramUnit = [HKUnit gramUnitWithMetricPrefix:metricPrefix];
184  acceptQuantity = [HKQuantity quantityWithUnit:prefixGramUnit doubleValue:nutritionAmount];
185  } else if ([pickQuantityType isCompatibleWithUnit:energyUnit]) {
186  switch(unitIndex) {
187  case 0:
188  acceptQuantity = [HKQuantity quantityWithUnit:[HKUnit calorieUnit] doubleValue:nutritionAmount];
189  break;
190  case 1:
191  acceptQuantity = [HKQuantity quantityWithUnit:[HKUnit calorieUnit] doubleValue:nutritionAmount];
192  break;
193  }
194  }
195  // END -- units
196 
197  NSLog(@"Z6ParamValueEditView.clickAcceptButton: quantity: %@", acceptQuantity);
198  return acceptQuantity;
199 }
int massUnitsMetricPrefixArray[]
HKQuantityType * pickQuantityType

◆ setPickerType:scalar:andUnit:()

- (void) setPickerType: (HKQuantityType*)  quanType
scalar: (int)  scalar
andUnit: (NSString *)  unit 
implementation

Definition at line 601 of file Z6ParamValueEditView.m.

601  :(HKQuantityType* )quanType scalar:(int)scalar andUnit:(NSString *)unit
602 {
603  NSArray *types = [[[Z5DataController sharedInstance] localDataController] availableNutritionParamArray];
604  int row = 0;
605  for (NSString *type in types) {
606  if ([type isEqualToString:[quanType description]]) {
607  // [newParameterPicker selectRow:row inComponent:0 animated:YES];
608  break;
609  }
610  row++;
611  }
612 
613  int hundreds = scalar / 100;
614  int tens = (scalar - (100*hundreds)) / 10;
615  int ones = scalar - (100*hundreds) - (10*tens);
616 
617  [newParameterPicker selectRow:hundreds inComponent:1 animated:YES];
618  [newParameterPicker selectRow:tens inComponent:2 animated:YES];
619  [newParameterPicker selectRow:ones inComponent:3 animated:YES];
620  NSLog(@"Z6ParamValueEditView.setPickerType");
621 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ setupDimensionWheel()

- (void) setupDimensionWheel
implementation

this will set up the wheel to provide a choice of metric measures, eg. kilogram, gram, milligram, microgram would be choices for a weight. picker will fetch the strings at 'titleForRow:forComponent', during a refresh, we set them up here

Definition at line 430 of file Z6ParamValueEditView.m.

431 {
432  // [newParameterPicker selectRow:row inComponent:4 animated:YES];
433 
434  pickerWheel4Titles = nil;
436  HKUnit *massUnit = [HKUnit unitFromString:@"g"];
437  HKUnit *energyUnit = [HKUnit unitFromString:@"cal"];
438  if ([pickQuantityType isCompatibleWithUnit:massUnit]) {
439  pickerWheel4Titles = [[NSMutableArray alloc] initWithArray:massUnitsArray];
440  } else if ([pickQuantityType isCompatibleWithUnit:energyUnit]) {
441  pickerWheel4Titles = [[NSMutableArray alloc] initWithArray:energyUnitsArray];
442  }
443  }
444  NSLog(@"Z6ParamValueEditView.setupDimensionWheel: count: %ld", (long)[pickerWheel4Titles count]);
445 }
NSMutableArray * pickerWheel4Titles
HKQuantityType * pickQuantityType

◆ showPickerViewNot:()

- (void) showPickerViewNot: (Boolean)  flag

From the working version: set the picker in global-USDAscreen coordinates to be 20% of the screen height. Other bounds set typically. Lazy instantiation - if the class var is nil, a picker is created with the frame, the delegate data source, and backgound color are set, and the view is added to the screen view. Adaption to factored views: picker frame is (sideMargin, topMargin, featureWid, 160.0)

Definition at line 87 of file Z6ParamValueEditView.m.

87  : (Boolean) flag
88 {
89  UIColor *okGreen = [UIColor colorWithHue:0.345
90  saturation:1.0
91  brightness:0.7
92  alpha:1.0];
93  [newParameterPicker setBackgroundColor:okGreen];
94  // [newParameterPicker setDataSource:self];
95  // [newParameterPicker setDelegate:self];
96 
97  [newParameterPicker setHidden:!flag];
98 }

◆ specializePickerView:()

- (void) specializePickerView: (NSDictionary *)  editSource

Definition at line 110 of file Z6ParamValueEditView.m.

110  : (NSDictionary *) editSource
111 {
112  NSLog(@"ParameterValueEditView.specializePickerView: editSource: %@", editSource);
113 
114  // RESTART HERE
115  // at this point, get the index of the name match, and set 'newParameterIndex'
116  NSString *incomingName = [editSource objectForKey:@"component-type"];
117  for (NSInteger parameterCardinal = 0; parameterCardinal<39; parameterCardinal++) {
118  NSString *entryName = [self stringForPickerRow:parameterCardinal];
119  if ([entryName isEqualToString:incomingName]) {
120  newParameterIndex = parameterCardinal;
121  break;
122  }
123  }
124 
125  if ( !editParameterSelected ) {
126  editParameterSelected = YES;
127  [newParameterPicker reloadAllComponents];
128  // i must set pickQuantityType and picQuantityUnit here
129  [self establishPick:newParameterIndex];
130  [newParameterPicker selectRow:newParameterIndex inComponent:0 animated:YES];
131 
132  [self setupDimensionWheel];
133  }
134 
135  [self showPickerViewNot:YES];
136 
137  NSString *caption = [editSource objectForKey:[Z5LocalDataController componentNameKey]];
138  HKQuantityType *rowQuantityType = [HKObjectType quantityTypeForIdentifier:[@"HKQuantityTypeIdentifierDietary"
139  stringByAppendingString:caption]];
140 
141  HKQuantity *componentQuanValue = [editSource objectForKey:[Z5LocalDataController componentValueKey]];
142  NSString *valueCaption = [componentQuanValue description];
143  NSArray<NSString *> *pieces = [valueCaption componentsSeparatedByString:@" "];
144  HKUnit *hkUnit = nil;
145  float quantityScalar = [pieces[0] floatValue];
146  if ([@"mcg" isEqualToString:pieces[1]]) {
147  HKMetricPrefix microPrefix = HKMetricPrefixMicro;
148  hkUnit = [HKUnit gramUnitWithMetricPrefix:microPrefix];
149  } else if ([@"mg" isEqualToString:pieces[1]]) {
150  HKMetricPrefix milliPrefix = HKMetricPrefixMilli;
151  hkUnit = [HKUnit gramUnitWithMetricPrefix:milliPrefix];
152  }
153  // HKQuantity *hkQuantity = [HKQuantity quantityWithUnit:hkUnit doubleValue:quantityScalar];
154 
155  // [self setPickerType:rowQuantityType andQuantity:hkQuantity];
156  int intScalar = (int)quantityScalar;
157  [self setPickerType:rowQuantityType scalar:intScalar andUnit:pieces[1]];
158 
159 }
Boolean editParameterSelected
NSInteger newParameterIndex

◆ stringForPickerRow:()

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

Definition at line 624 of file Z6ParamValueEditView.m.

624  : (NSInteger) row
625 {
626  NSString *ret;
627  NSArray<HKQuantityType *> *typesApprovedToWrite = [[[Z5DataController sharedInstance] localDataController] allHkTypes];
628  if ([typesApprovedToWrite count] > row) {
629  HKQuantityType *hkQtype = [typesApprovedToWrite objectAtIndex:row];
630  ret = [[hkQtype description] substringFromIndex:31];
631  } else {
632  ret = @"error?";
633  }
634  return ret;
635 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ unitForQuantityType:()

- (HKUnit *) unitForQuantityType: (HKQuantityType *)  quantityType
implementation

Definition at line 446 of file Z6ParamValueEditView.m.

446  : (HKQuantityType *)quantityType
447 {
448  // for each unit type, is it compatible with input?
449  HKUnit *ret = nil;
450  NSArray<HKUnit *> *unitsAvailable = [[NSArray alloc] initWithObjects: [HKUnit gramUnit],
451  [HKUnit meterUnit], [HKUnit literUnit], [HKUnit pascalUnit], [HKUnit secondUnit],
452  [HKUnit jouleUnit] , [HKUnit degreeCelsiusUnit], [HKUnit siemenUnit], nil];
453  for (HKUnit *u in unitsAvailable) {
454  if ([quantityType isCompatibleWithUnit:u]) {
455  ret = u;
456  break;
457  }
458  }
459  return ret;
460 }

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