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

#import <SecondViewController.h>

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

Instance Methods

(id) - initWithNibName:bundle: [implementation]
 
(void) - viewDidLoad [implementation]
 
(void) - viewWillAppear: [implementation]
 
(void) - render: [implementation]
 
(void) - saveToUserDefaults [implementation]
 
(void) - readUserDefaults [implementation]
 
(void) - logGoogleNow [implementation]
 
(void) - glkView:drawInRect: [implementation]
 
(void) - cycleClearColor [implementation]
 
(void) - showHomeAsk [implementation]
 
(void) - showHomeError: [implementation]
 
(BOOL) - tellHomeError [implementation]
 
(void) - showFetchAsk [implementation]
 
(void) - showFetchError [implementation]
 
(void) - showFetchResult: [implementation]
 
(void) - showPublishAsk [implementation]
 
(void) - showPublishError [implementation]
 
(void) - showPublishResult [implementation]
 
(void) - showDataFetch: [implementation]
 
(void) - showDataFetch:fromFile:withGoogleId: [implementation]
 
(void) - showGoogleFileTitle:andId: [implementation]
 
(void) - updateUI [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 

Properties

GLKView * portal
 
UIButton * logGoogleButton
 

Detailed Description

Definition at line 16 of file SecondViewController.h.

Method Documentation

◆ cycleClearColor()

- (void) cycleClearColor
implementation

Definition at line 173 of file SecondViewController.m.

174 {
175  if (currentIncreasing) {
176  currentRed += 0.002;
177  } else {
178  currentRed -= 0.01;
179  }
180  if (currentRed >= 1.0) {
181  currentRed = 1.0;
182  currentIncreasing = NO;
183  }
184  if (currentRed <= 0.0) {
185  currentRed = 0.0;
186  currentIncreasing = YES;
187  }
188 
189  glClearColor(currentRed*0.4, currentRed*0.7 + 0.2, 0.5, 1.0);
190  glClear(GL_COLOR_BUFFER_BIT);
191 
192 }
BOOL currentIncreasing

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 284 of file SecondViewController.m.

284  {
285  [super didReceiveMemoryWarning];
286  // Dispose of any resources that can be recreated.
287 }

◆ glkView:drawInRect:()

- (void) glkView: (GLKView *)  view
drawInRect: (CGRect)  rect 
implementation

Definition at line 163 of file SecondViewController.m.

163  :(GLKView *)view drawInRect:(CGRect)rect {
164 
165  if ([[[Z5DataController sharedInstance] remoteDataController] isSignedIn]) {
166  [self cycleClearColor];
167  } else {
168  glClearColor(0.3, 0.6, 0.3, 1.0);
169  glClear(GL_COLOR_BUFFER_BIT);
170  }
171 
172 }
Singleton interface to both core and remote data sources.

◆ initWithNibName:bundle:()

- (id) initWithNibName: (NSString *)  nibNameOrNil
bundle: (NSBundle *)  nibBundleOrNil 
implementation

Definition at line 23 of file SecondViewController.m.

23  :(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
24 {
25  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
26  if (self) {
27  // Custom initialization
28  currentRed = 0.0;
29  currentIncreasing = YES;
30  self.title = @"Network";
31  self.tabBarItem.image = [UIImage imageNamed:@"network32"];
32  }
33  return self;
34 }
BOOL currentIncreasing

◆ logGoogleNow()

- (void) logGoogleNow
implementation

Definition at line 147 of file SecondViewController.m.

147  {
148 
149  NSLog(@"SecondView.logGoogleNow");
150 
151  [[[Z5DataController sharedInstance] remoteDataController] loginDriveWithNavigation:self.navigationController andHandler:^(void) {
152 
153  // finish-handler will not be called if logging off
154  NSLog(@"SecondView.logGoogleNow/finish-handler");
155 
156  [[[Z5DataController sharedInstance] remoteDataController] initializeAvailableWithDelegate:self];
157  }];
158 
159 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ readUserDefaults()

- (void) readUserDefaults
implementation

this method will read menu items from user defaults, and put together a meal-under-edit. todays-meal will be created to contain the menu items found.

Definition at line 134 of file SecondViewController.m.

134  {
135  NSLog(@"SecondView.readUserDefaults");
136  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
137 
138 
140  for (MenuItem *meItem in [localData todaysMenuItems]) {
141  NSLog(@"SecondView.readUserDefaults: menu-item: %@", meItem);
142  }
143 }
instancetype sharedInstance()
NSMutableArray * createTodaysMenuFromUserDefaults()
Singleton interface to both core and remote data sources.

◆ render:()

- (void) render: (CADisplayLink*)  displayLink
implementation

Definition at line 117 of file SecondViewController.m.

117  :(CADisplayLink*)displayLink {
118  // GLKView * view = [self.window.subviews objectAtIndex:0];
119  [self.portal display];
120 }

◆ saveToUserDefaults()

- (void) saveToUserDefaults
implementation

Definition at line 124 of file SecondViewController.m.

124  {
125 
126  NSLog(@"SecondView.saveToUserDefaults");
127  [[[Z5DataController sharedInstance] localDataController] putTodaysMenuInUserDefaults];
128 }
instancetype sharedInstance()
Singleton interface to both core and remote data sources.

◆ showDataFetch:()

- (void) showDataFetch: (NSData *)  data
implementation

Definition at line 241 of file SecondViewController.m.

241  : (NSData *) data
242 {
243  NSLog(@"SecondView.showDataFetch");
244 }

◆ showDataFetch:fromFile:withGoogleId:()

- (void) showDataFetch: (NSData *)  data
fromFile: (NSString *)  title
withGoogleId: (NSString *)  fileId 
implementation

Definition at line 245 of file SecondViewController.m.

245  : (NSData *) data fromFile: (NSString *) title withGoogleId: (NSString *) fileId
246 {
247  NSLog(@"SecondView.showDataFetch");
248 }

◆ showFetchAsk()

- (void) showFetchAsk
implementation

Definition at line 217 of file SecondViewController.m.

218 {
219  NSLog(@"SecondView.showFetchAsk");
220 }

◆ showFetchError()

- (void) showFetchError
implementation

Definition at line 221 of file SecondViewController.m.

222 {
223  NSLog(@"SecondView.showFetchError");
224 }

◆ showFetchResult:()

- (void) showFetchResult: (NSArray *)  filen
implementation

Definition at line 225 of file SecondViewController.m.

225  : (NSArray *)filen
226 {
227  NSLog(@"SecondView.showFetchResult");
228 }

◆ showGoogleFileTitle:andId:()

- (void) showGoogleFileTitle: (NSString *)  title
andId: (NSString *)  fileId 
implementation

Definition at line 249 of file SecondViewController.m.

249  : (NSString *) title andId: (NSString *) fileId
250 {
251  NSLog(@"SecondView.showGoogleFileTitle");
252 }

◆ showHomeAsk()

- (void) showHomeAsk
implementation

Definition at line 195 of file SecondViewController.m.

196 {
197  NSLog(@"SecondView.showHomeAsk");
198 }

◆ showHomeError:()

- (void) showHomeError: (NSError *)  error
implementation

Definition at line 199 of file SecondViewController.m.

199  :(NSError *)error
200 {
201  NSLog(@"SecondView.showHomeError");
202 }

◆ showPublishAsk()

- (void) showPublishAsk
implementation

Definition at line 229 of file SecondViewController.m.

230 {
231  NSLog(@"SecondView.showPublishAsk");
232 }

◆ showPublishError()

- (void) showPublishError
implementation

Definition at line 233 of file SecondViewController.m.

234 {
235  NSLog(@"SecondView.showPublishError");
236 }

◆ showPublishResult()

- (void) showPublishResult
implementation

Definition at line 237 of file SecondViewController.m.

238 {
239  NSLog(@"SecondView.showPublishResult");
240 }

◆ tellHomeError()

- (BOOL) tellHomeError
implementation

Definition at line 203 of file SecondViewController.m.

204 {
205  NSLog(@"SecondView.tellHomeError");
206  return NO;
207 }

◆ updateUI()

- (void) updateUI
implementation

Definition at line 257 of file SecondViewController.m.

258 {
259  NSLog(@"SecondView.updateUI");
260  if (![[[Z5DataController sharedInstance] remoteDataController] isSignedIn]) {
261 
262  NSLog(@"SecondView.updateUI: NOT logged on");
263 
264  [self.logGoogleButton setTitle:@"LOG-ON" forState:UIControlStateNormal];
265 
266  [self.logGoogleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
267 
268  } else {
269 
270  NSLog(@"SecondView.updateUI: logged on");
271 
272  [self.logGoogleButton setTitle:@"LOG-OFF (already on)" forState:UIControlStateNormal];
273 
274  [self.logGoogleButton setBackgroundColor:[UIColor colorWithHue:0.48 saturation:0.4 brightness:0.4 alpha:1.0]];
275  [self.logGoogleButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
276 
277  }
278 
279 }
Singleton interface to both core and remote data sources.

◆ viewDidLoad()

- (void) viewDidLoad
implementation

Definition at line 36 of file SecondViewController.m.

36  {
37  [super viewDidLoad];
38  // Do any additional setup after loading the view, typically from a nib.
39 
40  // Create an OpenGL ES context and assign it to the view loaded from storyboard
41  // NSLog(@"SecondView.viewDidLoad: view class: %@", NSStringFromClass([[self view] class]));
42 
43  CGRect totalFrame = self.view.frame;
44  float leftMargin = 0.15*totalFrame.size.width;
45  float topMargin = 90;
46  float buttonHeight = 50.0;
47  float portalHeight = 280;
48  float controlMargin = 30.0;
49  float controlWidth = 0.7*totalFrame.size.width;
50  CGRect logGoogleFrame = CGRectMake(leftMargin, topMargin, controlWidth, buttonHeight);
51  CGRect portalFrame = CGRectMake(leftMargin, topMargin+buttonHeight+controlMargin, controlWidth, portalHeight);
52  CGRect saveLocallyFrame = CGRectMake(leftMargin, topMargin+buttonHeight+2*controlMargin+portalHeight, controlWidth, buttonHeight);
53  CGRect readLocallyFrame = CGRectMake(leftMargin, topMargin+2*buttonHeight+3*controlMargin+portalHeight-16, controlWidth, buttonHeight);
54 
55 // UIButton *logGoogleButton = [[UIButton alloc] initWithFrame:logGoogleFrame];
56  self.logGoogleButton = [[UIButton alloc] initWithFrame:logGoogleFrame];
57  [self.logGoogleButton setTitle:@"Log-On Google" forState:UIControlStateNormal];
58 
59  /*
60  if (![[[Z5DataController sharedInstance] remoteDataController] isSignedIn]) {
61  NSLog(@"SecondView.viewDidLoad: NOT logged on");
62  // [logGoogleButton setBackgroundColor:[UIColor colorWithHue:0.3 saturation:1.0 brightness:0.4 alpha:1.0]];
63  [logGoogleButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
64  } else {
65 
66  NSLog(@"SecondView.viewDidLoad: logged on");
67 
68  [logGoogleButton setTitle:@"LOG-OFF (already on)" forState:UIControlStateNormal];
69 
70  [logGoogleButton setBackgroundColor:[UIColor colorWithHue:0.8 saturation:0.4 brightness:0.4 alpha:1.0]];
71  [logGoogleButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
72 
73  }
74  */
75 
76  [self.logGoogleButton addTarget:self action:@selector(logGoogleNow) forControlEvents:UIControlEventTouchUpInside];
77  [self.view addSubview:self.logGoogleButton];
78 
79  EAGLContext *portalContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
80  self.portal = [[GLKView alloc] initWithFrame:portalFrame context:portalContext];
81  self.portal.delegate = self;
82 
83  // Configure renderbuffers created by the view
84  self.portal.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
85  self.portal.drawableDepthFormat = GLKViewDrawableDepthFormat24;
86  self.portal.drawableStencilFormat = GLKViewDrawableStencilFormat8;
87 
88  // Enable multisampling
89  self.portal.drawableMultisample = GLKViewDrawableMultisample4X;
90 
91  [self.view addSubview:self.portal];
92 
93  UIButton *saveLocallyButton = [[UIButton alloc] initWithFrame:saveLocallyFrame];
94  [saveLocallyButton setTitle:@"Save to Device" forState:UIControlStateNormal];
95  [saveLocallyButton addTarget:self action:@selector(saveToUserDefaults) forControlEvents:UIControlEventTouchUpInside];
96  [self.view addSubview:saveLocallyButton];
97 
98  UIButton *readLocallyButton = [[UIButton alloc] initWithFrame:readLocallyFrame];
99  [readLocallyButton setTitle:@"Read User Defaults" forState:UIControlStateNormal];
100  [readLocallyButton addTarget:self action:@selector(readUserDefaults) forControlEvents:UIControlEventTouchUpInside];
101  [self.view addSubview:readLocallyButton];
102 
103 
104  [[self view] setBackgroundColor:[UIColor lightGrayColor]];
105 }

◆ viewWillAppear:()

- (void) viewWillAppear: (BOOL)  animated
implementation

Definition at line 107 of file SecondViewController.m.

107  :(BOOL)animated
108 {
109  // self.portal.enableSetNeedsDisplay = YES;
110 
111  self.portal.enableSetNeedsDisplay = NO;
112  CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
113  [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
114 
115 
116 }

Property Documentation

◆ logGoogleButton

- (UIButton*) logGoogleButton
readwritenonatomicstrong

Definition at line 20 of file SecondViewController.h.

◆ portal

- (GLKView*) portal
readwritenonatomicstrong

Definition at line 19 of file SecondViewController.h.


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