33 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
35 self = [
super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
38 self.title =
@"Focus";
39 UIColor *ivory = [UIColor colorWithRed:0.9297f green:0.9297f blue:0.8784f alpha:1.0f];
40 [
self.view setBackgroundColor:ivory];
52 [dspNearDateFormatter setDateStyle:NSDateFormatterMediumStyle];
53 [dspNearDateFormatter setTimeStyle:NSDateFormatterShortStyle];
64 NSLog(
@"GmailDisplayController.viewDidLoad: focus: %@", [
self focusEmailMsg]);
67 CGRect totalFrame =
self.view.frame;
68 CGRect topNavigationFrame = [[[
self navigationController] navigationBar] frame];
69 float topOfPageF = topNavigationFrame.origin.y + topNavigationFrame.size.height;
72 float tailHeightF = topOfPageF + 8.0;
74 float buttonBarFrameHeight = 44.0;
75 float buttonWidth = totalFrame.size.width/3.0 - 6.0;
76 float buttonLeft = 6.0;
78 CGRect itemRecipeButtonFrame = CGRectMake(buttonLeft, tailHeightF, buttonWidth, buttonBarFrameHeight);
86 UIFont *messageDisplayButtonFont = [UIFont fontWithName:@"Georgia-Bold" size:20.0];
88 [itemRecipeButton addTarget:self action:@selector(showItemRecipe) forControlEvents:UIControlEventTouchUpInside];
91 [
self.view addSubview:itemRecipeButton];
92 buttonLeft += (buttonWidth + 2.0);
94 CGRect itemUSDAButtonFrame = CGRectMake(buttonLeft, tailHeightF, buttonWidth, buttonBarFrameHeight);
103 [itemUSDAButton addTarget:self action:@selector(showItemUSDA) forControlEvents:UIControlEventTouchUpInside];
104 [
self.view addSubview:itemUSDAButton];
105 buttonLeft += (buttonWidth + 2.0);
109 CGRect itemAddToMenuButtonFrame = CGRectMake(buttonLeft, tailHeightF, buttonWidth, buttonBarFrameHeight);
118 [itemAddToMenuButton addTarget:self action:@selector(execAddMenuItem) forControlEvents:UIControlEventTouchUpInside];
119 [
self.view addSubview:itemAddToMenuButton];
120 tailHeightF += (buttonBarFrameHeight + 4.0);
122 float imageViewFrameHeight = 300.0f;
123 CGRect imageViewFrame = CGRectMake(10.0f, tailHeightF, totalFrame.size.width - 20, imageViewFrameHeight);
124 imageView = [[UIImageView alloc] initWithFrame:imageViewFrame];
125 [
self.view addSubview:imageView];
126 tailHeightF += (imageViewFrameHeight + 8.0);
128 float plainTextFrameHeight = 180.0;
129 CGRect msgPlainTextFrame = CGRectMake(10.0f, tailHeightF, totalFrame.size.width - 20, plainTextFrameHeight);
130 msgPlainText = [[UITextView alloc] initWithFrame:msgPlainTextFrame];
131 [
self.view addSubview:msgPlainText];
132 tailHeightF += (plainTextFrameHeight + 8.0);
135 - (void) viewWillAppear:(BOOL)animated
139 NSLog(
@"GmailDisplay.viewWillAppear: focus: %@", _focusEmailMsg);
141 NSString *caption = [_focusEmailMsg subject];
142 NSLog(
@"GmailDisplayController.viewWillAppear: caption: %@", caption);
144 UIImage *img = [[UIImage alloc] initWithData:[_focusEmailMsg photo]];
145 [imageView setImage: img];
147 NSString *displayText = [[NSString alloc] initWithString:caption];
148 displayText = [displayText stringByAppendingString:@"\n"];
149 NSDate *messageDate = [_focusEmailMsg date];
150 NSString *msgDateStr = [dspNearDateFormatter stringFromDate:messageDate];
151 displayText = [displayText stringByAppendingString: msgDateStr];
152 displayText = [displayText stringByAppendingString:@"\nFrom: "];
153 displayText = [displayText stringByAppendingString:[_focusEmailMsg from]];
154 displayText = [displayText stringByAppendingString:@"\n"];
155 if (nil == [_focusEmailMsg bodytext]) {
156 displayText = [displayText stringByAppendingString:@"nil bodytext"];
158 displayText = [displayText stringByAppendingString:[_focusEmailMsg bodytext]];
160 [msgPlainText setText:displayText];
163 - (void) showItemRecipe
167 [vc2 setFocusEmailMsg:_focusEmailMsg];
170 [[
self navigationController] pushViewController:vc2 animated:YES];
172 - (void) showItemUSDA
176 [vc2 setFocusEmailMsg:_focusEmailMsg];
179 [[
self navigationController] pushViewController:vc2 animated:YES];
185 - (void) execAddMenuItem
189 NSString *remoteUniqueIID = [_focusEmailMsg remoteUniqueIID];
190 NSLog(
@"Y3MailDisplayViewController.execAddMenuItem: remoteUniqueIID: %@", remoteUniqueIID);
194 [_focusEmailMsg setRandomkey:remoteUniqueIID];
197 newMenuItem.
photo = [_focusEmailMsg photo];
198 newMenuItem.
name = [[_focusEmailMsg subject] stringByReplacingOccurrencesOfString:@"(Nutrition Journal Information)" withString:@""];
203 [
self.navigationController popViewControllerAnimated: YES];
215 - (void)logMessagePart:(GTLRGmail_MessagePart *)msgPt underCaption:(NSString *)caption
217 if ([NSStringFromClass([msgPt.body
class]) isEqualToString:
@"GTLRGmail_MessagePartBody"]) {
218 NSLog(
@"Y3MailDisplayController/log.%@\n body size: %ld\n filename: %@\n mimeType: %@\n partID %@\n header count: %lu\n parts count: %lu",caption,
219 [msgPt.body.size integerValue],
223 [msgPt.headers count],
224 [msgPt.parts count]);
227 NSLog(
@"display gmail:%@\n body: %@\n filename: %@\n mimeType: %@\n partID %@\n header count: %lu\n parts count:%luu",caption,
232 (
unsigned long)[msgPt.headers count],
233 [msgPt.parts count]);
237 - (void)didReceiveMemoryWarning {
238 [
super didReceiveMemoryWarning];
UIButton * itemRecipeButton
NSDateFormatter * msgNearDateFormatter
UIButton * itemAddToMenuButton
instancetype sharedInstance()
NSInteger getPrevGalleryPositionIdx()
UITextView * msgPlainText
UIButton * itemUSDAButton
NSDateFormatter * RFC3339DateFormatter
NSDateFormatter * dspNearDateFormatter
NSMutableArray * outstandingTickets
Singleton interface to both core and remote data sources.
UIButton * makeGradientButton:withFrame:andFont:(NSString *caption, [withFrame] CGRect buttonFrame, [andFont] UIFont *buttonFont)
MenuItem * findOrCreateMenuItemWithFileIdentification:(NSString *googlefileid)