Today's Menu  Portugal
journal and plan nutrition
V7GoogDriveTableView.m
Go to the documentation of this file.
1 //
2 // V7GoogDriveTableView.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 8/3/18.
6 // Copyright © 2018 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
10 #import "Z5DataController.h"
12 
13 @implementation V7GoogDriveTableView
14 {
15  id<V7GoogDriveTableDelegate> dataDelegate;
16  NSDateFormatter *mDateFormatter;
17 }
18 
19 - (id) initWithFrame:(CGRect)frame
20  andHeader:(UIView *)headerView
21  inContainer:(id<V7GoogDriveTableDelegate>)container
22 {
23  NSLog(@"V7GoogDriveTableView.init");
24 
25  self = [super initWithFrame:frame];
26  [self setTableHeaderView:headerView];
27  [self setBackgroundColor:[[Z5DataController sharedInstance] wheatColor]];
28  self.dataSource = self;
29 
30  dataDelegate = container;
31 
32  mDateFormatter = [[NSDateFormatter alloc] init];
33  [mDateFormatter setTimeStyle:NSDateFormatterNoStyle];
34  [mDateFormatter setDateStyle:NSDateFormatterMediumStyle];
35 
36  return self;
37 
38 }
39 - (void) setTableCaption:(Z1ContainedLabel *)captionLabel
40 {
41  [self setViewForHead:captionLabel];
42 }
43 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
44 {
45  NSArray<NSString *> *foodEntries = [dataDelegate provideFocusFoodListDriveArray];
46  NSInteger nMesgs = [foodEntries count];
47  return nMesgs;
48 }
49 
50 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
51 {
52  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"todays-drive-item"];
53  NSLog(@"V7GoogDriveTableView.cellForRow: cell: %@", cell);
54  if (cell == nil) {
55  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"todays-drive-item"];
56 
57  cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
58 
59  CGRect contentRect = [cell.contentView frame];
60  CGRect fetchPublishButton1Frame = CGRectMake(0.0 /*contentRect.size.width - 86.0f */, 5.0, 34.0f, contentRect.size.height - 10);
61  UIButton *pushMe = [[UIButton alloc] initWithFrame:fetchPublishButton1Frame];
62  [pushMe setBackgroundColor:[UIColor redColor]];
63  [pushMe setTitle:@"GO" forState:UIControlStateApplication];
64  [cell setBackgroundColor:[UIColor pearlColor]];
65  [cell.contentView addSubview:pushMe];
66  // [cell setHidden:NO];
67  }
68 
69  NSArray<NSString *> *foodEntries = [dataDelegate provideFocusFoodListDriveArray];
70  NSInteger nMesgs = [foodEntries count];
71 
72  if (nMesgs > [indexPath row]) {
73  // NSDictionary *foodForCell = [foodEntries objectAtIndex:[indexPath row]];
74  // NSString *caption = [foodForCell objectForKey:@"name"];
75  NSString *caption = [foodEntries objectAtIndex:[indexPath row]];
76  // NSDate *cellDate = [foodForCell date];
77  // NSString *messageDate = [mDateFormatter stringFromDate:cellDate];
78  // NSLog(@"MessageTableView.cellForRow: msg date: %@", messageDate);
79  // NSString *subCaption = [NSString stringWithFormat:@"Message date: %@", messageDate];
80 
81  // NSString *dateStrX = @"Tue, 25 May 2010 12:53:58 +0000";
82  // // [dateFormat setDateFormat:@"EE, d LLLL yyyy HH:mm:ss Z"];
83  // NSString *dateStr = @"2016-08-04 19:38:27 +0000";
84 
85  // Convert string to date object
86  // NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
87  // [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
88  // NSString *cellDate2 = [NSString stringWithString:(NSString *)cellDate];
89  // NSDate *date = [dateFormat dateFromString:cellDate2];
90  // NSLog(@"MessageTableView.cellForRow: (DEBUG - 8/4/16) msg derived date: %@", date);
91 
92  cell.textLabel.text = caption;
93  // cell.detailTextLabel.text = subCaption;
94  // if (foodForCell.randomkey) {
95  // [cell setBackgroundColor:[UIColor orangeColor]];
96  // } else {
97  // [cell setBackgroundColor:[UIColor colorWithRed:0.9 green:1.0 blue:0.95 alpha:1.0]];
98  // }
99  }
100 
101  return cell;
102 
103 }
104 
106 {
107  NSArray<NSDictionary *> *foodEntries = [dataDelegate provideFocusFoodListDriveArray];
108  NSInteger nFoods = [foodEntries count];
109 
110  float ret = [super getViewHeightReqmt] + nFoods * 42.0;
111  NSLog(@"V7GoogDriveTableView.getViewHeightReqmt: ret: %3.2f", ret);
112  return ret;
113 }
114 
115 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
116  // int row = (int)[indexPath row];
117 
118  /*
119  Z5EmailDataController *eMailCntrlr = [[[Z5DataController sharedInstance] remoteDataController] emailDataController];
120 
121  _focusEmailMsg = [[dataDelegate retrieveEmailMessages] objectAtIndex:[indexPath row]];
122  NSLog(@"V7GoogDriveTableView.tableView:didSelectRowAtIndexPath: focusEmail: bodytext: %@ date: %@ name: %@ randomkey: %@ remoteUniqueId: %@ uid: %@", [_focusEmailMsg bodytext], [_focusEmailMsg date], [_focusEmailMsg name], [_focusEmailMsg randomkey], [_focusEmailMsg remoteUniqueIID], [_focusEmailMsg uid]);
123 
124  NSString *caption = [_focusEmailMsg name];
125 
126  NSLog(@"V7GoogDriveTableView.tableView:didSelectRowAtIndexPath: row: %d caption: %@", row, caption);
127 
128  NSInteger focusEmailMsgUid = [_focusEmailMsg.uid integerValue];
129 
130  if ([_focusEmailMsg randomkey]) {
131  NSData *mphoto = [_focusEmailMsg photo];
132  UIImage *mPhotoImage = [UIImage imageWithData:_focusEmailMsg.photo];
133  [dataDelegate updateHTML:[_focusEmailMsg bodytext]];
134  } else {
135  [eMailCntrlr retrieveMessageStructure:focusEmailMsgUid fromFolder:@"INBOX"];
136  [eMailCntrlr retrieveTotalMessageHTML:focusEmailMsgUid fromFolder:@"INBOX" toDelegate:dataDelegate];
137  }
138 
139  [self showFoot:YES];
140  [self reloadData];
141  [self setNeedsDisplay];
142  [self scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
143  */
144 }
145 
146 
147 @end
id initWithFrame:(CGRect frame)
NSDateFormatter * mDateFormatter
instancetype sharedInstance()
void setViewForHead:(UIView< Z6ContainedView > *headView)
Singleton interface to both core and remote data sources.