78 self.title =
@"Google Drive";
80 [[
self view] setBackgroundColor:[UIColor colorWithHue:0.32
84 UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Create item"
85 style:UIBarButtonItemStylePlain
87 action:@selector(createFoodItem)];
88 self.navigationItem.rightBarButtonItem = anotherButton;
89 self.navigationItem.rightBarButtonItem.enabled = YES;
100 if ([[loginControl signedIn] boolValue]) {
103 [driveControl listRootFor:self];
126 -(void)viewWillAppear:(BOOL)animated
128 CGRect totalFrame =
self.view.frame;
129 float tableWidth = totalFrame.size.width - 8;
130 CGRect tableBound = CGRectMake(0.0, 0.0, tableWidth, 70.0);
132 CGRect focusFoodBaseLabelFrame = CGRectMake(4.0, 0.0, tableWidth - 8.0, 36);
133 UILabel *focusFoodBaseLabel = [[UILabel alloc] initWithFrame:focusFoodBaseLabelFrame];
136 [focusFoodLabel setMessageLabel:focusFoodBaseLabel];
137 [focusFoodLabel appear:tableBound];
139 [controlBar appear:googDriveControlBarFrame];
141 NSLog(
@"V7GoogDriveViewController.viewWillAppear end");
147 float snugMargin = 2.0;
148 CGRect totalFrame =
self.view.frame;
149 float totalWidth = totalFrame.size.width - (2*snugMargin);
150 float tableWidth = totalFrame.size.width - (2*snugMargin);
151 CGRect topNavigationFrame = [[[
self navigationController] navigationBar] frame];
152 float topOfContent = topNavigationFrame.origin.y + topNavigationFrame.size.height;
154 float controlbarHeight = 52.0;
156 topOfContent+snugMargin,
157 totalWidth - (2*snugMargin),
161 float tableTop = topOfContent + controlbarHeight+(2*snugMargin);
163 = CGRectMake(snugMargin,
166 totalFrame.size.height - tableTop - 150);
168 float focusFoodLabelFrameHeight = 60;
169 CGRect focusFoodLabelFrame = CGRectMake(4.0,
172 focusFoodLabelFrameHeight);
175 NSNumber *labelHeight = [NSNumber numberWithFloat:36.0];
176 [focusFoodLabel setContainedHeight:labelHeight];
177 [focusFoodLabel setBackgroundColor:[UIColor greenColor]];
180 initWithFrame:googDriveListTableViewFrame
181 andHeader:focusFoodLabel
183 [googDriveListTableView setDataSource:self];
184 [googDriveListTableView setDelegate:self];
185 [googDriveListTableView setTableCaption:focusFoodLabel];
186 [googDriveListTableView setBackgroundColor:[UIColor wheatColor]];
188 [
self.view addSubview:controlBar];
189 [
self.view addSubview:googDriveListTableView];
205 [controlBar placeLoginButton];
211 [driveControl
signedIn:signedInUser];
215 GTLRDriveService *ret = [driveControl
service];
243 [
self.listFilesButton removeFromSuperview];
254 [controlBar userLoggedIn:YES];
260 [controlBar userLoggedIn:NO];
265 #pragma mark - V7GoogDriveAPIProtocol 266 - (void) ticketCompleted:(GTLRServiceTicket *)ticket;
268 NSLog(
@"GoogDriveViewController.ticketCompleted");
270 - (void) resultStage: (
QueryStage)stage returnedFiles: (NSArray<GTLRDrive_File *> *)files
275 NSLog(
@"V7GoogDriveViewController.resultStage: qNone");
280 NSLog(
@"V7GoogDriveViewController.resultStage: qRoot");
285 NSLog(
@"V7GoogDriveViewController.resultStage: qJournalRoot");
300 [googDriveListTableView reloadData];
307 NSLog(
@"V7GoogDriveViewController.resultStage: qJournalPartRoot");
313 NSLog(
@"V7GoogDriveViewController.resultStage: kOblateSpheroid");
321 #pragma mark - moved to APIController 324 #pragma mark - local controls 327 NSLog(
@"V7GoogDriveViewController.createFoodItem");
334 [
self.navigationController pushViewController:driveMenuItem animated:YES];
339 NSLog(
@"V7GoogDriveViewController.clickRecipeBuuton");
342 #pragma mark - UITableViewDataSource 344 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
349 NSLog(
@"V7GoogDriveViewController.numberOfSectionsInTableView: %ld", (
long)ret);
353 - (NSInteger)tableView:(UITableView *)tableView
354 numberOfRowsInSection:(NSInteger)section
356 NSInteger ret = [focusFoodDriveArray count];
358 NSLog(
@"V7GoogDriveViewController.numberOfRowsInSection: section# %ld, rows: %ld", (
long)section, (
long)ret);
363 - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
365 UITableViewCell *cell = nil;
369 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"usda-pdata-display"];
371 cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
373 CGRect contentRect = [cell.contentView frame];
374 CGRect fetchPublishButton1Frame = CGRectMake(contentRect.size.width - 86.0f, 5.0, 64.0f, contentRect.size.height - 10);
375 UIButton *pushMe = [[UIButton alloc] initWithFrame:fetchPublishButton1Frame];
376 [pushMe setBackgroundColor:[UIColor grayColor]];
377 [pushMe setTitle:@"GO" forState:UIControlStateNormal];
378 [pushMe setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
380 [cell.contentView addSubview:pushMe];
382 [cell.layer setCornerRadius:7.0f];
383 [cell.layer setMasksToBounds:YES];
384 [cell.layer setBorderWidth:1.0f];
386 [cell.textLabel setTextColor:[UIColor purpleColor]];
387 [cell.textLabel setOpaque:YES];
389 [cell setBackgroundColor:[UIColor brownColor]];
390 NSInteger nComponents = [focusFoodDriveArray count];
392 if (nComponents > [indexPath row]) {
394 GTLRDrive_File *driveFile = [focusFoodDriveArray objectAtIndex:[indexPath row]];
397 }
else if (0 == nComponents) {
398 cell.textLabel.text =
@"no food data";
404 #pragma mark - UITableViewDelegate 406 - (void)tableView:(UITableView *)tableView
407 didSelectRowAtIndexPath:(NSIndexPath *)indexPath
409 NSUInteger row_n = [indexPath row];
410 GTLRDrive_File *file = [focusFoodDriveArray objectAtIndex:row_n];
411 NSLog(
@"V7GoogDriveViewController.didSelectRowAtIndexPath: %@, mimeType %@", [file name], file.mimeType);
412 if ([file.mimeType isEqualToString:
@"application/vnd.google-apps.folder"]){
415 NSLog(
@"V7GoogDriveViewController.didSelectRowAtIndexPath: no directory");
423 [
super didReceiveMemoryWarning];
NSMutableArray * focusFoodDriveArray
GTLRDriveService * viewDidLoadLoggedIn:(GIDGoogleUser *signedInUser)
GTLRDriveService * service
void extraLabelize:withText:(UILabel *targLabel, [withText] NSString *txt)
V7GoogDriveTableView * googDriveListTableView
void unloadViewLoggedIn()
void didReceiveMemoryWarning()
CGRect googDriveControlBarFrame
instancetype sharedInstance()
id< GTMFetcherAuthorizationProtocol > fetcherAuthorizer()
Z5GoogleDriveController * driveControl
void signedIn:(GIDGoogleUser *user)
GTLRServiceTicket * listJournaItemPartRoot:(NSString *journalItemPartRootId)
NSMutableArray * provideFocusFoodListDriveArray()
id< GIDSignInUIDelegate > uiDelegate
void viewDidLoadAnonymous()
Z1ContainedLabel * focusFoodLabel
Singleton interface to both core and remote data sources.
GIDSignIn * sharedInstance()
void configureGoogleSignIn()
GIDAuthentication * authentication
GIDGoogleUser * signedInUser
void labelizeCell:withText:inColor:andDetail:(UITableViewCell *targCell, [withText] NSString *txt, [inColor] UIColor *color, [andDetail] NSString *detailTxt)
CGRect googDriveListTableViewFrame