123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- //
- // CCControlCenterActivity.m
- // Nextcloud
- //
- // Created by Marino Faggiana on 01/03/17.
- // Copyright © 2017 TWS. All rights reserved.
- //
- #import "CCControlCenterActivity.h"
- #import "AppDelegate.h"
- #import "CCSection.h"
- @interface CCControlCenterActivity ()
- {
- // Datasource
- CCSectionDataSourceActivity *_sectionDataSource;
- }
- @end
- @implementation CCControlCenterActivity
- #pragma --------------------------------------------------------------------------------------------
- #pragma mark ===== Init =====
- #pragma --------------------------------------------------------------------------------------------
- - (id)initWithCoder:(NSCoder *)aDecoder
- {
- if (self = [super initWithCoder:aDecoder]) {
-
- app.controlCenterActivity = self;
- }
- return self;
- }
- - (void)viewDidLoad {
-
- [super viewDidLoad];
-
- _sectionDataSource = [CCSectionDataSourceActivity new];
-
- // empty Data Source
-
- /*
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.backgroundColor = [UIColor clearColor];
- */
- }
- // Apparirà
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- [self reloadDatasource];
- }
- // E' arrivato
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- }
- - (void)didReceiveMemoryWarning {
-
- [super didReceiveMemoryWarning];
- }
- #pragma --------------------------------------------------------------------------------------------
- #pragma mark - ==== Datasource ====
- #pragma --------------------------------------------------------------------------------------------
- - (void)reloadDatasource
- {
- // test
- if (app.activeAccount.length == 0)
- return;
-
- if (app.controlCenter.isOpen) {
-
- NSArray *records = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@)", app.activeAccount]];
-
- _sectionDataSource = [CCSectionActivity creataDataSourseSectionActivity:records activeAccount:app.activeAccount];
-
- if ([records count] == 0) {
-
- app.controlCenter.noRecord.text = NSLocalizedString(@"_no_activity_",nil);
- app.controlCenter.noRecord.hidden = NO;
-
- } else {
-
- app.controlCenter.noRecord.hidden = YES;
- }
- }
-
- [self.collectionView reloadData];
-
- [app updateApplicationIconBadgeNumber];
- }
- #pragma --------------------------------------------------------------------------------------------
- #pragma mark - ==== Table ====
- #pragma --------------------------------------------------------------------------------------------
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- {
- return [[_sectionDataSource.sectionArrayRow allKeys] count];
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- return [[_sectionDataSource.sectionArrayRow objectForKey:[_sectionDataSource.sections objectAtIndex:section]] count];
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
- {
- if (kind == UICollectionElementKindSectionHeader) {
-
- UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
-
- //headerView.backgroundColor = COLOR_GROUPBY_BAR_NO_BLUR;
-
- UILabel *titleLabel = (UILabel *)[headerView viewWithTag:100];
- titleLabel.textColor = COLOR_TEXT_ANTHRACITE;
- titleLabel.text = [CCUtility getTitleSectionDate:[_sectionDataSource.sections objectAtIndex:indexPath.section]];
-
- return headerView;
- }
-
- return nil;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- 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];
-
- return cell;
- }
- @end
|