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

#import <Y3MailDisplayViewController.h>

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

Instance Methods

(id) - initWithNibName:bundle: [implementation]
 
(void) - viewDidLoad [implementation]
 
(void) - viewWillAppear: [implementation]
 
(void) - showItemRecipe [implementation]
 
(void) - showItemUSDA [implementation]
 
(void) - execAddMenuItem [implementation]
 
(void) - logMessagePart:underCaption: [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 

Properties

EmailMessagefocusEmailMsg
 

Detailed Description

Definition at line 12 of file Y3MailDisplayViewController.h.

Method Documentation

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 237 of file Y3MailDisplayViewController.m.

237  {
238  [super didReceiveMemoryWarning];
239  // Dispose of any resources that can be recreated.
240 }

◆ execAddMenuItem()

- (void) execAddMenuItem
implementation

This method takes the menu-item from the focus-email-message and adds it to the data base.

Definition at line 185 of file Y3MailDisplayViewController.m.

186 {
187  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
188 
189  NSString *remoteUniqueIID = [_focusEmailMsg remoteUniqueIID];
190  NSLog(@"Y3MailDisplayViewController.execAddMenuItem: remoteUniqueIID: %@", remoteUniqueIID);
191  // MenuItem *newMenuItem = [localData findOrCreateMenuItemWithUID:uidnum];
192  MenuItem *newMenuItem = [localData findOrCreateMenuItemWithFileIdentification:remoteUniqueIID];
193 
194  [_focusEmailMsg setRandomkey:remoteUniqueIID];
195 
196  // update data base item (with ==uid) with message photo and name
197  newMenuItem.photo = [_focusEmailMsg photo];
198  newMenuItem.name = [[_focusEmailMsg subject] stringByReplacingOccurrencesOfString:@"(Nutrition Journal Information)" withString:@""];
199  newMenuItem.galleryNumber = [NSNumber numberWithInt:1]; // home gallery
200  newMenuItem.galleryPositionNo = [NSNumber numberWithLong:[localData getPrevGalleryPositionIdx]];
201 
202  [localData saveContext];
203  [self.navigationController popViewControllerAnimated: YES];
204 }
instancetype sharedInstance()
NSNumber * galleryPositionNo
Singleton interface to both core and remote data sources.
MenuItem * findOrCreateMenuItemWithFileIdentification:(NSString *googlefileid)

◆ initWithNibName:bundle:()

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

Definition at line 33 of file Y3MailDisplayViewController.m.

33  :(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
34 {
35  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
36  if (self) {
37  // Custom initialization
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];
41  outstandingTickets = [[NSMutableArray alloc] init];
42 
43  RFC3339DateFormatter = [[NSDateFormatter alloc] init];
44  RFC3339DateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
45  RFC3339DateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZZZ";
46  RFC3339DateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
47  msgNearDateFormatter = [[NSDateFormatter alloc] init];
48  msgNearDateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
49  msgNearDateFormatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss ZZZZZ";
50  msgNearDateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8];
51  dspNearDateFormatter = [[NSDateFormatter alloc] init];
52  [dspNearDateFormatter setDateStyle:NSDateFormatterMediumStyle];
53  [dspNearDateFormatter setTimeStyle:NSDateFormatterShortStyle];
54 
55 
56  }
57  return self;
58 }
NSDateFormatter * msgNearDateFormatter
NSDateFormatter * RFC3339DateFormatter
NSDateFormatter * dspNearDateFormatter
NSMutableArray * outstandingTickets

◆ logMessagePart:underCaption:()

- (void) logMessagePart: (GTLRGmail_MessagePart *)  msgPt
underCaption: (NSString *)  caption 
implementation

GTLRGmail_MessagePart GTLRGmail_MessagePartBody body NSString *filename NSArray<GTLRGmail_MessagePartHeader> headers NSString *mimeType NSString *partId NSArray<GTLRGmail_MessagePart> *parts

Definition at line 215 of file Y3MailDisplayViewController.m.

215  :(GTLRGmail_MessagePart *)msgPt underCaption:(NSString *)caption
216 {
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],
220  msgPt.filename,
221  msgPt.mimeType,
222  msgPt.partId,
223  [msgPt.headers count],
224  [msgPt.parts count]);
225 
226  } else {
227  NSLog(@"display gmail:%@\n body: %@\n filename: %@\n mimeType: %@\n partID %@\n header count: %lu\n parts count:%luu",caption,
228  msgPt.body,
229  msgPt.filename,
230  msgPt.mimeType,
231  msgPt.partId,
232  (unsigned long)[msgPt.headers count],
233  [msgPt.parts count]);
234  }
235 }

◆ showItemRecipe()

- (void) showItemRecipe
implementation

Definition at line 163 of file Y3MailDisplayViewController.m.

164 {
165  // this does init and viewDidLoad
167  [vc2 setFocusEmailMsg:_focusEmailMsg];
168  // this does viewWillAppear
169  // NSLog(@"GmailViewController.didSelectRow: vc.focusEmailMsg: %@", vc2.focusEmailMsg);
170  [[self navigationController] pushViewController:vc2 animated:YES];
171 }

◆ showItemUSDA()

- (void) showItemUSDA
implementation

Definition at line 172 of file Y3MailDisplayViewController.m.

173 {
174  // this does init and viewDidLoad
176  [vc2 setFocusEmailMsg:_focusEmailMsg];
177  // this does viewWillAppear
178  // NSLog(@"GmailViewController.didSelectRow: vc.focusEmailMsg: %@", vc2.focusEmailMsg);
179  [[self navigationController] pushViewController:vc2 animated:YES];
180 }

◆ viewDidLoad()

- (void) viewDidLoad
implementation

Definition at line 59 of file Y3MailDisplayViewController.m.

59  {
60  [super viewDidLoad];
61  // Do any additional setup after loading the view.
62 
63  NSLog(@"\f\n"); // does not new-page
64  NSLog(@"GmailDisplayController.viewDidLoad: focus: %@", [self focusEmailMsg]);
65  // NSLog(@"GmailDisplayController.viewDidLoad: messageUID: %@", [self focusEmailUniqueID]);
66 
67  CGRect totalFrame = self.view.frame;
68  CGRect topNavigationFrame = [[[self navigationController] navigationBar] frame];
69  float topOfPageF = topNavigationFrame.origin.y + topNavigationFrame.size.height;
70 
71  topOfPageF = 60.0;
72  float tailHeightF = topOfPageF + 8.0;
73 
74  float buttonBarFrameHeight = 44.0;
75  float buttonWidth = totalFrame.size.width/3.0 - 6.0;
76  float buttonLeft = 6.0;
77 
78  CGRect itemRecipeButtonFrame = CGRectMake(buttonLeft, tailHeightF, buttonWidth, buttonBarFrameHeight);
79 // itemRecipeButton = [[UIButton alloc] initWithFrame:itemRecipeButtonFrame];
80 // [itemRecipeButton addTarget:self action:@selector(showItemRecipe) forControlEvents:UIControlEventTouchUpInside];
81 // // [itemRecipeButton setTitle:@"recipe" forState:UIControlStateNormal];
82 // // [itemRecipeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
83 // [itemRecipeButton setBackgroundColor:[[Z5DataController sharedInstance] wheatColor]];
84 // [itemRecipeButton setHidden:NO];
85 // [Z5DataController labelizeButton:itemRecipeButton withText:@"recipe"];
86  UIFont *messageDisplayButtonFont = [UIFont fontWithName:@"Georgia-Bold" size:20.0];
87  itemRecipeButton = [Z5DataController makeGradientButton:@"recipe" withFrame:itemRecipeButtonFrame andFont:messageDisplayButtonFont];
88  [itemRecipeButton addTarget:self action:@selector(showItemRecipe) forControlEvents:UIControlEventTouchUpInside];
89 
90 
91  [self.view addSubview:itemRecipeButton];
92  buttonLeft += (buttonWidth + 2.0);
93 
94  CGRect itemUSDAButtonFrame = CGRectMake(buttonLeft, tailHeightF, buttonWidth, buttonBarFrameHeight);
95 // itemUSDAButton = [[UIButton alloc] initWithFrame:itemUSDAButtonFrame];
96 // [itemUSDAButton addTarget:self action:@selector(showItemUSDA) forControlEvents:UIControlEventTouchUpInside];
97 // [itemUSDAButton setTitle:@"usda" forState:UIControlStateNormal];
98 // [itemUSDAButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
99 // [itemUSDAButton setBackgroundColor:[UIColor grayColor]];
100 // [itemUSDAButton setHidden:NO];
101 
102  itemUSDAButton = [Z5DataController makeGradientButton:@"usda" withFrame:itemUSDAButtonFrame andFont:messageDisplayButtonFont];
103  [itemUSDAButton addTarget:self action:@selector(showItemUSDA) forControlEvents:UIControlEventTouchUpInside];
104  [self.view addSubview:itemUSDAButton];
105  buttonLeft += (buttonWidth + 2.0);
106 
107 // NSLog(@"Y3MailDisplayViewController.viewDidLoad: add-item-button frame:\nX: %3.2f Y: %3.2f\nWid: %3.2f Hgt: %3.2f", itemAddToMenuButtonFrame.origin.x, itemAddToMenuButtonFrame.origin.y, itemAddToMenuButtonFrame.size.width, itemAddToMenuButtonFrame.size.height);
108 
109  CGRect itemAddToMenuButtonFrame = CGRectMake(buttonLeft, tailHeightF, buttonWidth, buttonBarFrameHeight);
110 // itemAddToMenuButton = [[UIButton alloc] initWithFrame:itemAddToMenuButtonFrame];
111 // [itemAddToMenuButton addTarget:self action:@selector(execAddMenuItem) forControlEvents:UIControlEventTouchUpInside];
112 // [itemAddToMenuButton setTitle:@"add item" forState:UIControlStateNormal];
113 // [itemAddToMenuButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
114 // [itemAddToMenuButton setBackgroundColor:[UIColor greenColor]];
115 // [itemAddToMenuButton setHidden:NO];
116 
117  itemAddToMenuButton = [Z5DataController makeGradientButton:@"add item" withFrame:itemAddToMenuButtonFrame andFont:messageDisplayButtonFont];
118  [itemAddToMenuButton addTarget:self action:@selector(execAddMenuItem) forControlEvents:UIControlEventTouchUpInside];
119  [self.view addSubview:itemAddToMenuButton];
120  tailHeightF += (buttonBarFrameHeight + 4.0);
121 
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);
127 
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);
133 
134 }
UIButton * itemRecipeButton
UIImageView * imageView
UIButton * itemAddToMenuButton
UITextView * msgPlainText
UIButton * itemUSDAButton
Singleton interface to both core and remote data sources.
UIButton * makeGradientButton:withFrame:andFont:(NSString *caption, [withFrame] CGRect buttonFrame, [andFont] UIFont *buttonFont)

◆ viewWillAppear:()

- (void) viewWillAppear: (BOOL)  animated
implementation

Definition at line 135 of file Y3MailDisplayViewController.m.

135  :(BOOL)animated
136 {
137 
138 
139  NSLog(@"GmailDisplay.viewWillAppear: focus: %@", _focusEmailMsg);
140  //
141  NSString *caption = [_focusEmailMsg subject];
142  NSLog(@"GmailDisplayController.viewWillAppear: caption: %@", caption);
143 
144  UIImage *img = [[UIImage alloc] initWithData:[_focusEmailMsg photo]];
145  [imageView setImage: img];
146 
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"];
157  } else {
158  displayText = [displayText stringByAppendingString:[_focusEmailMsg bodytext]];
159  }
160  [msgPlainText setText:displayText];
161 }

Property Documentation

◆ focusEmailMsg

- (EmailMessage*) focusEmailMsg
readwritenonatomicstrong

Definition at line 14 of file Y3MailDisplayViewController.h.


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