Today's Menu  Portugal
journal and plan nutrition
Instance Methods | Properties | List of all members
V7GoogCalendarViewController Class Reference

#import <V7GoogCalendarViewController.h>

Inheritance diagram for V7GoogCalendarViewController:
Inheritance graph
[legend]
Collaboration diagram for V7GoogCalendarViewController:
Collaboration graph
[legend]

Instance Methods

(void) - viewDidLoad [implementation]
 
(void) - signedIn: [implementation]
 
(void) - signedOut: [implementation]
 
(void) - fetchEvents [implementation]
 
(void) - displayResultWithTicket:finishedWithObject:error: [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 

Properties

GTLRCalendarService * service
 
GIDSignInButtonsignInButton
 
UIButton * listEventsButton
 

Detailed Description

Definition at line 16 of file V7GoogCalendarViewController.h.

Method Documentation

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 134 of file V7GoogCalendarViewController.m.

134  {
135  [super didReceiveMemoryWarning];
136  // Dispose of any resources that can be recreated.
137 }

◆ displayResultWithTicket:finishedWithObject:error:()

- (void) displayResultWithTicket: (GTLRServiceTicket *)  ticket
finishedWithObject: (GTLRCalendar_Events *)  events
error: (NSError *)  error 
implementation

Definition at line 107 of file V7GoogCalendarViewController.m.

107  :(GTLRServiceTicket *)ticket
108  finishedWithObject:(GTLRCalendar_Events *)events
109  error:(NSError *)error {
110  NSLog(@"GoogCalendarViewController.displayResult");
111  if (error == nil) {
112  NSMutableString *output = [[NSMutableString alloc] init];
113  if (events.items.count > 0) {
114  [output appendString:@"Upcoming events:\n"];
115  for (GTLRCalendar_Event *event in events) {
116  GTLRDateTime *start = event.start.dateTime ?: event.start.date;
117  NSString *startString =
118  [NSDateFormatter localizedStringFromDate:[start date]
119  dateStyle:NSDateFormatterShortStyle
120  timeStyle:NSDateFormatterShortStyle];
121  [output appendFormat:@"%@ - %@\n", startString, event.summary];
122  }
123  } else {
124  [output appendString:@"No upcoming events found."];
125  }
126  NSLog(@"GoogCalendarViewController.displayResult:\n%@", output);
127  // self.output.text = output;
128  } else {
129  // [self showAlert:@"Error" message:error.localizedDescription];
130  NSLog(@"GoogCalendarViewController.displayResult:\nerror: %@", error.localizedDescription);
131  }
132 }

◆ fetchEvents()

- (void) fetchEvents
implementation

Definition at line 92 of file V7GoogCalendarViewController.m.

92  {
93  NSLog(@"GoogCalendarViewController.fetchEvents");
94 
95  GTLRCalendarQuery_EventsList *query =
96  [GTLRCalendarQuery_EventsList queryWithCalendarId:@"primary"];
97  query.maxResults = 10;
98  query.timeMin = [GTLRDateTime dateTimeWithDate:[NSDate date]];
99  query.singleEvents = YES;
100  query.orderBy = kGTLRCalendarOrderByStartTime;
101 
102  [self.service executeQuery:query
103  delegate:self
104  didFinishSelector:@selector(displayResultWithTicket:finishedWithObject:error:)];
105 }

◆ signedIn:()

- (void) signedIn: (GIDGoogleUser *)  user
implementation

Definition at line 78 of file V7GoogCalendarViewController.m.

78  : (GIDGoogleUser *)user
79 {
80  NSLog(@"GoogCalendarViewController.signedIn: user-auth: %@", user.authentication.fetcherAuthorizer);
81 
82  Z5GoogleCalendarDataController *calendarControl = [[[Z5DataController sharedInstance] remoteDataController] calendarController];
83  self.service = [calendarControl service];
84 }
instancetype sharedInstance()
id< GTMFetcherAuthorizationProtocol > fetcherAuthorizer()
Singleton interface to both core and remote data sources.
GIDAuthentication * authentication
Definition: GIDGoogleUser.h:27

◆ signedOut:()

- (void) signedOut: (GIDGoogleUser *)  user
implementation

Definition at line 85 of file V7GoogCalendarViewController.m.

85  :(GIDGoogleUser *)user
86 {
87  self.service = nil;
88 }

◆ viewDidLoad()

- (void) viewDidLoad
implementation

Definition at line 20 of file V7GoogCalendarViewController.m.

20  {
21  [super viewDidLoad];
22 
23  self.title = @"Google Calendar";
24  // Initialize the service object.
25  self.service = [[GTLRCalendarService alloc] init];
26  [[self view] setBackgroundColor:[UIColor colorWithHue:0.32
27  saturation:0.8
28  brightness:0.5
29  alpha:1.0]];
30 
31  CGRect totalFrame = self.view.frame;
32 
33  Z5GoogleLoginController *loginControl = [[[Z5DataController sharedInstance] remoteDataController] loginController];
34 
35  Z5GoogleCalendarDataController *calendarControl = [[[Z5DataController sharedInstance] remoteDataController] calendarController];
36 
37  if ([[loginControl signedIn] boolValue]) {
38  [calendarControl signedIn:[loginControl signedInUser]];
39  [calendarControl addCalendarListener:self];
40 
41  CGRect listFilesButtonFrame = CGRectMake(totalFrame.size.width * 0.30,
42  totalFrame.size.height * 0.2,
43  totalFrame.size.width * 0.4,
44  totalFrame.size.height * 0.1);
45 
46  self.listEventsButton = [[UIButton alloc] initWithFrame:listFilesButtonFrame];
47  [self.listEventsButton setTitle:@"list events" forState:UIControlStateNormal];
48  [self.listEventsButton addTarget:self action:@selector(fetchEvents) forControlEvents:UIControlEventTouchUpInside];
49  [self.view addSubview:self.listEventsButton];
50 
51  self.service = [calendarControl service];
52 
53  } else {
54  // Add the sign-in button.
55  CGRect signInButtonFrame = CGRectMake(totalFrame.size.width * 0.45,
56  totalFrame.size.height * 0.1,
57  totalFrame.size.width * 0.1,
58  totalFrame.size.height * 0.05);
59 
60 
61  [loginControl configureGoogleSignIn];
63  signIn.delegate = loginControl;
64  signIn.uiDelegate = self;
65 
66  self.signInButton = [[GIDSignInButton alloc] init];
67  [self.signInButton setFrame:signInButtonFrame];
68  _signInButton.layer.cornerRadius = 8;
69  _signInButton.layer.borderColor = [[UIColor blackColor] CGColor];
70  _signInButton.layer.borderWidth = 3.0;
71  _signInButton .clipsToBounds = YES;
72  [self.view addSubview:self.signInButton];
73 
74  }
75 }
id< GIDSignInDelegate > delegate
Definition: GIDSignIn.h:103
instancetype sharedInstance()
id< GIDSignInUIDelegate > uiDelegate
Definition: GIDSignIn.h:106
Singleton interface to both core and remote data sources.
void addCalendarListener:(id< Z5GoogleCalendarListener > ear)
GIDSignIn * sharedInstance()

Property Documentation

◆ listEventsButton

- (UIButton*) listEventsButton
readwritenonatomicstrong

Definition at line 20 of file V7GoogCalendarViewController.h.

◆ service

- (GTLRCalendarService*) service
readwritenonatomicstrong

Definition at line 18 of file V7GoogCalendarViewController.h.

◆ signInButton

- (GIDSignInButton*) signInButton
readwritenonatomicstrong

Definition at line 19 of file V7GoogCalendarViewController.h.


The documentation for this class was generated from the following files: