17 id<V3KitchenTableProtocol> dataDelegate;
31 - (id) initWithFrame:(CGRect)frame
32 andDelegate:(
id<V3KitchenTableProtocol>)delegate
42 [mDateFormatter setTimeStyle:NSDateFormatterNoStyle];
43 [mDateFormatter setDateStyle:NSDateFormatterMediumStyle];
45 CGRect kitchenTableHeadFrame = CGRectMake(0, 0,
self.bounds.size.width - 8.0, 60);
54 unsigned long nEntries = [kitchenTableMenuItems count];
56 NSLog(
@"V3KitchentableView.heghtRequirement: nEntries: %lu ret: %3.2f", nEntries, ret);
59 - (void) appear:(CGRect)bound
61 self.dataSource =
self;
62 [
self setDelegate:self];
64 [
self.layer setBorderColor: [[UIColor blackColor] CGColor]];
65 [
self.layer setBorderWidth: 2.0];
66 self.layer.cornerRadius = 8.0f;
67 self.layer.masksToBounds = YES;
73 #pragma mark - V3GalleryMenuItemControlbarProtocol protocol 76 NSLog(
@"V3KitchenTableView.fireRecipeCheck");
78 - (void) addMenuItemOnToday:(UIButton *)sender
80 NSLog(
@"V3KitchenTableView.V3GalleryMenuItemControlbarProtocol");
84 NSLog(
@"V3KitchenTableView.clickPlusButton");
85 [memDelegate clickPlusButton];
92 #pragma mark - UITableViewDataSource protocol 93 - (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
99 - (NSInteger)tableView:(UITableView *)tableView
100 numberOfRowsInSection:(NSInteger)section
102 NSInteger ret = [kitchenTableMenuItems count];
107 - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
108 NSString *cellKey =
@"usda-pdata-display";
109 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellKey];
113 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellKey];
117 CGRect contentRect = [cell.contentView frame];
118 CGRect fetchPublishButton1Frame = CGRectMake(contentRect.size.width - 86.0f, 5.0, 64.0f, contentRect.size.height - 10);
119 UIButton *pushMe = [[UIButton alloc] initWithFrame:fetchPublishButton1Frame];
120 [pushMe setBackgroundColor:[UIColor grayColor]];
121 [pushMe setTitle:@"GO" forState:UIControlStateNormal];
122 [pushMe setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
124 [cell.contentView addSubview:pushMe];
126 [cell.layer setCornerRadius:7.0f];
127 [cell.layer setMasksToBounds:YES];
128 [cell.layer setBorderWidth:1.0f];
130 [cell.textLabel setTextColor:[UIColor purpleColor]];
131 [cell.textLabel setOpaque:YES];
133 [cell setBackgroundColor:[UIColor brownColor]];
134 NSInteger nComponents = [kitchenTableMenuItems count];
136 if (nComponents > [indexPath row]) {
138 MenuItem *item = [kitchenTableMenuItems objectAtIndex:[indexPath row]];
139 NSString *itemName = [item
name];
142 }
else if (0 == nComponents) {
143 cell.textLabel.text =
@"no food data";
145 NSLog(
@"V3KitchenTableView.tableCellForRow: %3.2f", cell.bounds.size.height);
149 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
151 switch ([fromIndexPath section]) {
154 NSInteger fromRow = [fromIndexPath row];
155 NSInteger toRow = [toIndexPath row];
156 NSLog(
@"V3GalleryEdit.moveRowAtIndexPath: from %ld to %ld", (
long)fromRow, (
long)toRow);
159 [kitchenTableMenuItems removeObjectAtIndex:fromRow];
160 [kitchenTableMenuItems insertObject:menuItem atIndex:toRow];
165 #pragma mark - UITableViewDelegate 167 - (void)tableView:(UITableView *)tableView
168 didSelectRowAtIndexPath:(NSIndexPath *)indexPath
170 NSInteger selectSection = [indexPath section];
171 NSInteger selectRow = [indexPath row];
172 NSLog(
@"V3GalleryEdit.didSelectRowAtIndexPath: sect: %ld row: %ld", (
long)selectSection, (
long)selectRow);
173 switch (selectSection) {
176 MenuItem *selectedMenuItem = [kitchenTableMenuItems objectAtIndex:selectRow];
178 [memDelegate itemSelected:selectedMenuItem];
184 - (CGFloat)tableView:(UITableView *)tableView
185 heightForRowAtIndexPath:(NSIndexPath *)indexPath
194 #pragma mark - section header 196 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
198 [kitchenTableHeadView appear:self.bounds];
201 NSLog(
@"V3KitchenTableView.heightForHeaderInSection: ret: %3.2f", ret);
204 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
206 NSLog(
@"V3KitchenTableView.viewForHeaderInSection: section: %ld width: %f", (
long)section,
self.contentSize.width);
211 #pragma mark - editting 214 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
220 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
223 if (editingStyle == UITableViewCellEditingStyleDelete) {
225 NSInteger rowNo = [indexPath row];
226 MenuItem *removedItem = [kitchenTableMenuItems objectAtIndex:rowNo];
227 [removedItem setGalleryNumber:0];
229 [kitchenTableMenuItems removeObjectAtIndex:rowNo];
231 [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
232 }
else if (editingStyle == UITableViewCellEditingStyleInsert) {
245 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
250 #pragma mark - Picker View delegate 252 - (CGFloat)pickerView:(UIPickerView *)pickerView
253 rowHeightForComponent:(NSInteger)component
258 - (NSAttributedString *)pickerView:(UIPickerView *)pickerView
259 attributedTitleForRow:(NSInteger)row
260 forComponent:(NSInteger)component
265 }
else if (1 == row) {
266 txt =
@"Available Now";
267 }
else if (2 == row) {
268 txt =
@"Off-menu Kitchen Recipes";
270 UIFont *herefont = [UIFont fontWithName:@"Helvetica-Bold" size:18];
271 NSDictionary *attribs = @{
272 NSForegroundColorAttributeName: [UIColor blackColor],
273 NSFontAttributeName: herefont
275 NSMutableAttributedString *attributedText =
276 [[NSMutableAttributedString alloc] initWithString:txt
278 return attributedText;
281 - (void)pickerView:(UIPickerView *)pickerView
282 didSelectRow:(NSInteger)row
283 inComponent:(NSInteger)component
285 NSLog(
@"V3GalleryEdit.didSelectRow: row %ld", (
long)row);
292 [memDelegate sizeKitchenTable];
294 -(void) fillDataForGallery:(
int)galleryNo
297 NSLog(
@"V3GalleryEdit.fillDataForGallery: gallery#: %d", galleryNo);
298 NSNumber *galleryChoice = [NSNumber numberWithInt:galleryNo];
300 NSLog(
@"V3GalleryEdit.fillDataForGallery: count of all menu items in d/b: %ld", (
unsigned long)[tmp count]);
304 #pragma mark - Picker View data source 305 - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
309 - (NSInteger)pickerView:(UIPickerView *)pickerView
310 numberOfRowsInComponent:(NSInteger)component
NSInteger focusKitchenGallery
id initWithFrame:(CGRect frame)
NSArray< MenuItem * > * retrieveAllMenuItems:(NSNumber *galleryNo)
instancetype sharedInstance()
NSInteger getKitchenFocusGallery()
float heightRequirement()
float getViewHeightReqmt()
NSDateFormatter * mDateFormatter
id< V3KitchenTableProtocol > memDelegate
id< U7ParamEditControlDelegate > delegate
V3GalleryMenuItemControlbarView * kitchenTableHeadView
Singleton interface to both core and remote data sources.
void fillDataForGallery:(int galleryNo)
NSMutableArray< MenuItem * > * kitchenTableMenuItems
void labelizeCell:withText:inColor:andDetail:(UITableViewCell *targCell, [withText] NSString *txt, [inColor] UIColor *color, [andDetail] NSString *detailTxt)