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

#import <CameraSnapViewController.h>

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

Instance Methods

(id) - initWithNibName:bundle: [implementation]
 
(void) - viewDidLoad [implementation]
 
(void) - generateLoginControlbar [implementation]
 
(void) - viewWillAppear: [implementation]
 
(void) - addButtons [implementation]
 
(void) - fireDataCollectScreen [implementation]
 
(void) - webView:didFinishNavigation: [implementation]
 
(void) - cameraButtonHit [implementation]
 
(void) - picturesButtonHit [implementation]
 
(void) - messagesButtonHit [implementation]
 
(void) - usdaButtonHit [implementation]
 
(void) - driveButtonHit [implementation]
 
(void) - webButtonHit [implementation]
 
(void) - imagePickerController:didFinishPickingMediaWithInfo: [implementation]
 
(void) - returnFromEntryReviewWithInfo: [implementation]
 
(void) - imagePickerControllerDidCancel: [implementation]
 
(void) - fireMealEntryReviewScreen [implementation]
 
(BOOL) - startPictureControllerFromViewController:usingDelegate: [implementation]
 
(void) - updatedParameterArray: [implementation]
 
(float) - resizeParameterFrame [implementation]
 
(void) - didSelectParameterRow: [implementation]
 
(float) - parameterViewHeight [implementation]
 
(void) - popPushController: [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 
(void) - regenerateLoginView [implementation]
 

Class Methods

(BOOL) + startCameraControllerFromViewController:usingDelegate:
 

Detailed Description

cameraSnap.png
dot_inline_dotgraph_2.png

Definition at line 16 of file CameraSnapViewController.h.

Method Documentation

◆ addButtons()

- (void) addButtons
implementation

Definition at line 146 of file CameraSnapViewController.m.

147 {
148  CGRect totalFrame = self.view.frame;
149 
150  float topButtonTop = 0.72;
151  float buttonInterval = 0.088;
152  float cameraButtonTop = totalFrame.size.height * topButtonTop;
153  float picturesButtonTop = totalFrame.size.height * (topButtonTop+buttonInterval);
154  float messagesButtonTop = totalFrame.size.height * (topButtonTop+2*buttonInterval);
155  // float driveButtonTop = totalFrame.size.height * (topButtonTop+3*buttonInterval);
156  // float webButtonTop = totalFrame.size.height * (topButtonTop+4*buttonInterval);
157  float buttonColumn1LeftEdge = totalFrame.size.width * 0.02;
158  float buttonColumn2LeftEdge = totalFrame.size.width * 0.52;
159  float buttonWidth = totalFrame.size.width * 0.44;
160 
161  CGRect buttonCameraFrame = CGRectMake(buttonColumn1LeftEdge,
162  cameraButtonTop,
163  buttonWidth,
164  totalFrame.size.height * 0.08);
166  withFrame:buttonCameraFrame
167  andFont:nil];
168  [buttonCammera addTarget:self
169  action:@selector(cameraButtonHit)
170  forControlEvents:UIControlEventTouchUpInside];
171  [self.view addSubview:buttonCammera];
172 
173  CGRect buttonPicturesFrame = CGRectMake(buttonColumn1LeftEdge,
174  picturesButtonTop,
175  buttonWidth,
176  totalFrame.size.height * 0.08);
178  withFrame:buttonPicturesFrame
179  andFont:nil];
180  [buttonPictures addTarget:self
181  action:@selector(picturesButtonHit)
182  forControlEvents:UIControlEventTouchUpInside];
183  [self.view addSubview:buttonPictures];
184 
185  CGRect buttonMessagesFrame = CGRectMake(buttonColumn1LeftEdge,
186  messagesButtonTop,
187  buttonWidth,
188  totalFrame.size.height * 0.08);
190  withFrame:buttonMessagesFrame
191  andFont:nil];
192  [buttonMessages addTarget:self
193  action:@selector(messagesButtonHit)
194  forControlEvents:UIControlEventTouchUpInside];
195  [self.view addSubview:buttonMessages];
196 
197  CGRect buttonUSDAFrame = CGRectMake(buttonColumn2LeftEdge,
198  cameraButtonTop,
199  buttonWidth,
200  totalFrame.size.height * 0.08);
202  withFrame:buttonUSDAFrame
203  andFont:nil];
204  [buttonUSDA addTarget:self
205  action:@selector(usdaButtonHit)
206  forControlEvents:UIControlEventTouchUpInside];
207  [self.view addSubview:buttonUSDA];
208 
209  CGRect buttonDriveFrame = CGRectMake(buttonColumn2LeftEdge,
210  picturesButtonTop,
211  buttonWidth,
212  totalFrame.size.height * 0.08);
214  withFrame:buttonDriveFrame
215  andFont:nil];
216  [buttonDrive addTarget:self
217  action:@selector(driveButtonHit)
218  forControlEvents:UIControlEventTouchUpInside];
219  [self.view addSubview:buttonDrive];
220 
221  CGRect buttonWebFrame = CGRectMake(buttonColumn2LeftEdge,
222  messagesButtonTop,
223  buttonWidth,
224  totalFrame.size.height * 0.08);
226  withFrame:buttonWebFrame
227  andFont:nil];
228  [buttonWeb addTarget:self
229  action:@selector(webButtonHit)
230  forControlEvents:UIControlEventTouchUpInside];
231  [self.view addSubview:buttonWeb];
232 }
UIButton * buttonDrive
UIButton * buttonUSDA
UIButton * buttonPictures
UIButton * buttonWeb
UIButton * buttonCammera
Singleton interface to both core and remote data sources.
UIButton * buttonMessages
UIButton * makeGradientButton:withFrame:andFont:(NSString *caption, [withFrame] CGRect buttonFrame, [andFont] UIFont *buttonFont)

◆ cameraButtonHit()

- (void) cameraButtonHit
implementation

Definition at line 254 of file CameraSnapViewController.m.

255 {
257 }
BOOL startCameraControllerFromViewController:usingDelegate:(UIViewController *controller, [usingDelegate] id< UINavigationControllerDelegate, UIImagePickerControllerDelegate > delegate)

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 497 of file CameraSnapViewController.m.

498  {
499  [super didReceiveMemoryWarning];
500  // Dispose of any resources that can be recreated.

◆ didSelectParameterRow:()

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

Definition at line 457 of file CameraSnapViewController.m.

458  : (NSIndexPath *)iPath
459 {
460  // editParameterIndexRow = [iPath row];

◆ driveButtonHit()

- (void) driveButtonHit
implementation

Definition at line 274 of file CameraSnapViewController.m.

275 {
276  V7GoogDriveViewController *gDriveVC = [[V7GoogDriveViewController alloc] init];
277  [self.navigationController pushViewController:gDriveVC animated:YES];
278 
279 
280  // SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
281  // [self.navigationController pushViewController:secondVC animated:YES];
282 }

◆ fireDataCollectScreen()

- (void) fireDataCollectScreen
implementation

Definition at line 234 of file CameraSnapViewController.m.

235 {
236  // NSDate *now = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
237 
238  U7UsdaParamEntryViewController *recipeView =
239  [[U7UsdaParamEntryViewController alloc] initWithMenuItem:menuItem];
240  [self.navigationController pushViewController:recipeView animated:YES];
241 }

◆ fireMealEntryReviewScreen()

- (void) fireMealEntryReviewScreen
implementation

Definition at line 365 of file CameraSnapViewController.m.

366 {
367  }

◆ generateLoginControlbar()

- (void) generateLoginControlbar
implementation

Definition at line 133 of file CameraSnapViewController.m.

134 {
135  CGRect totalFrame = self.view.frame;
136  float loginControlbarHeight = 52;
137  CGRect loginControlbarFrame = CGRectMake(32, topOfLoginControlbar, totalFrame.size.width - 64, loginControlbarHeight);
138  loginControlbar = [[V7GoogleLoginControlbar alloc] initWithFrame:loginControlbarFrame andDelegate:self];
139  [self.view addSubview:loginControlbar];
140 }
float topOfLoginControlbar
V7GoogleLoginControlbar * loginControlbar

◆ imagePickerController:didFinishPickingMediaWithInfo:()

- (void) imagePickerController: (UIImagePickerController *)  picker
didFinishPickingMediaWithInfo: (NSDictionary<NSString *,id> *)  info 
implementation

Definition at line 291 of file CameraSnapViewController.m.

291  :(UIImagePickerController *)picker
292 didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
293 {
294  mealEntryReviewPicker = picker;
295 
296  P2SnapMealEntryViewController *recipeView =
297  [[P2SnapMealEntryViewController alloc] init];
298  [self.navigationController pushViewController:recipeView animated:YES];
299 }
UIImagePickerController * mealEntryReviewPicker

◆ imagePickerControllerDidCancel:()

- (void) imagePickerControllerDidCancel: (UIImagePickerController *)  picker
implementation

Definition at line 360 of file CameraSnapViewController.m.

360  :(UIImagePickerController *)picker
361 {
362  NSLog(@"CameraSnap.imagePickerControllerDidCancel");
363  [picker dismissViewControllerAnimated:YES completion:nil];
364 };

◆ initWithNibName:bundle:()

- (id) initWithNibName: (NSString *)  nibNameOrNil
bundle: (NSBundle *)  nibBundleOrNil 
implementation

Definition at line 74 of file CameraSnapViewController.m.

74  :(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
75 {
76  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
77  if (self) {
78  // Custom initialization
79  self.title = @"Create";
80  [self.view setBackgroundColor:[UIColor colorWithWhite:0.7f alpha:1.0f]];
81  usdaParameterArray = [[NSMutableArray alloc] init];
82  }
83  return self;
84 }
NSMutableArray * usdaParameterArray

◆ messagesButtonHit()

- (void) messagesButtonHit
implementation

Definition at line 262 of file CameraSnapViewController.m.

263 {
264  Y3GmailViewController *googleBit = [[Y3GmailViewController alloc] init];
265  [googleBit setParentController:self];
266  [self.navigationController pushViewController:googleBit animated:YES];
267 }
Fetch all marked emails into the local database, and display a list.

◆ parameterViewHeight()

- (float) parameterViewHeight
implementation

Definition at line 466 of file CameraSnapViewController.m.

468 {
469  CGRect totalFrame = self.view.frame;
470  float paramLineHgt = 42.0 / totalFrame.size.height;
471  // float paramLineHgt = 30;
472 
473  // NSLog(@"CameraSnapViewController.parameterViewHeight: nutrComp count: %ld",[focusUSDAparameterArray count]);
474 
475  float suggestedParamHeight = paramLineHgt * [usdaParameterArray count]; // = 42;
476  if (0.28 < suggestedParamHeight) {
477  suggestedParamHeight = 0.28;
478  }
479  // float parameterViewHeight = totalFrame.size.height * 0.30;
480  float parameterViewHeight = totalFrame.size.height * suggestedParamHeight;
481  // NSLog(@"CameraSnapViewController.parameterViewHeight: parameterViewHeight: %3.2f", parameterViewHeight);
482  return parameterViewHeight;

◆ picturesButtonHit()

- (void) picturesButtonHit
implementation

Definition at line 258 of file CameraSnapViewController.m.

259 {
260  [self startPictureControllerFromViewController:self usingDelegate:self];
261 }

◆ popPushController:()

- (void) popPushController: (UIViewController *)  rebuildVC
implementation

Definition at line 484 of file CameraSnapViewController.m.

485  :(UIViewController *)rebuildVC
486 {
487  NSString *rebuildClassStr = NSStringFromClass([rebuildVC class]);
488  if ([rebuildClassStr isEqualToString:@"Y3GmailViewController"]) {
489  UIViewController *popped = [self.navigationController popViewControllerAnimated:NO];
490  NSLog(@"CameraSnapViewController.popPushController: %@", NSStringFromClass([popped class]));
491 
492  // NSLog(@"CameraSnapViewController.popPushController: HIT MESSAGES BUTTON");
493  [self messagesButtonHit];
494  }

◆ regenerateLoginView()

- (void) regenerateLoginView
implementation

Definition at line 502 of file CameraSnapViewController.m.

504 {
505  [loginControlbar removeFromSuperview];
506  [NSThread sleepForTimeInterval:5.0]; // seconds
507  [self generateLoginControlbar];

◆ resizeParameterFrame()

- (float) resizeParameterFrame
implementation

Definition at line 441 of file CameraSnapViewController.m.

443 {
444  /*
445  CGRect totalFrame = self.view.frame;
446  float leftMargin = 0.02*totalFrame.size.width;
447  float topMargin = 48;
448  float portalHeight = 280;
449  float controlWidth = 0.96*totalFrame.size.width;
450  */
451 
452  float parameterPanelHeight = [self parameterViewHeight];
453  // CGRect menuItemParametersFrame = CGRectMake(leftMargin, topMargin + portalHeight +4, controlWidth, parameterPanelHeight);
454  // [parameterTableView setFrame:menuItemParametersFrame];
455  return parameterPanelHeight;

◆ returnFromEntryReviewWithInfo:()

- (void) returnFromEntryReviewWithInfo: (NSDictionary<NSString *,id> *)  info
implementation

Definition at line 300 of file CameraSnapViewController.m.

300  :(NSDictionary<NSString *,id> *)info
301 {
302  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
303  // NSLog(@"CameraSnap.didFinishPickingMediaWithInfo: info: %@", info);
304  // UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
305 
306  NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
307  UIImage *originalImage, *editedImage, *imageToSave;
308 
309  // Handle a still image capture
310  if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0)
311  == kCFCompareEqualTo) {
312 
313  editedImage = (UIImage *) [info objectForKey:
314  UIImagePickerControllerEditedImage];
315  originalImage = (UIImage *) [info objectForKey:
316  UIImagePickerControllerOriginalImage];
317 
318  if (editedImage) {
319  imageToSave = editedImage;
320  } else {
321  imageToSave = originalImage;
322  }
323 
324  // Save the new image (original or edited) to the Camera Roll
325  // UIImageWriteToSavedPhotosAlbum (imageToSave, nil, nil , nil);
326 
327  NSString *randomkey = [Z5DataController produceRandomkey];
328  menuItem = [localData findOrCreateMenuItemWithRandomkey:randomkey];
329  menuItem.photo = UIImageJPEGRepresentation(imageToSave, 0.90);
330  menuItem.galleryNumber = [NSNumber numberWithInt:1];
331 
332  usdaParameterArray = [[NSMutableArray alloc] init];
333  // [parameterTableView update:nil];
334 
335  [cameraImage setImage:imageToSave];
336  [buttonCammera setHidden:YES];
337  [buttonPictures setHidden:YES];
338  [buttonMessages setHidden:YES];
339  [buttonDrive setHidden:YES];
340  [buttonWeb setHidden:YES];
341  [addDataButton setHidden:NO];
342  }
343 
344  // Handle a movie capture
345  if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
346  == kCFCompareEqualTo) {
347 
348  NSString *moviePath = [[info objectForKey:
349  UIImagePickerControllerMediaURL] path];
350 
351  if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
352  UISaveVideoAtPathToSavedPhotosAlbum (
353  moviePath, nil, nil, nil);
354  }
355  }
356 
357  [mealEntryReviewPicker dismissViewControllerAnimated:YES completion:nil];
358 
359 }
NSString * produceRandomkey()
MenuItem * menuItem
instancetype sharedInstance()
Singleton interface to both core and remote data sources.
NSMutableArray * usdaParameterArray
MenuItem * findOrCreateMenuItemWithRandomkey:(NSString *randomkey)

◆ startCameraControllerFromViewController:usingDelegate:()

+ (BOOL) startCameraControllerFromViewController: (UIViewController*)  controller
usingDelegate: (id <UINavigationControllerDelegate,UIImagePickerControllerDelegate>)  delegate 

Definition at line 368 of file CameraSnapViewController.m.

368  : (UIViewController*) controller
369  usingDelegate: (id <UINavigationControllerDelegate,UIImagePickerControllerDelegate>) delegate
370 {
371 
372  if (([UIImagePickerController isSourceTypeAvailable:
373  UIImagePickerControllerSourceTypeCamera] == NO)
374  || (delegate == nil)
375  || (controller == nil)) {
376  NSLog(@"CameraSnap.startCameraControllerFromViewController: no source");
377  return NO;
378  }
379 
380 
381  UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
382  cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
383 
384  // Displays a control that allows the user to choose picture or
385  // movie capture, if both are available:
386  cameraUI.mediaTypes =
387  [UIImagePickerController availableMediaTypesForSourceType:
388  UIImagePickerControllerSourceTypeCamera];
389 
390  // Hides the controls for moving & scaling pictures, or for
391  // trimming movies. To instead show the controls, use YES.
392  cameraUI.allowsEditing = NO;
393 
394  cameraUI.delegate = delegate;
395 
396  [controller presentViewController: cameraUI animated: YES completion:^(void) {
397 
398  // this completion handler is running within a class function.
399  NSLog(@"CameraSnapViewContoller.camera controller complete");
400 
401  }];
402  return YES;
403 }
id< U7ParamEditControlDelegate > delegate

◆ startPictureControllerFromViewController:usingDelegate:()

- (BOOL) startPictureControllerFromViewController: (UIViewController*)  controller
usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>)  delegate 
implementation

Definition at line 404 of file CameraSnapViewController.m.

404  : (UIViewController*) controller
405  usingDelegate: (id <UIImagePickerControllerDelegate,
406  UINavigationControllerDelegate>) delegate {
407 
408  if (([UIImagePickerController isSourceTypeAvailable:
409  UIImagePickerControllerSourceTypeCamera] == NO)
410  || (delegate == nil)
411  || (controller == nil)) {
412  NSLog(@"CameraSnap.startCameraControllerFromViewController: no source");
413  return NO;
414  }
415 
416 
417  UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
418  cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
419 
420  // Displays a control that allows the user to choose picture or
421  // movie capture, if both are available:
422  cameraUI.mediaTypes =
423  [UIImagePickerController availableMediaTypesForSourceType:
424  UIImagePickerControllerSourceTypePhotoLibrary];
425 
426  // Hides the controls for moving & scaling pictures, or for
427  // trimming movies. To instead show the controls, use YES.
428  cameraUI.allowsEditing = YES;
429 
430  cameraUI.delegate = delegate;
431 
432  [controller presentViewController: cameraUI animated: YES completion:^(void) {
433  NSLog(@"CameraSnap.starPictureController");
434  }];
435  return YES;
id< U7ParamEditControlDelegate > delegate

◆ updatedParameterArray:()

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

Definition at line 437 of file CameraSnapViewController.m.

438  :(NSArray *)menuItemArray
439 {
440  NSLog(@"CameraSnapViewController.updatedParameterArray: ??");

◆ usdaButtonHit()

- (void) usdaButtonHit
implementation

Definition at line 268 of file CameraSnapViewController.m.

269 {
270  V7USDAdataViewController *gUsdaVC = [[V7USDAdataViewController alloc] init];
271  [self.navigationController pushViewController:gUsdaVC animated:YES];
272 }

◆ viewDidLoad()

- (void) viewDidLoad
implementation

Definition at line 86 of file CameraSnapViewController.m.

86  {
87  [super viewDidLoad];
88  // Do any additional setup after loading the view.
89 
90  lightGreenColor = [UIColor colorWithRed:0.2 green:1.0 blue:0.5 alpha:1.0];
91 
92  instructionHTML = @"<html><body style=\"background-color:#f0c07d;margin:20;padding-top:36;padding-left:160;top-margin:8\"><font size=\"+6\" face=\"verdana\"><b>Create a new menu item</b><ul><li> from your Camera<li>or Photos<li> from a message in your email<li> from a shared folder on Google-Drive<li> or from the web</ul></b></font></body></html>";
93 
94  self.tabBarItem.image = [UIImage imageNamed:@"picture_3"];
95  CGRect totalFrame = self.view.frame;
96  float navigationBarHeight = 62.0;
97  float instructionPanelHeight = 192.0;
98 
99  // [self.view setBackgroundColor:[[Z5DataController sharedInstance] wheatColor]];
100 
101  UIImage *backgrdImage = [UIImage imageNamed:@"empty_table.png"];
102  UIImageView *backgrd = [[UIImageView alloc] initWithImage:backgrdImage];
103  float topSpace = navigationBarHeight + instructionPanelHeight;
104  topSpace = 0.0; // TODO: tune page placement
105  CGRect backImageFrame = CGRectMake(0.0, topSpace, totalFrame.size.width, totalFrame.size.height - topSpace);
106  [backgrd setFrame:backImageFrame];
107  [self.view addSubview:backgrd];
108 
109  [self addButtons];
110 
111  CGRect webViewFrame = CGRectMake(32,
112  navigationBarHeight+8,
113  totalFrame.size.width - 64,
114  instructionPanelHeight);
115  webView = [[WKWebView alloc] initWithFrame:webViewFrame];
116  webView.navigationDelegate = self;
117  webView.UIDelegate = nil;
118  // background-color:#e5ceb3;
119  // background-image:url(\"tiffany_gradient.png\");
120  [webView loadHTMLString:instructionHTML baseURL:nil];
121  [webView setOpaque:NO];
122  webView.layer.cornerRadius = 8;
123  webView.layer.borderColor = [[UIColor blackColor] CGColor];
124  webView.layer.borderWidth = 3.0;
125  webView.clipsToBounds = YES;
126  [self.view addSubview:webView];
127 
128  topOfLoginControlbar = navigationBarHeight+8 + instructionPanelHeight + 8;
129 
130  [self generateLoginControlbar];
131 }
float topOfLoginControlbar
WKWebView * webView
NSString * instructionHTML
UIColor * lightGreenColor

◆ viewWillAppear:()

- (void) viewWillAppear: (BOOL)  animated
implementation

Definition at line 141 of file CameraSnapViewController.m.

141  :(BOOL)animated
142 {
143  NSLog(@"CameraSnapViewController.viewWillAppear");
144  [loginControlbar appear];
145 }

◆ webButtonHit()

- (void) webButtonHit
implementation

Definition at line 283 of file CameraSnapViewController.m.

284 {
285  U4WebViewController *gWebVC = [[U4WebViewController alloc] init];
286  [self.navigationController pushViewController:gWebVC animated:YES];
287 }

◆ webView:didFinishNavigation:()

- (void) webView: (WKWebView *)  webView2
didFinishNavigation: (WKNavigation *)  navigation 
implementation

Definition at line 245 of file CameraSnapViewController.m.

245  :(WKWebView *)webView2 didFinishNavigation:(WKNavigation *)navigation
246 {
247  NSLog(@"CameraSnapViewController.didFinishNavigation");
248 
249  // NSInteger height = 260;
250  // [NSThread sleepForTimeInterval:.5];
251  // NSString* javascript = [NSString stringWithFormat:@"window.scrollBy(0, %ld);", (long)height];
252  // [webView2 evaluateJavaScript:javascript completionHandler:^(id objec, NSError *error) { /* objec = null */ } ];
253 }

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