Today's Menu  Portugal
journal and plan nutrition
V7foodTextFieldView.m
Go to the documentation of this file.
1 //
2 // V7foodTextFieldView.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 6/22/18.
6 // Copyright © 2018 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
9 #import "V7foodTextFieldView.h"
10 #import "Z5DataController.h"
11 
12 @implementation V7foodTextFieldView
13 {
14  id<V7foodTextFieldDelegate> delegate;
15  UILabel *captionLabel;
16  // UITextField *foodEntryTextField;
17  UIButton *scanDatabaseButton;
18 }
19 @synthesize foodTextField = _foodTextField;
20 
21 - (instancetype) initWithDelegate: (id<V7foodTextFieldDelegate>) dele
22 {
23  self = [super init];
24  if (self) {
25  delegate = dele;
26  [self originate];
27  }
28  return self;
29 }
30 - (void) originate
31 {
32  [self setClipsToBounds:YES];
33 
34  CGRect headerViewFrame = CGRectMake(4.0f, 70.0f, 100.0f, 100.0f);
35  [self setFrame:headerViewFrame];
36 
37  CGRect captionLabelFrame = CGRectMake(2.0f, 2.0f, 50.0f, 35.0f);
38  captionLabel = [[UILabel alloc] initWithFrame:captionLabelFrame];
39  [captionLabel setText:@"Food "];
40  [captionLabel setTextColor:[UIColor blackColor]];
41 
42  CGRect foodEntryTextFieldFrame = CGRectMake(54.0f, 2.0f, 180.0f, 35.0f);
43  _foodTextField = [[UITextField alloc] initWithFrame:foodEntryTextFieldFrame];
44  [_foodTextField setBackgroundColor:[UIColor lightGrayColor]];
45 
46  CGRect scanDatabaseButtonFrame = CGRectMake(240.0f, 2.0f, 100.0f, 35.0f);
47  scanDatabaseButton = [[UIButton alloc] initWithFrame:scanDatabaseButtonFrame];
48  [self showUSDAFoodDatabaseResponse:USDAFoodInit];
49  [scanDatabaseButton addTarget:delegate action:@selector(clickScan) forControlEvents:UIControlEventTouchDown];
50  [Z5DataController labelizeButton:scanDatabaseButton withText:@"scan"];
51 
52  [self addSubview:captionLabel];
53  [self addSubview:_foodTextField];
54  [self addSubview:scanDatabaseButton];
55 }
56 
57 - (void) showUSDAFoodDatabaseResponse:(USDAFoodDatabaseStatus)flag
58 {
59  switch(flag) {
60  case USDAFoodInit:
61  {
62  [scanDatabaseButton setBackgroundColor:[UIColor whiteColor]];
63  }
64  break;
66  {
67  [scanDatabaseButton setBackgroundColor:[UIColor magentaColor]];
68  }
69  break;
71  {
72  [scanDatabaseButton setBackgroundColor:[UIColor greenColor]];
73  }
74  break;
76  {
77  [scanDatabaseButton setBackgroundColor:[UIColor orangeColor]];
78  }
79  break;
80  }
81 }
82 
83 #pragma mark - Z6ContainedView protocol
85 {
86  float returnHeight = 36.0f;
87 
88  return returnHeight;
89 }
90 - (void) appear:(CGRect)bound
91 {
92 // NSLog(@"FoodTextFieldView.appear: bound: %3.2f/%3.2f, %3.2f/%3.2f",
93 // bound.origin.x, bound.origin.y, bound.size.width, bound.size.height);
94 // NSLog(@"FoodTextFieldView.appear: foodEntryTextField: %@", _foodTextField);
95 }
96 
97 /*
98 // Only override drawRect: if you perform custom drawing.
99 // An empty implementation adversely affects performance during animation.
100 - (void)drawRect:(CGRect)rect {
101  // Drawing code
102 }
103 */
104 
105 @end
id< U7ParamEditControlDelegate > delegate
Singleton interface to both core and remote data sources.
void labelizeButton:withText:(UIButton *targButton, [withText] NSString *txt)
UILabel * captionLabel
UITextField * foodTextField
UIButton * scanDatabaseButton
void showUSDAFoodDatabaseResponse:(USDAFoodDatabaseStatus flag)