Today's Menu  Portugal
journal and plan nutrition
Y3GmailViewHeader.m
Go to the documentation of this file.
1 //
2 // Y3GmailViewHeader.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 6/2/17.
6 // Copyright © 2017 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
9 #import "Y3GmailViewHeader.h"
12 #import "Z5DataController.h"
14 
15 @implementation Y3GmailViewHeader
16 {
17  UIButton *scanMailServerButton;
18  UILabel *loginInfoLabel;
19 }
20 static float loginInfoViewHeight = 52;
21 - (instancetype) initWithDelegate:(id<Y3GmailHeaderProtocol>) delegate
22 {
23  self = [super init];
24  if (self) {
25  _msgHeaderDelegate = delegate;
26  }
27  return self;
28 }
29 
30 #pragma mark - Z6ContainedView protocol
32 {
33  float ret = loginInfoViewHeight;
34  return ret;
35 }
36 - (void) appear:(CGRect)bound
37 {
38  // CGRect totalFrame = self.frame;
39  NSLog(@"GmailViewHeader.appear: size: %3.2f x %3.2f",
40  [self bounds].size.width, [self bounds].size.height);
41 
42  Z5GoogleLoginController *loginControl = [[[Z5DataController sharedInstance] remoteDataController] loginController];
43 
44  Boolean isLoggedIn = [[loginControl signedIn] boolValue];
45  if (isLoggedIn) {
46  [self.contentView setBackgroundColor:[UIColor brownColor]];
47 
48  CGRect loginInfoLabelFrame = CGRectMake(2.0, 2.0, bound.size.width/2, loginInfoViewHeight - 4.0);
49 
50  loginInfoLabel = [[UILabel alloc] initWithFrame:loginInfoLabelFrame];
51  [loginInfoLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16.0]];
52  [loginInfoLabel setTextAlignment:NSTextAlignmentCenter];
53  [loginInfoLabel setBackgroundColor:[[Z5DataController sharedInstance] wheatColor]];
54  // [loginInfoLabel setTextColor:[UIColor blackColor]];
55  [self addSubview:loginInfoLabel];
56  NSString *loginName = [[_msgHeaderDelegate getLoggedInProfile] name];
57  [loginInfoLabel setText:loginName];
58 
59  } else {
60  CGRect signInButtonFrame = CGRectMake(bound.size.width/2 + 2,
61  2.0,
62  bound.size.width/2 - 4,
64 
65 
66 
67 
68  [loginControl configureGoogleSignIn];
70  signIn.uiDelegate = (id<GIDSignInUIDelegate>)_msgHeaderDelegate;
71  signIn.delegate = loginControl;
72 
73  _signInButton = [[GIDSignInButton alloc] init];
74  [_signInButton setFrame:signInButtonFrame];
75  _signInButton.layer.cornerRadius = 8;
76  _signInButton.layer.borderColor = [[UIColor blackColor] CGColor];
77  _signInButton.layer.borderWidth = 3.0;
78  _signInButton .clipsToBounds = YES;
79  [self addSubview:_signInButton];
80  }
81  //[self declareLogin];
82 }
83 
84 //- (float)heightRequirement {
85 // return [Y3GmailViewHeader heightRequirement];
86 //}
87 
88 //-(void) declareLogin
89 //{
90 // Z5GoogleLoginController *loginControl = [[[Z5DataController sharedInstance] remoteDataController] loginController];
91 // if ([[loginControl signedIn] boolValue]) {
92 // [_signInButton setHidden:YES];
93 // [self setBackgroundColor:[UIColor brownColor]];
94 //
95 // NSString *loginName = [[_msgHeaderDelegate getLoggedInProfile] name];
96 // [loginInfoLabel setText:loginName];
97 // } else {
98 // [_signInButton setHidden:NO];
99 // [loginInfoLabel setHidden:YES];
100 // [self setBackgroundColor:[UIColor orangeColor]];
101 // }
102 //}
103 
104 
105 //- (void) clickedScanServer
106 //{
107 // NSLog(@"MenuApprovalBar.clickedScanServer");
108 // [gmailHdrDelegate didTapScanServer];
109 //}
110 
111 #pragma mark - Z5GoogleLoginListener
112 - (void) signedIn: (GIDGoogleUser *)user
113 {
114  NSLog(@"Y3GmailViewHeader.signedIn: %@", user.profile.name);
115  // [self setNeedsDisplay];
116 }
117 - (void) signedOut: (GIDGoogleUser *)user
118 {
119  NSLog(@"Y3GmailViewHeader.signedOut: %@", user.profile.name);
120  // [self setNeedsDisplay];
121 }
122 //- (void) logOutGoogle {
123 // NSLog(@"Y3GmailViewHeader.logOutGoogle");
124 // [loginInfoLabel setHidden:YES];
125 // [_signInButton setHidden:NO];
126 //}
127 
128 /*
129  // Only override drawRect: if you perform custom drawing.
130  // An empty implementation adversely affects performance during animation.
131  - (void)drawRect:(CGRect)rect {
132  // Drawing code
133  }
134  */
135 
136 
137 @end
id< GIDSignInDelegate > delegate
Definition: GIDSignIn.h:103
GIDProfileData * profile
Definition: GIDGoogleUser.h:24
instancetype sharedInstance()
UILabel * loginInfoLabel
id< U7ParamEditControlDelegate > delegate
id< GIDSignInUIDelegate > uiDelegate
Definition: GIDSignIn.h:106
Singleton interface to both core and remote data sources.
NSString * name
GIDSignIn * sharedInstance()
static float loginInfoViewHeight