|
@@ -14,7 +14,8 @@
|
|
|
@interface CCControlCenterActivity ()
|
|
|
{
|
|
|
// Datasource
|
|
|
- CCSectionDataSourceActivity *_sectionDataSource;
|
|
|
+ NSArray *_sectionDataSource;
|
|
|
+ NSDate *_oldDate;
|
|
|
}
|
|
|
@end
|
|
|
|
|
@@ -37,7 +38,8 @@
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
- _sectionDataSource = [CCSectionDataSourceActivity new];
|
|
|
+ _sectionDataSource = [NSArray new];
|
|
|
+ _oldDate = [NSDate date];
|
|
|
|
|
|
// empty Data Source
|
|
|
|
|
@@ -80,11 +82,11 @@
|
|
|
|
|
|
if (app.controlCenter.isOpen) {
|
|
|
|
|
|
- NSArray *records = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
|
|
|
+ _sectionDataSource = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
|
|
|
|
|
|
- _sectionDataSource = [CCSectionActivity creataDataSourseSectionActivity:records activeAccount:app.activeAccount];
|
|
|
+ //_sectionDataSource = [CCSectionActivity creataDataSourseSectionActivity:records activeAccount:app.activeAccount];
|
|
|
|
|
|
- if ([records count] == 0) {
|
|
|
+ if ([_sectionDataSource count] == 0) {
|
|
|
|
|
|
app.controlCenter.noRecord.text = NSLocalizedString(@"_no_activity_",nil);
|
|
|
app.controlCenter.noRecord.hidden = NO;
|
|
@@ -106,12 +108,27 @@
|
|
|
|
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
|
|
|
{
|
|
|
- return [[_sectionDataSource.sectionArrayRow allKeys] count];
|
|
|
+ return [_sectionDataSource count];
|
|
|
}
|
|
|
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
|
|
{
|
|
|
- return [[_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:section]] count];
|
|
|
+ //return [[_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:section]] count];
|
|
|
+ return 10;
|
|
|
+}
|
|
|
+
|
|
|
+-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
|
|
|
+{
|
|
|
+ TableActivity *activity = [_sectionDataSource objectAtIndex:section];
|
|
|
+
|
|
|
+ UILabel *subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, collectionView.frame.size.width , CGFLOAT_MAX)];
|
|
|
+ subjectLabel.numberOfLines = 0;
|
|
|
+ subjectLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
|
|
+ [subjectLabel setFont:[UIFont fontWithName:@"System" size:12]];
|
|
|
+ subjectLabel.text = activity.subject;
|
|
|
+ [subjectLabel sizeToFit];
|
|
|
+
|
|
|
+ return CGSizeMake(collectionView.frame.size.width, subjectLabel.frame.size.height+22+20);
|
|
|
}
|
|
|
|
|
|
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
|
@@ -120,12 +137,26 @@
|
|
|
|
|
|
UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
|
|
|
|
|
|
- //headerView.backgroundColor = COLOR_GROUPBY_BAR_NO_BLUR;
|
|
|
+ TableActivity *activity = [_sectionDataSource objectAtIndex:indexPath.section];
|
|
|
+
|
|
|
+ NSDateComponents* comps = [[NSCalendar currentCalendar] components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:activity.date];
|
|
|
+ NSDate *date = [[NSCalendar currentCalendar] dateFromComponents:comps];
|
|
|
|
|
|
- UILabel *titleLabel = (UILabel *)[headerView viewWithTag:100];
|
|
|
- titleLabel.textColor = COLOR_TEXT_ANTHRACITE;
|
|
|
- titleLabel.text = [CCUtility getTitleSectionDate:[_sectionDataSource.sections objectAtIndex:indexPath.section]];
|
|
|
+ UILabel *dataLabel = (UILabel *)[headerView viewWithTag:100];
|
|
|
+ UILabel *subjectLabel = (UILabel *)[headerView viewWithTag:101];
|
|
|
|
|
|
+ dataLabel.textColor = COLOR_TEXT_ANTHRACITE;
|
|
|
+ dataLabel.text = [CCUtility getTitleSectionDate:date];
|
|
|
+
|
|
|
+ subjectLabel.textColor = COLOR_TEXT_ANTHRACITE;
|
|
|
+ subjectLabel.text = activity.subject;
|
|
|
+
|
|
|
+
|
|
|
+ CGFloat x = [self getLabelHeight:subjectLabel];
|
|
|
+
|
|
|
+ headerView.frame = CGRectMake(headerView.frame.origin.x, headerView.frame.origin.y, headerView.frame.size.width, 20 + dataLabel.frame.size.height + x);
|
|
|
+ headerView.backgroundColor = [UIColor redColor];
|
|
|
+
|
|
|
return headerView;
|
|
|
}
|
|
|
|
|
@@ -137,11 +168,29 @@
|
|
|
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
|
|
|
cell.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
- NSArray *metadatasForKey = [_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:indexPath.section]];
|
|
|
- TableActivity *activity = [metadatasForKey objectAtIndex:indexPath.row];
|
|
|
+ //NSArray *metadatasForKey = [_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:indexPath.section]];
|
|
|
+ //TableActivity *activity = [metadatasForKey objectAtIndex:indexPath.row];
|
|
|
|
|
|
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+#pragma mark - ==== Utility ====
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+- (CGFloat)getLabelHeight:(UILabel*)label
|
|
|
+{
|
|
|
+ CGSize constraint = CGSizeMake(label.frame.size.width, CGFLOAT_MAX);
|
|
|
+ CGSize size;
|
|
|
+
|
|
|
+ NSStringDrawingContext *context = [[NSStringDrawingContext alloc] init];
|
|
|
+ CGSize boundingBox = [label.text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font} context:context].size;
|
|
|
+
|
|
|
+ size = CGSizeMake(ceil(boundingBox.width), ceil(boundingBox.height));
|
|
|
+
|
|
|
+ return size.height;
|
|
|
+}
|
|
|
+
|
|
|
@end
|