Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added MarsWater/.DS_Store
Binary file not shown.
374 changes: 374 additions & 0 deletions MarsWater/MarsWater.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// AppDelegate.h
// SavingForever
// MarsWater
//
// Created by Michael Kavouras on 10/4/15.
// Copyright © 2015 Michael Kavouras. All rights reserved.
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// AppDelegate.m
// SavingForever
// MarsWater
//
// Created by Michael Kavouras on 10/4/15.
// Copyright © 2015 Michael Kavouras. All rights reserved.
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import "AppDelegate.h"
Expand Down Expand Up @@ -51,7 +51,7 @@ - (void)applicationWillTerminate:(UIApplication *)application {
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;

- (NSURL *)applicationDocumentsDirectory {
// The directory the application uses to store the Core Data store file. This code uses a directory named "com.mikekavouras.SavingForever" in the application's documents directory.
// The directory the application uses to store the Core Data store file. This code uses a directory named "nyc.c4q.justinekay.MarsWater" in the application's documents directory.
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

Expand All @@ -60,7 +60,7 @@ - (NSManagedObjectModel *)managedObjectModel {
if (_managedObjectModel != nil) {
return _managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"SavingForever" withExtension:@"momd"];
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MarsWater" withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}
Expand All @@ -74,7 +74,7 @@ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
// Create the coordinator and store

_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"SavingForever.sqlite"];
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MarsWater.sqlite"];
NSError *error = nil;
NSString *failureReason = @"There was an error creating or loading the application's saved data.";
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
Expand Down
6 changes: 6 additions & 0 deletions MarsWater/MarsWater/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Checkmark Filled-100 (1).png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
413 changes: 413 additions & 0 deletions MarsWater/MarsWater/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

File renamed without changes.
25 changes: 25 additions & 0 deletions MarsWater/MarsWater/List+CoreDataProperties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// List+CoreDataProperties.h
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//

#import "List.h"

NS_ASSUME_NONNULL_BEGIN

@interface List (CoreDataProperties)

@property (nullable, nonatomic, retain) NSString *title;
@property (nullable, nonatomic, retain) NSDate *createdAt;
@property (nullable, nonatomic, retain) id color;
@property (nullable, nonatomic, retain) NSOrderedSet *task;

@end

NS_ASSUME_NONNULL_END
21 changes: 21 additions & 0 deletions MarsWater/MarsWater/List+CoreDataProperties.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// List+CoreDataProperties.m
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//

#import "List+CoreDataProperties.h"

@implementation List (CoreDataProperties)

@dynamic title;
@dynamic createdAt;
@dynamic color;
@dynamic task;

@end
24 changes: 24 additions & 0 deletions MarsWater/MarsWater/List.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// List.h
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Task;

NS_ASSUME_NONNULL_BEGIN

@interface List : NSManagedObject

// Insert code here to declare functionality of your managed object subclass

@end

NS_ASSUME_NONNULL_END

#import "List+CoreDataProperties.h"
16 changes: 16 additions & 0 deletions MarsWater/MarsWater/List.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// List.m
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import "List.h"
#import "Task.h"

@implementation List

// Insert code here to add functionality to your managed object subclass

@end
16 changes: 16 additions & 0 deletions MarsWater/MarsWater/ListCreationTableViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// ListCreationTableViewController.h
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "List.h"

@interface ListCreationTableViewController : UITableViewController

@property (nonatomic)List *selectedList;

@end
174 changes: 174 additions & 0 deletions MarsWater/MarsWater/ListCreationTableViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
//
// ListCreationTableViewController.m
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import <CoreData/CoreData.h>
#import "ListCreationTableViewController.h"
#import "AppDelegate.h"

@interface ListCreationTableViewController ()

@property (weak, nonatomic) IBOutlet UITextField *titleTextField;

@property (nonatomic)List *list;

@property (nonatomic)BOOL colorButtonSelected;

@end

@implementation ListCreationTableViewController

-(void)viewDidLoad{

[super viewDidLoad];

self.colorButtonSelected = NO;

[self setupNavigationBar];

[self createNewList];

}

-(void)createNewList{

if (self.selectedList == nil) {

AppDelegate *delegate = [UIApplication sharedApplication].delegate;

self.list = [NSEntityDescription insertNewObjectForEntityForName:@"List" inManagedObjectContext:delegate.managedObjectContext];
}
}

-(void)setupNavigationBar{

if (self.selectedList == nil) {

self.navigationItem.title = @"Create New List";

}else {

self.navigationItem.title = [NSString stringWithFormat:@"Edit '%@'", self.selectedList.title];

self.titleTextField.text = self.selectedList.title;
}

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save)];

self.navigationItem.leftBarButtonItem.tintColor = [UIColor grayColor];
self.navigationItem.rightBarButtonItem.tintColor = [UIColor colorWithRed:224.0/255.0 green:35.0/255.0 blue:70.0/255.0 alpha:1.0];
}

-(void)cancel{

[self removeObjectFromNSManagedObjectContext:self.list];

[self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popViewControllerAnimated:YES];
}

-(void)save{

if ([self.titleTextField.text isEqualToString:@""]) {

[self emptyTextFieldAlertController];

}else if (self.colorButtonSelected == NO) {

[self colorButtonAlertController];

}else {

[self setNewListProperties];
[self setSelectedListProperties];

AppDelegate *delegate = [UIApplication sharedApplication].delegate;
[delegate.managedObjectContext save:nil];

self.list = nil;
self.selectedList = nil;

[self dismissViewControllerAnimated:YES completion:nil];

[self.navigationController popViewControllerAnimated:YES];

}

}

-(void)setNewListProperties{

if (self.list != nil) {

self.list.title = self.titleTextField.text;
self.list.createdAt = [NSDate date];
}
}

-(void)setSelectedListProperties{

if (self.selectedList != nil) {

self.selectedList.title = self.titleTextField.text;
}
}


#pragma mark - color button

- (IBAction)colorButtonTapped:(UIButton *)sender {

self.colorButtonSelected = YES;

self.list.color = sender.backgroundColor;
self.selectedList.color = sender.backgroundColor;
}

#pragma mark - alertController

-(void)colorButtonAlertController{

UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil
message:@"Please select a color."
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];

}

-(void)emptyTextFieldAlertController{

UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil
message:@"Please fill in the list title."
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];

}

#pragma mark - NSManagedObjectContext

-(void)removeObjectFromNSManagedObjectContext:(List *)list {

AppDelegate *delegate = [UIApplication sharedApplication].delegate;
NSManagedObjectContext *context = delegate.managedObjectContext;
[context deleteObject:list];
[context processPendingChanges];

}


@end
13 changes: 13 additions & 0 deletions MarsWater/MarsWater/ListTableViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ListTableViewController.h
// MarsWater
//
// Created by Justine Gartner on 10/4/15.
// Copyright © 2015 Justine Gartner. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ListTableViewController : UITableViewController

@end
Loading