From 40fd77f92f3ea9debd111b2975973bf2a78128c0 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Tue, 3 Mar 2020 21:41:41 -0600
Subject: [PATCH 01/13] test git workflow
---
Notare/Notes.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Notare/Notes.swift b/Notare/Notes.swift
index cdf6698..d5c5326 100644
--- a/Notare/Notes.swift
+++ b/Notare/Notes.swift
@@ -4,7 +4,7 @@
//
// Created by Bree Jeune on 3/2/20.
// Copyright © 2020 Young. All rights reserved.
-//
+// maodmd
import Foundation
From b0165ecb6b2b0e0da48620e56d55a0633dffe824 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Wed, 4 Mar 2020 19:07:33 -0600
Subject: [PATCH 02/13] Theme Selection Storyboard setup
---
Notare/Base.lproj/Main.storyboard | 172 +++++++++++++++++++++++++++++-
1 file changed, 171 insertions(+), 1 deletion(-)
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index d426f79..3d194e0 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -193,10 +193,178 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -229,6 +397,8 @@
+
+
From 9674712b63d252492928a5c700cc1448e6ea3fe1 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Wed, 4 Mar 2020 19:36:47 -0600
Subject: [PATCH 03/13] Theme Protocol and classes
---
Notare/DarkTheme.swift | 9 +++++++++
Notare/LightTheme.swift | 9 +++++++++
Notare/Theme.swift | 9 +++++++++
Notare/ThemeProtocol.swift | 9 +++++++++
4 files changed, 36 insertions(+)
create mode 100644 Notare/DarkTheme.swift
create mode 100644 Notare/LightTheme.swift
create mode 100644 Notare/Theme.swift
create mode 100644 Notare/ThemeProtocol.swift
diff --git a/Notare/DarkTheme.swift b/Notare/DarkTheme.swift
new file mode 100644
index 0000000..d9d213e
--- /dev/null
+++ b/Notare/DarkTheme.swift
@@ -0,0 +1,9 @@
+//
+// DarkTheme.swift
+// Notare
+//
+// Created by conner on 3/4/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/LightTheme.swift b/Notare/LightTheme.swift
new file mode 100644
index 0000000..74733cb
--- /dev/null
+++ b/Notare/LightTheme.swift
@@ -0,0 +1,9 @@
+//
+// LightTheme.swift
+// Notare
+//
+// Created by conner on 3/4/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/Theme.swift b/Notare/Theme.swift
new file mode 100644
index 0000000..882abdd
--- /dev/null
+++ b/Notare/Theme.swift
@@ -0,0 +1,9 @@
+//
+// Theme.swift
+// Notare
+//
+// Created by conner on 3/4/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/ThemeProtocol.swift b/Notare/ThemeProtocol.swift
new file mode 100644
index 0000000..7492f92
--- /dev/null
+++ b/Notare/ThemeProtocol.swift
@@ -0,0 +1,9 @@
+//
+// ThemeProtocol.swift
+// Notare
+//
+// Created by conner on 3/4/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
From ab91d023217cff70e3d3bed0bc58cd8684597593 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Wed, 4 Mar 2020 20:06:41 -0600
Subject: [PATCH 04/13] Some setup for implementing background colors
---
Notare.xcodeproj/project.pbxproj | 32 +++++++++++++++++++++++
Notare/Base.lproj/Main.storyboard | 2 ++
Notare/DarkTheme.swift | 12 ++++++---
Notare/Extensions/UIButtonExtension.swift | 13 +++++++++
Notare/LightTheme.swift | 12 ++++++---
Notare/TableViewCell.swift | 24 +++++++++++++++++
Notare/Theme.swift | 4 +++
Notare/ThemeProtocol.swift | 11 +++++---
Notare/ViewController.swift | 4 ++-
9 files changed, 104 insertions(+), 10 deletions(-)
create mode 100644 Notare/Extensions/UIButtonExtension.swift
create mode 100644 Notare/TableViewCell.swift
diff --git a/Notare.xcodeproj/project.pbxproj b/Notare.xcodeproj/project.pbxproj
index 24b06b6..7d89e33 100644
--- a/Notare.xcodeproj/project.pbxproj
+++ b/Notare.xcodeproj/project.pbxproj
@@ -7,6 +7,12 @@
objects = {
/* Begin PBXBuildFile section */
+ 13E26AD3241088A800D2BC08 /* ThemeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */; };
+ 13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD42410896300D2BC08 /* DarkTheme.swift */; };
+ 13E26AD724108B5300D2BC08 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD624108B5300D2BC08 /* Theme.swift */; };
+ 13E26AD924108D9100D2BC08 /* LightTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD824108D9100D2BC08 /* LightTheme.swift */; };
+ 13E26ADC24108FAF00D2BC08 /* UIButtonExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26ADB24108FAF00D2BC08 /* UIButtonExtension.swift */; };
+ 13E26ADE241095BD00D2BC08 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26ADD241095BD00D2BC08 /* TableViewCell.swift */; };
1FB17190240DC53B00F8EC0F /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */; };
1FB17195240DE8DF00F8EC0F /* Notes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB17194240DE8DF00F8EC0F /* Notes.swift */; };
1FC510B9240D8C54006BD691 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC510B8240D8C54006BD691 /* AppDelegate.swift */; };
@@ -18,6 +24,12 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeProtocol.swift; sourceTree = ""; };
+ 13E26AD42410896300D2BC08 /* DarkTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkTheme.swift; sourceTree = ""; };
+ 13E26AD624108B5300D2BC08 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; };
+ 13E26AD824108D9100D2BC08 /* LightTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightTheme.swift; sourceTree = ""; };
+ 13E26ADB24108FAF00D2BC08 /* UIButtonExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIButtonExtension.swift; sourceTree = ""; };
+ 13E26ADD241095BD00D2BC08 /* TableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; };
1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; };
1FB17194240DE8DF00F8EC0F /* Notes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notes.swift; sourceTree = ""; };
1FC510B5240D8C54006BD691 /* Notare.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Notare.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -41,6 +53,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 13E26ADA24108F9500D2BC08 /* Extensions */ = {
+ isa = PBXGroup;
+ children = (
+ 13E26ADB24108FAF00D2BC08 /* UIButtonExtension.swift */,
+ );
+ path = Extensions;
+ sourceTree = "";
+ };
1FB17193240DE8B100F8EC0F /* Resources */ = {
isa = PBXGroup;
children = (
@@ -74,9 +94,15 @@
1FB17193240DE8B100F8EC0F /* Resources */,
1FB17194240DE8DF00F8EC0F /* Notes.swift */,
1FC510BC240D8C54006BD691 /* ViewController.swift */,
+ 13E26ADD241095BD00D2BC08 /* TableViewCell.swift */,
1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */,
1FC510BE240D8C54006BD691 /* Main.storyboard */,
1FC510C6240D8C58006BD691 /* Info.plist */,
+ 13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */,
+ 13E26AD42410896300D2BC08 /* DarkTheme.swift */,
+ 13E26AD824108D9100D2BC08 /* LightTheme.swift */,
+ 13E26ADA24108F9500D2BC08 /* Extensions */,
+ 13E26AD624108B5300D2BC08 /* Theme.swift */,
);
path = Notare;
sourceTree = "";
@@ -153,9 +179,15 @@
buildActionMask = 2147483647;
files = (
1FC510BD240D8C54006BD691 /* ViewController.swift in Sources */,
+ 13E26ADC24108FAF00D2BC08 /* UIButtonExtension.swift in Sources */,
+ 13E26AD724108B5300D2BC08 /* Theme.swift in Sources */,
1FC510B9240D8C54006BD691 /* AppDelegate.swift in Sources */,
1FC510BB240D8C54006BD691 /* SceneDelegate.swift in Sources */,
+ 13E26AD924108D9100D2BC08 /* LightTheme.swift in Sources */,
+ 13E26ADE241095BD00D2BC08 /* TableViewCell.swift in Sources */,
+ 13E26AD3241088A800D2BC08 /* ThemeProtocol.swift in Sources */,
1FB17190240DC53B00F8EC0F /* DetailViewController.swift in Sources */,
+ 13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */,
1FB17195240DE8DF00F8EC0F /* Notes.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index 3d194e0..e1a5410 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -68,6 +68,8 @@
+
+
diff --git a/Notare/DarkTheme.swift b/Notare/DarkTheme.swift
index d9d213e..528c4e4 100644
--- a/Notare/DarkTheme.swift
+++ b/Notare/DarkTheme.swift
@@ -2,8 +2,14 @@
// DarkTheme.swift
// Notare
//
-// Created by conner on 3/4/20.
-// Copyright © 2020 Young. All rights reserved.
+// Created by conner on 3/3/20.
+// Copyright © 2020 conner. All rights reserved.
//
-import Foundation
+import UIKit
+
+class DarkTheme: ThemeProtocol {
+ var fontColor: UIColor = UIColor.lightGray
+ var headerColor: UIColor = UIColor.darkGray
+ var backgroundColor: UIColor = UIColor.black
+}
diff --git a/Notare/Extensions/UIButtonExtension.swift b/Notare/Extensions/UIButtonExtension.swift
new file mode 100644
index 0000000..92b89c1
--- /dev/null
+++ b/Notare/Extensions/UIButtonExtension.swift
@@ -0,0 +1,13 @@
+//
+// UIButtonExtension.swift
+// Notare
+//
+// Created by conner on 3/4/20.
+// Copyright © 2020 conner. All rights reserved.
+//
+
+import UIKit
+
+extension UIButton {
+
+}
diff --git a/Notare/LightTheme.swift b/Notare/LightTheme.swift
index 74733cb..10c49e5 100644
--- a/Notare/LightTheme.swift
+++ b/Notare/LightTheme.swift
@@ -2,8 +2,14 @@
// LightTheme.swift
// Notare
//
-// Created by conner on 3/4/20.
-// Copyright © 2020 Young. All rights reserved.
+// Created by conner on 3/3/20.
+// Copyright © 2020 conner. All rights reserved.
//
-import Foundation
+import UIKit
+
+class LightTheme: ThemeProtocol {
+ var fontColor: UIColor = UIColor.black
+ var headerColor: UIColor = UIColor.white
+ var backgroundColor: UIColor = UIColor.white
+}
diff --git a/Notare/TableViewCell.swift b/Notare/TableViewCell.swift
new file mode 100644
index 0000000..aa12f2b
--- /dev/null
+++ b/Notare/TableViewCell.swift
@@ -0,0 +1,24 @@
+//
+// TableViewCell.swift
+// Notare
+//
+// Created by conner on 3/4/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import UIKit
+
+class TableViewCell: UITableViewCell {
+
+ override func awakeFromNib() {
+ super.awakeFromNib()
+ // Initialization code
+ }
+
+ override func setSelected(_ selected: Bool, animated: Bool) {
+ super.setSelected(selected, animated: animated)
+
+ // Configure the view for the selected state
+ }
+
+}
diff --git a/Notare/Theme.swift b/Notare/Theme.swift
index 882abdd..4dfc279 100644
--- a/Notare/Theme.swift
+++ b/Notare/Theme.swift
@@ -7,3 +7,7 @@
//
import Foundation
+
+class Theme {
+ static var current: ThemeProtocol = DarkTheme()
+}
diff --git a/Notare/ThemeProtocol.swift b/Notare/ThemeProtocol.swift
index 7492f92..94ca53e 100644
--- a/Notare/ThemeProtocol.swift
+++ b/Notare/ThemeProtocol.swift
@@ -2,8 +2,13 @@
// ThemeProtocol.swift
// Notare
//
-// Created by conner on 3/4/20.
-// Copyright © 2020 Young. All rights reserved.
+// Created by conner on 3/3/20.
+// Copyright © 2020 conner. All rights reserved.
//
+import UIKit
-import Foundation
+protocol ThemeProtocol {
+ var fontColor: UIColor { get }
+ var headerColor: UIColor { get }
+ var backgroundColor: UIColor { get }
+}
diff --git a/Notare/ViewController.swift b/Notare/ViewController.swift
index 7de2e0b..c86072c 100644
--- a/Notare/ViewController.swift
+++ b/Notare/ViewController.swift
@@ -64,7 +64,9 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
navigationItem.searchController = searchController
// closes the search bar when the user navigates to another view controller
definesPresentationContext = true
-
+
+ // Theme inclusion
+ tableView.backgroundColor = Theme.current.backgroundColor
}
// ***********
From 6619c8f19d1cf89f73587946f1fdf123997dbebc Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Wed, 4 Mar 2020 20:50:52 -0600
Subject: [PATCH 05/13] Partial bg color for detailTextView
---
Notare.xcodeproj/project.pbxproj | 4 ----
Notare/Base.lproj/Main.storyboard | 4 +---
Notare/DarkTheme.swift | 3 +--
Notare/DetailViewController.swift | 2 ++
Notare/TableViewCell.swift | 24 ------------------------
5 files changed, 4 insertions(+), 33 deletions(-)
delete mode 100644 Notare/TableViewCell.swift
diff --git a/Notare.xcodeproj/project.pbxproj b/Notare.xcodeproj/project.pbxproj
index 7d89e33..3ca2194 100644
--- a/Notare.xcodeproj/project.pbxproj
+++ b/Notare.xcodeproj/project.pbxproj
@@ -12,7 +12,6 @@
13E26AD724108B5300D2BC08 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD624108B5300D2BC08 /* Theme.swift */; };
13E26AD924108D9100D2BC08 /* LightTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD824108D9100D2BC08 /* LightTheme.swift */; };
13E26ADC24108FAF00D2BC08 /* UIButtonExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26ADB24108FAF00D2BC08 /* UIButtonExtension.swift */; };
- 13E26ADE241095BD00D2BC08 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26ADD241095BD00D2BC08 /* TableViewCell.swift */; };
1FB17190240DC53B00F8EC0F /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */; };
1FB17195240DE8DF00F8EC0F /* Notes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FB17194240DE8DF00F8EC0F /* Notes.swift */; };
1FC510B9240D8C54006BD691 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC510B8240D8C54006BD691 /* AppDelegate.swift */; };
@@ -29,7 +28,6 @@
13E26AD624108B5300D2BC08 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; };
13E26AD824108D9100D2BC08 /* LightTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightTheme.swift; sourceTree = ""; };
13E26ADB24108FAF00D2BC08 /* UIButtonExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIButtonExtension.swift; sourceTree = ""; };
- 13E26ADD241095BD00D2BC08 /* TableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; };
1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; };
1FB17194240DE8DF00F8EC0F /* Notes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notes.swift; sourceTree = ""; };
1FC510B5240D8C54006BD691 /* Notare.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Notare.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -94,7 +92,6 @@
1FB17193240DE8B100F8EC0F /* Resources */,
1FB17194240DE8DF00F8EC0F /* Notes.swift */,
1FC510BC240D8C54006BD691 /* ViewController.swift */,
- 13E26ADD241095BD00D2BC08 /* TableViewCell.swift */,
1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */,
1FC510BE240D8C54006BD691 /* Main.storyboard */,
1FC510C6240D8C58006BD691 /* Info.plist */,
@@ -184,7 +181,6 @@
1FC510B9240D8C54006BD691 /* AppDelegate.swift in Sources */,
1FC510BB240D8C54006BD691 /* SceneDelegate.swift in Sources */,
13E26AD924108D9100D2BC08 /* LightTheme.swift in Sources */,
- 13E26ADE241095BD00D2BC08 /* TableViewCell.swift in Sources */,
13E26AD3241088A800D2BC08 /* ThemeProtocol.swift in Sources */,
1FB17190240DC53B00F8EC0F /* DetailViewController.swift in Sources */,
13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */,
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index e1a5410..06f7274 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -19,7 +19,7 @@
-
+
@@ -68,8 +68,6 @@
-
-
diff --git a/Notare/DarkTheme.swift b/Notare/DarkTheme.swift
index 528c4e4..cd5f735 100644
--- a/Notare/DarkTheme.swift
+++ b/Notare/DarkTheme.swift
@@ -5,11 +5,10 @@
// Created by conner on 3/3/20.
// Copyright © 2020 conner. All rights reserved.
//
-
import UIKit
class DarkTheme: ThemeProtocol {
var fontColor: UIColor = UIColor.lightGray
var headerColor: UIColor = UIColor.darkGray
- var backgroundColor: UIColor = UIColor.black
+ var backgroundColor: UIColor = UIColor.darkGray
}
diff --git a/Notare/DetailViewController.swift b/Notare/DetailViewController.swift
index 37c17d3..b8419d8 100644
--- a/Notare/DetailViewController.swift
+++ b/Notare/DetailViewController.swift
@@ -21,6 +21,8 @@ class DetailViewController: UIViewController {
detailTextView.text = text
self.navigationItem.largeTitleDisplayMode = .never
+ // Theme inclusion
+ detailTextView.backgroundColor = Theme.current.backgroundColor
}
override func viewWillAppear(_ animated: Bool) {
diff --git a/Notare/TableViewCell.swift b/Notare/TableViewCell.swift
deleted file mode 100644
index aa12f2b..0000000
--- a/Notare/TableViewCell.swift
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// TableViewCell.swift
-// Notare
-//
-// Created by conner on 3/4/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-class TableViewCell: UITableViewCell {
-
- override func awakeFromNib() {
- super.awakeFromNib()
- // Initialization code
- }
-
- override func setSelected(_ selected: Bool, animated: Bool) {
- super.setSelected(selected, animated: animated)
-
- // Configure the view for the selected state
- }
-
-}
From be6dcc8023a7a3c6be85439023f23a1bf2f00c52 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 16:42:28 -0600
Subject: [PATCH 06/13] Dark Theme Default, adding selection next.
---
Notare/Base.lproj/Main.storyboard | 20 ++++++++++++----
Notare/DarkTheme.swift | 6 ++---
Notare/DetailViewController.swift | 8 +++++++
Notare/LightTheme.swift | 2 +-
Notare/ThemeProtocol.swift | 2 +-
Notare/ViewController.swift | 40 +++++++++++++++++++++++++++++++
6 files changed, 69 insertions(+), 9 deletions(-)
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index 06f7274..643e4a2 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -19,7 +19,7 @@
-
+
@@ -67,13 +67,22 @@
+
+
+
+
+
+
+
+
+
-
+
@@ -88,7 +97,7 @@
Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.
-
+
@@ -114,12 +123,15 @@
+
+
+
-
+
diff --git a/Notare/DarkTheme.swift b/Notare/DarkTheme.swift
index cd5f735..96bcae0 100644
--- a/Notare/DarkTheme.swift
+++ b/Notare/DarkTheme.swift
@@ -8,7 +8,7 @@
import UIKit
class DarkTheme: ThemeProtocol {
- var fontColor: UIColor = UIColor.lightGray
- var headerColor: UIColor = UIColor.darkGray
- var backgroundColor: UIColor = UIColor.darkGray
+ var fontColor: UIColor = UIColor.white
+ var buttonColor: UIColor = UIColor.systemGreen
+ var backgroundColor: UIColor = UIColor.black
}
diff --git a/Notare/DetailViewController.swift b/Notare/DetailViewController.swift
index b8419d8..423abd5 100644
--- a/Notare/DetailViewController.swift
+++ b/Notare/DetailViewController.swift
@@ -9,7 +9,11 @@
import UIKit
class DetailViewController: UIViewController {
+ @IBOutlet var detailView: UIView!
@IBOutlet weak var detailTextView: UITextView!
+ @IBOutlet weak var cancelButton: UIBarButtonItem!
+ @IBOutlet weak var saveButton: UIBarButtonItem!
+
var text: String = ""
@@ -23,6 +27,10 @@ class DetailViewController: UIViewController {
// Theme inclusion
detailTextView.backgroundColor = Theme.current.backgroundColor
+ detailTextView.textColor = Theme.current.fontColor
+ cancelButton.tintColor = Theme.current.buttonColor
+ saveButton.tintColor = Theme.current.buttonColor
+ detailView.backgroundColor = Theme.current.backgroundColor
}
override func viewWillAppear(_ animated: Bool) {
diff --git a/Notare/LightTheme.swift b/Notare/LightTheme.swift
index 10c49e5..fdd2793 100644
--- a/Notare/LightTheme.swift
+++ b/Notare/LightTheme.swift
@@ -10,6 +10,6 @@ import UIKit
class LightTheme: ThemeProtocol {
var fontColor: UIColor = UIColor.black
- var headerColor: UIColor = UIColor.white
+ var buttonColor: UIColor = UIColor.systemBlue
var backgroundColor: UIColor = UIColor.white
}
diff --git a/Notare/ThemeProtocol.swift b/Notare/ThemeProtocol.swift
index 94ca53e..0267f36 100644
--- a/Notare/ThemeProtocol.swift
+++ b/Notare/ThemeProtocol.swift
@@ -9,6 +9,6 @@ import UIKit
protocol ThemeProtocol {
var fontColor: UIColor { get }
- var headerColor: UIColor { get }
+ var buttonColor: UIColor { get }
var backgroundColor: UIColor { get }
}
diff --git a/Notare/ViewController.swift b/Notare/ViewController.swift
index c86072c..4f356bc 100644
--- a/Notare/ViewController.swift
+++ b/Notare/ViewController.swift
@@ -15,6 +15,23 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
// making table view a property inside view controller
@IBOutlet weak var tableView: UITableView!
+ @IBOutlet var viewTest: UIView!
+
+ @IBOutlet weak var toolbar: UIToolbar!
+
+ @IBOutlet weak var editButton: UIBarButtonItem!
+
+ @IBOutlet weak var addNoteButton: UIBarButtonItem!
+
+ @IBOutlet weak var cameraButton: UIBarButtonItem!
+
+ @IBOutlet weak var imageButton: UIBarButtonItem!
+
+ @IBOutlet weak var microphoneButton: UIBarButtonItem!
+
+ @IBOutlet weak var fileButton: UIBarButtonItem!
+
+ @IBOutlet weak var shareButton: UIBarButtonItem!
// creating a new instance of the variable "data" in order to get a data source for table view
var data: [String] = []
@@ -44,6 +61,7 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
//setting the tableview as the data source
tableView.delegate = self
tableView.dataSource = self
+
self.title = "Notare"
self.navigationItem.largeTitleDisplayMode = .always
@@ -67,6 +85,24 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
// Theme inclusion
tableView.backgroundColor = Theme.current.backgroundColor
+ viewTest.backgroundColor = Theme.current.backgroundColor
+ toolbar.barTintColor = Theme.current.backgroundColor
+ toolbar.backgroundColor = Theme.current.backgroundColor
+ addNoteButton.tintColor = Theme.current.buttonColor
+ editButton.tintColor = Theme.current.buttonColor
+ cameraButton.tintColor = Theme.current.buttonColor
+ imageButton.tintColor = Theme.current.buttonColor
+ microphoneButton.tintColor = Theme.current.buttonColor
+ fileButton.tintColor = Theme.current.buttonColor
+ shareButton.tintColor = Theme.current.buttonColor
+
+ // Change barStyle based on dark/light theme color
+ switch Theme.current.backgroundColor {
+ case UIColor.black, UIColor.darkGray, UIColor.gray:
+ navigationController?.navigationBar.barStyle = .black
+ default:
+ navigationController?.navigationBar.barStyle = .default
+ }
}
// ***********
@@ -131,6 +167,10 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
let cell = tableView.dequeueReusableCell(withIdentifier: "noteCell", for: indexPath)
cell.textLabel?.text = data[indexPath.row] //setting the text for the cell based on the text label property
// IndexPath contains the row and the section of the table view whose cell we are creating
+
+ // Theme Inclusion
+ cell.backgroundColor = Theme.current.backgroundColor
+ cell.textLabel?.textColor = Theme.current.fontColor
return cell
}
From c79120065c07a94d8bbb7bcaccb3f66b3b0d9ea8 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 16:46:05 -0600
Subject: [PATCH 07/13] Link Theme Selection to nav controller
---
Notare/ThemeSelectionViewController.swift | 30 +++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 Notare/ThemeSelectionViewController.swift
diff --git a/Notare/ThemeSelectionViewController.swift b/Notare/ThemeSelectionViewController.swift
new file mode 100644
index 0000000..4939b71
--- /dev/null
+++ b/Notare/ThemeSelectionViewController.swift
@@ -0,0 +1,30 @@
+//
+// ThemeSelectionViewController.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import UIKit
+
+class ThemeSelectionViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ // Do any additional setup after loading the view.
+ }
+
+
+ /*
+ // MARK: - Navigation
+
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+ // Get the new view controller using segue.destination.
+ // Pass the selected object to the new view controller.
+ }
+ */
+
+}
From 4c6fcbc8fb3bc16aa00737686b89932ce6b72026 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 17:02:24 -0600
Subject: [PATCH 08/13] Segue ThemeSelectionViewController
---
Notare.xcodeproj/project.pbxproj | 4 +++
Notare/Base.lproj/Main.storyboard | 35 ++++++++---------------
Notare/Theme.swift | 2 +-
Notare/ThemeSelectionViewController.swift | 3 ++
Notare/ViewController.swift | 13 ++++++---
5 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/Notare.xcodeproj/project.pbxproj b/Notare.xcodeproj/project.pbxproj
index 3ca2194..4ad9098 100644
--- a/Notare.xcodeproj/project.pbxproj
+++ b/Notare.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 1385C2952411B804002FAA2C /* ThemeSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2942411B804002FAA2C /* ThemeSelectionViewController.swift */; };
13E26AD3241088A800D2BC08 /* ThemeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */; };
13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD42410896300D2BC08 /* DarkTheme.swift */; };
13E26AD724108B5300D2BC08 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD624108B5300D2BC08 /* Theme.swift */; };
@@ -23,6 +24,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 1385C2942411B804002FAA2C /* ThemeSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSelectionViewController.swift; sourceTree = ""; };
13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeProtocol.swift; sourceTree = ""; };
13E26AD42410896300D2BC08 /* DarkTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkTheme.swift; sourceTree = ""; };
13E26AD624108B5300D2BC08 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; };
@@ -93,6 +95,7 @@
1FB17194240DE8DF00F8EC0F /* Notes.swift */,
1FC510BC240D8C54006BD691 /* ViewController.swift */,
1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */,
+ 1385C2942411B804002FAA2C /* ThemeSelectionViewController.swift */,
1FC510BE240D8C54006BD691 /* Main.storyboard */,
1FC510C6240D8C58006BD691 /* Info.plist */,
13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */,
@@ -185,6 +188,7 @@
1FB17190240DC53B00F8EC0F /* DetailViewController.swift in Sources */,
13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */,
1FB17195240DE8DF00F8EC0F /* Notes.swift in Sources */,
+ 1385C2952411B804002FAA2C /* ThemeSelectionViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index 643e4a2..50fa84f 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -37,7 +37,11 @@
-
+
+
+
+
+
@@ -131,7 +135,7 @@
-
+
@@ -193,7 +197,7 @@
-
+
@@ -208,6 +212,9 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
diff --git a/Notare/Theme.swift b/Notare/Theme.swift
index 4dfc279..371a282 100644
--- a/Notare/Theme.swift
+++ b/Notare/Theme.swift
@@ -9,5 +9,5 @@
import Foundation
class Theme {
- static var current: ThemeProtocol = DarkTheme()
+ static var current: ThemeProtocol = LightTheme()
}
diff --git a/Notare/ThemeSelectionViewController.swift b/Notare/ThemeSelectionViewController.swift
index 4939b71..56cb4a3 100644
--- a/Notare/ThemeSelectionViewController.swift
+++ b/Notare/ThemeSelectionViewController.swift
@@ -15,6 +15,9 @@ class ThemeSelectionViewController: UIViewController {
// Do any additional setup after loading the view.
}
+ @IBAction func darkThemeTapped(_ sender: Any) {
+ Theme.current = DarkTheme()
+ }
/*
diff --git a/Notare/ViewController.swift b/Notare/ViewController.swift
index 4f356bc..59126bf 100644
--- a/Notare/ViewController.swift
+++ b/Notare/ViewController.swift
@@ -197,10 +197,15 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- let detailView: DetailViewController = segue.destination as! DetailViewController
- selectedRow = tableView.indexPathForSelectedRow!.row // always making sure you have a selected row before transistion to detail view controller screen
- detailView.masterView = self
- detailView.setText(t: data[selectedRow]) // sending selected cell text/data to the detail view
+ if segue.identifier == "detailNotes" {
+ let detailView: DetailViewController = segue.destination as! DetailViewController
+ selectedRow = tableView.indexPathForSelectedRow!.row // always making sure you have a selected row before transistion to detail view controller screen
+ detailView.masterView = self
+ detailView.setText(t: data[selectedRow]) // sending selected cell text/data to the detail view
+ }
+ if segue.identifier == "themeSelection" {
+ //let controller: ThemeSelectionViewController = segue.destination as! ThemeSelectionViewController
+ }
}
// saving the notes using persistence
From 8340a3ffe49cce57ab00491377a69b62b4e37439 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 18:29:50 -0600
Subject: [PATCH 09/13] Working Theme Switcher
---
.../Extensions/UIBarButtonItemExtension.swift | 9 ++++++++
Notare/Extensions/UITableViewExtension.swift | 9 ++++++++
Notare/Extensions/UITextViewExtension.swift | 9 ++++++++
Notare/Extensions/UIToolbarExtension.swift | 9 ++++++++
Notare/Extensions/UIViewExtension.swift | 9 ++++++++
Notare/backgroundColorButton.swift | 21 +++++++++++++++++++
Notare/buttonColorButton.swift | 21 +++++++++++++++++++
Notare/fontColorButton.swift | 21 +++++++++++++++++++
8 files changed, 108 insertions(+)
create mode 100644 Notare/Extensions/UIBarButtonItemExtension.swift
create mode 100644 Notare/Extensions/UITableViewExtension.swift
create mode 100644 Notare/Extensions/UITextViewExtension.swift
create mode 100644 Notare/Extensions/UIToolbarExtension.swift
create mode 100644 Notare/Extensions/UIViewExtension.swift
create mode 100644 Notare/backgroundColorButton.swift
create mode 100644 Notare/buttonColorButton.swift
create mode 100644 Notare/fontColorButton.swift
diff --git a/Notare/Extensions/UIBarButtonItemExtension.swift b/Notare/Extensions/UIBarButtonItemExtension.swift
new file mode 100644
index 0000000..c8feb3e
--- /dev/null
+++ b/Notare/Extensions/UIBarButtonItemExtension.swift
@@ -0,0 +1,9 @@
+//
+// UIBarButtonItemExtension.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/Extensions/UITableViewExtension.swift b/Notare/Extensions/UITableViewExtension.swift
new file mode 100644
index 0000000..ff5913e
--- /dev/null
+++ b/Notare/Extensions/UITableViewExtension.swift
@@ -0,0 +1,9 @@
+//
+// UITableViewExtension.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/Extensions/UITextViewExtension.swift b/Notare/Extensions/UITextViewExtension.swift
new file mode 100644
index 0000000..2ab459a
--- /dev/null
+++ b/Notare/Extensions/UITextViewExtension.swift
@@ -0,0 +1,9 @@
+//
+// UITextViewExtension.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/Extensions/UIToolbarExtension.swift b/Notare/Extensions/UIToolbarExtension.swift
new file mode 100644
index 0000000..e23152d
--- /dev/null
+++ b/Notare/Extensions/UIToolbarExtension.swift
@@ -0,0 +1,9 @@
+//
+// UIToolbarExtension.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/Extensions/UIViewExtension.swift b/Notare/Extensions/UIViewExtension.swift
new file mode 100644
index 0000000..1a58ba4
--- /dev/null
+++ b/Notare/Extensions/UIViewExtension.swift
@@ -0,0 +1,9 @@
+//
+// UIViewExtension.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import Foundation
diff --git a/Notare/backgroundColorButton.swift b/Notare/backgroundColorButton.swift
new file mode 100644
index 0000000..4e71e33
--- /dev/null
+++ b/Notare/backgroundColorButton.swift
@@ -0,0 +1,21 @@
+//
+// backgroundColorButton.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import UIKit
+
+class backgroundColorButton: UIButton {
+
+ /*
+ // Only override draw() if you perform custom drawing.
+ // An empty implementation adversely affects performance during animation.
+ override func draw(_ rect: CGRect) {
+ // Drawing code
+ }
+ */
+
+}
diff --git a/Notare/buttonColorButton.swift b/Notare/buttonColorButton.swift
new file mode 100644
index 0000000..b871fa1
--- /dev/null
+++ b/Notare/buttonColorButton.swift
@@ -0,0 +1,21 @@
+//
+// buttonColorButton.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import UIKit
+
+class buttonColorButton: UIButton {
+
+ /*
+ // Only override draw() if you perform custom drawing.
+ // An empty implementation adversely affects performance during animation.
+ override func draw(_ rect: CGRect) {
+ // Drawing code
+ }
+ */
+
+}
diff --git a/Notare/fontColorButton.swift b/Notare/fontColorButton.swift
new file mode 100644
index 0000000..ee802bb
--- /dev/null
+++ b/Notare/fontColorButton.swift
@@ -0,0 +1,21 @@
+//
+// fontColorButton.swift
+// Notare
+//
+// Created by conner on 3/5/20.
+// Copyright © 2020 Young. All rights reserved.
+//
+
+import UIKit
+
+class fontColorButton: UIButton {
+
+ /*
+ // Only override draw() if you perform custom drawing.
+ // An empty implementation adversely affects performance during animation.
+ override func draw(_ rect: CGRect) {
+ // Drawing code
+ }
+ */
+
+}
From 6b45e022e6e55e46c3f90ea7ee7850484a8a6116 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 19:10:56 -0600
Subject: [PATCH 10/13] Update
---
Notare.xcodeproj/project.pbxproj | 32 +++
Notare/Base.lproj/Main.storyboard | 246 +++++++++++++++++-
Notare/DetailViewController.swift | 19 +-
.../Extensions/UIBarButtonItemExtension.swift | 6 +-
Notare/Extensions/UITableViewExtension.swift | 6 +-
Notare/Extensions/UITextViewExtension.swift | 6 +-
Notare/Extensions/UIToolbarExtension.swift | 6 +-
Notare/Extensions/UIViewExtension.swift | 6 +-
Notare/Theme.swift | 2 +-
Notare/ThemeProtocol.swift | 6 +-
Notare/ThemeSelectionViewController.swift | 42 ++-
Notare/ViewController.swift | 47 ++--
Notare/backgroundColorButton.swift | 36 ++-
Notare/buttonColorButton.swift | 36 ++-
Notare/fontColorButton.swift | 37 ++-
15 files changed, 464 insertions(+), 69 deletions(-)
diff --git a/Notare.xcodeproj/project.pbxproj b/Notare.xcodeproj/project.pbxproj
index 4ad9098..d0625bc 100644
--- a/Notare.xcodeproj/project.pbxproj
+++ b/Notare.xcodeproj/project.pbxproj
@@ -8,6 +8,14 @@
/* Begin PBXBuildFile section */
1385C2952411B804002FAA2C /* ThemeSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2942411B804002FAA2C /* ThemeSelectionViewController.swift */; };
+ 1385C2972411C2BD002FAA2C /* UIViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2962411C2BD002FAA2C /* UIViewExtension.swift */; };
+ 1385C2992411C332002FAA2C /* UIBarButtonItemExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2982411C332002FAA2C /* UIBarButtonItemExtension.swift */; };
+ 1385C29B2411C36E002FAA2C /* UIToolbarExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C29A2411C36E002FAA2C /* UIToolbarExtension.swift */; };
+ 1385C29D2411C37D002FAA2C /* UITableViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C29C2411C37D002FAA2C /* UITableViewExtension.swift */; };
+ 1385C29F2411C3CE002FAA2C /* UITextViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C29E2411C3CE002FAA2C /* UITextViewExtension.swift */; };
+ 1385C2A12411CA55002FAA2C /* fontColorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2A02411CA55002FAA2C /* fontColorButton.swift */; };
+ 1385C2A52411CB97002FAA2C /* buttonColorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2A42411CB97002FAA2C /* buttonColorButton.swift */; };
+ 1385C2A72411CC5D002FAA2C /* backgroundColorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1385C2A62411CC5D002FAA2C /* backgroundColorButton.swift */; };
13E26AD3241088A800D2BC08 /* ThemeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */; };
13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD42410896300D2BC08 /* DarkTheme.swift */; };
13E26AD724108B5300D2BC08 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E26AD624108B5300D2BC08 /* Theme.swift */; };
@@ -25,6 +33,14 @@
/* Begin PBXFileReference section */
1385C2942411B804002FAA2C /* ThemeSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSelectionViewController.swift; sourceTree = ""; };
+ 1385C2962411C2BD002FAA2C /* UIViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtension.swift; sourceTree = ""; };
+ 1385C2982411C332002FAA2C /* UIBarButtonItemExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIBarButtonItemExtension.swift; sourceTree = ""; };
+ 1385C29A2411C36E002FAA2C /* UIToolbarExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIToolbarExtension.swift; sourceTree = ""; };
+ 1385C29C2411C37D002FAA2C /* UITableViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITableViewExtension.swift; sourceTree = ""; };
+ 1385C29E2411C3CE002FAA2C /* UITextViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextViewExtension.swift; sourceTree = ""; };
+ 1385C2A02411CA55002FAA2C /* fontColorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = fontColorButton.swift; sourceTree = ""; };
+ 1385C2A42411CB97002FAA2C /* buttonColorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = buttonColorButton.swift; sourceTree = ""; };
+ 1385C2A62411CC5D002FAA2C /* backgroundColorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = backgroundColorButton.swift; sourceTree = ""; };
13E26AD2241088A800D2BC08 /* ThemeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeProtocol.swift; sourceTree = ""; };
13E26AD42410896300D2BC08 /* DarkTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkTheme.swift; sourceTree = ""; };
13E26AD624108B5300D2BC08 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; };
@@ -57,6 +73,11 @@
isa = PBXGroup;
children = (
13E26ADB24108FAF00D2BC08 /* UIButtonExtension.swift */,
+ 1385C2962411C2BD002FAA2C /* UIViewExtension.swift */,
+ 1385C29E2411C3CE002FAA2C /* UITextViewExtension.swift */,
+ 1385C29A2411C36E002FAA2C /* UIToolbarExtension.swift */,
+ 1385C29C2411C37D002FAA2C /* UITableViewExtension.swift */,
+ 1385C2982411C332002FAA2C /* UIBarButtonItemExtension.swift */,
);
path = Extensions;
sourceTree = "";
@@ -95,6 +116,9 @@
1FB17194240DE8DF00F8EC0F /* Notes.swift */,
1FC510BC240D8C54006BD691 /* ViewController.swift */,
1FB1718F240DC53B00F8EC0F /* DetailViewController.swift */,
+ 1385C2A02411CA55002FAA2C /* fontColorButton.swift */,
+ 1385C2A42411CB97002FAA2C /* buttonColorButton.swift */,
+ 1385C2A62411CC5D002FAA2C /* backgroundColorButton.swift */,
1385C2942411B804002FAA2C /* ThemeSelectionViewController.swift */,
1FC510BE240D8C54006BD691 /* Main.storyboard */,
1FC510C6240D8C58006BD691 /* Info.plist */,
@@ -178,17 +202,25 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 1385C2A72411CC5D002FAA2C /* backgroundColorButton.swift in Sources */,
1FC510BD240D8C54006BD691 /* ViewController.swift in Sources */,
13E26ADC24108FAF00D2BC08 /* UIButtonExtension.swift in Sources */,
13E26AD724108B5300D2BC08 /* Theme.swift in Sources */,
+ 1385C29B2411C36E002FAA2C /* UIToolbarExtension.swift in Sources */,
1FC510B9240D8C54006BD691 /* AppDelegate.swift in Sources */,
1FC510BB240D8C54006BD691 /* SceneDelegate.swift in Sources */,
+ 1385C29D2411C37D002FAA2C /* UITableViewExtension.swift in Sources */,
13E26AD924108D9100D2BC08 /* LightTheme.swift in Sources */,
+ 1385C2992411C332002FAA2C /* UIBarButtonItemExtension.swift in Sources */,
+ 1385C2A52411CB97002FAA2C /* buttonColorButton.swift in Sources */,
+ 1385C2972411C2BD002FAA2C /* UIViewExtension.swift in Sources */,
13E26AD3241088A800D2BC08 /* ThemeProtocol.swift in Sources */,
1FB17190240DC53B00F8EC0F /* DetailViewController.swift in Sources */,
13E26AD52410896300D2BC08 /* DarkTheme.swift in Sources */,
+ 1385C2A12411CA55002FAA2C /* fontColorButton.swift in Sources */,
1FB17195240DE8DF00F8EC0F /* Notes.swift in Sources */,
1385C2952411B804002FAA2C /* ThemeSelectionViewController.swift in Sources */,
+ 1385C29F2411C3CE002FAA2C /* UITextViewExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index 50fa84f..d853849 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -19,7 +19,7 @@
-
+
@@ -209,7 +209,7 @@
-
+
@@ -227,38 +227,45 @@
+
+
+
+
+
+
+
-
diff --git a/Notare/DetailViewController.swift b/Notare/DetailViewController.swift
index 423abd5..aaa13ce 100644
--- a/Notare/DetailViewController.swift
+++ b/Notare/DetailViewController.swift
@@ -24,7 +24,19 @@ class DetailViewController: UIViewController {
detailTextView.text = text
self.navigationItem.largeTitleDisplayMode = .never
-
+ initTheme()
+ }
+
+ override func viewWillAppear(_ animated: Bool) {
+ super.viewWillAppear(animated)
+ detailTextView.becomeFirstResponder() // function to bring up software keyboard by automatically selecting text view
+ }
+
+ override func viewDidAppear(_ animated: Bool) {
+ initTheme()
+ }
+
+ func initTheme() {
// Theme inclusion
detailTextView.backgroundColor = Theme.current.backgroundColor
detailTextView.textColor = Theme.current.fontColor
@@ -33,11 +45,6 @@ class DetailViewController: UIViewController {
detailView.backgroundColor = Theme.current.backgroundColor
}
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- detailTextView.becomeFirstResponder() // function to bring up software keyboard by automatically selecting text view
- }
-
func setText(t: String) {
text = t
diff --git a/Notare/Extensions/UIBarButtonItemExtension.swift b/Notare/Extensions/UIBarButtonItemExtension.swift
index c8feb3e..14a3dfc 100644
--- a/Notare/Extensions/UIBarButtonItemExtension.swift
+++ b/Notare/Extensions/UIBarButtonItemExtension.swift
@@ -6,4 +6,8 @@
// Copyright © 2020 Young. All rights reserved.
//
-import Foundation
+import UIKit
+
+extension UIBarButtonItem {
+
+}
diff --git a/Notare/Extensions/UITableViewExtension.swift b/Notare/Extensions/UITableViewExtension.swift
index ff5913e..0bb20b7 100644
--- a/Notare/Extensions/UITableViewExtension.swift
+++ b/Notare/Extensions/UITableViewExtension.swift
@@ -6,4 +6,8 @@
// Copyright © 2020 Young. All rights reserved.
//
-import Foundation
+import UIKit
+
+extension UITableView {
+
+}
diff --git a/Notare/Extensions/UITextViewExtension.swift b/Notare/Extensions/UITextViewExtension.swift
index 2ab459a..502a494 100644
--- a/Notare/Extensions/UITextViewExtension.swift
+++ b/Notare/Extensions/UITextViewExtension.swift
@@ -6,4 +6,8 @@
// Copyright © 2020 Young. All rights reserved.
//
-import Foundation
+import UIKit
+
+extension UITextView {
+
+}
diff --git a/Notare/Extensions/UIToolbarExtension.swift b/Notare/Extensions/UIToolbarExtension.swift
index e23152d..153f398 100644
--- a/Notare/Extensions/UIToolbarExtension.swift
+++ b/Notare/Extensions/UIToolbarExtension.swift
@@ -6,4 +6,8 @@
// Copyright © 2020 Young. All rights reserved.
//
-import Foundation
+import UIKit
+
+extension UIToolbar {
+
+}
diff --git a/Notare/Extensions/UIViewExtension.swift b/Notare/Extensions/UIViewExtension.swift
index 1a58ba4..7d6a679 100644
--- a/Notare/Extensions/UIViewExtension.swift
+++ b/Notare/Extensions/UIViewExtension.swift
@@ -6,4 +6,8 @@
// Copyright © 2020 Young. All rights reserved.
//
-import Foundation
+import UIKit
+
+extension UIView {
+
+}
diff --git a/Notare/Theme.swift b/Notare/Theme.swift
index 371a282..4dfc279 100644
--- a/Notare/Theme.swift
+++ b/Notare/Theme.swift
@@ -9,5 +9,5 @@
import Foundation
class Theme {
- static var current: ThemeProtocol = LightTheme()
+ static var current: ThemeProtocol = DarkTheme()
}
diff --git a/Notare/ThemeProtocol.swift b/Notare/ThemeProtocol.swift
index 0267f36..623b043 100644
--- a/Notare/ThemeProtocol.swift
+++ b/Notare/ThemeProtocol.swift
@@ -8,7 +8,7 @@
import UIKit
protocol ThemeProtocol {
- var fontColor: UIColor { get }
- var buttonColor: UIColor { get }
- var backgroundColor: UIColor { get }
+ var fontColor: UIColor { get set }
+ var buttonColor: UIColor { get set }
+ var backgroundColor: UIColor { get set }
}
diff --git a/Notare/ThemeSelectionViewController.swift b/Notare/ThemeSelectionViewController.swift
index 56cb4a3..863a719 100644
--- a/Notare/ThemeSelectionViewController.swift
+++ b/Notare/ThemeSelectionViewController.swift
@@ -9,17 +9,49 @@
import UIKit
class ThemeSelectionViewController: UIViewController {
-
+ @IBOutlet weak var navigationBar: UINavigationItem!
+ @IBOutlet var themeView: UIView!
+
+ @IBOutlet weak var backgroundColorLabel: UILabel!
+ @IBOutlet weak var buttonColorLabel: UILabel!
+ @IBOutlet weak var fontColorLabel: UILabel!
+ @IBOutlet weak var sliderLabel: UILabel!
+
+ @IBOutlet weak var darkThemeSwitch: UISwitch!
override func viewDidLoad() {
super.viewDidLoad()
-
- // Do any additional setup after loading the view.
+ initTheme()
}
+ override func viewDidAppear(_ animated: Bool) {
+ initTheme()
+ }
+
+ func initTheme() {
+ themeView.backgroundColor = Theme.current.backgroundColor
+ backgroundColorLabel.textColor = Theme.current.fontColor
+ buttonColorLabel.textColor = Theme.current.fontColor
+ fontColorLabel.textColor = Theme.current.fontColor
+ sliderLabel.textColor = Theme.current.fontColor
+ }
+
@IBAction func darkThemeTapped(_ sender: Any) {
- Theme.current = DarkTheme()
+ if darkThemeSwitch.isOn {
+ Theme.current = DarkTheme()
+ } else {
+ Theme.current = LightTheme()
+ }
+ self.view.setNeedsDisplay();
}
-
+ @IBAction func doneTapped(_ sender: Any) {
+navigationController?.popViewController(animated: true)
+ viewWillDisappear(true)
+ }
+
+
+
+
+
/*
// MARK: - Navigation
diff --git a/Notare/ViewController.swift b/Notare/ViewController.swift
index 59126bf..3d9fad8 100644
--- a/Notare/ViewController.swift
+++ b/Notare/ViewController.swift
@@ -82,8 +82,29 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
navigationItem.searchController = searchController
// closes the search bar when the user navigates to another view controller
definesPresentationContext = true
-
- // Theme inclusion
+ }
+
+ // ***********
+ override func viewWillAppear(_ animated: Bool) {
+ super.viewWillAppear(animated)
+ if selectedRow == -1 {
+ return
+ }
+ data[selectedRow] = newRowText
+ if newRowText == "" {
+ data.remove(at: selectedRow)
+ }
+ tableView.reloadData()
+ saveNotes()
+ initTheme()
+ }
+
+ override func viewDidAppear(_ animated: Bool) {
+ initTheme()
+ }
+
+ func initTheme() {
+ // Themeing
tableView.backgroundColor = Theme.current.backgroundColor
viewTest.backgroundColor = Theme.current.backgroundColor
toolbar.barTintColor = Theme.current.backgroundColor
@@ -105,20 +126,6 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
}
}
- // ***********
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- if selectedRow == -1 {
- return
- }
- data[selectedRow] = newRowText
- if newRowText == "" {
- data.remove(at: selectedRow)
- }
- tableView.reloadData()
- saveNotes()
- }
-
// ***********
// IBAction to call createNewNote method
@@ -237,7 +244,6 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
filteredNotes = notes.filter { (note: Note) -> Bool in
return note.name.lowercased().contains(searchText.lowercased())
}
-
tableView.reloadData()
}
@@ -245,10 +251,9 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
extension ViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
- // TODO
+ let searchBar = searchController.searchBar
+ filterContentForSearchText(searchBar.text!)
+ tableView.reloadData()
}
-
-
-
}
diff --git a/Notare/backgroundColorButton.swift b/Notare/backgroundColorButton.swift
index 4e71e33..8efbfa2 100644
--- a/Notare/backgroundColorButton.swift
+++ b/Notare/backgroundColorButton.swift
@@ -10,12 +10,34 @@ import UIKit
class backgroundColorButton: UIButton {
- /*
- // Only override draw() if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- override func draw(_ rect: CGRect) {
- // Drawing code
+ @IBAction func red(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemRed
+ print(Theme.current.backgroundColor)
+ }
+ @IBAction func orange(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemOrange
+ }
+ @IBAction func yellow(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemYellow
+ }
+ @IBAction func green(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemGreen
+ }
+ @IBAction func blue(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemBlue
+ }
+ @IBAction func indigo(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemIndigo
+ }
+ @IBAction func purple(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.systemPurple
+ }
+ @IBAction func white(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.white
+ }
+ @IBAction func black(_ sender: Any) {
+ Theme.current.backgroundColor = UIColor.black
+ }
+ @IBAction func more(_ sender: Any) {
}
- */
-
}
diff --git a/Notare/buttonColorButton.swift b/Notare/buttonColorButton.swift
index b871fa1..d118c80 100644
--- a/Notare/buttonColorButton.swift
+++ b/Notare/buttonColorButton.swift
@@ -10,12 +10,34 @@ import UIKit
class buttonColorButton: UIButton {
- /*
- // Only override draw() if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- override func draw(_ rect: CGRect) {
- // Drawing code
+ @IBAction func red(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemRed
+ print(Theme.current.buttonColor)
+ }
+ @IBAction func orange(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemOrange
+ }
+ @IBAction func yellow(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemYellow
+ }
+ @IBAction func green(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemGreen
+ }
+ @IBAction func blue(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemBlue
+ }
+ @IBAction func indigo(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemIndigo
+ }
+ @IBAction func purple(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.systemPurple
+ }
+ @IBAction func white(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.white
+ }
+ @IBAction func black(_ sender: Any) {
+ Theme.current.buttonColor = UIColor.black
+ }
+ @IBAction func more(_ sender: Any) {
}
- */
-
}
diff --git a/Notare/fontColorButton.swift b/Notare/fontColorButton.swift
index ee802bb..530546d 100644
--- a/Notare/fontColorButton.swift
+++ b/Notare/fontColorButton.swift
@@ -9,13 +9,34 @@
import UIKit
class fontColorButton: UIButton {
-
- /*
- // Only override draw() if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- override func draw(_ rect: CGRect) {
- // Drawing code
+ @IBAction func red(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemRed
+ print(Theme.current.fontColor)
+ }
+ @IBAction func orange(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemOrange
+ }
+ @IBAction func yellow(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemYellow
+ }
+ @IBAction func green(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemGreen
+ }
+ @IBAction func blue(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemBlue
+ }
+ @IBAction func indigo(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemIndigo
+ }
+ @IBAction func purple(_ sender: Any) {
+ Theme.current.fontColor = UIColor.systemPurple
+ }
+ @IBAction func white(_ sender: Any) {
+ Theme.current.fontColor = UIColor.white
+ }
+ @IBAction func black(_ sender: Any) {
+ Theme.current.fontColor = UIColor.black
+ }
+ @IBAction func more(_ sender: Any) {
}
- */
-
}
From 2f33c52b4b96660490b180a92c0944c21194c527 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 19:39:37 -0600
Subject: [PATCH 11/13] Edit Note
---
Notare/ViewController.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Notare/ViewController.swift b/Notare/ViewController.swift
index 3d9fad8..f73576a 100644
--- a/Notare/ViewController.swift
+++ b/Notare/ViewController.swift
@@ -135,7 +135,7 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
// IBAction to call editNote method
@IBAction func editNote(_ sender: UIBarButtonItem) {
-
+ self.navigationItem.leftBarButtonItem = editButtonItem
}
From f4d0d7f6ed268d98adfea7a82d25635a0a24a046 Mon Sep 17 00:00:00 2001
From: conner <0xconr@protonmail.com>
Date: Thu, 5 Mar 2020 20:00:08 -0600
Subject: [PATCH 12/13] Custom Color Selection
---
Notare/Base.lproj/Main.storyboard | 800 ++++++++++++++++++++++++++++++
1 file changed, 800 insertions(+)
diff --git a/Notare/Base.lproj/Main.storyboard b/Notare/Base.lproj/Main.storyboard
index d853849..91704c9 100644
--- a/Notare/Base.lproj/Main.storyboard
+++ b/Notare/Base.lproj/Main.storyboard
@@ -455,6 +455,7 @@
+
@@ -378,235 +346,236 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
-
-
-
-
-
-
-
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
-
-
-
-
-
-
-
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
-
-
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -614,827 +583,31 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
diff --git a/Notare/DarkTheme.swift b/Notare/DarkTheme.swift
old mode 100644
new mode 100755
diff --git a/Notare/DetailViewController.swift b/Notare/DetailViewController.swift
old mode 100644
new mode 100755
index aaa13ce..ad0dfdc
--- a/Notare/DetailViewController.swift
+++ b/Notare/DetailViewController.swift
@@ -13,7 +13,11 @@ class DetailViewController: UIViewController {
@IBOutlet weak var detailTextView: UITextView!
@IBOutlet weak var cancelButton: UIBarButtonItem!
@IBOutlet weak var saveButton: UIBarButtonItem!
-
+ @IBAction func shareTapped(_ sender: UIBarButtonItem) {
+ let activityVC = UIActivityViewController(activityItems: [detailTextView.text ?? ""], applicationActivities: nil)
+ activityVC.popoverPresentationController?.sourceView = self.view
+ self.present(activityVC, animated: true, completion: nil)
+ }
var text: String = ""
@@ -24,62 +28,39 @@ class DetailViewController: UIViewController {
detailTextView.text = text
self.navigationItem.largeTitleDisplayMode = .never
- initTheme()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
detailTextView.becomeFirstResponder() // function to bring up software keyboard by automatically selecting text view
- }
-
- override func viewDidAppear(_ animated: Bool) {
- initTheme()
- }
-
- func initTheme() {
- // Theme inclusion
- detailTextView.backgroundColor = Theme.current.backgroundColor
- detailTextView.textColor = Theme.current.fontColor
- cancelButton.tintColor = Theme.current.buttonColor
- saveButton.tintColor = Theme.current.buttonColor
- detailView.backgroundColor = Theme.current.backgroundColor
+ setTheme()
}
func setText(t: String) {
text = t
-
- // verifying to see if the view is loaded before we perform any modifications
-
- if isViewLoaded {
- // modify text view after view has loaded
- detailTextView.text = t
- }
+ if isViewLoaded { detailTextView.text = t }
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
- masterView.newRowText = detailTextView.text
detailTextView.resignFirstResponder()
-
}
@IBAction func saveTapped(_ sender: UIBarButtonItem) {
navigationController?.popViewController(animated: true)
+ masterView.newRowText = detailTextView.text
viewWillDisappear(true)
}
@IBAction func cancelTapped(_ sender: UIBarButtonItem) {
navigationController?.popViewController(animated: true)
}
-
- /*
- // MARK: - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- // Get the new view controller using segue.destination.
- // Pass the selected object to the new view controller.
+
+ func setTheme() {
+ detailTextView.backgroundColor = Theme.current.backgroundColor
+ detailTextView.textColor = Theme.current.fontColor
+ cancelButton.tintColor = Theme.current.buttonColor
+ saveButton.tintColor = Theme.current.buttonColor
+ detailView.backgroundColor = Theme.current.backgroundColor
}
- */
-
}
diff --git a/Notare/Extensions/UIBarButtonItemExtension.swift b/Notare/Extensions/UIBarButtonItemExtension.swift
deleted file mode 100644
index 14a3dfc..0000000
--- a/Notare/Extensions/UIBarButtonItemExtension.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// UIBarButtonItemExtension.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-extension UIBarButtonItem {
-
-}
diff --git a/Notare/Extensions/UIButtonExtension.swift b/Notare/Extensions/UIButtonExtension.swift
deleted file mode 100644
index 92b89c1..0000000
--- a/Notare/Extensions/UIButtonExtension.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// UIButtonExtension.swift
-// Notare
-//
-// Created by conner on 3/4/20.
-// Copyright © 2020 conner. All rights reserved.
-//
-
-import UIKit
-
-extension UIButton {
-
-}
diff --git a/Notare/Extensions/UITableViewExtension.swift b/Notare/Extensions/UITableViewExtension.swift
deleted file mode 100644
index 0bb20b7..0000000
--- a/Notare/Extensions/UITableViewExtension.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// UITableViewExtension.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-extension UITableView {
-
-}
diff --git a/Notare/Extensions/UITextViewExtension.swift b/Notare/Extensions/UITextViewExtension.swift
deleted file mode 100644
index 502a494..0000000
--- a/Notare/Extensions/UITextViewExtension.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// UITextViewExtension.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-extension UITextView {
-
-}
diff --git a/Notare/Extensions/UIToolbarExtension.swift b/Notare/Extensions/UIToolbarExtension.swift
deleted file mode 100644
index 153f398..0000000
--- a/Notare/Extensions/UIToolbarExtension.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// UIToolbarExtension.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-extension UIToolbar {
-
-}
diff --git a/Notare/Extensions/UIViewExtension.swift b/Notare/Extensions/UIViewExtension.swift
deleted file mode 100644
index 7d6a679..0000000
--- a/Notare/Extensions/UIViewExtension.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// UIViewExtension.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-extension UIView {
-
-}
diff --git a/Notare/Info.plist b/Notare/Info.plist
old mode 100644
new mode 100755
diff --git a/Notare/LightTheme.swift b/Notare/LightTheme.swift
old mode 100644
new mode 100755
diff --git a/Notare/Notes.swift b/Notare/Notes.swift
old mode 100644
new mode 100755
diff --git a/Notare/Resources/AppDelegate.swift b/Notare/Resources/AppDelegate.swift
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-20@2x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-20@2x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-20@3x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-20@3x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/AppIcon.appiconset/ios-marketing.png b/Notare/Resources/Assets.xcassets/AppIcon.appiconset/ios-marketing.png
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Assets.xcassets/Contents.json b/Notare/Resources/Assets.xcassets/Contents.json
old mode 100644
new mode 100755
diff --git a/Notare/Resources/Base.lproj/LaunchScreen.storyboard b/Notare/Resources/Base.lproj/LaunchScreen.storyboard
old mode 100644
new mode 100755
diff --git a/Notare/Resources/SceneDelegate.swift b/Notare/Resources/SceneDelegate.swift
old mode 100644
new mode 100755
diff --git a/Notare/Theme.swift b/Notare/Theme.swift
old mode 100644
new mode 100755
index 4dfc279..7ac65ae
--- a/Notare/Theme.swift
+++ b/Notare/Theme.swift
@@ -7,7 +7,7 @@
//
import Foundation
-
+import UIKit
class Theme {
- static var current: ThemeProtocol = DarkTheme()
+ static var current: ThemeProtocol = LightTheme()
}
diff --git a/Notare/ThemeProtocol.swift b/Notare/ThemeProtocol.swift
old mode 100644
new mode 100755
diff --git a/Notare/ThemeSelectionViewController.swift b/Notare/ThemeSelectionViewController.swift
old mode 100644
new mode 100755
index 863a719..eedc1eb
--- a/Notare/ThemeSelectionViewController.swift
+++ b/Notare/ThemeSelectionViewController.swift
@@ -9,57 +9,123 @@
import UIKit
class ThemeSelectionViewController: UIViewController {
- @IBOutlet weak var navigationBar: UINavigationItem!
- @IBOutlet var themeView: UIView!
+ var darkMode = Bool()
+ var lightMode = Bool()
+ @IBOutlet weak var donebutton: UIBarButtonItem!
+ @IBOutlet weak var darkThemeSwitch: UISwitch!
+ @IBOutlet weak var lightThemeSwitch: UISwitch!
+ @IBOutlet weak var DarkLabel: UILabel!
+ @IBOutlet weak var lightLabel: UILabel!
+ @IBOutlet weak var fontLabel: UILabel!
+ @IBOutlet weak var buttonLabel: UILabel!
+ @IBOutlet weak var backgroundLabel: UILabel!
+ @IBOutlet weak var topBar: UINavigationItem!
- @IBOutlet weak var backgroundColorLabel: UILabel!
- @IBOutlet weak var buttonColorLabel: UILabel!
- @IBOutlet weak var fontColorLabel: UILabel!
- @IBOutlet weak var sliderLabel: UILabel!
+ var colors: [UIColor] = [
+ .systemRed,
+ .systemOrange,
+ .systemYellow,
+ .systemGreen,
+ .systemBlue,
+ .systemIndigo,
+ .systemPurple,
+ .white,
+ .black
+ ]
- @IBOutlet weak var darkThemeSwitch: UISwitch!
- override func viewDidLoad() {
- super.viewDidLoad()
- initTheme()
- }
- override func viewDidAppear(_ animated: Bool) {
- initTheme()
- }
+ var identifiers: [String] = [
+ "red",
+ "orange",
+ "yellow",
+ "green",
+ "blue",
+ "indigo",
+ "purple",
+ "white",
+ "black"
+ ]
- func initTheme() {
- themeView.backgroundColor = Theme.current.backgroundColor
- backgroundColorLabel.textColor = Theme.current.fontColor
- buttonColorLabel.textColor = Theme.current.fontColor
- fontColorLabel.textColor = Theme.current.fontColor
- sliderLabel.textColor = Theme.current.fontColor
+ @IBAction func colorTapped(_ sender: UIButton) {
+ if sender.accessibilityLabel == "font" {
+ for index in 0...identifiers.count {
+ if sender.accessibilityIdentifier == identifiers[index] {
+ Theme.current.fontColor = colors[index]
+ return;
+ }
+ }
+ }
+ if sender.accessibilityLabel == "button" {
+ for index in 0...identifiers.count {
+ if sender.accessibilityIdentifier == identifiers[index] {
+ Theme.current.buttonColor = colors[index]
+ return;
+ }
+ }
+ }
+ if sender.accessibilityLabel == "background" {
+ for index in 0...identifiers.count {
+ if sender.accessibilityIdentifier == identifiers[index] {
+ Theme.current.backgroundColor = colors[index]
+ return;
+ }
+ }
+ }
}
- @IBAction func darkThemeTapped(_ sender: Any) {
- if darkThemeSwitch.isOn {
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ let darkDefault = UserDefaults.standard
+ let lightDefault = UserDefaults.standard
+ darkMode = darkDefault.bool(forKey: "darkDefault")
+ lightMode = lightDefault.bool(forKey: "lightDefault")
+ if darkMode {
+ darkThemeSwitch.isOn = true
+ lightThemeSwitch.isOn = false
Theme.current = DarkTheme()
+ setTheme()
} else {
+ lightThemeSwitch.isOn = true
+ darkThemeSwitch.isOn = false
Theme.current = LightTheme()
+ setTheme()
}
- self.view.setNeedsDisplay();
}
- @IBAction func doneTapped(_ sender: Any) {
-navigationController?.popViewController(animated: true)
- viewWillDisappear(true)
+ @IBAction func darkSwitched(_ sender: Any) {
+ darkThemeSwitch.isOn = true
+ lightThemeSwitch.isOn = false
+ let darkDefault = UserDefaults.standard
+ darkDefault.set(true, forKey: "darkDefault")
+ let lightDefault = UserDefaults.standard
+ lightDefault.set(false, forKey: "lightDefault")
+ Theme.current = DarkTheme()
+ navigationController?.navigationBar.barStyle = .black
+ setTheme()
}
+ @IBAction func lightSwitched(_ sender: Any) {
+ lightThemeSwitch.isOn = true
+ darkThemeSwitch.isOn = false
+ let darkDefault = UserDefaults.standard
+ darkDefault.set(false, forKey: "darkDefault")
+ let lightDefault = UserDefaults.standard
+ lightDefault.set(true, forKey: "lightDefault")
+ Theme.current = LightTheme()
+ navigationController?.navigationBar.barStyle = .default
+ setTheme()
+ }
+ @IBAction func doneTapped(_ sender: Any) {
+ navigationController?.popViewController(animated: true)
+ }
-
-
-
- /*
- // MARK: - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- // Get the new view controller using segue.destination.
- // Pass the selected object to the new view controller.
+ func setTheme() {
+ self.view.backgroundColor = Theme.current.backgroundColor
+ DarkLabel.textColor = Theme.current.fontColor
+ lightLabel.textColor = Theme.current.fontColor
+ fontLabel.textColor = Theme.current.fontColor
+ buttonLabel.textColor = Theme.current.fontColor
+ backgroundLabel.textColor = Theme.current.fontColor
+ topBar.titleView?.tintColor = Theme.current.fontColor
+ donebutton.tintColor = Theme.current.buttonColor
}
- */
-
}
diff --git a/Notare/ViewController.swift b/Notare/ViewController.swift
old mode 100644
new mode 100755
index f73576a..9669810
--- a/Notare/ViewController.swift
+++ b/Notare/ViewController.swift
@@ -8,252 +8,174 @@
import UIKit
-
-// adding a protocol to get class to conform to UITableViewDataSource and UITableViewDelegate
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
- // making table view a property inside view controller
+ // MARK: Outlets
+ @IBOutlet weak var addNote: UIBarButtonItem!
+ @IBOutlet weak var editButton: UIBarButtonItem!
+ @IBOutlet weak var paintButton: UIBarButtonItem!
@IBOutlet weak var tableView: UITableView!
-
- @IBOutlet var viewTest: UIView!
-
@IBOutlet weak var toolbar: UIToolbar!
- @IBOutlet weak var editButton: UIBarButtonItem!
-
- @IBOutlet weak var addNoteButton: UIBarButtonItem!
-
- @IBOutlet weak var cameraButton: UIBarButtonItem!
-
- @IBOutlet weak var imageButton: UIBarButtonItem!
-
- @IBOutlet weak var microphoneButton: UIBarButtonItem!
-
- @IBOutlet weak var fileButton: UIBarButtonItem!
-
- @IBOutlet weak var shareButton: UIBarButtonItem!
- // creating a new instance of the variable "data" in order to get a data source for table view
+ @IBOutlet weak var sortButton: UIBarButtonItem!
+ // MARK: Initial Variables
var data: [String] = []
-
var notes: [Note] = []
-
- var selectedRow: Int = -1
- var newRowText: String = ""
-
-
- let searchController = UISearchController(searchResultsController: nil)
+ var selectedRow = -1
+ var newRowText = ""
- var filteredNotes: [Note] = [] // will hold the results of the user search
-
- var isSearchBarEmpty: Bool {
- return searchController.searchBar.text?.isEmpty ?? true
- }
-
-
- // to save data to a file - we have to start UserDefault saving code and modify it using File URL
+ // filteredNotes holds results for notes search
+ var filteredNotes: [Note] = []
+ let searchController = UISearchController(searchResultsController: nil)
+ var isSearchBarEmpty: Bool { return searchController.searchBar.text?.isEmpty ?? true }
var fileURL: URL!
- // runs when all user interface elements are loaded
+ // MARK: viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
-
- //setting the tableview as the data source
tableView.delegate = self
tableView.dataSource = self
-
- self.title = "Notare"
- self.navigationItem.largeTitleDisplayMode = .always
-
- // file URL
+ setFileURL()
+ loadNotes()
+ setupSearchController()
+ setTheme()
+ }
+
+ // MARK: sortTapped
+ @IBAction func sortTapped(_ sender: Any) {
+ let sortedNotes = data.sorted(by: {$0 < $1})
+ data = sortedNotes
+ tableView.reloadData()
+ }
+
+ // MARK: setFileURL
+ func setFileURL() {
let baseURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
fileURL = baseURL.appendingPathComponent("notes.txt")
-
- loadNotes() // calls the load notes function from persistence when loading/opening up app
-
-
-
- // informs the search controller of any text changes within the UI search bar
+ }
+ // MARK: loadNotes
+ func loadNotes() {
+ if let loadedNotes: [String] = NSArray(contentsOf: fileURL) as? [String] {
+ data = loadedNotes
+ tableView.reloadData()
+ }
+ }
+ // MARK: Search Functionality
+ func setupSearchController() {
searchController.searchResultsUpdater = self
- // the current view will show the results and not obscure view
searchController.obscuresBackgroundDuringPresentation = false
- // placeholder text
searchController.searchBar.placeholder = "Search Notes"
navigationItem.searchController = searchController
- // closes the search bar when the user navigates to another view controller
definesPresentationContext = true
}
-
- // ***********
+
+ func filterContentForSearchText(_ searchText: String, category: Note.Category? = nil) {
+ filteredNotes = notes.filter { (note: Note) -> Bool in
+ return note.name.lowercased().contains(searchText.lowercased())
+ }
+ tableView.reloadData()
+ }}
+
+ extension ViewController: UISearchResultsUpdating {
+ func updateSearchResults(for searchController: UISearchController) {
+ let searchBar = searchController.searchBar
+ filterContentForSearchText(searchBar.text!)
+ tableView.reloadData()
+ }
+
+ // MARK: viewWillAppear
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
- if selectedRow == -1 {
- return
- }
- data[selectedRow] = newRowText
- if newRowText == "" {
- data.remove(at: selectedRow)
+ if selectedRow != -1 {
+ data[selectedRow] = newRowText
+ if newRowText == "" {
+ data.remove(at: selectedRow)
+ }
+ tableView.reloadData()
+ saveNotes()
}
- tableView.reloadData()
- saveNotes()
- initTheme()
+ setTheme()
}
-
- override func viewDidAppear(_ animated: Bool) {
- initTheme()
- }
-
- func initTheme() {
- // Themeing
- tableView.backgroundColor = Theme.current.backgroundColor
- viewTest.backgroundColor = Theme.current.backgroundColor
- toolbar.barTintColor = Theme.current.backgroundColor
- toolbar.backgroundColor = Theme.current.backgroundColor
- addNoteButton.tintColor = Theme.current.buttonColor
- editButton.tintColor = Theme.current.buttonColor
- cameraButton.tintColor = Theme.current.buttonColor
- imageButton.tintColor = Theme.current.buttonColor
- microphoneButton.tintColor = Theme.current.buttonColor
- fileButton.tintColor = Theme.current.buttonColor
- shareButton.tintColor = Theme.current.buttonColor
-
- // Change barStyle based on dark/light theme color
- switch Theme.current.backgroundColor {
- case UIColor.black, UIColor.darkGray, UIColor.gray:
- navigationController?.navigationBar.barStyle = .black
- default:
- navigationController?.navigationBar.barStyle = .default
+ // MARK: saveNotes
+ func saveNotes() {
+ let arrayDirectory = NSArray(array: data)
+ do {
+ try arrayDirectory.write(to: fileURL)
+ } catch {
+ print("Error in saveNotes()")
}
}
- // ***********
-
- // IBAction to call createNewNote method
+ // MARK: Plus Button
@IBAction func createNewNoteButton(_ sender: UIBarButtonItem) {
- createNewNote()
- }
-
- // IBAction to call editNote method
- @IBAction func editNote(_ sender: UIBarButtonItem) {
- self.navigationItem.leftBarButtonItem = editButtonItem
- }
-
-
- // method for creating new notes
-
- func createNewNote() {
-
- if tableView.isEditing {
- return
- }
-
- let name: String = "" // gives note a string title based on user input
- data.insert(name, at: 0) // indexes new note at the beginning of the index of "data" array
-
- let indexPath: IndexPath = IndexPath(row: 0, section: 0) // creates a new row after adding a new note to array
- tableView.insertRows(at: [indexPath], with: .automatic) // animates the creation of a new row
-
- // identifies selected row when segue is triggered / connected to prepare for segue method
+ if tableView.isEditing { return }
+ let name: String = ""
+ data.insert(name, at: 0)
+ let indexPath = IndexPath(row: 0, section: 0)
+ tableView.insertRows(at: [indexPath], with: .automatic)
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
-
self.performSegue(withIdentifier: "detailNotes", sender: nil)
-
tableView.reloadData()
}
- //numberOfRowsInSection method - how many rows are going to be in the table view?
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return data.count // setting number of rows based on the count of elements in the array "data"
+ return data.count
}
- //CellForRowAt method - creating cell, applying data from array and returning a UITableView cell based on the index path of the array "data"
-
- // add guard let / if let to check and make sure cell is not nil before running code
-
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "noteCell", for: indexPath)
- cell.textLabel?.text = data[indexPath.row] //setting the text for the cell based on the text label property
-// IndexPath contains the row and the section of the table view whose cell we are creating
-
- // Theme Inclusion
+ cell.textLabel?.text = data[indexPath.row]
+ // MARK: Cell Themeing
cell.backgroundColor = Theme.current.backgroundColor
cell.textLabel?.textColor = Theme.current.fontColor
return cell
}
- // when edit button is selected, puts table into editing mode - allows for deletion
+ // MARK: Edit button Functions
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
tableView.setEditing(editing, animated: animated)
}
-
-
- // deletes rows when in edit mode and updates the "data" array after deletion
- // also adds animation effect when deleting
+ @IBAction func editNote(_ sender: UIBarButtonItem) {
+ self.navigationItem.leftBarButtonItem = editButtonItem
+ }
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
data.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
tableView.reloadData()
}
- // uses the delagate to find which row was selected
-
+ // Segue on row select
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: "detailNotes", sender: nil)
-
}
+ // MARK: prepare for segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "detailNotes" {
let detailView: DetailViewController = segue.destination as! DetailViewController
selectedRow = tableView.indexPathForSelectedRow!.row // always making sure you have a selected row before transistion to detail view controller screen
detailView.masterView = self
detailView.setText(t: data[selectedRow]) // sending selected cell text/data to the detail view
- }
- if segue.identifier == "themeSelection" {
- //let controller: ThemeSelectionViewController = segue.destination as! ThemeSelectionViewController
+ } else if segue.identifier == "themeSelection" {
+
}
}
-
- // saving the notes using persistence
-
- func saveNotes() {
-// creating NSArray instead of using user defaults
- let arrayDirectory = NSArray(array: data)
- do {
- try arrayDirectory.write(to: fileURL)
- } catch {
- print("Error")
- }
- }
-
- func loadNotes() {
- // if the value being created is not "nil" then execute the code inside of the { }
- // getting value from user defaults and typecasting it as a string array
+
- if let loadedNotes: [String] = NSArray(contentsOf: fileURL) as? [String] {
- data = loadedNotes
- tableView.reloadData()
- }
+ func setTheme() {
+ self.view.backgroundColor = Theme.current.backgroundColor
+ paintButton.tintColor = Theme.current.buttonColor
+ tableView.backgroundColor = Theme.current.backgroundColor
+ //editButton.tintColor = Theme.current.buttonColor
+ addNote.tintColor = Theme.current.buttonColor
+ toolbar.barTintColor = Theme.current.backgroundColor
+ toolbar.backgroundColor = Theme.current.backgroundColor
+ sortButton.tintColor = Theme.current.buttonColor
+ tableView.reloadData()
}
-
- func filterContentForSearchText(_ searchText: String,
- category: Note.Category? = nil) {
- filteredNotes = notes.filter { (note: Note) -> Bool in
- return note.name.lowercased().contains(searchText.lowercased())
- }
- tableView.reloadData()
- }
-
-}
-
-extension ViewController: UISearchResultsUpdating {
- func updateSearchResults(for searchController: UISearchController) {
- let searchBar = searchController.searchBar
- filterContentForSearchText(searchBar.text!)
- tableView.reloadData()
- }
}
diff --git a/Notare/backgroundColorButton.swift b/Notare/backgroundColorButton.swift
deleted file mode 100644
index 8efbfa2..0000000
--- a/Notare/backgroundColorButton.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// backgroundColorButton.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-class backgroundColorButton: UIButton {
-
- @IBAction func red(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemRed
- print(Theme.current.backgroundColor)
- }
- @IBAction func orange(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemOrange
- }
- @IBAction func yellow(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemYellow
- }
- @IBAction func green(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemGreen
- }
- @IBAction func blue(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemBlue
- }
- @IBAction func indigo(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemIndigo
- }
- @IBAction func purple(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.systemPurple
- }
- @IBAction func white(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.white
- }
- @IBAction func black(_ sender: Any) {
- Theme.current.backgroundColor = UIColor.black
- }
- @IBAction func more(_ sender: Any) {
- }
-}
diff --git a/Notare/buttonColorButton.swift b/Notare/buttonColorButton.swift
deleted file mode 100644
index d118c80..0000000
--- a/Notare/buttonColorButton.swift
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// buttonColorButton.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-class buttonColorButton: UIButton {
-
- @IBAction func red(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemRed
- print(Theme.current.buttonColor)
- }
- @IBAction func orange(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemOrange
- }
- @IBAction func yellow(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemYellow
- }
- @IBAction func green(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemGreen
- }
- @IBAction func blue(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemBlue
- }
- @IBAction func indigo(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemIndigo
- }
- @IBAction func purple(_ sender: Any) {
- Theme.current.buttonColor = UIColor.systemPurple
- }
- @IBAction func white(_ sender: Any) {
- Theme.current.buttonColor = UIColor.white
- }
- @IBAction func black(_ sender: Any) {
- Theme.current.buttonColor = UIColor.black
- }
- @IBAction func more(_ sender: Any) {
- }
-}
diff --git a/Notare/fontColorButton.swift b/Notare/fontColorButton.swift
deleted file mode 100644
index 530546d..0000000
--- a/Notare/fontColorButton.swift
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// fontColorButton.swift
-// Notare
-//
-// Created by conner on 3/5/20.
-// Copyright © 2020 Young. All rights reserved.
-//
-
-import UIKit
-
-class fontColorButton: UIButton {
- @IBAction func red(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemRed
- print(Theme.current.fontColor)
- }
- @IBAction func orange(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemOrange
- }
- @IBAction func yellow(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemYellow
- }
- @IBAction func green(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemGreen
- }
- @IBAction func blue(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemBlue
- }
- @IBAction func indigo(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemIndigo
- }
- @IBAction func purple(_ sender: Any) {
- Theme.current.fontColor = UIColor.systemPurple
- }
- @IBAction func white(_ sender: Any) {
- Theme.current.fontColor = UIColor.white
- }
- @IBAction func black(_ sender: Any) {
- Theme.current.fontColor = UIColor.black
- }
- @IBAction func more(_ sender: Any) {
- }
-}