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

#import <U5MealPanoramaView.h>

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

Instance Methods

(instancetype) - initWithFrame:andDelegate:
 
(void) - reloadMeals
 
(void) - initialize [implementation]
 
(void) - registerCells [implementation]
 
(float) - heightRequirement [implementation]
 
(void) - appear: [implementation]
 
(NSInteger) - collectionView:numberOfItemsInSection: [implementation]
 
(__kindof UICollectionViewCell *) - collectionView:cellForItemAtIndexPath: [implementation]
 

Class Methods

(NSValue *) + mealCellDefaultSize
 

Properties

NSMutableArray< Meal * > * snapMeals
 
MealfocusSnapMeal
 

Detailed Description

Definition at line 21 of file U5MealPanoramaView.h.

Method Documentation

◆ appear:()

- (void) appear: (CGRect)  bound
implementation

Definition at line 98 of file U5MealPanoramaView.m.

98  :(CGRect)bound
99 {
100  NSNumber *galleryChoice = [NSNumber numberWithInt:1];
101  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
102  // NSArray *tmp = [localData retrieveAllMenuItems:galleryChoice];
103  NSArray *tmp = [localData retrieveAllMeals:galleryChoice];
104  NSLog(@"U5MenuPanoramaView.appear: width: %3.2f self-width: %3.2f", bound.size.width, self.bounds.size.width);
105  [self setSnapMeals:[[NSMutableArray alloc] initWithArray:tmp]];
106 
107 // CGRect collectionViewFrame = CGRectMake(10, 36, self.bounds.size.width-20, mealDefaultCellSize.height+12.0);
108 // [mealCollectionView setFrame:collectionViewFrame];
109  [mealCollectionView setBackgroundColor:[UIColor yellowColor]];
110  [mealCollectionView reloadData];
111 // if (0 <= selectedRow) {
112 // [self centerGalleryItem:selectedRow];
113 // }
114 }
instancetype sharedInstance()
NSArray< Meal * > * retrieveAllMeals:(NSNumber *galleryNumber)
Singleton interface to both core and remote data sources.

◆ collectionView:cellForItemAtIndexPath:()

- (__kindof UICollectionViewCell *) collectionView: (UICollectionView *)  collectionView
cellForItemAtIndexPath: (NSIndexPath *)  indexPath 
implementation

Definition at line 124 of file U5MealPanoramaView.m.

124  :(UICollectionView *)collectionView
125  cellForItemAtIndexPath:(NSIndexPath *)indexPath
126 {
127  int imageHeight = 120; //
128  int selectedImageHeight = 160;
129  int outputImageHeight = 0;
130 
132  if (selectedMealRow == indexPath.row) {
133  cell = (U5MealCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:selectedCellIdentifier forIndexPath:indexPath];
134  outputImageHeight = selectedImageHeight;
135  } else {
136  cell = (U5MealCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
137  outputImageHeight = imageHeight;
138  }
139  // NSLog(@"U5MealPanoramaView.cellForItemAtIndexPath: cell: %@", cell);
140 
141  Meal *cellItem = [_snapMeals objectAtIndex:indexPath.row];
142  UIImage *photoImage = [UIImage imageWithData:cellItem.photo];
143  NSDate *photoDate = [cellItem consumeDate];
144  NSString *itemName = [mDateFormatter stringFromDate:photoDate];
145  // NSString *itemName = @"Meal"; // [cellItem name];
146 
147  CGSize photoSize = [photoImage size];
148  float resizeRatio = photoSize.height / (float)outputImageHeight;
149  UIImage *keptImage = [UIImage imageWithCGImage:[photoImage CGImage]
150  scale:photoImage.scale * resizeRatio
151  orientation:(photoImage.imageOrientation) ];
152 
153  [cell.imageView setImage:keptImage];
154  [Z5DataController labelize:cell.textLabel withText:itemName];
155 
156  return cell;
157 }
NSInteger selectedMealRow
NSDate * consumeDate
static NSString * selectedCellIdentifier
Singleton interface to both core and remote data sources.
void labelize:withText:(UILabel *targLabel, [withText] NSString *txt)
static NSString * cellIdentifier
UICollectionView * collectionView

◆ collectionView:numberOfItemsInSection:()

- (NSInteger) collectionView: (UICollectionView *)  collectionView
numberOfItemsInSection: (NSInteger)  section 
implementation

Definition at line 117 of file U5MealPanoramaView.m.

117  :(UICollectionView *)collectionView
118  numberOfItemsInSection:(NSInteger)section
119 {
120  NSInteger ret = [_snapMeals count];
121  NSLog(@"U5MealPanoramaView.numberOfItemsInSection: %ld", (long)ret);
122  return ret;
123 }
UICollectionView * collectionView

◆ heightRequirement()

- (float) heightRequirement
implementation

Definition at line 93 of file U5MealPanoramaView.m.

94 {
95  float ret = initialCollectViewHgt;
96  return ret;
97 }
float initialCollectViewHgt

◆ initialize()

- (void) initialize
implementation

Definition at line 46 of file U5MealPanoramaView.m.

47 {
48  // start definition of collection view layout - class var, used many places
49  float defaultCellwidth = 224;
50  float defaultCellheight = 268;
51  mealDefaultCellSize = CGSizeMake(defaultCellwidth, defaultCellheight);
52  float selectCellWidth = 156;
53  float selectCellHeight = 180;
54  mealSelectCellSize = CGSizeMake(selectCellWidth, selectCellHeight);
55  // end, for now - start definition of collection view layout
56 
57  mealFlowLayout = [[UICollectionViewFlowLayout alloc] init];
58  [mealFlowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
59  [mealFlowLayout setMinimumInteritemSpacing:1.0];
60  [mealFlowLayout setItemSize:mealDefaultCellSize];
61 
62  initialCollectViewHgt = defaultCellheight + 6;
63  CGRect collectionViewFrame = CGRectMake(4.0, 4.0, self.bounds.size.width-8, initialCollectViewHgt);
64  mealCollectionView = [[UICollectionView alloc] initWithFrame:collectionViewFrame collectionViewLayout:mealFlowLayout];
65  [self addSubview:mealCollectionView];
66  [self registerCells];
67  [mealCollectionView setDelegate:self];
68  [mealCollectionView setDataSource:self];
69  // [collectionView setBackgroundColor:[UIColor lightGrayColor]];
70  [mealCollectionView setBackgroundColor:[[Z5DataController alloc] wheatColor]];
71 
72  mDateFormatter = [[NSDateFormatter alloc] init];
73  [mDateFormatter setDateStyle:NSDateFormatterMediumStyle];
74  [mDateFormatter setTimeStyle:NSDateFormatterShortStyle];
75 }
UICollectionView * mealCollectionView
UICollectionViewFlowLayout * mealFlowLayout
CGSize mealDefaultCellSize
CGSize mealSelectCellSize
float initialCollectViewHgt
NSDateFormatter * mDateFormatter
Singleton interface to both core and remote data sources.

◆ initWithFrame:andDelegate:()

- (instancetype) initWithFrame: (CGRect)  frame
andDelegate: (id<Z6MealPanoramaDelegate>)  delegate 

Definition at line 35 of file U5MealPanoramaView.m.

35  :(CGRect)frame andDelegate:(id<Z6MealPanoramaDelegate>)dele
36 {
37  self = [super initWithFrame:frame];
38  mealPanoramaDelegate = dele;
39  mealBackgroundShade = [UIColor colorWithRed:226.0/256 green:201.0/256 blue:114.0/256 alpha:1.0];
40  selectedMealRow = 1001;
41  [self initialize];
42  return self;
43 }
NSInteger selectedMealRow
id< Z6MealPanoramaDelegate > mealPanoramaDelegate
UIColor * mealBackgroundShade

◆ mealCellDefaultSize()

+ (NSValue *) mealCellDefaultSize

Definition at line 29 of file U5MealPanoramaView.m.

30 {
31  NSValue *ret = [NSValue valueWithCGSize:mealDefaultCellSize];
32  return ret;
33 }

◆ registerCells()

- (void) registerCells
implementation

Definition at line 82 of file U5MealPanoramaView.m.

83 {
84 // setup how cells are built
85 [mealCollectionView registerClass:[U5MealCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
86 [mealCollectionView registerClass:[U5MealCollectionViewCell class] forCellWithReuseIdentifier:selectedCellIdentifier];
87 mealCollectionView.delegate = self;
88 // end - setup how cells are built
89 }
UICollectionView * mealCollectionView

◆ reloadMeals()

- (void) reloadMeals

Definition at line 77 of file U5MealPanoramaView.m.

78 {
79  [mealCollectionView reloadData];
80 }

Property Documentation

◆ focusSnapMeal

- (Meal*) focusSnapMeal
readwritenonatomicstrong

Definition at line 24 of file U5MealPanoramaView.h.

◆ snapMeals

- (NSMutableArray<Meal *>*) snapMeals
readwritenonatomicstrong

Definition at line 23 of file U5MealPanoramaView.h.


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