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

#import <B2NutritionCalendarView.h>

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

Instance Methods

(void) - refreshCalendar
 
(void) - drawRect:
 
(instancetype) - init [implementation]
 
(NSArray< NSArray< Meal *> *> *) - monthMeals [implementation]
 
(NSInteger) - getDateDay: [implementation]
 
(NSInteger) - getDateMonth: [implementation]
 
(NSInteger) - getDateYear: [implementation]
 
- Instance Methods inherited from CalendarView
(instancetype) - initWithPosition:y:
 
(void) - setMode:
 
(void) - refresh
 
(void) - goToToday
 
(void) - advanceCalendarContents
 
(void) - rewindCalendarContents
 
(NSDictionary *) - generateAttributes:withFontSize:withColor:withAlignment:
 
(void) - drawCircle:toContext:withColor:
 
(instancetype) - initWithFrame: [implementation]
 
(void) - awakeFromNib [implementation]
 
(void) - dealloc [implementation]
 
(void) - initProperties [implementation]
 
(void) - setup [implementation]
 
(void) - setCalendarIdentifier: [implementation]
 
(void) - setLocale: [implementation]
 
(void) - setCurrentDate: [implementation]
 
(NSDateComponents *) - generateDateComponents [implementation]
 
(NSDate *) - generateDateWithDay:month:year: [implementation]
 
(NSInteger) - getLastDayOfMonth:year: [implementation]
 
(void) - generateDayRects [implementation]
 
(void) - generatePersianDayRects [implementation]
 
(void) - generateMonthRects [implementation]
 
(void) - generateYearRects [implementation]
 
(CGFloat) - getEffectiveWeekDaysYOffset [implementation]
 
(CGFloat) - getEffectiveDaysYOffset [implementation]
 
(CGFloat) - getEffectiveMonthsYOffset [implementation]
 
(CGFloat) - getEffectiveYearsYOffset [implementation]
 
(void) - drawRoundedRectangle:toContext: [implementation]
 
(void) - drawWeekDays [implementation]
 
(void) - changeDateEvent [implementation]
 
(void) - selectRangeOfCalendar [implementation]
 
(void) - advanceCalendarContentsWithEvent: [implementation]
 
(void) - rewindCalendarContentsWithEvent: [implementation]
 
(void) - leftSwipe: [implementation]
 
(void) - rightSwipe: [implementation]
 
(void) - pinch: [implementation]
 
(void) - tap: [implementation]
 
(void) - doubleTap: [implementation]
 
(void) - longPress: [implementation]
 
(BOOL) - checkPoint:inArray:andSetValue: [implementation]
 
(CalendarViewRect *) - checkPoint:inArray: [implementation]
 
(void) - fade [implementation]
 

Additional Inherited Members

- Protected Attributes inherited from CalendarView
NSInteger type
 
NSInteger minType
 
NSInteger mode
 
NSInteger event
 
NSInteger currentDay
 
NSInteger currentMonth
 
NSInteger currentYear
 
NSInteger todayDay
 
NSInteger todayMonth
 
NSInteger todayYear
 
NSMutableArray * monthRects
 
NSMutableArray * yearRects
 
CGRect yearTitleRect
 
CGRect monthTitleRect
 
NSInteger startRangeDay
 
NSInteger startRangeMonth
 
NSInteger startRangeYear
 
CalendarViewRectstartRangeDayRect
 
NSDate * startDate
 
NSInteger endRangeDay
 
NSInteger endRangeMonth
 
NSInteger endRangeYear
 
CalendarViewRectendRangeDayRect
 
NSDate * endDate
 
- Properties inherited from CalendarView
NSMutableArray * dayRects
 
id< CalendarViewDelegate > calendarDelegate
 
NSDate * currentDate
 
UIColor * fontColor
 
UIColor * fontHeaderColor
 
UIColor * fontSelectedColor
 
UIColor * selectionColor
 
UIColor * todayColor
 
UIColor * bgColor
 
CGFloat dayCellWidth
 
CGFloat dayCellHeight
 
CGFloat monthCellWidth
 
CGFloat monthCellHeight
 
CGFloat yearCellWidth
 
CGFloat yearCellHeight
 
NSString * fontName
 
CGFloat dayFontSize
 
CGFloat headerFontSize
 
BOOL shouldMarkSelectedDate
 
BOOL shouldMarkToday
 
BOOL shouldShowHeaders
 
NSCalendarIdentifier calendarIdentifier
 
NSLocale * locale
 
NSInteger preferredWeekStartIndex
 
BOOL useVeryShortWeekdaySymbols
 
NSCalendarIdentifier calendarId [implementation]
 
NSLocale * calenderLocale [implementation]
 

Detailed Description

Definition at line 11 of file B2NutritionCalendarView.h.

Method Documentation

◆ drawRect:()

- (void) drawRect: (CGRect)  rect

Reimplemented from CalendarView.

Definition at line 91 of file B2NutritionCalendarView.m.

91  :(CGRect)rect
92 {
93  [super drawRect:rect];
94 
95  // NSLog(@"B2NutritionCalendarView.drawRect: self class: %@", NSStringFromClass([self class]));
96  // draws entire rectangle
97  // NSLog(@"B2NutritionCalendarView.drawRect: %3.2f/%3.2f @ %3.2f/%3.2f\n", rect.size.width, rect.size.height, rect.origin.x, rect.origin.y);
98  CGContextRef context = UIGraphicsGetCurrentContext();
99  NSDictionary *attributesBlack = [self generateAttributes:self.fontName
100  withFontSize:self.dayFontSize
101  withColor:self.fontColor
102  withAlignment:NSTextAlignmentFromCTTextAlignment(kCTTextAlignmentCenter)];
103 
104  NSMutableArray *rects = [super dayRects];
105 
106 
107  if (rects) {
108  for (CalendarViewRect *rect in rects) {
109  NSDictionary *attrs = attributesBlack;
110  CGRect rectText = rect.frame;
111  //dateComponents.day = 4;
112  // NSDate *calendarCellDate = [gregorianCalendar dateFromComponents:dateComponents];
113 
114 
115  NSArray *dayMeals = [mMeals objectAtIndex:rect.value];
116  NSInteger nMealsInDay = [dayMeals count];
117  if (0 < nMealsInDay) {
118  [self drawCircle:rect.frame toContext:&context withColor:[UIColor yellowColor]];
119  } else {
120  [self drawCircle:rect.frame toContext:&context withColor:[UIColor greenColor]];
121  }
122 
123  // attrs = attributesBlack;
124  [rect.str drawUsingRect:rectText withAttributes:attrs];
125  }
126  }
127 }

◆ getDateDay:()

- (NSInteger) getDateDay: (NSDate *)  date
implementation

Definition at line 71 of file B2NutritionCalendarView.m.

71  :(NSDate *)date
72 {
73  assert(date);
74  NSInteger mealDay = [gregorianCalendar component:(NSCalendarUnitDay) fromDate:date];
75  return mealDay;
76 }

◆ getDateMonth:()

- (NSInteger) getDateMonth: (NSDate *)  date
implementation

Definition at line 77 of file B2NutritionCalendarView.m.

77  :(NSDate *)date
78 {
79  assert(date);
80  NSInteger currentMonth = [gregorianCalendar component:NSCalendarUnitMonth fromDate:date];
81  return currentMonth;
82 }
NSInteger currentMonth
Definition: CalendarView.m:67

◆ getDateYear:()

- (NSInteger) getDateYear: (NSDate *)  date
implementation

Definition at line 84 of file B2NutritionCalendarView.m.

84  :(NSDate *)date
85 {
86  assert(date);
87 // NSInteger currentYear = [gregorianCalendar component:NSCalendarUnitYear fromDate:[self currentDate]];
88  NSInteger currentYear = [gregorianCalendar component:NSCalendarUnitYear fromDate:date];
89  return currentYear;
90 }
NSInteger currentYear
Definition: CalendarView.m:68

◆ init()

- (instancetype) init
implementation

Reimplemented from CalendarView.

Definition at line 19 of file B2NutritionCalendarView.m.

20 {
21  self = [super init];
22  gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
23  return self;
24 }

◆ monthMeals()

- (NSArray< NSArray< Meal * > * > *) monthMeals
implementation

Definition at line 31 of file B2NutritionCalendarView.m.

32 {
33  Z5LocalDataController *localData = [[Z5DataController sharedInstance] localDataController];
34 
35  NSMutableArray *ret = [[NSMutableArray alloc] initWithCapacity:32];
36  NSMutableArray *mealsInDay;
37  for (int day=0; day<32; day++) {
38  mealsInDay = [[NSMutableArray alloc] init];
39  [ret addObject:mealsInDay];
40  }
41 
42  gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
43  NSInteger currentYear = [self getDateYear:[self currentDate]];
44  NSInteger currentMonth = [self getDateMonth:[self currentDate]];
45 
46  NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
47  [dateComponents setYear:currentYear];
48  [dateComponents setMonth:currentMonth];
49 
50  NSDate *calendarMonthDate = [gregorianCalendar dateFromComponents:dateComponents];
51  NSArray<Meal *> *monthMeals = [localData findMealsThisMonthDate:calendarMonthDate];
52 
53  NSInteger mealDay;
54  // set value of return array: value at index 0 unused
55  for (Meal *meal in monthMeals) {
56  if (nil == [meal consumeDate]) {
57  NSLog(@"NutritionCalendarView.monthMeals: no consume date: %@", meal);
58  } else {
59  mealDay = [self getDateDay:[meal consumeDate]];
60  NSLog(@"NutritionCalendarView.monthMeals: mealDay: %ld", (long)mealDay);
61  if ((0<mealDay)&&(31>=mealDay)){
62  [ret[mealDay] addObject:meal];
63  } else {
64  NSLog(@"NutritionCalendarView.monthMeals: ERROR?");
65  }
66  }
67  }
68 
69  return ret;
70 }
NSArray< Meal * > * findMealsThisMonthDate:(NSDate *findDate)
NSArray< NSArray< Meal *> *> * monthMeals()
instancetype sharedInstance()
NSInteger currentMonth
Definition: CalendarView.m:67
Singleton interface to both core and remote data sources.
NSInteger currentYear
Definition: CalendarView.m:68

◆ refreshCalendar()

- (void) refreshCalendar

Definition at line 26 of file B2NutritionCalendarView.m.

27 {
28  mMeals = [self monthMeals];
29 }
NSArray< NSArray< Meal * > * > * mMeals

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