diff --git a/Time/StopwatchViewController.h b/Time/StopwatchViewController.h new file mode 100644 index 0000000..7ddabc6 --- /dev/null +++ b/Time/StopwatchViewController.h @@ -0,0 +1,14 @@ +// +// StopwatchViewController.h +// Time +// +// Created by Lauren Caponong on 8/22/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface StopwatchViewController : UIViewController + + +@end diff --git a/Time/StopwatchViewController.m b/Time/StopwatchViewController.m new file mode 100644 index 0000000..3076710 --- /dev/null +++ b/Time/StopwatchViewController.m @@ -0,0 +1,134 @@ +// +// StopwatchViewController.m +// Time +// +// Created by Lauren Caponong on 8/22/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "StopwatchViewController.h" + +@interface StopwatchViewController () + +@property (weak, nonatomic) IBOutlet UILabel *stopwatchTimerLabel; + +@property (weak, nonatomic) IBOutlet UIButton *startButtonTapped; +@property (weak, nonatomic) IBOutlet UIButton *pauseButtonTapped; +@property (weak, nonatomic) IBOutlet UIButton *lapButtonTapped; + +@property (weak, nonatomic) IBOutlet UIButton *resetButtonTapped; + + +@property (nonatomic) float nextNumber; +@property (nonatomic) float currentNumber; + +@property (nonatomic) NSTimer *timer1; + +@property (weak, nonatomic) IBOutlet UITableView *lapsTableView; +@property (nonatomic) NSMutableArray *laps; +@property (nonatomic) float currentLapTime; + +@end + + + + +@implementation StopwatchViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.laps = [[NSMutableArray alloc] init]; + self.lapsTableView.dataSource = self; + + + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +- (IBAction)startButtonTapped:(id)sender { + + [self.timer1 invalidate]; + + self.timer1 = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(startButtonTapped:) userInfo:nil repeats:NO]; + + float currentNumber = [self.stopwatchTimerLabel.text floatValue]; + self.nextNumber = currentNumber + 0.001; + self.stopwatchTimerLabel.text = [NSString stringWithFormat:@"%lf", self.nextNumber]; + +} + + +- (IBAction)pauseButtonTapped:(id)sender { + + [self.timer1 invalidate]; + + + + +} + + +- (IBAction)lapButtonTapped:(id)sender { + + NSString *currentLapTime = self.stopwatchTimerLabel.text; + + [self.laps addObject:currentLapTime]; + + [self.lapsTableView reloadData]; + +} + + + + +- (IBAction)resetButtonTapped:(id)sender { + + [self.timer1 invalidate]; + + self.currentNumber = 0; + self.stopwatchTimerLabel.text = [NSString stringWithFormat:@"--"]; + + [self.laps removeAllObjects]; + [self.lapsTableView reloadData]; + +} + + + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.laps.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LapCellIdentifier" forIndexPath:indexPath]; + + cell.textLabel.text = self.laps[indexPath.row]; + + cell.detailTextLabel.text = [NSString stringWithFormat:@"Lap %ld", (long)indexPath.row]; + + return cell; +} + + + +@end diff --git a/Time/Time.xcodeproj/project.pbxproj b/Time/Time.xcodeproj/project.pbxproj index c8743f0..436a1a9 100644 --- a/Time/Time.xcodeproj/project.pbxproj +++ b/Time/Time.xcodeproj/project.pbxproj @@ -7,13 +7,22 @@ objects = { /* Begin PBXBuildFile section */ + 89060FBB1B94B04E005C707A /* UpcomingEventsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89060FBA1B94B04E005C707A /* UpcomingEventsTableViewController.m */; }; + 89060FBE1B94B47C005C707A /* UpcomingEvents.m in Sources */ = {isa = PBXBuildFile; fileRef = 89060FBD1B94B47C005C707A /* UpcomingEvents.m */; }; + 892D1E9D1B97D8630039EA41 /* AnotherEventViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 892D1E9C1B97D8630039EA41 /* AnotherEventViewController.m */; }; + 89C909871B88DB5800216084 /* StopwatchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89C909861B88DB5800216084 /* StopwatchViewController.m */; }; + 89FD9A441B86AC7500D7A645 /* TimerUITabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89FD9A431B86AC7500D7A645 /* TimerUITabBarController.m */; }; + 89FD9A471B86B55600D7A645 /* PresetTimersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89FD9A461B86B55600D7A645 /* PresetTimersViewController.m */; }; + 89FD9A4D1B86B58900D7A645 /* SpecialEventsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89FD9A4C1B86B58900D7A645 /* SpecialEventsViewController.m */; }; 8D05375E1B86687C00588318 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D05375D1B86687C00588318 /* main.m */; }; 8D0537611B86687C00588318 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D0537601B86687C00588318 /* AppDelegate.m */; }; - 8D0537641B86687C00588318 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D0537631B86687C00588318 /* ViewController.m */; }; 8D0537671B86687C00588318 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D0537651B86687C00588318 /* Main.storyboard */; }; 8D0537691B86687C00588318 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D0537681B86687C00588318 /* Images.xcassets */; }; 8D05376C1B86687C00588318 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8D05376A1B86687C00588318 /* LaunchScreen.xib */; }; 8D0537781B86687C00588318 /* TimeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D0537771B86687C00588318 /* TimeTests.m */; }; + EB7C5AA31B97BA5100F86122 /* AnotherEventTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EB7C5AA21B97BA5100F86122 /* AnotherEventTableViewController.m */; }; + EB9EE0951B8E803500DB27D1 /* NewCustomTimerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EB9EE0941B8E803500DB27D1 /* NewCustomTimerViewController.m */; }; + EB9EE1791B96519900DB27D1 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB9EE1781B96519900DB27D1 /* AudioToolbox.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -27,19 +36,36 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 89060FB91B94B04E005C707A /* UpcomingEventsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpcomingEventsTableViewController.h; sourceTree = ""; }; + 89060FBA1B94B04E005C707A /* UpcomingEventsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpcomingEventsTableViewController.m; sourceTree = ""; }; + 89060FBC1B94B47C005C707A /* UpcomingEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpcomingEvents.h; sourceTree = ""; }; + 89060FBD1B94B47C005C707A /* UpcomingEvents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpcomingEvents.m; sourceTree = ""; }; + 892D1E9B1B97D8630039EA41 /* AnotherEventViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnotherEventViewController.h; sourceTree = ""; }; + 892D1E9C1B97D8630039EA41 /* AnotherEventViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnotherEventViewController.m; sourceTree = ""; }; + 89C909851B88DB5800216084 /* StopwatchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StopwatchViewController.h; path = ../StopwatchViewController.h; sourceTree = ""; }; + 89C909861B88DB5800216084 /* StopwatchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StopwatchViewController.m; path = ../StopwatchViewController.m; sourceTree = ""; }; + 89FD9A421B86AC7500D7A645 /* TimerUITabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimerUITabBarController.h; sourceTree = SOURCE_ROOT; }; + 89FD9A431B86AC7500D7A645 /* TimerUITabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TimerUITabBarController.m; sourceTree = SOURCE_ROOT; }; + 89FD9A451B86B55600D7A645 /* PresetTimersViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PresetTimersViewController.h; sourceTree = ""; }; + 89FD9A461B86B55600D7A645 /* PresetTimersViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PresetTimersViewController.m; sourceTree = ""; }; + 89FD9A4B1B86B58900D7A645 /* SpecialEventsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpecialEventsViewController.h; sourceTree = ""; }; + 89FD9A4C1B86B58900D7A645 /* SpecialEventsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpecialEventsViewController.m; sourceTree = ""; }; 8D0537581B86687B00588318 /* Time.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Time.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D05375C1B86687B00588318 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8D05375D1B86687C00588318 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D05375F1B86687C00588318 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8D0537601B86687C00588318 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8D0537621B86687C00588318 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8D0537631B86687C00588318 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 8D0537661B86687C00588318 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8D0537681B86687C00588318 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 8D05376B1B86687C00588318 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 8D0537711B86687C00588318 /* TimeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TimeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8D0537761B86687C00588318 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8D0537771B86687C00588318 /* TimeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TimeTests.m; sourceTree = ""; }; + EB7C5AA11B97BA5100F86122 /* AnotherEventTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnotherEventTableViewController.h; sourceTree = ""; }; + EB7C5AA21B97BA5100F86122 /* AnotherEventTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnotherEventTableViewController.m; sourceTree = ""; }; + EB9EE0931B8E803500DB27D1 /* NewCustomTimerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewCustomTimerViewController.h; sourceTree = ""; }; + EB9EE0941B8E803500DB27D1 /* NewCustomTimerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewCustomTimerViewController.m; sourceTree = ""; }; + EB9EE1781B96519900DB27D1 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -47,6 +73,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + EB9EE1791B96519900DB27D1 /* AudioToolbox.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -60,9 +87,25 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 89060FB81B94B028005C707A /* OLD */ = { + isa = PBXGroup; + children = ( + 89060FB91B94B04E005C707A /* UpcomingEventsTableViewController.h */, + 89060FBA1B94B04E005C707A /* UpcomingEventsTableViewController.m */, + EB7C5AA11B97BA5100F86122 /* AnotherEventTableViewController.h */, + EB7C5AA21B97BA5100F86122 /* AnotherEventTableViewController.m */, + 89060FBC1B94B47C005C707A /* UpcomingEvents.h */, + 89060FBD1B94B47C005C707A /* UpcomingEvents.m */, + 89FD9A4B1B86B58900D7A645 /* SpecialEventsViewController.h */, + 89FD9A4C1B86B58900D7A645 /* SpecialEventsViewController.m */, + ); + name = OLD; + sourceTree = ""; + }; 8D05374F1B86687B00588318 = { isa = PBXGroup; children = ( + EB9EE1781B96519900DB27D1 /* AudioToolbox.framework */, 8D05375A1B86687B00588318 /* Time */, 8D0537741B86687C00588318 /* TimeTests */, 8D0537591B86687B00588318 /* Products */, @@ -83,9 +126,18 @@ children = ( 8D05375F1B86687C00588318 /* AppDelegate.h */, 8D0537601B86687C00588318 /* AppDelegate.m */, - 8D0537621B86687C00588318 /* ViewController.h */, - 8D0537631B86687C00588318 /* ViewController.m */, 8D0537651B86687C00588318 /* Main.storyboard */, + 89FD9A421B86AC7500D7A645 /* TimerUITabBarController.h */, + 89FD9A431B86AC7500D7A645 /* TimerUITabBarController.m */, + 89FD9A451B86B55600D7A645 /* PresetTimersViewController.h */, + 89FD9A461B86B55600D7A645 /* PresetTimersViewController.m */, + EB9EE0931B8E803500DB27D1 /* NewCustomTimerViewController.h */, + EB9EE0941B8E803500DB27D1 /* NewCustomTimerViewController.m */, + 89C909851B88DB5800216084 /* StopwatchViewController.h */, + 89C909861B88DB5800216084 /* StopwatchViewController.m */, + 892D1E9B1B97D8630039EA41 /* AnotherEventViewController.h */, + 892D1E9C1B97D8630039EA41 /* AnotherEventViewController.m */, + 89060FB81B94B028005C707A /* OLD */, 8D0537681B86687C00588318 /* Images.xcassets */, 8D05376A1B86687C00588318 /* LaunchScreen.xib */, 8D05375B1B86687B00588318 /* Supporting Files */, @@ -219,9 +271,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D0537641B86687C00588318 /* ViewController.m in Sources */, + 89FD9A441B86AC7500D7A645 /* TimerUITabBarController.m in Sources */, + EB9EE0951B8E803500DB27D1 /* NewCustomTimerViewController.m in Sources */, + 89FD9A471B86B55600D7A645 /* PresetTimersViewController.m in Sources */, + 89C909871B88DB5800216084 /* StopwatchViewController.m in Sources */, + 89060FBB1B94B04E005C707A /* UpcomingEventsTableViewController.m in Sources */, + EB7C5AA31B97BA5100F86122 /* AnotherEventTableViewController.m in Sources */, 8D0537611B86687C00588318 /* AppDelegate.m in Sources */, + 892D1E9D1B97D8630039EA41 /* AnotherEventViewController.m in Sources */, 8D05375E1B86687C00588318 /* main.m in Sources */, + 89FD9A4D1B86B58900D7A645 /* SpecialEventsViewController.m in Sources */, + 89060FBE1B94B47C005C707A /* UpcomingEvents.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -418,6 +478,7 @@ 8D05377D1B86687C00588318 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8D05377E1B86687C00588318 /* Build configuration list for PBXNativeTarget "TimeTests" */ = { isa = XCConfigurationList; @@ -426,6 +487,7 @@ 8D0537801B86687C00588318 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Time/Time/AnotherEventTableViewController.h b/Time/Time/AnotherEventTableViewController.h new file mode 100644 index 0000000..23d1f99 --- /dev/null +++ b/Time/Time/AnotherEventTableViewController.h @@ -0,0 +1,13 @@ +// +// AnotherEventTableViewController.h +// Time +// +// Created by Christian Maldonado on 9/2/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface AnotherEventTableViewController : UITableViewController + +@end diff --git a/Time/Time/AnotherEventTableViewController.m b/Time/Time/AnotherEventTableViewController.m new file mode 100644 index 0000000..c42ce4d --- /dev/null +++ b/Time/Time/AnotherEventTableViewController.m @@ -0,0 +1,108 @@ +//// +//// AnotherEventTableViewController.m +//// Time +//// +//// Created by Christian Maldonado on 9/2/15. +//// Copyright (c) 2015 Mike Kavouras. All rights reserved. +//// +// +//#import "AnotherEventTableViewController.h" +// +//@interface AnotherEventTableViewController () +// +// +//@property (weak, nonatomic) IBOutlet UILabel *countdownLabel; +// +// +//@property (strong, nonatomic)NSDate *destinationDay; +// +//@property (strong, nonatomic)NSTimer *timer; +// +//@end +// +//@implementation AnotherEventTableViewController +//-(void)viewDidLoad{ +// [super viewDidLoad]; +// +// self.destinationDay = [NSDate dateWithTimeIntervalSince1970:1450155600]; +// self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateLabel)userInfo:nil repeats:YES]; +// +// +//} +// +// +// +//- (IBAction)updateLabel{ +// NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; +// int units = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; +// +// NSDateComponents *components = [calendar components:units fromDate:[NSDate date] toDate: self.destinationDay options:0]; +// +// self.countdownLabel.text = [NSString stringWithFormat:@"%ld%c:%ld%c:%ld%c:%ld%c", (long)[components day], 'd', (long)[components hour]+4, 'h', (long)[components minute], 'm', (long)[components second], 's']; +//} +// +// +//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { +// +// return 1; +//} +// +//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +// +// return 1; +//} +// +//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { +// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EventIdentifier" forIndexPath:indexPath]; +// +// +// +// return cell; +//} +// +// +///* +//// Override to support conditional editing of the table view. +//- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { +// // Return NO if you do not want the specified item to be editable. +// return YES; +//} +//*/ +// +///* +//// Override to support editing the table view. +//- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { +// if (editingStyle == UITableViewCellEditingStyleDelete) { +// // Delete the row from the data source +// [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; +// } else if (editingStyle == UITableViewCellEditingStyleInsert) { +// // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view +// } +//} +//*/ +// +///* +//// Override to support rearranging the table view. +//- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +//} +//*/ +// +///* +//// Override to support conditional rearranging of the table view. +//- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { +// // Return NO if you do not want the item to be re-orderable. +// return YES; +//} +//*/ +// +///* +//#pragma mark - Navigation +// +//// In a storyboard-based application, you will often want to do a little preparation before navigation +//- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { +// // Get the new view controller using [segue destinationViewController]. +// // Pass the selected object to the new view controller. +//} +//*/ +// +//@end diff --git a/Time/Time/AnotherEventViewController.h b/Time/Time/AnotherEventViewController.h new file mode 100644 index 0000000..3cbd7e9 --- /dev/null +++ b/Time/Time/AnotherEventViewController.h @@ -0,0 +1,13 @@ +// +// AnotherEventViewController.h +// Time +// +// Created by Lauren Caponong on 9/2/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface AnotherEventViewController : UIViewController + +@end diff --git a/Time/Time/AnotherEventViewController.m b/Time/Time/AnotherEventViewController.m new file mode 100644 index 0000000..b0ec7d8 --- /dev/null +++ b/Time/Time/AnotherEventViewController.m @@ -0,0 +1,86 @@ +// +// AnotherEventViewController.m +// Time +// +// Created by Lauren Caponong on 9/2/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "AnotherEventViewController.h" + +@interface AnotherEventViewController () + +@property (weak, nonatomic) IBOutlet UILabel *countdownLabel; +@property (strong, nonatomic)NSDate *destinationDay; +@property (strong, nonatomic)NSTimer *timer; + + + +@end + +@implementation AnotherEventViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + + self.destinationDay = [NSDate dateWithTimeIntervalSince1970:1456617600]; + self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateLabel)userInfo:nil repeats:YES]; + + +} + + + +- (IBAction)updateLabel{ + NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; + int units = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; + + NSDateComponents *components = [calendar components:units fromDate:[NSDate date] toDate: self.destinationDay options:0]; + + self.countdownLabel.text = [NSString stringWithFormat:@"%ld%c:%ld%c:%ld%c:%ld%c", (long)[components day], 'd', (long)[components hour]+4, 'h', (long)[components minute], 'm', (long)[components second], 's']; + +} + + + +-(IBAction)startFade:(id)sender{ + + [self.countdownLabel setAlpha:0.0f]; + + //fade in + [UIView animateWithDuration:2.0f animations:^{ + + [self.countdownLabel setAlpha:1.0f]; + + } completion:^(BOOL finished) { + + //fade out + [UIView animateWithDuration:2.0f animations:^{ + + [self.countdownLabel setAlpha:0.0f]; + + } completion:nil]; + + }]; +} + + + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/Time/Time/Base.lproj/Main.storyboard b/Time/Time/Base.lproj/Main.storyboard index f56d2f3..981f7c6 100644 --- a/Time/Time/Base.lproj/Main.storyboard +++ b/Time/Time/Base.lproj/Main.storyboard @@ -1,25 +1,838 @@ - + - + + + + + - - + + - + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Time/Time/Images.xcassets/C4Q+AC+20.imageset/C4Q+AC+20.jpg b/Time/Time/Images.xcassets/C4Q+AC+20.imageset/C4Q+AC+20.jpg new file mode 100644 index 0000000..d572e6b Binary files /dev/null and b/Time/Time/Images.xcassets/C4Q+AC+20.imageset/C4Q+AC+20.jpg differ diff --git a/Time/Time/Images.xcassets/C4Q+AC+20.imageset/Contents.json b/Time/Time/Images.xcassets/C4Q+AC+20.imageset/Contents.json new file mode 100644 index 0000000..61c2714 --- /dev/null +++ b/Time/Time/Images.xcassets/C4Q+AC+20.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "C4Q+AC+20.jpg" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Time/Time/Images.xcassets/Untitled-1.imageset/Contents.json b/Time/Time/Images.xcassets/Untitled-1.imageset/Contents.json new file mode 100644 index 0000000..f9d80db --- /dev/null +++ b/Time/Time/Images.xcassets/Untitled-1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Untitled-1.jpg" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Time/Time/Images.xcassets/Untitled-1.imageset/Untitled-1.jpg b/Time/Time/Images.xcassets/Untitled-1.imageset/Untitled-1.jpg new file mode 100644 index 0000000..0e6e1f8 Binary files /dev/null and b/Time/Time/Images.xcassets/Untitled-1.imageset/Untitled-1.jpg differ diff --git a/Time/Time/Images.xcassets/clock125.imageset/Contents.json b/Time/Time/Images.xcassets/clock125.imageset/Contents.json new file mode 100644 index 0000000..e586e5b --- /dev/null +++ b/Time/Time/Images.xcassets/clock125.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "clock125.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Time/Time/Images.xcassets/clock125.imageset/clock125.png b/Time/Time/Images.xcassets/clock125.imageset/clock125.png new file mode 100644 index 0000000..26fa2fc Binary files /dev/null and b/Time/Time/Images.xcassets/clock125.imageset/clock125.png differ diff --git a/Time/Time/Images.xcassets/clock136.imageset/Contents.json b/Time/Time/Images.xcassets/clock136.imageset/Contents.json new file mode 100644 index 0000000..25e2a48 --- /dev/null +++ b/Time/Time/Images.xcassets/clock136.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "clock136.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Time/Time/Images.xcassets/clock136.imageset/clock136.png b/Time/Time/Images.xcassets/clock136.imageset/clock136.png new file mode 100644 index 0000000..6042c88 Binary files /dev/null and b/Time/Time/Images.xcassets/clock136.imageset/clock136.png differ diff --git a/Time/Time/Images.xcassets/favourite24.imageset/Contents.json b/Time/Time/Images.xcassets/favourite24.imageset/Contents.json new file mode 100644 index 0000000..757f222 --- /dev/null +++ b/Time/Time/Images.xcassets/favourite24.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "favourite24.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Time/Time/Images.xcassets/favourite24.imageset/favourite24.png b/Time/Time/Images.xcassets/favourite24.imageset/favourite24.png new file mode 100644 index 0000000..65573c4 Binary files /dev/null and b/Time/Time/Images.xcassets/favourite24.imageset/favourite24.png differ diff --git a/Time/Time/NewCustomTimerViewController.h b/Time/Time/NewCustomTimerViewController.h new file mode 100644 index 0000000..4b1ec60 --- /dev/null +++ b/Time/Time/NewCustomTimerViewController.h @@ -0,0 +1,21 @@ +// +// NewCustomTimerViewController.h +// Time +// +// Created by Christian Maldonado on 8/26/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + + +@class PresetTimersViewController; + +@interface NewCustomTimerViewController : UIViewController + +@property (nonatomic, weak) PresetTimersViewController *timerViewController; +@property (nonatomic) NSMutableDictionary *customTimersDictionary; + + + +@end diff --git a/Time/Time/NewCustomTimerViewController.m b/Time/Time/NewCustomTimerViewController.m new file mode 100644 index 0000000..bb4ea4f --- /dev/null +++ b/Time/Time/NewCustomTimerViewController.m @@ -0,0 +1,104 @@ +// +// NewCustomTimerViewController.m +// Time +// +// Created by Christian Maldonado on 8/26/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "NewCustomTimerViewController.h" +#import "PresetTimersViewController.h" + +@interface NewCustomTimerViewController () + +@property (weak, nonatomic) IBOutlet UIDatePicker *timePickerView; +@property (weak, nonatomic) IBOutlet UITextField *alarmNameLabel; +@property (weak, nonatomic) IBOutlet UIButton *doneButton; +@property (nonatomic) NSDate *chosenDate; + +@end + +@implementation NewCustomTimerViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.timePickerView.countDownDuration = 60.0; +} + + +- (IBAction)doneButtonTapped:(id)sender { + [self dismissViewControllerAnimated:YES completion:nil]; + + NSString *alarmName = self.alarmNameLabel.text; + + + NSLog(@"%@ is the current alarm name", alarmName); + + NSTimeInterval timeInterval = self.timePickerView.countDownDuration; + + NSLog(@"%f is the current time interval", timeInterval); + + [self.customTimersDictionary setObject:@(timeInterval) forKey:alarmName]; + + // something like [self.timerViewController doSomethingWithThisNewTimer] + +// [self.timerViewController addTimer:timeInterval]; + + //break this down into hours and minutes because it's displayed in seconds + //deligation to comunitcate this info back to the next view controller + + /* + when the user hits 'done' use delegation to provide all timer info back to the + presettimersviewcontroller + + ex. + + NSInteger hours = x; + NSInteger minutues = x; + + [self.delegate newCustomTimeViewController:self didAddTimerWithHours:hours minutes:minutes name:alarmName]; + + */ + +} + + +- (IBAction)alarmNameLabel:(id)sender { + + //[ViewControllerDelegate updateAlarmLabel]; + +} + +- (IBAction)timePickerView:(id)sender { + +// NSDate *chosenDate = [self.timePickerView date]; +// NSLog(@"%@ is my chosen date",chosenDate); + +} + + + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +// +//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { +// +// [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; +// +// NSString *selected = [self.category.options objectAtIndex:indexPath.row]; +// +// self.category.selection = selected; +// + + + +@end diff --git a/Time/Time/PresetTimersViewController.h b/Time/Time/PresetTimersViewController.h new file mode 100644 index 0000000..c2f09c1 --- /dev/null +++ b/Time/Time/PresetTimersViewController.h @@ -0,0 +1,23 @@ +// +// PresetTimersViewController.h +// Time +// +// Created by Lauren Caponong on 8/20/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "NewCustomTimerViewController.h" +#import + + +@interface PresetTimersViewController : UIViewController +{ + SystemSoundID playSoundID; +} + +-(IBAction) playAudio:(id)sender; + + +@end + diff --git a/Time/Time/PresetTimersViewController.m b/Time/Time/PresetTimersViewController.m new file mode 100644 index 0000000..9e04b6d --- /dev/null +++ b/Time/Time/PresetTimersViewController.m @@ -0,0 +1,253 @@ +// +// PresetTimersViewController.m +// Time +// +// Created by Lauren Caponong on 8/20/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "PresetTimersViewController.h" + + +@interface PresetTimersViewController () +// + +@property (weak, nonatomic) IBOutlet UILabel *timeEndingLabel; +@property (weak, nonatomic) IBOutlet UILabel *alarmNameLabel; + +@property (weak, nonatomic) IBOutlet UIButton *startButtonTapped; +@property (weak, nonatomic) IBOutlet UIButton *stopButtonTapped; + +@property (nonatomic) NSTimer *countDownTimer; +@property (nonatomic) NSInteger totalSeconds; +@property (nonatomic) NSInteger unformattedSeconds; + +@property (nonatomic) int hours; +@property (nonatomic) int minutes; +@property (nonatomic) int seconds; +@property (nonatomic) NSString *timeFormatted; + +@property (nonatomic) NSMutableDictionary *customTimersDictionary; + +@property (weak, nonatomic) IBOutlet UITableView *customTimersTableViewList; + +@end + + +@implementation PresetTimersViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.customTimersTableViewList.delegate = self; + + self.customTimersTableViewList.dataSource = self; + + self.customTimersDictionary = [[NSMutableDictionary alloc] init]; + + self.timeEndingLabel.hidden = YES; + self.alarmNameLabel.hidden = YES; + + +} + +- (void)tableView:(UITableView * )tableView +didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + [self.countDownTimer invalidate]; + + NSArray *keys = [self.customTimersDictionary allKeys]; + NSString *key = [keys objectAtIndex:indexPath.row]; + NSArray *value = [self.customTimersDictionary objectForKey:key]; + + self.alarmNameLabel.text = [NSString stringWithFormat:@"%@", key]; + + self.timeEndingLabel.text = [NSString stringWithFormat:@"%@ seconds", [self.customTimersDictionary objectForKey:key]]; + + NSTimeInterval duration = [[self.customTimersDictionary objectForKey:key] doubleValue]; + self.totalSeconds = duration; + + self.alarmNameLabel.hidden = NO; + self.timeEndingLabel.hidden = NO; + +} + + + +-(void)viewWillAppear:(BOOL)animated { + + [self.customTimersTableViewList reloadData]; + +} + + +- (IBAction)addTimerButtonTapped:(id)sender { + + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + + NewCustomTimerViewController *newPresetVC = [storyboard instantiateViewControllerWithIdentifier:@"newPresetVC"]; + + + newPresetVC.customTimersDictionary = self.customTimersDictionary; + + [self presentViewController:newPresetVC animated:YES completion:nil]; + +} + + +- (void) timer { + + self.totalSeconds = self.totalSeconds - 1; + NSLog(@"%ld", (long)self.totalSeconds); + if (self.totalSeconds == 0) { + [self.countDownTimer invalidate]; + } +} + + +- (NSString *)timeFormatted:(int)totalSeconds +{ + + NSString *timeFormatDisplay; + + int seconds = totalSeconds % 60; + int minutes = (totalSeconds / 60) % 60; + int hours = totalSeconds / 3600; + timeFormatDisplay = [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds]; + return timeFormatDisplay; +} + + +- (IBAction)startButtonTapped:(id)sender { + + if([self.customTimersDictionary count] == 0) { + + UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Warning" + message:@"You must add a new timer first." + delegate:self + cancelButtonTitle:@"OK" + otherButtonTitles: nil]; + + [alert show]; + + } else { + + [self startTimer]; + + } + + + // +} + + +-(void) startTimer { + [self.countDownTimer invalidate]; + + self.countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired:) userInfo:nil repeats:YES]; + + self.timeEndingLabel.text = [self timeFormatted:self.totalSeconds]; + + + +} + + +- (void)timerFired:(NSTimer *)timer { + self.totalSeconds--; + self.timeEndingLabel.text = [self timeFormatted:self.totalSeconds]; + + if (self.totalSeconds == 0) { + [self.countDownTimer invalidate]; + + UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Alarm" + message:@"Your time is up" + delegate:self + cancelButtonTitle:@"OK" + otherButtonTitles: nil]; + [alert show]; + } + +} + + +- (IBAction)stopButtonTapped:(id)sender { + + [self.countDownTimer invalidate]; + + +} + + +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + return YES; +} + + +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + //remove the deleted object from your data source. + //If your data source is an NSMutableArray, do this + + NSArray *keys = [self.customTimersDictionary allKeys]; + + NSString *key = keys[indexPath.row]; + + [self.customTimersDictionary removeObjectForKey:key]; + + self.alarmNameLabel.hidden = YES; + self.timeEndingLabel.hidden = YES; + + [tableView reloadData]; // tell table to refresh now + } +} + + + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [self.customTimersDictionary count]; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"customTimersCellIdentifier" forIndexPath:indexPath]; + + NSArray *keys = [self.customTimersDictionary allKeys]; + NSString *key = keys[indexPath.row]; + + //ALARM NAME LABEL TEXT + if ([key isEqual: @""]) { + self.alarmNameLabel.text = @"Untitled"; + } else { + self.alarmNameLabel.text = [NSString stringWithFormat:@"%@", key]; + } + + //CELL - ALARM LABEL TEXT + if ([key isEqual: @""]) { + cell.textLabel.text = @"Untitled"; + } else { + cell.textLabel.text = key; + } + + //CELL - TIME ENDING DETAIL TEXT + cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ seconds", [self.customTimersDictionary objectForKey:key]]; + + + //TIME ENDING LABEL TEXT + self.timeEndingLabel.text = [NSString stringWithFormat:@"%@ seconds", [self.customTimersDictionary objectForKey:key]]; + + return cell; + + +} + + + +@end diff --git a/Time/Time/SpecialEventsViewController.h b/Time/Time/SpecialEventsViewController.h new file mode 100644 index 0000000..acbd0a6 --- /dev/null +++ b/Time/Time/SpecialEventsViewController.h @@ -0,0 +1,13 @@ +// +// SpecialEventsViewController.h +// Time +// +// Created by Lauren Caponong on 8/20/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface SpecialEventsViewController : UIViewController + +@end diff --git a/Time/Time/SpecialEventsViewController.m b/Time/Time/SpecialEventsViewController.m new file mode 100644 index 0000000..daa58b4 --- /dev/null +++ b/Time/Time/SpecialEventsViewController.m @@ -0,0 +1,37 @@ +// +// SpecialEventsViewController.m +// Time +// +// Created by Lauren Caponong on 8/20/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "SpecialEventsViewController.h" + +@interface SpecialEventsViewController () + +@end + +@implementation SpecialEventsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/Time/Time/UpcomingEvents.h b/Time/Time/UpcomingEvents.h new file mode 100644 index 0000000..abe3647 --- /dev/null +++ b/Time/Time/UpcomingEvents.h @@ -0,0 +1,17 @@ +// +// UpcomingEvents.h +// Time +// +// Created by Lauren Caponong on 8/31/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface UpcomingEvents : NSObject + +@property (nonatomic) NSString *eventName; + ++ (NSDictionary *) upcomingEventsDictionary; + +@end diff --git a/Time/Time/UpcomingEvents.m b/Time/Time/UpcomingEvents.m new file mode 100644 index 0000000..8d9acf8 --- /dev/null +++ b/Time/Time/UpcomingEvents.m @@ -0,0 +1,24 @@ +// +// UpcomingEvents.m +// Time +// +// Created by Lauren Caponong on 8/31/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "UpcomingEvents.h" + +@implementation UpcomingEvents + + ++ (NSDictionary *) upcomingEventsDictionary { + return @{ + + @"Christmas" : @"12/25/2015", + @"New Years" : @"01/01/2016", + @"Labor Day" : @"09/07/2015" + + }; +} + +@end diff --git a/Time/Time/UpcomingEventsTableViewController.h b/Time/Time/UpcomingEventsTableViewController.h new file mode 100644 index 0000000..6e7aa37 --- /dev/null +++ b/Time/Time/UpcomingEventsTableViewController.h @@ -0,0 +1,13 @@ +// +// UpcomingEventsTableViewController.h +// Time +// +// Created by Lauren Caponong on 8/31/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface UpcomingEventsTableViewController : UITableViewController + +@end diff --git a/Time/Time/UpcomingEventsTableViewController.m b/Time/Time/UpcomingEventsTableViewController.m new file mode 100644 index 0000000..faa5505 --- /dev/null +++ b/Time/Time/UpcomingEventsTableViewController.m @@ -0,0 +1,103 @@ +// +// UpcomingEventsTableViewController.m +// Time +// +// Created by Lauren Caponong on 8/31/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "UpcomingEventsTableViewController.h" +#import "UpcomingEvents.h" + +@interface UpcomingEventsTableViewController () + +@property (nonatomic) NSDictionary *eventsDictionary; +@property (nonatomic) NSDate *today; + +@end + + + +@implementation UpcomingEventsTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.navigationItem.title = @"Upcoming Events"; + + //initializing eventsDictionary + self.eventsDictionary = [[NSDictionary alloc]init]; + + //getting today's date which will print to the console + self.today = [NSDate date]; + NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; + [dateFormat setDateFormat:@"MM/dd/yyyy"]; + NSString *dateString = [dateFormat stringFromDate:self.today]; + NSLog(@"Today's date: %@", dateString); + + +} + + +//method for calculating the difference between one date and another date + +-(int)dateDiffrenceFromDate:(NSString *)date1 second:(NSString *)date2 { + // Manage Date Formation same for both dates + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateFormat:@"dd-MM-yyyy"]; + NSDate *startDate = [formatter dateFromString:date1]; + NSDate *endDate = [formatter dateFromString:date2]; + + unsigned flags = NSDayCalendarUnit; + NSDateComponents *difference = [[NSCalendar currentCalendar] components:flags fromDate:startDate toDate:endDate options:0]; + + int dayDiff = [difference day]; + + return dayDiff; +} + + + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + return self.eventsDictionary.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DateCellIdentifier" forIndexPath:indexPath]; + + //trying to print the values of the dictionary in the cell + NSArray *key = [self.eventsDictionary allKeys][indexPath.row]; + + NSString *eventNameString = self.eventsDictionary[key]; +// NSString *eventDateString = key; + + cell.textLabel.text = [self.eventsDictionary objectForKey:@"Christmas"]; + + // printing value of the key in the detail text label +// cell.detailTextLabel.text = eventDateString; + + return cell; + +} + +// // Configure the cell... +// cell.textLabel.text = [[self.events objectAtIndex:indexPath.row] objectForKey: @"Christmas"]; +// cell.detailTextLabel.text = [[self.events objectAtIndex:indexPath.row] objectForKey:@"New Years"]; +// // continue configuration etc.. +// return cell; +//} + + + + + +@end diff --git a/Time/Time/ViewController.h b/Time/Time/ViewController.h deleted file mode 100644 index 9d0e38f..0000000 --- a/Time/Time/ViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ViewController.h -// Time -// -// Created by Michael Kavouras on 8/20/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. -// - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/Time/TimerUITabBarController.h b/Time/TimerUITabBarController.h new file mode 100644 index 0000000..1ff5d3a --- /dev/null +++ b/Time/TimerUITabBarController.h @@ -0,0 +1,13 @@ +// +// TimerUITabBarController.h +// Time +// +// Created by Lauren Caponong on 8/20/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface TimerUITabBarController : UITabBarController + +@end diff --git a/Time/Time/ViewController.m b/Time/TimerUITabBarController.m similarity index 52% rename from Time/Time/ViewController.m rename to Time/TimerUITabBarController.m index 194fe5f..9e14f7d 100644 --- a/Time/Time/ViewController.m +++ b/Time/TimerUITabBarController.m @@ -1,22 +1,22 @@ // -// ViewController.m +// TimerUITabBarController.m // Time // -// Created by Michael Kavouras on 8/20/15. +// Created by Lauren Caponong on 8/20/15. // Copyright (c) 2015 Mike Kavouras. All rights reserved. // -#import "ViewController.h" +#import "TimerUITabBarController.h" -@interface ViewController () +@interface TimerUITabBarController () @end -@implementation ViewController +@implementation TimerUITabBarController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { @@ -24,4 +24,6 @@ - (void)didReceiveMemoryWarning { // Dispose of any resources that can be recreated. } + + @end