Today's Menu  Portugal
journal and plan nutrition
V3GalleryMenuItemControlbarView.m
Go to the documentation of this file.
1 //
2 // V3GalleryMenuItemControlbarView.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 12/26/18.
6 // Copyright © 2018 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 #import <UIKit/UIKit.h>
10 #import "Z5DataController.h"
12 
13 @implementation V3GalleryMenuItemControlbarView
14 {
15  id<V3GalleryMenuItemControlbarProtocol> mDelegate;
16  // NSInteger pickerFocusGallery;
17  NSDateFormatter *mTimeOfDayFormatter;
19 
20  UILabel *label;
21  UIPickerView *kitchenPickerView;
22  UIButton *plusButton;
23 }
24 
25 - (instancetype)initWithFrame:(CGRect)frame andDelegate:(id<V3GalleryMenuItemControlbarProtocol>)delegate
26 {
27  self = [super initWithFrame:frame];
28  if (self) {
29  mDelegate = delegate;
30 
31  mTimeOfDayFormatter = [[NSDateFormatter alloc] init];
32  [mTimeOfDayFormatter setDateStyle:NSDateFormatterNoStyle];
33  [mTimeOfDayFormatter setTimeStyle:NSDateFormatterShortStyle];
34 
35  label = [[UILabel alloc] init];
36  [label setTextAlignment:NSTextAlignmentCenter];
37  [self addSubview:label];
38 
39  kitchenPickerView = [[UIPickerView alloc] init];
40  [kitchenPickerView setDelegate:mDelegate];
41  [kitchenPickerView setDataSource:mDelegate];
42  [kitchenPickerView setBackgroundColor:[UIColor wheatColor]];
43  [self addSubview:kitchenPickerView];
44 
45  plusButton = [[UIButton alloc] init];
46  [plusButton addTarget:mDelegate action:@selector(clickPlusButton) forControlEvents:UIControlEventTouchUpInside];
47  UIImage *plusButtonImage = [UIImage imageNamed:@"plusSign.png"];
48  [plusButton setImage:plusButtonImage forState:UIControlStateNormal];
49  [self addSubview:plusButton];
50 
51  heightRequired = 80;
52 
53  }
54 
55  return self;
56 }
57 
58 - (void)appear:(CGRect)bound {
59  float controlbarWidth = bound.size.width;
60 
61  CGRect labelFrame = CGRectMake(0, 0, controlbarWidth, 32);
62  CGRect galleryPickerFrame = CGRectMake(0, 32, controlbarWidth, 48);
63  CGRect plusButtonFrame = CGRectMake(controlbarWidth - 48, 2, 44, 44);
64 
65  NSString *headerText = [mTimeOfDayFormatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]];
66  [Z5DataController labelize:label withText:headerText];
67  [label setFrame:labelFrame];
68 
69  [kitchenPickerView selectRow:[mDelegate getKitchenFocusGallery] inComponent:0 animated:YES];
70  [kitchenPickerView setFrame:galleryPickerFrame];
71 
72  [plusButton setFrame:plusButtonFrame];
73  [self bringSubviewToFront:plusButton];
74 }
75 
77  return heightRequired;
78 }
79 
80 @end
id< U7ParamEditControlDelegate > delegate
Singleton interface to both core and remote data sources.
void labelize:withText:(UILabel *targLabel, [withText] NSString *txt)