Today's Menu  Portugal
journal and plan nutrition
Z5LocalDataController.h
Go to the documentation of this file.
1 //
2 // Z5LocalDataController.h
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 12/9/15.
6 // Copyright © 2015 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 // Attribute: http://stackoverflow.com/questions/1268509/convert-utc-nsdate-to-local-timezone-objective-c
9 //
10 
11 // @import GoogleSignIn;
12 
13 #import <Foundation/Foundation.h>
14 #import <CoreData/CoreData.h>
15 #import <UIKit/UIKit.h>
16 #import <HealthKit/HealthKit.h>
19 #import "Meal+CoreDataClass.h"
21 
22 @interface Z5LocalDataController : NSObject
23 
24 @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
25 @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
26 @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
27 
28 @property (readonly, strong, nonatomic) NSNumber* usingHealthKit;
29 @property (nonatomic) HKHealthStore* healthStore;
30 @property (strong, nonatomic) NSMutableArray *availableNutritionParamArray;
31 
32 @property (strong, nonatomic) NSArray<HKQuantityTypeIdentifier> *hkQuantityTypes;
33 // @property (strong, nonatomic) NSNumber *highIndexForMealItem;
34 @property (strong, nonatomic) Meal *todaysMeal;
35 
36 - (void)saveContext;
37 
38 // - (EmailMessage *) findOrCreateEmailMessageWithRandomkey: (NSString *)randomkey;
39 // - (EmailMessage *) findOrCreateEmailMessageWithUID: (NSNumber *)uidkey;
40 - (EmailMessage *) findOrCreateEmailMessageWithFileIdentification: (NSString *)googlefileid;
41 - (Boolean) deleteEmailMessageWithFileIdentification:(NSString *)googlefileid;
42 - (NSArray *) retrieveAllEmailMessages;
43 
44 + (NSString *) componentNameKey;
45 + (NSString *) componentValueKey;
46 + (NSString *) componentSampleKey;
47 + (NSString *) componentAuthorityKey;
48 + (NSString *) componentAuthorityDateKey;
49 + (NSString *) componentHKComponentKey;
50 + (UIColor *) panelBackgroundColor;
51 + (UIColor *) menuHeaderBackground;
52 + (UIColor *) menuContentsBackground;
53 + (UIColor *) wheatBackground;
54 + (UIColor *) colorForAuthority: (NSNumber *) authorityValue;
55 + (NSString *) captionForAuthority: (NSNumber *) authorityValue;
56 - (MenuItem *) findOrCreateMenuItemWithRandomkey: (NSString *)randomkey;
57 - (MenuItem *) findOrCreateMenuItemWithFileIdentification: (NSString *)googlefileid;
58 - (MenuItem *) findNextMenuItemForGallery: (NSNumber *) galleryNo afterPosition: (NSNumber *) positionInGallery;
59 - (NSArray<Meal *> *) findMealsWithDate: (NSDate *)findDate;
60 - (NSArray<Meal *> *) findMealsThisMonthDate: (NSDate *)findDate;
61 - (NSArray<Meal *> *) findOrCreateMealWithDate: (NSDate *)findDate;
62 - (void) eraseMealsThisMonthDate: (NSDate *)findDate;
63 
64 - (void) initializeTodaysMeal;
65 - (void) clearTodaysMenuItems;
66 - (void) todaysMealRequested: (NSDate *)date;
67 - (void) todaysMealConsumed: (NSDate *)date forDelegate: (id<Z5HealthConnectionProtocol>)jingo;
68 - (NSArray<Meal *> *) retrieveAllMeals: (NSNumber *)galleryNumber;
69 - (void) todaysMealRated: (float)rating;
70 - (void) todaysMealSkipped;
71 - (NSDate *) toLocalTime: (NSDate *)grenwich;
72 - (NSDictionary *) jsonForUsdaNumbersInMenuItem:(MenuItem *)menuItem;
73 - (NSMutableDictionary *) mergeJsonForUsdaNumbers:(NSDictionary *)usdaDictionary inMenuItem:(MenuItem *)menuItem inContext:(UIView *) screen;
74 - (NSArray<HKQuantityType *> *)typesForWriting;
75 - (NSArray<HKQuantityType *> *)allHkTypes;
76 - (void) setUseHealthKit:(Boolean)useHealthKit;
77 - (void) setupHealthKit;
78 - (void) getAddedAuthorizationToShare: (NSSet *)writeNutrTypes forDelegate: (id<Z5HealthConnectionProtocol>) requestFrom;
79 // - (NSSet *)dataTypesToRead;
80 - (NSSet *)dataTypesToWrite;
81 - (NSNumber *) checkTypeAuthorization: (HKQuantityType *) quantityType;
82 + (HKQuantity *) hkQuantityForString: (NSString *) quantityDescript;
83 - (NSNumber *) askAgain: (HKQuantityType *) quantityType;
84 - (NSMutableArray *) establishNutritionParameters;
85 - (Boolean) goHealthData:(NSArray<NSDictionary *> *) parametersForHK forDelegate: (id<Z5HealthConnectionProtocol>)jingo;
86 - (void) saveQuantityToHealthStore:(HKQuantityType *)quantityType amount:(HKQuantity *)quantityAmount;
87 - (NSMutableArray *) annotateAuthority:(NSArray *)componentArray;
90 
91 // @property (strong, nonatomic) NSMutableArray *menuItemsArray; // used only in second-view-controller
92 @property (strong, nonatomic) NSMutableArray<MenuItem *> *todaysMenuItems;
93 - (NSArray<NSDictionary *> *) todaysMenuComponents;
94 - (NSArray<NSDictionary *> *) mealComponents: (Meal *)meal;
95 
96 
97 // - (void) validateHealthKitAuthority;
100 - (void) putMenuItemOnToday: (MenuItem *)focusMenuItem;
101 - (void) initNutritionTypes;
102 - (NSMutableArray *) createTodaysMenuFromUserDefaults;
103 
104 - (NSArray<MenuItem *> *) retrieveAllMenuItems: (NSNumber *)galleryNo;
105 - (NSInteger) getPrevGalleryPositionIdx;
106 - (NSInteger) getNextGalleryPositionIdx;
107 - (void) initGalleryPositionsRange: (NSRange) fetchAllRange;
108 - (void) logGallery: (NSNumber *)galleryChoice caption: (NSString *) caption;
109 - (void) logTodaysMenu: (NSString *) caption;
110 
111 @end
NSManagedObjectModel * managedObjectModel
NSArray< HKQuantityType * > * allHkTypes()
NSArray< NSDictionary * > * todaysMenuComponents()
NSPersistentStoreCoordinator * persistentStoreCoordinator
NSMutableArray * availableNutritionParamArray
NSArray< HKQuantityTypeIdentifier > * hkQuantityTypes
NSMutableArray * createTodaysMenuFromUserDefaults()
NSMutableArray * establishNutritionParameters()
NSManagedObjectContext * managedObjectContext
NSArray< HKQuantityType * > * typesForWriting()
NSMutableArray< MenuItem * > * todaysMenuItems