Skip to content

Commit 2b700cc

Browse files
committed
Hopefully final update before going live on the App Store
1 parent 3867f13 commit 2b700cc

File tree

8 files changed

+130
-294
lines changed

8 files changed

+130
-294
lines changed

Coury Leadership Program/Coury Leadership Program.xcodeproj/project.pbxproj

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
BE0593BE23CE9F2100B0CD3B /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BE0593BD23CE9F2100B0CD3B /* GoogleService-Info.plist */; };
1414
BE0AFA0D23C43EAE005CC6B2 /* CubeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BE0AFA0C23C43EAE005CC6B2 /* CubeView.xib */; };
1515
BE0AFA0F23C43EB8005CC6B2 /* CubeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0AFA0E23C43EB8005CC6B2 /* CubeView.swift */; };
16-
BE0AFA1323C46B2B005CC6B2 /* AddGoalTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0AFA1223C46B2B005CC6B2 /* AddGoalTableView.swift */; };
1716
BE0EC70F23B858150000C9C0 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0EC70E23B858150000C9C0 /* Feed.swift */; };
1817
BE0EC71123B8650F0000C9C0 /* CollectionableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0EC71023B8650E0000C9C0 /* CollectionableCell.swift */; };
1918
BE0EC71323B865230000C9C0 /* TableableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0EC71223B865230000C9C0 /* TableableCell.swift */; };
@@ -84,7 +83,6 @@
8483
BE0593BD23CE9F2100B0CD3B /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
8584
BE0AFA0C23C43EAE005CC6B2 /* CubeView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CubeView.xib; sourceTree = "<group>"; };
8685
BE0AFA0E23C43EB8005CC6B2 /* CubeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CubeView.swift; sourceTree = "<group>"; };
87-
BE0AFA1223C46B2B005CC6B2 /* AddGoalTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddGoalTableView.swift; sourceTree = "<group>"; };
8886
BE0EC70E23B858150000C9C0 /* Feed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feed.swift; sourceTree = "<group>"; };
8987
BE0EC71023B8650E0000C9C0 /* CollectionableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionableCell.swift; sourceTree = "<group>"; };
9088
BE0EC71223B865230000C9C0 /* TableableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableableCell.swift; sourceTree = "<group>"; };
@@ -174,7 +172,6 @@
174172
children = (
175173
C4CA5A90220E0DB900ECF768 /* GoalViewController.swift */,
176174
BE4CFB0723120CFD0029A1D2 /* AddGoalViewController.swift */,
177-
BE0AFA1223C46B2B005CC6B2 /* AddGoalTableView.swift */,
178175
);
179176
name = Goals;
180177
sourceTree = "<group>";
@@ -561,7 +558,6 @@
561558
C4CA5AB8220E189600ECF768 /* QuoteCell.swift in Sources */,
562559
BE0EC71523B8872E0000C9C0 /* Uploadable.swift in Sources */,
563560
C4CA5AA4220E0F9000ECF768 /* ProfileViewController.swift in Sources */,
564-
BE0AFA1323C46B2B005CC6B2 /* AddGoalTableView.swift in Sources */,
565561
C4ADBE4822E2711B007F8BC0 /* Util.swift in Sources */,
566562
C4CA5AC8220E1A0700ECF768 /* Values.swift in Sources */,
567563
BE4CFB0E23135B2B0029A1D2 /* Goals.swift in Sources */,
@@ -750,7 +746,7 @@
750746
"$(inherited)",
751747
"@executable_path/Frameworks",
752748
);
753-
MARKETING_VERSION = 1.4;
749+
MARKETING_VERSION = 1.5;
754750
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.marshall.couryleadershipprogram;
755751
PRODUCT_NAME = "$(TARGET_NAME)";
756752
SWIFT_VERSION = 5.0;
@@ -773,7 +769,7 @@
773769
"$(inherited)",
774770
"@executable_path/Frameworks",
775771
);
776-
MARKETING_VERSION = 1.4;
772+
MARKETING_VERSION = 1.5;
777773
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.marshall.couryleadershipprogram;
778774
PRODUCT_NAME = "$(TARGET_NAME)";
779775
SWIFT_VERSION = 5.0;

Coury Leadership Program/Coury Leadership Program/Controllers/AddGoalTableView.swift

-74
This file was deleted.

Coury Leadership Program/Coury Leadership Program/Controllers/AddGoalViewController.swift

+40-32
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import UIKit
1010

1111
class AddGoalViewController: UIViewController {
1212

13-
@IBOutlet weak var segmentedControl: UISegmentedControl!
14-
@IBOutlet weak var instructionLabel: UILabel!
1513
@IBOutlet weak var datePicker: UIDatePicker!
14+
@IBOutlet weak var promptView: UITextView!
1615
@IBOutlet weak var goalWritingView: UITextView!
1716

17+
@IBOutlet weak var opaqueView: UIView!
18+
@IBOutlet weak var opaqueViewYPosition: NSLayoutConstraint!
19+
1820
@IBOutlet weak var cubeView: CubeView!
1921
internal var cubeFaces: [UIImageView] = []
2022

@@ -24,54 +26,49 @@ class AddGoalViewController: UIViewController {
2426
public static var activeRecommendations: [String] = []
2527

2628
internal var lastUpdated: Date = Date()
27-
internal var selectedSegment: Int = 0
2829

2930
override func viewDidLoad() {
3031
super.viewDidLoad()
3132
// Do any additional setup after loading the view.
33+
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
34+
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
3235

33-
// engageTableView()
36+
opaqueView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
3437

3538
let tap = UITapGestureRecognizer(target: self, action: #selector(onCubeTap(_:)))
3639
cubeView.addGestureRecognizer(tap)
37-
3840
setupCubeView()
3941
cubeView.enableMotion()
4042

41-
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
42-
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
43+
goalWritingView.delegate = self
4344
}
4445

4546
override func viewDidAppear(_ animated: Bool) {
4647
super.viewDidAppear(animated)
48+
goalWritingView.becomeFirstResponder()
4749

4850
cubeView.needsTaring = true
4951
cubeView.trackMotion(true)
5052

5153
CLPProfile.shared.onFetchSuccess {
5254
self.setupCubeView()
53-
// self.updateTableView()
55+
self.onCubeTap()
5456
}
5557
if CLPProfile.shared.basicInformation.lastModified > lastUpdated {
5658
self.setupCubeView()
57-
// self.updateTableView()
59+
self.onCubeTap()
5860
}
61+
self.onCubeTap()
5962
}
6063

6164
override func viewDidDisappear(_ animated: Bool) {
6265
super.viewDidDisappear(animated)
63-
66+
goalWritingView.resignFirstResponder()
6467
cubeView.trackMotion(false)
6568
}
6669

67-
@IBAction func onSegmentSwitch(_ sender: UISegmentedControl) {
68-
selectedSegment = sender.selectedSegmentIndex
69-
switch selectedSegment {
70-
case 0: instructionLabel.text = "Tap the dice (bottom left), then tap a prompt"
71-
case 1: instructionLabel.text = "Enter your goal and set a deadline"
72-
default: break
73-
}
74-
// updateTableView()
70+
@IBAction func onModalViewTap(_ sender: UITapGestureRecognizer) {
71+
dismiss(animated: true, completion: nil)
7572
}
7673

7774
@objc func onCubeTap(_ sender: UITapGestureRecognizer? = nil) {
@@ -81,17 +78,32 @@ class AddGoalViewController: UIViewController {
8178
let i = cubeView.topFaceIndex % CLPProfile.shared.basicInformation.values.count
8279
Self.activeValueForRecs = VALUE_LIST.owned[i].name
8380

84-
// updateTableView()
81+
updatePrompt()
8582
}
8683
}
8784

85+
private func updatePrompt() {
86+
let prompt = Self.activeRecommendations.randomElement() ?? "What's something you've always wanted to do?"
87+
if prompt.contains("?") {
88+
promptView.text = prompt
89+
goalWritingView.text = ""
90+
}else {
91+
promptView.text = "Personalize the given goal. It will be easier to accomplish if it's more specific."
92+
goalWritingView.text = prompt
93+
}
94+
95+
// if !goalWritingView.isFirstResponder {
96+
// goalWritingView.textColor = .lightGray
97+
// }
98+
}
99+
88100
private func setupCubeView() {
89101
cubeFaces = cubeView.createFaces(in: cubeView.bounds)
90102
cubeView.situate(in: cubeView.bounds)
91103

92104
let backgroundColor: UIColor?
93105
// cannot use ternary operator because #available is special
94-
if #available(iOS 13.0, *) {backgroundColor = .lightGray} else {backgroundColor = .lightGray}
106+
if #available(iOS 13.0, *) {backgroundColor = .label} else {backgroundColor = .black}
95107

96108
var images = VALUE_LIST.owned.map({$0.image})
97109
// one image will be duplicated because user has 5 strengths
@@ -112,12 +124,9 @@ class AddGoalViewController: UIViewController {
112124

113125
extension AddGoalViewController: UITextViewDelegate {
114126
func textViewDidBeginEditing(_ textView: UITextView) {
115-
if textView.text.contains("?") {textView.clearsOnInsertion = true}
116127
}
117128

118129
func textViewDidEndEditing(_ textView: UITextView) {
119-
// guard let indexPath = tableView.indexPathForSelectedRow else {return}
120-
// if (selectedSegment == 0 && Self.activeRecommendations.count > indexPath.row) {Self.activeRecommendations[indexPath.row] = textView.text}
121130
}
122131

123132
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
@@ -129,25 +138,24 @@ extension AddGoalViewController: UITextViewDelegate {
129138
}
130139

131140
func textViewDidChange(_ textView: UITextView) {
132-
UIView.setAnimationsEnabled(false)
133-
textView.sizeToFit()
134-
// DispatchQueue.main.async {
135-
// self.tableView.beginUpdates()
136-
// self.tableView.endUpdates()
137-
// UIView.setAnimationsEnabled(true)
138-
// }
139141
}
140142
}
141143

142144
extension AddGoalViewController {
143145
@objc func keyboardWillShow(_ notification: Notification) {
144146
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
145-
// tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height, right: 0)
147+
self.opaqueViewYPosition.constant = keyboardSize.height
148+
UIView.animate(withDuration: 0.1) {
149+
self.view.layoutIfNeeded()
150+
}
146151
}
147152
}
148153
@objc func keyboardWillHide(_ notification: Notification) {
149154
if let _ = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
150-
// tableView.contentInset = UIEdgeInsets.zero
155+
self.opaqueViewYPosition.constant = 0
156+
UIView.animate(withDuration: 0.1) {
157+
self.view.layoutIfNeeded()
158+
}
151159
}
152160
}
153161
}

Coury Leadership Program/Coury Leadership Program/Controllers/GoalViewController.swift

+1-17
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,7 @@ extension GoalViewController {
9797
let value = AddGoalViewController.activeValueForRecs
9898
let due = addGoalController.datePicker.date
9999

100-
let text: String
101-
switch addGoalController.selectedSegment {
102-
// case 0:
103-
// guard let indexPath = addGoalController.tableView.indexPathForSelectedRow else {
104-
// text = ""
105-
// break
106-
// }
107-
// text = AddGoalViewController.activeRecommendations[indexPath.row]
108-
// case 1:
109-
// guard let indexPath = addGoalController.tableView.indexPathForSelectedRow else {
110-
// text = ""
111-
// break
112-
// }
113-
// text = (addGoalController.tableView.cellForRow(at: indexPath) as! RecommendedCell).textView.text
114-
default:
115-
text = ""
116-
}
100+
let text = addGoalController.goalWritingView.text ?? ""
117101

118102
// Create goal
119103
if text != "" {

0 commit comments

Comments
 (0)