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

#import <P2SnapMealInfoView.h>

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

Instance Methods

(instancetype) - initWithMeal:inFrame:delegate:
 
(float) - heightRequirement [implementation]
 
(void) - originate [implementation]
 
(void) - appear: [implementation]
 
(void) - textFieldDidEndEditing: [implementation]
 
(BOOL) - textFieldShouldReturn: [implementation]
 

Properties

MealfocusMeal
 
MealsnapMeal [implementation]
 

Detailed Description

Definition at line 29 of file P2SnapMealInfoView.h.

Method Documentation

◆ appear:()

- (void) appear: (CGRect)  bound
implementation

Definition at line 106 of file P2SnapMealInfoView.m.

106  : (CGRect) bound
107 {
108  NSLog(@"MenuMealInfoView.appear: width: %3.2f outer: %3.2f", self.bounds.size.width, bound.size.width);
109 
110  [snapMealImageView setFrame:focusMealImageFrame];
111  [snapMealCaptionTextField setFrame:mealCaptionFrame];
112 }

◆ heightRequirement()

- (float) heightRequirement
implementation

Definition at line 31 of file P2SnapMealInfoView.m.

32 {
33  return 300;
34 }

◆ initWithMeal:inFrame:delegate:()

- (instancetype) initWithMeal: (Meal *)  meal
inFrame: (CGRect)  frame
delegate: (id<P2SnapMealInfoProtocol>)  delegate 

Definition at line 46 of file P2SnapMealInfoView.m.

46  :(Meal *)meal inFrame:(CGRect)frame delegate:(id<P2SnapMealInfoProtocol>)delegate
47 {
48  self = [super initWithFrame:frame];
49  if (self) {
50  _focusMeal = meal;
51 
53  [self originate];
54 
55  UIImage *mealImage = [UIImage imageWithData:meal.photo];
56  [snapMealImageView setImage:mealImage];
57  }
58  return self;
59 }
id< P2SnapMealInfoProtocol > mMealInfoDelegate
id< U7ParamEditControlDelegate > delegate

◆ originate()

- (void) originate
implementation

Definition at line 60 of file P2SnapMealInfoView.m.

61 {
62  float totalWidth = self.bounds.size.width;
63  float totalHeight = self.bounds.size.height;
64  mealCaptionFrame = CGRectMake(6, 6, totalWidth - 12 - 60, 60);
65  reviewApproveFrame = CGRectMake(totalWidth-60, 6, 60, 60);
66  focusMealImageFrame = CGRectMake(6, 74, totalWidth - 12, totalHeight - 78);
67 
68  snapMealImageView = [[UIImageView alloc] initWithFrame:focusMealImageFrame];
69  [snapMealImageView.layer setBorderColor: [[UIColor blackColor] CGColor]];
70  [snapMealImageView.layer setBorderWidth: 2.0];
71  snapMealImageView.layer.cornerRadius = 8.0f;
72  snapMealImageView.layer.masksToBounds = YES;
73  snapMealImageView.image = [UIImage imageWithData:_focusMeal.photo];
74  [self addSubview:snapMealImageView];
75 
76  UIFont *herefont = [UIFont fontWithName:@"Helvetica-Bold" size:22];
77  NSDictionary *attribs = @{
78  NSForegroundColorAttributeName: [UIColor blackColor],
79  NSFontAttributeName: herefont
80  };
81  snapMealCaptionTextField = [[Z5TextField alloc] initWithFrame:mealCaptionFrame];
82  [snapMealCaptionTextField setBackgroundColor:[[Z5DataController sharedInstance] wheatColor]];
83 
84  reviewApprovalButton = [[UIButton alloc] initWithFrame:reviewApproveFrame];
85  UIImage *reviewApprovalImage = [UIImage imageNamed:@"finishIcon60.png"];
86  [reviewApprovalButton setImage:reviewApprovalImage forState:UIControlStateNormal];
87  [reviewApprovalButton addTarget:mMealInfoDelegate action:@selector(reviewComplete) forControlEvents:UIControlEventTouchUpInside];
88  [self addSubview:reviewApprovalButton];
89 
90  NSString *focusName = [_focusMeal caption];
91  if (focusName) {
92  NSMutableAttributedString *attributedText =
93  [[NSMutableAttributedString alloc] initWithString:focusName
94  attributes:attribs];
95  [snapMealCaptionTextField setAttributedText:attributedText];
96  } else {
97  [snapMealCaptionTextField setPlaceholder:@"enter menu item name"];
98  }
99  [snapMealCaptionTextField setTextAlignment:NSTextAlignmentCenter];
100  snapMealCaptionTextField.layer.cornerRadius = 8.0f;
101  snapMealCaptionTextField.layer.masksToBounds = YES;
102  [snapMealCaptionTextField setDelegate:self];
103  [self addSubview:snapMealCaptionTextField];
104 }
CGRect reviewApproveFrame
instancetype sharedInstance()
CGRect focusMealImageFrame
Singleton interface to both core and remote data sources.
CGRect mealCaptionFrame
UITextField * snapMealCaptionTextField
UIButton * reviewApprovalButton

◆ textFieldDidEndEditing:()

- (void) textFieldDidEndEditing: (UITextField *)  textField
implementation

Definition at line 118 of file P2SnapMealInfoView.m.

118  :(UITextField *)textField
119 {
120  [self.focusMeal setCaption:[textField text]];
121 }

◆ textFieldShouldReturn:()

- (BOOL) textFieldShouldReturn: (UITextField *)  textField
implementation

Definition at line 122 of file P2SnapMealInfoView.m.

122  :(UITextField *)textField {
123  [textField resignFirstResponder];
124  return NO;
125 }

Property Documentation

◆ focusMeal

- (Meal*) focusMeal
readwritenonatomicstrong

Definition at line 30 of file P2SnapMealInfoView.h.

◆ snapMeal

- (Meal*) snapMeal
readwritenonatomicstrongimplementation

Definition at line 15 of file P2SnapMealInfoView.m.


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