50 - (id) initWithFrame:(CGRect)frame
51 andComponents:(NSArray<NSDictionary *>*)components
52 inContainer:(
id<U3ParameterTableDelegate>) container
54 NSLog(
@"U3parameterTableView.init: #-components: %ld", (
long)[components count]);
56 self = [
super initWithFrame:frame style:UITableViewStyleGrouped];
58 [
self setDelegate:self];
59 self.dataSource =
self;
62 [mDateFormatter setDateStyle:NSDateFormatterMediumStyle];
63 [mDateFormatter setTimeStyle:NSDateFormatterShortStyle];
65 [
self setGivenParameters:[[NSMutableArray alloc] initWithArray:components]];
66 [
self setGivenContainer:container];
68 [
self setScrollEnabled:YES];
77 - (void) setViewForHead: (
id <Z6ContainedView>)headView
81 NSLog(
@"U3ParameterTableView.setViewForHead: paramHeaderHeight: %3.2f",
paramHeaderHeight);
83 - (void) setViewForTail: (UIView<Z6ContainedView> *) tailView
87 NSLog(
@"U3ParameterTableView.setViewForTail: paramFooterHeight: %3.2f",
paramFooterHeight);
94 - (void) update:(NSArray<NSDictionary *> *)components
96 NSLog(
@"U3ParameterTableView.update: components: %@", components);
100 for (NSDictionary *givenPrmDict in components) {
101 NSLog(
@"U3ParameterTableView.update: given-parameter-dictionary: %@", givenPrmDict);
111 - (NSInteger) isListedAlready: (NSString *)checkCaption
114 int parameterIndex = 0;
117 NSString *compoTypeClass = NSStringFromClass([componentType
class]);
118 if ([componentType isEqualToString:checkCaption]) {
119 NSLog(
@"Z6ParameterTableView.isListedAlready: yes, class: %@", compoTypeClass);
120 ret = parameterIndex;
127 -(void) addParameter: (NSDictionary *)newComponentSpecDict
134 -(void) updateParameter: (NSDictionary *)newComponentSpecDict
137 for (NSUInteger index = 0; index < [[
self givenParameters] count]; index++) {
138 NSDictionary *paramListed = [[
self givenParameters] objectAtIndex:index];
140 if ([updateParamName isEqualToString:listedParamName]) {
141 [[
self givenParameters] replaceObjectAtIndex:index withObject:newComponentSpecDict];
160 NSInteger tailHeightReqmt = [tableTail heightRequirement];
161 if (0 < tailHeightReqmt) {
162 ret += 2 + [tableTail heightRequirement];
164 NSLog(
@"U3ParameterTableView.getViewHeightReqmt: head: %3.2f total: %3.2f",
paramHeaderHeight, ret);
170 NSIndexPath *firstIndex = [NSIndexPath indexPathForRow:0 inSection:0];
171 [
self scrollToRowAtIndexPath:firstIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];
178 NSIndexPath *lastIndex = [NSIndexPath indexPathForRow:nParams-1 inSection:0];
179 [
self scrollToRowAtIndexPath:lastIndex atScrollPosition:UITableViewScrollPositionBottom animated:YES];
184 NSLog(
@"ParameterTablView.scrollForInstructionPanel: entry");
185 NSInteger nSections = [
self numberOfSections];
186 NSLog(
@" .. nSections: %ld", (
long)nSections);
187 for (
int j=0;j<nSections;j++) {
188 NSLog(
@" ... nRows, section %d: %ld", j, (
long)[
self numberOfRowsInSection:j]);
190 NSInteger endSection = nSections - 1;
191 NSInteger nRows = [
self numberOfRowsInSection:endSection];
194 NSInteger lastRowEndSection = nRows - 1;
195 NSLog(
@" .. last index: S:%ld R:%ld", (
long)endSection, (
long)lastRowEndSection);
196 NSAssert(!(lastRowEndSection<0),
@"empty last section");
197 NSIndexPath *lastIndex = [NSIndexPath indexPathForRow:lastRowEndSection inSection:endSection];
198 [
self scrollToRowAtIndexPath:lastIndex atScrollPosition:UITableViewScrollPositionBottom animated:YES];
200 NSLog(
@"ParameterTablView.scrollForInstructionPanel: exit");
212 #pragma mark - UITableViewDelegate 213 - (void)tableView:(UITableView *)tableView
214 didSelectRowAtIndexPath:(NSIndexPath *)indexPath
216 NSLog(
@"U3ParameterTableView.didSelectRowAtIndexPath: %ld", (
long)indexPath.row);
220 #pragma mark - UITableViewDataSource 221 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
223 NSLog(
@"U3ParameterTableView.numberOfSectionsInTableView: 1");
227 - (NSInteger)tableView:(UITableView *)tableView
228 numberOfRowsInSection:(NSInteger)section
232 NSLog(
@"U3ParameterTableView.numberOfRowsInSection: # of rows in table: %ld", (
long)ret);
235 - (UITableViewCell *)tableView:(UITableView *)tableView
236 cellForRowAtIndexPath:(NSIndexPath *)indexPath
238 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"usda-parameters-menu"];
241 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"usda-parameters-menu"];
243 cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
244 [cell.layer setCornerRadius:7.0f];
245 [cell.layer setMasksToBounds:YES];
246 [cell.layer setBorderWidth:1.0f];
251 if (nComponents > [indexPath row]) {
253 NSObject *parameterObj = [[
self givenParameters] objectAtIndex:[indexPath row]];
254 if ([NSStringFromClass([parameterObj
class]) containsString:
@"Dictionary"]) {
255 NSDictionary *focusNutritionComp = (NSDictionary *)parameterObj;
258 NSMutableString *captionWithSpace = [[NSMutableString alloc] initWithString:caption];
259 if ([caption hasPrefix:
@"Fat"]) {
260 [captionWithSpace insertString:@" " atIndex:3];
261 }
else if ([caption hasPrefix:
@"Vitamin"]) {
262 [captionWithSpace insertString:@" " atIndex:7];
266 NSString *compoTypeClass = NSStringFromClass([valueCaption
class]);
268 NSString *detailCaption;
269 if ([compoTypeClass isEqualToString:
@"HKQuantity"]) {
271 HKQuantity* hkq = (HKQuantity *)valueCaption;
274 detailCaption = hkq.description;
277 detailCaption = valueCaption;
285 [cell setBackgroundColor:authorityColor];
286 }
else if ([
@"Meal" isEqualToString:NSStringFromClass([parameterObj
class]) ]) {
287 Meal *focusNutritionMeal = (
Meal *)parameterObj;
288 NSDate *mealDate = [focusNutritionMeal
orderDate];
289 NSString *mealDateStr = [mDateFormatter stringFromDate:mealDate];
291 NSString *detailCaption =
@"none";
294 NSLog(
@"U3ParameterTableView.cellForRow: parameter-obj class: %@", NSStringFromClass([parameterObj
class]));
296 }
else if (0 == nComponents) {
297 cell.textLabel.text =
@"no parameter";
304 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
312 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
318 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
327 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
UIColor * colorForAuthority:(NSNumber *authorityValue)
UIColor * paramTableBackgrndColor
void scrollForInstructionPanel()
NSString * componentNameKey()
NSMutableArray< NSDictionary * > * givenParameters
instancetype sharedInstance()
UIView< Z6ContainedView > * tableTail
NSDateFormatter * mDateFormatter
float getViewHeightReqmt()
NSMutableArray * focusUSDAparameterArray
id< Z6ContainedView > tableHead
id< U3ParameterTableDelegate > givenContainer
NSString * componentValueKey()
NSString * componentAuthorityKey()
Singleton interface to both core and remote data sources.
NSUInteger parameterCount()
void scrollForControlPanel()
void labelizeCell:withText:inColor:andDetail:(UITableViewCell *targCell, [withText] NSString *txt, [inColor] UIColor *color, [andDetail] NSString *detailTxt)