Today's Menu  Portugal
journal and plan nutrition
P2SnapMealGalleryViewController.m
Go to the documentation of this file.
1 //
2 // P2SnapMealGalleryViewController.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 12/30/18.
6 // Copyright © 2018 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
10 #import "Z5DataController.h"
12 
14 
15 @end
16 
72 @implementation P2SnapMealGalleryViewController
73 
75 
79 
80 - (void)viewDidLoad
81 {
82  [super viewDidLoad];
83  self.title = @"Meal Memory Lane";
84 
85  [self orientLoadUI];
86 
87  [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
88  [[NSNotificationCenter defaultCenter] addObserver:self
89  selector:@selector(deviceOrientationDidChange:)
90  name: UIDeviceOrientationDidChangeNotification
91  object: nil];
92 }
93 
94 - (void) viewWillAppear:(BOOL)animated
95 {
96  [self orientAppearUI];
97 }
98 
99 - (void)deviceOrientationDidChange:(NSNotification *)notification {
100  NSLog(@"P2SnapMealGalleryViewController.deviceOrientationDidChange: %@", notification);
101  [self orientAppearUI];
102 }
103 
104 - (void) orientLoadUI {
105  NSLog(@"P2SnapMealGalleryViewController.orientLoadUI");
106  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
107  switch (orientation)
108  {
109  case UIDeviceOrientationPortrait:
110  case UIDeviceOrientationFaceUp:
111  {
112  [self viewDidLoadPortrait];
113  }
114  break;
115  case UIDeviceOrientationLandscapeLeft:
116  case UIDeviceOrientationLandscapeRight:
117  {
118  [self viewDidLoadLandscape];
119  }
120  break;
121  default:
122  {
123  NSLog(@"P2SnapMealGalleryViewController.orientLoadUI: unk orrientation");
124  }
125  break;
126  }
127 }
128 
130 {
131  navbarBottomEdge = self.navigationController.navigationBar.frame.origin.y
132  + self.navigationController.navigationBar.frame.size.height;
133 
135 
136  float tableWidth = self.view.bounds.size.width;
137  float tableHeight = self.view.bounds.size.height - navbarBottomEdge;
138  CGRect headFrame = CGRectMake(4.0, navbarBottomEdge+4.0, tableWidth-8.0, tableHeight-8.0);
139 
140  tableSpecial = [[U5MealPanoramaView alloc] initWithFrame:headFrame andDelegate:self];
141  float headerVert = [tableSpecial heightRequirement];
142  NSLog(@"P2SnapMealViewController.viewDidLoadPortrait: headerVert: %3.2f", headerVert);
143  [tableSpecial reloadMeals];
144  [self.view addSubview:tableSpecial];
145 }
146 
148 {
149  navbarBottomEdge = self.navigationController.navigationBar.frame.origin.y
150  + self.navigationController.navigationBar.frame.size.height;
151 
152  // fetch, scale, and add a subview background image
153  CGRect totalFrame = self.view.frame;
154  mealGalleryOverallSize = totalFrame.size;
155  UIImage *backgrdImage = [UIImage imageNamed:@"elphieLandscape.png"];
156  CGSize photoSize = [backgrdImage size];
157  float resizeRatio = photoSize.width / totalFrame.size.width;
158  UIImage *resizedImage = [UIImage imageWithCGImage:[backgrdImage CGImage]
159  scale:backgrdImage.scale * resizeRatio
160  orientation:(backgrdImage.imageOrientation) ];
161  snapGalleryImageBackground = [[UIImageView alloc] initWithImage:resizedImage];
162  [self.view addSubview:snapGalleryImageBackground];
163  // end - fetch, scale, and add a subview background image
164 
165  float tableWidth = self.view.bounds.size.width;
166  CGRect headFrame = CGRectMake(4.0, navbarBottomEdge, tableWidth - 12.0, 420.0); tableSpecial = [[U5MealPanoramaView alloc] initWithFrame:headFrame andDelegate:self];
167  float headerVert = [tableSpecial heightRequirement];
168  NSLog(@"P2SnapMealViewController.viewDidLoadLandscape: headerVert: %3.2f", headerVert);
169  [tableSpecial reloadMeals];
170 }
171 
172 - (void) orientAppearUI {
173  NSLog(@"P2SnapMealViewController.orientAppearUI");
174  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
175  switch (orientation)
176  {
177  case UIDeviceOrientationPortrait:
178  case UIDeviceOrientationFaceUp:
179  {
180  [self viewDidAppearPortrait];
181  }
182  break;
183  case UIDeviceOrientationLandscapeLeft:
184  case UIDeviceOrientationLandscapeRight:
185  {
186  [self viewDidAppearLandscape];
187  }
188  break;
189  default:
190  {
191  NSLog(@"P2SnapMealViewController.viewDidLoad: unk orrientation");
192  }
193  break;
194  }
195 }
196 
198 {
199  CGRect bound = self.view.bounds;
200  // NSLog(@"P2SnapMealViewController.viewDidAppearPortrait: bound: (%3.2f,%3.2f)-(%3.2fx%3.2f)",
201  // bound.origin.x, bound.origin.y, bound.size.width, bound.size.height);
202  [tableSpecial appear:bound];
203 }
204 
206 {
207  NSLog(@"P2SnapMealViewController.viewDidAppearLandscape");
208 }
209 
211 {
212  // fetch, scale, and add a subview background image
213  CGRect totalFrame = self.view.frame;
214  mealGalleryOverallSize = totalFrame.size;
215  UIImage *backgrdImage = [UIImage imageNamed:@"elphie.png"];
216  CGSize photoSize = [backgrdImage size];
217  float resizeRatio = photoSize.height / totalFrame.size.height;
218  UIImage *resizedImage = [UIImage imageWithCGImage:[backgrdImage CGImage]
219  scale:backgrdImage.scale * resizeRatio
220  orientation:(backgrdImage.imageOrientation) ];
221  snapGalleryImageBackground = [[UIImageView alloc] initWithImage:resizedImage];
222  [self.view addSubview:snapGalleryImageBackground];
223  // end - fetch, scale, and add a subview background image
224 }
225 - (CGRect) screenBound
226 {
227  CGRect bound = self.view.bounds;
228  NSLog(@"P2SnapMealViewController.screenBound: bound: (%3.2f,%3.2f)-(%3.2fx%3.2f",
229  bound.origin.x, bound.origin.y, bound.size.width, bound.size.height);
230  return bound;
231 }
232 
233 
234 - (void) clickedMeal: (Meal *)meal atRow: (NSUInteger)row
235 {
236 
237 }
238 
239 
240 @end
241 
void appear:(CGRect bound)