Skip to content

Commit

Permalink
Merge pull request #13 from nathanb95/newuitest
Browse files Browse the repository at this point in the history
Finally Figured That Shit Out
  • Loading branch information
okrek6 committed Oct 14, 2018
2 parents c88a336 + 2b99d99 commit 0aef76a
Show file tree
Hide file tree
Showing 67 changed files with 7,894 additions and 397 deletions.
8 changes: 8 additions & 0 deletions SplitNote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
95303F2B21727226003519D3 /* foldersHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95303F2A21727226003519D3 /* foldersHeaderView.swift */; };
95303F2E217272B7003519D3 /* extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95303F2D217272B7003519D3 /* extensions.swift */; };
95303F30217285F8003519D3 /* notesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95303F2F217285F8003519D3 /* notesViewController.swift */; };
95303F332172C498003519D3 /* notesHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95303F322172C498003519D3 /* notesHeaderView.swift */; };
95303F352172C4D7003519D3 /* noteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95303F342172C4D7003519D3 /* noteCell.swift */; };
E2ADFD5421728B3800A90069 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2ADFD5321728B3800A90069 /* Launch Screen.storyboard */; };
/* End PBXBuildFile section */

Expand All @@ -37,6 +39,8 @@
95303F2A21727226003519D3 /* foldersHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = foldersHeaderView.swift; sourceTree = "<group>"; };
95303F2D217272B7003519D3 /* extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = extensions.swift; sourceTree = "<group>"; };
95303F2F217285F8003519D3 /* notesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = notesViewController.swift; sourceTree = "<group>"; };
95303F322172C498003519D3 /* notesHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = notesHeaderView.swift; sourceTree = "<group>"; };
95303F342172C4D7003519D3 /* noteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = noteCell.swift; sourceTree = "<group>"; };
E2ADFD5321728B3800A90069 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -99,7 +103,9 @@
children = (
95303F1F2171C2FD003519D3 /* recentsCell.swift */,
95303F2321725AA1003519D3 /* folderCell.swift */,
95303F342172C4D7003519D3 /* noteCell.swift */,
95303F2A21727226003519D3 /* foldersHeaderView.swift */,
95303F322172C498003519D3 /* notesHeaderView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -198,10 +204,12 @@
4926E82321718F7800AFB28E /* AppDelegate.swift in Sources */,
95303F202171C2FD003519D3 /* recentsCell.swift in Sources */,
95303F22217259FC003519D3 /* folderViewController.swift in Sources */,
95303F332172C498003519D3 /* notesHeaderView.swift in Sources */,
95303F2E217272B7003519D3 /* extensions.swift in Sources */,
95303F2B21727226003519D3 /* foldersHeaderView.swift in Sources */,
95303F2421725AA1003519D3 /* folderCell.swift in Sources */,
4926E82B21718F7800AFB28E /* SplitNote.xcdatamodeld in Sources */,
95303F352172C4D7003519D3 /* noteCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion SplitNote/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5) {

self.window?.rootViewController = UINavigationController(rootViewController: FolderViewController())
self.window?.rootViewController = homeViewController()

}

Expand Down
23 changes: 23 additions & 0 deletions SplitNote/View/noteCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// noteCell.swift
// SplitNote
//
// Created by Nick J Grove on 10/13/18.
// Copyright © 2018 teamSplitNote. All rights reserved.
//

import UIKit

class NoteCell: UITableViewCell {

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

backgroundColor = .white
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}
137 changes: 137 additions & 0 deletions SplitNote/View/notesHeaderView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
//
// notesHeaderView.swift
// SplitNote
//
// Created by Nick J Grove on 10/13/18.
// Copyright © 2018 teamSplitNote. All rights reserved.
//

import UIKit

class NotesHeaderView: UIView, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {

lazy var collectionView: UICollectionView = {

let layout = UICollectionViewFlowLayout()
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.dataSource = self
cv.delegate = self
return cv

}()

let cellId = "cellId"
let barHeadings = ["Title", "Duration", "Date"]

override init(frame: CGRect) {

super.init(frame: frame)

collectionView.register(FoldersHeaderViewCell.self, forCellWithReuseIdentifier: cellId)

addSubview(collectionView)
addConstraintsWithFormat(format: "H:|[v0]|", views: collectionView)
addConstraintsWithFormat(format: "V:|[v0]|", views: collectionView)

}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 2
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! FoldersHeaderViewCell

cell.headerLabel.text = barHeadings[indexPath.row]
cell.layer.borderWidth = 1.0
cell.layer.borderColor = UIColor.white.cgColor

return cell
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

return CGSize(width: frame.width/3, height: frame.height)

}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}

class NotesHeaderViewCell: UICollectionViewCell {

override init(frame: CGRect) {

super.init(frame: frame)
setupViews()

}

var SplitNoteDarkPurple = UIColor(displayP3Red: 66/255, green: 39/255, blue: 90/255, alpha: 1.0)
var SplitNoteLightPurple = UIColor(displayP3Red: 115/255, green: 75/255, blue: 109/255, alpha: 1.0)

private lazy var gradient: CAGradientLayer = {

let gradientLayer = CAGradientLayer()
gradientLayer.colors = [SplitNoteLightPurple.cgColor,SplitNoteDarkPurple.cgColor]
gradientLayer.locations = [0.0,1.0]
gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)
gradientLayer.frame = self.bounds
return gradientLayer

}()

let headerLabel: UILabel = {

let hL = UILabel()
hL.font = UIFont(name: "Helvetica", size: 15)
hL.textColor = .white
hL.textAlignment = NSTextAlignment.center
return hL

}()

override var isSelected: Bool {
didSet {

if isSelected {
gradient.removeFromSuperlayer()
backgroundColor = UIColor.white
headerLabel.textColor = SplitNoteDarkPurple
let border = CALayer()
border.frame = CGRect(x: 0, y: self.frame.height - 1.0, width: self.frame.width, height: 1.0)
self.layer.insertSublayer(border, at: 0)
} else {
layer.insertSublayer(gradient, at: 0)
headerLabel.textColor = .white
}

}
}

func setupViews() {

addSubview(headerLabel)
addConstraintsWithFormat(format: "H:[v0(80)]", views: headerLabel)
addConstraintsWithFormat(format: "V:[v0(20)]", views: headerLabel)

layer.insertSublayer(gradient, at: 0)

addConstraint(NSLayoutConstraint(item: headerLabel, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant: 0))
addConstraint(NSLayoutConstraint(item: headerLabel, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0))

}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

}
13 changes: 12 additions & 1 deletion SplitNote/folderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ import UIKit

class FolderCell: UITableViewCell {

@IBOutlet var testTextLabel: UILabel!

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

contentView.backgroundColor = .white
backgroundColor = .white

testTextLabel = UILabel(frame: CGRect(x: 0, y: 0, width: frame.width/2, height: 50))
testTextLabel.text = "Click Me!"
testTextLabel.textColor = .black
testTextLabel.textAlignment = NSTextAlignment.left
testTextLabel.font = UIFont(name: "Helvetica-Ultralight", size: 20)

addSubview(testTextLabel)

}

required init?(coder aDecoder: NSCoder) {
Expand Down
5 changes: 3 additions & 2 deletions SplitNote/folderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ class FolderViewController: UIViewController, UITableViewDataSource, UITableView
}()

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("You selected one of your notes")
self.present(UINavigationController(rootViewController: NotesViewController()), animated: true, completion: nil)
print("You selected one of your folders")
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath)
let cell = FolderCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "cellId")

return cell
}
Expand Down
81 changes: 72 additions & 9 deletions SplitNote/notesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,86 @@

import UIKit

class NotesViewController: UIViewController/*, UITableViewDataSource, UITableViewDelegate*/ {
class NotesViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

@IBOutlet var notes: UITableView!

var SplitNoteDarkPurple = UIColor(displayP3Red: 66/255, green: 39/255, blue: 90/255, alpha: 1.0)

let cellId = "cellId"

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .white

setupNavigationBarItems()
setupTableView()
setupNotesHeaderView()

}

// func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// <#code#>
// }
//
// func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// <#code#>
// }
//
private func setupNavigationBarItems() {

navigationController?.navigationBar.barTintColor = SplitNoteDarkPurple

navigationItem.title = "Notes"
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
navigationItem.rightBarButtonItem = add

navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = false;

}

private func setupTableView() {

notes = UITableView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height))
notes.register(NoteCell.self, forCellReuseIdentifier: "cellId")
notes.rowHeight = 50
notes.dataSource = self
notes.delegate = self
view.addSubview(notes)

}

private func setupNotesHeaderView() {

view.addSubview(notesHeader)
view.addConstraintsWithFormat(format: "H:|[v0]|", views: notesHeader)
view.addConstraintsWithFormat(format: "V:|[v0(50)]", views: notesHeader)

}

let add: UIBarButtonItem = {

let a = UIBarButtonItem()
a.title = "ADD"
a.tintColor = .white
return a

}()

let notesHeader: NotesHeaderView = {

let nH = NotesHeaderView()
return nH

}()

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("You selected one of your notes")
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath) as! NoteCell

return cell
}

}
2 changes: 1 addition & 1 deletion SplitNote/recentsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RecentsCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

contentView.backgroundColor = .white
backgroundColor = .white
}

required init?(coder aDecoder: NSCoder) {
Expand Down
Binary file modified build/Debug-iphonesimulator/SplitNote.app/SplitNote
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0aef76a

Please sign in to comment.