Today's Menu  Portugal
journal and plan nutrition
V7GoogDriveControlbarView.m
Go to the documentation of this file.
1 //
2 // V7GoogDriveControlbarView.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 1/1/17.
6 // Copyright © 2017 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 #import <GTLRDrive.h>
9 
10 #import "Z5DataController.h"
14 #import "TotalEditStateEnum.h"
15 
16 @implementation V7GoogDriveControlbarView
17 {
18  Boolean isUserLoggedIn;
19  UIButton *controlbarRightButton;
25  CGSize buttonSize;
26 
27  id<V7GoogDriveControlDelegate> delegate;
28 }
29 
30 - (instancetype) initWithDelegate:(id<V7GoogDriveControlDelegate>) dele andFrame: (CGRect)frame
31 {
32  self = [super initWithFrame:frame];
33  if (self) {
34  delegate = dele;
35  [self setClipsToBounds:YES];
36  NSLog(@"Z7GoogDriveControlbar.initWithDelegate: (%@) finish init", NSStringFromClass([delegate class]));
37  }
38  return self;
39 }
40 
41 #pragma mark - Z6ContainedView
42 
44 {
45  return buttonSize.height + 2;
46 }
47 - (void) appear:(CGRect)bound
48 {
49  float viewWidth = bound.size.width;
50  NSLog(@"Z7GoogDriveControlBar.appear: bound: %3.2f/%3.2f %3.2f/%3.2f",
51  bound.origin.x, bound.origin.y, bound.size.width, bound.size.height);
52 
53  buttonSize = CGSizeMake(viewWidth * 0.50 - 4.0, 40.0);
54  [self fillViewOnAppearance:self.bounds];
55 }
56 
57 - (void) fillViewOnAppearance: (CGRect) parentBound
58 {
59  float viewWidth = parentBound.size.width;
60  NSLog(@"Z7GoogDriveControlBar.fillViewForDelegate: viewWidth: %3.2f", viewWidth);
61  buttonSize = CGSizeMake(viewWidth * 0.5, 40.0);
62  // CGRect totalFrame = self.frame;
63 
64  if (isUserLoggedIn) {
65  [self setBackgroundColor:[UIColor orangeColor]];
66  [self placeLoginButton];
67  } else {
68  [self setBackgroundColor:[UIColor yellowColor]];
69  }
70 }
71 
73 {
74  CGRect totalFrame = self.frame;
75  float buttonWidth = 160.0;
76 // CGRect signInButtonFrame = CGRectMake(totalFrame.size.width * 0.45,
77 // totalFrame.size.height * 0.1,
78 // totalFrame.size.width * 0.1,
79 // totalFrame.size.height * 0.05);
80  CGRect signInButtonFrame = CGRectMake(totalFrame.size.width - buttonWidth - 12.0,
81  2.0,
82  buttonWidth,
83  totalFrame.size.height -4.0);
84 
85  Z5GoogleLoginController *loginControl = [[[Z5DataController sharedInstance] remoteDataController] loginController];
86 
87  [loginControl configureGoogleSignIn];
89  signIn.uiDelegate = (id<GIDSignInUIDelegate>)delegate;
90  signIn.delegate = loginControl;
91 
92  _signInButton = [[GIDSignInButton alloc] init];
93  _signInButton.layer.cornerRadius = 8;
94  _signInButton.layer.borderColor = [[UIColor blackColor] CGColor];
95  _signInButton.layer.borderWidth = 3.0;
96  _signInButton .clipsToBounds = YES;
97 
98  NSLog(@"Z7GoogDriveControlBar.placeLoginButton: init/size: %3.2f %3.2f", [_signInButton frame].size.width, [_signInButton frame].size.height); // 120x48
99  [_signInButton setFrame:signInButtonFrame];
100  [self addSubview:_signInButton];
101 }
102 - (void) userLoggedIn:(BOOL) flag
103 {
104  isUserLoggedIn = flag;
105  [_signInButton setHidden:flag];
106 }
107 - (void) showRecipeOption:(Boolean)flag
108 {
109  ;
110 }
112 {
113  NSLog(@"Z7GoogDriveControlBar: clickRecipeButton");
114 }
115 
116 /*
117 // Only override drawRect: if you perform custom drawing.
118 // An empty implementation adversely affects performance during animation.
119 - (void)drawRect:(CGRect)rect {
120  // Drawing code
121 }
122 */
123 
124 @end
id< GIDSignInDelegate > delegate
Definition: GIDSignIn.h:103
CGRect controlbarLeftButtonFrame
UIButton * controlbarRightButton
id< V7GoogDriveControlDelegate > delegate
instancetype sharedInstance()
UIButton * controlbarLeftButton
CGRect recipeOpenFrame
void fillViewOnAppearance:(CGRect parentBound)
UIButton * controlbarRecipeButton
CGRect controlbarRightButtonFrame
id< GIDSignInUIDelegate > uiDelegate
Definition: GIDSignIn.h:106
CGSize buttonSize
Singleton interface to both core and remote data sources.
GIDSignIn * sharedInstance()