9 #import <MobileCoreServices/MobileCoreServices.h> 74 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
76 self = [
super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
79 self.title =
@"Create";
80 [
self.view setBackgroundColor:[UIColor colorWithWhite:0.7f alpha:1.0f]];
90 lightGreenColor = [UIColor colorWithRed:0.2 green:1.0 blue:0.5 alpha:1.0];
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>";
94 self.tabBarItem.image = [UIImage imageNamed:@"picture_3"];
95 CGRect totalFrame =
self.view.frame;
96 float navigationBarHeight = 62.0;
97 float instructionPanelHeight = 192.0;
101 UIImage *backgrdImage = [UIImage imageNamed:@"empty_table.png"];
102 UIImageView *backgrd = [[UIImageView alloc] initWithImage:backgrdImage];
103 float topSpace = navigationBarHeight + instructionPanelHeight;
105 CGRect backImageFrame = CGRectMake(0.0, topSpace, totalFrame.size.width, totalFrame.size.height - topSpace);
106 [backgrd setFrame:backImageFrame];
107 [
self.view addSubview:backgrd];
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;
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;
126 [
self.view addSubview:webView];
135 CGRect totalFrame =
self.view.frame;
136 float loginControlbarHeight = 52;
137 CGRect loginControlbarFrame = CGRectMake(32,
topOfLoginControlbar, totalFrame.size.width - 64, loginControlbarHeight);
139 [
self.view addSubview:loginControlbar];
141 - (void) viewWillAppear:(BOOL)animated
143 NSLog(
@"CameraSnapViewController.viewWillAppear");
144 [loginControlbar appear];
148 CGRect totalFrame =
self.view.frame;
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);
157 float buttonColumn1LeftEdge = totalFrame.size.width * 0.02;
158 float buttonColumn2LeftEdge = totalFrame.size.width * 0.52;
159 float buttonWidth = totalFrame.size.width * 0.44;
161 CGRect buttonCameraFrame = CGRectMake(buttonColumn1LeftEdge,
164 totalFrame.size.height * 0.08);
168 [buttonCammera addTarget:self
169 action:@selector(cameraButtonHit)
170 forControlEvents:UIControlEventTouchUpInside];
171 [
self.view addSubview:buttonCammera];
173 CGRect buttonPicturesFrame = CGRectMake(buttonColumn1LeftEdge,
176 totalFrame.size.height * 0.08);
180 [buttonPictures addTarget:self
181 action:@selector(picturesButtonHit)
182 forControlEvents:UIControlEventTouchUpInside];
183 [
self.view addSubview:buttonPictures];
185 CGRect buttonMessagesFrame = CGRectMake(buttonColumn1LeftEdge,
188 totalFrame.size.height * 0.08);
192 [buttonMessages addTarget:self
193 action:@selector(messagesButtonHit)
194 forControlEvents:UIControlEventTouchUpInside];
195 [
self.view addSubview:buttonMessages];
197 CGRect buttonUSDAFrame = CGRectMake(buttonColumn2LeftEdge,
200 totalFrame.size.height * 0.08);
204 [buttonUSDA addTarget:self
205 action:@selector(usdaButtonHit)
206 forControlEvents:UIControlEventTouchUpInside];
207 [
self.view addSubview:buttonUSDA];
209 CGRect buttonDriveFrame = CGRectMake(buttonColumn2LeftEdge,
212 totalFrame.size.height * 0.08);
216 [buttonDrive addTarget:self
217 action:@selector(driveButtonHit)
218 forControlEvents:UIControlEventTouchUpInside];
219 [
self.view addSubview:buttonDrive];
221 CGRect buttonWebFrame = CGRectMake(buttonColumn2LeftEdge,
224 totalFrame.size.height * 0.08);
228 [buttonWeb addTarget:self
229 action:@selector(webButtonHit)
230 forControlEvents:UIControlEventTouchUpInside];
231 [
self.view addSubview:buttonWeb];
240 [
self.navigationController pushViewController:recipeView animated:YES];
243 #pragma mark - WKUIDelegate 245 - (void)
webView:(WKWebView *)webView2 didFinishNavigation:(WKNavigation *)navigation
247 NSLog(
@"CameraSnapViewController.didFinishNavigation");
265 [googleBit setParentController:self];
266 [
self.navigationController pushViewController:googleBit animated:YES];
271 [
self.navigationController pushViewController:gUsdaVC animated:YES];
277 [
self.navigationController pushViewController:gDriveVC animated:YES];
286 [
self.navigationController pushViewController:gWebVC animated:YES];
289 #pragma mark - UIImagePickerControllerDelegate 291 - (void)imagePickerController:(UIImagePickerController *)picker
292 didFinishPickingMediaWithInfo:(NSDictionary<NSString *,
id> *)info
298 [
self.navigationController pushViewController:recipeView animated:YES];
300 - (void) returnFromEntryReviewWithInfo:(NSDictionary<NSString *,
id> *)info
306 NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
307 UIImage *originalImage, *editedImage, *imageToSave;
310 if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0)
311 == kCFCompareEqualTo) {
313 editedImage = (UIImage *) [info objectForKey:
314 UIImagePickerControllerEditedImage];
315 originalImage = (UIImage *) [info objectForKey:
316 UIImagePickerControllerOriginalImage];
319 imageToSave = editedImage;
321 imageToSave = originalImage;
329 menuItem.
photo = UIImageJPEGRepresentation(imageToSave, 0.90);
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];
345 if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
346 == kCFCompareEqualTo) {
348 NSString *moviePath = [[info objectForKey:
349 UIImagePickerControllerMediaURL] path];
351 if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
352 UISaveVideoAtPathToSavedPhotosAlbum (
353 moviePath, nil, nil, nil);
357 [mealEntryReviewPicker dismissViewControllerAnimated:YES completion:nil];
360 - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
362 NSLog(
@"CameraSnap.imagePickerControllerDidCancel");
363 [picker dismissViewControllerAnimated:YES completion:nil];
368 + (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
369 usingDelegate: (
id <UINavigationControllerDelegate,UIImagePickerControllerDelegate>) delegate
372 if (([UIImagePickerController isSourceTypeAvailable:
373 UIImagePickerControllerSourceTypeCamera] == NO)
375 || (controller == nil)) {
376 NSLog(
@"CameraSnap.startCameraControllerFromViewController: no source");
381 UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
382 cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
386 cameraUI.mediaTypes =
387 [UIImagePickerController availableMediaTypesForSourceType:
388 UIImagePickerControllerSourceTypeCamera];
392 cameraUI.allowsEditing = NO;
396 [controller presentViewController: cameraUI animated: YES completion:^(void) {
399 NSLog(@"CameraSnapViewContoller.camera controller complete");
404 - (BOOL) startPictureControllerFromViewController: (UIViewController*) controller
405 usingDelegate: (
id <UIImagePickerControllerDelegate,
406 UINavigationControllerDelegate>) delegate {
408 if (([UIImagePickerController isSourceTypeAvailable:
409 UIImagePickerControllerSourceTypeCamera] == NO)
411 || (controller == nil)) {
412 NSLog(
@"CameraSnap.startCameraControllerFromViewController: no source");
417 UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
418 cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
422 cameraUI.mediaTypes =
423 [UIImagePickerController availableMediaTypesForSourceType:
424 UIImagePickerControllerSourceTypePhotoLibrary];
428 cameraUI.allowsEditing = YES;
432 [controller presentViewController: cameraUI animated: YES completion:^(void) {
433 NSLog(@"CameraSnap.starPictureController");
437 #pragma mark <U3ParameterTableDelegate> 438 - (void) updatedParameterArray:(NSArray *)menuItemArray
440 NSLog(
@"CameraSnapViewController.updatedParameterArray: ??");
452 float parameterPanelHeight = [
self parameterViewHeight];
455 return parameterPanelHeight;
458 - (void) didSelectParameterRow: (NSIndexPath *)iPath
469 CGRect totalFrame =
self.view.frame;
470 float paramLineHgt = 42.0 / totalFrame.size.height;
475 float suggestedParamHeight = paramLineHgt * [usdaParameterArray count];
476 if (0.28 < suggestedParamHeight) {
477 suggestedParamHeight = 0.28;
485 - (void) popPushController:(UIViewController *)rebuildVC
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]));
499 [
super didReceiveMemoryWarning];
505 [loginControlbar removeFromSuperview];
506 [NSThread sleepForTimeInterval:5.0];
NSString * produceRandomkey()
UIImagePickerController * mealEntryReviewPicker
float topOfLoginControlbar
void regenerateLoginView()
void fireDataCollectScreen()
void didReceiveMemoryWarning()
instancetype sharedInstance()
float parameterViewHeight()
NSString * instructionHTML
id< U7ParamEditControlDelegate > delegate
float resizeParameterFrame()
UIButton * buttonPictures
void fireMealEntryReviewScreen()
Singleton interface to both core and remote data sources.
UIButton * buttonMessages
UIColor * lightGreenColor
UIButton * makeGradientButton:withFrame:andFont:(NSString *caption, [withFrame] CGRect buttonFrame, [andFont] UIFont *buttonFont)
UIImageView * cameraImage
NSMutableArray * usdaParameterArray
MenuItem * findOrCreateMenuItemWithRandomkey:(NSString *randomkey)
void generateLoginControlbar()
BOOL startCameraControllerFromViewController:usingDelegate:(UIViewController *controller, [usingDelegate] id< UINavigationControllerDelegate, UIImagePickerControllerDelegate > delegate)
Fetch all marked emails into the local database, and display a list.
V7GoogleLoginControlbar * loginControlbar
BOOL startPictureControllerFromViewController:usingDelegate:(UIViewController *controller, [usingDelegate] id< UIImagePickerControllerDelegate, UINavigationControllerDelegate > delegate)