From 47cfec5d4359d3000495ed548e9d00756c9a6488 Mon Sep 17 00:00:00 2001 From: Massimiliano Cannarozzo Date: Tue, 26 Jun 2012 15:57:58 +0200 Subject: [PATCH 1/4] Rimossa tabella eventi --- src/KalViewController.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/KalViewController.m b/src/KalViewController.m index 62245b8..54ff7b5 100644 --- a/src/KalViewController.m +++ b/src/KalViewController.m @@ -183,11 +183,18 @@ - (void)loadView { if (!self.title) self.title = @"Calendar"; - KalView *kalView = [[[KalView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] delegate:self logic:logic] autorelease]; + + CGRect popoverRect = CGRectMake(0, 0, self.contentSizeForViewInPopover.width, self.contentSizeForViewInPopover.height); + CGRect windowsRect = [[UIScreen mainScreen] applicationFrame]; + + CGRect rect = CGRectMake(0, 0, MIN(popoverRect.size.width, windowsRect.size.width), MIN(popoverRect.size.height, windowsRect.size.height)); + + KalView *kalView = [[[KalView alloc] initWithFrame:rect delegate:self logic:logic] autorelease]; self.view = kalView; tableView = kalView.tableView; tableView.dataSource = dataSource; tableView.delegate = delegate; + [tableView removeFromSuperview]; [tableView retain]; [kalView selectDate:[KalDate dateFromNSDate:self.initialDate]]; [self reloadData]; From 890fed6882397d29a10859073d2a723bb2adf4fb Mon Sep 17 00:00:00 2001 From: Massimiliano Cannarozzo Date: Wed, 8 Aug 2012 15:23:00 +0200 Subject: [PATCH 2/4] Gestione selezione data --- src/KalGridView.m | 4 ++-- src/KalView.h | 1 + src/KalView.m | 2 +- src/KalViewController.h | 3 ++- src/KalViewController.m | 12 +++++++++--- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/KalGridView.m b/src/KalGridView.m index 798d73e..9cc9b9c 100644 --- a/src/KalGridView.m +++ b/src/KalGridView.m @@ -95,7 +95,7 @@ - (void)setSelectedTile:(KalTileView *)tile selectedTile = [tile retain]; tile.selected = YES; [delegate didSelectDate:tile.date]; - } + } else [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_DISMISS_POPOVER object:nil]; } - (void)receivedTouches:(NSSet *)touches withEvent:event @@ -142,7 +142,7 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event } else { [delegate showPreviousMonth]; } - self.selectedTile = [frontMonthView tileForDate:tile.date]; + //self.selectedTile = [frontMonthView tileForDate:tile.date]; } else { self.selectedTile = tile; } diff --git a/src/KalView.h b/src/KalView.h index fe9db0b..75b0ea4 100644 --- a/src/KalView.h +++ b/src/KalView.h @@ -50,6 +50,7 @@ @property (nonatomic, assign) id delegate; @property (nonatomic, readonly) UITableView *tableView; @property (nonatomic, readonly) KalDate *selectedDate; +@property (nonatomic, readonly) KalGridView *gridView; - (id)initWithFrame:(CGRect)frame delegate:(id)delegate logic:(KalLogic *)logic; - (BOOL)isSliding; diff --git a/src/KalView.m b/src/KalView.m index def1dcb..d7a8d9b 100644 --- a/src/KalView.m +++ b/src/KalView.m @@ -19,7 +19,7 @@ - (void)setHeaderTitleText:(NSString *)text; @implementation KalView -@synthesize delegate, tableView; +@synthesize delegate, tableView, gridView; - (id)initWithFrame:(CGRect)frame delegate:(id)theDelegate logic:(KalLogic *)theLogic { diff --git a/src/KalViewController.h b/src/KalViewController.h index ba9ddb9..4104862 100644 --- a/src/KalViewController.h +++ b/src/KalViewController.h @@ -24,7 +24,7 @@ { KalLogic *logic; UITableView *tableView; - id delegate; + id delegate; id dataSource; NSDate *initialDate; // The date that the calendar was initialized with *or* the currently selected date when the view hierarchy was torn down in order to satisfy a low memory warning. NSDate *selectedDate; // I cache the selected date because when we respond to a memory warning, we cannot rely on the view hierarchy still being alive, and thus we cannot always derive the selected date from KalView's selectedDate property. @@ -35,6 +35,7 @@ @property (nonatomic, retain, readonly) NSDate *selectedDate; - (id)initWithSelectedDate:(NSDate *)selectedDate; // designated initializer. When the calendar is first displayed to the user, the month that contains 'selectedDate' will be shown and the corresponding tile for 'selectedDate' will be automatically selected. +- (id)initWithSelectedDate:(NSDate *)date andDelegate:(id)aDelegate; - (void)reloadData; // If you change the KalDataSource after the KalViewController has already been displayed to the user, you must call this method in order for the view to reflect the new data. - (void)showAndSelectDate:(NSDate *)date; // Updates the state of the calendar to display the specified date's month and selects the tile for that date. diff --git a/src/KalViewController.m b/src/KalViewController.m index 54ff7b5..00b68ea 100644 --- a/src/KalViewController.m +++ b/src/KalViewController.m @@ -40,18 +40,24 @@ @implementation KalViewController @synthesize dataSource, delegate, initialDate, selectedDate; -- (id)initWithSelectedDate:(NSDate *)date +- (id)initWithSelectedDate:(NSDate *)date andDelegate:(id)aDelegate { if ((self = [super init])) { logic = [[KalLogic alloc] initForDate:date]; self.initialDate = date; self.selectedDate = date; + self.delegate = aDelegate; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(significantTimeChangeOccurred) name:UIApplicationSignificantTimeChangeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadData) name:KalDataSourceChangedNotification object:nil]; } return self; } +- (id)initWithSelectedDate:(NSDate *)date +{ + return [self initWithSelectedDate:[NSDate date]]; +} + - (id)init { return [self initWithSelectedDate:[NSDate date]]; @@ -67,7 +73,7 @@ - (void)setDataSource:(id)aDataSource } } -- (void)setDelegate:(id)aDelegate +- (void)setDelegate:(id)aDelegate { if (delegate != aDelegate) { delegate = aDelegate; @@ -189,7 +195,7 @@ - (void)loadView CGRect rect = CGRectMake(0, 0, MIN(popoverRect.size.width, windowsRect.size.width), MIN(popoverRect.size.height, windowsRect.size.height)); - KalView *kalView = [[[KalView alloc] initWithFrame:rect delegate:self logic:logic] autorelease]; + KalView *kalView = [[[KalView alloc] initWithFrame:rect delegate:delegate != nil ? (id)delegate:self logic:logic] autorelease]; self.view = kalView; tableView = kalView.tableView; tableView.dataSource = dataSource; From 82473b1dde68b2add6eb5c0e6df321824788edc8 Mon Sep 17 00:00:00 2001 From: Massimiliano Cannarozzo Date: Mon, 3 Sep 2012 18:25:22 +0200 Subject: [PATCH 3/4] Cambiata notifica in NOTIFICATION_SELECTED_DATE --- src/KalGridView.h | 1 + src/KalGridView.m | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/KalGridView.h b/src/KalGridView.h index 2253285..3de49d8 100644 --- a/src/KalGridView.h +++ b/src/KalGridView.h @@ -4,6 +4,7 @@ */ #import +#define NOTIFICATION_SELECTED_DATE @"notificationSelectedDate" @class KalTileView, KalMonthView, KalLogic, KalDate; @protocol KalViewDelegate; diff --git a/src/KalGridView.m b/src/KalGridView.m index 9cc9b9c..291ce30 100644 --- a/src/KalGridView.m +++ b/src/KalGridView.m @@ -95,7 +95,7 @@ - (void)setSelectedTile:(KalTileView *)tile selectedTile = [tile retain]; tile.selected = YES; [delegate didSelectDate:tile.date]; - } else [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_DISMISS_POPOVER object:nil]; + } else [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_SELECTED_DATE object:nil]; } - (void)receivedTouches:(NSSet *)touches withEvent:event From 2b3eca680619a11510499b30d09ea6fe3ea24fa8 Mon Sep 17 00:00:00 2001 From: Massimiliano Cannarozzo Date: Mon, 17 Sep 2012 17:45:58 +0200 Subject: [PATCH 4/4] Passo la data selezionata nella notifica --- src/KalGridView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KalGridView.m b/src/KalGridView.m index 291ce30..c7d300d 100644 --- a/src/KalGridView.m +++ b/src/KalGridView.m @@ -95,7 +95,7 @@ - (void)setSelectedTile:(KalTileView *)tile selectedTile = [tile retain]; tile.selected = YES; [delegate didSelectDate:tile.date]; - } else [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_SELECTED_DATE object:nil]; + } else [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_SELECTED_DATE object:[tile.date NSDate]]; } - (void)receivedTouches:(NSSet *)touches withEvent:event