Skip to content

Commit

Permalink
Hopefully final update before going live on the App Store
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenshively committed Jan 21, 2020
1 parent 3867f13 commit 2b700cc
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
BE0593BE23CE9F2100B0CD3B /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BE0593BD23CE9F2100B0CD3B /* GoogleService-Info.plist */; };
BE0AFA0D23C43EAE005CC6B2 /* CubeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BE0AFA0C23C43EAE005CC6B2 /* CubeView.xib */; };
BE0AFA0F23C43EB8005CC6B2 /* CubeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0AFA0E23C43EB8005CC6B2 /* CubeView.swift */; };
BE0AFA1323C46B2B005CC6B2 /* AddGoalTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0AFA1223C46B2B005CC6B2 /* AddGoalTableView.swift */; };
BE0EC70F23B858150000C9C0 /* Feed.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0EC70E23B858150000C9C0 /* Feed.swift */; };
BE0EC71123B8650F0000C9C0 /* CollectionableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0EC71023B8650E0000C9C0 /* CollectionableCell.swift */; };
BE0EC71323B865230000C9C0 /* TableableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0EC71223B865230000C9C0 /* TableableCell.swift */; };
Expand Down Expand Up @@ -84,7 +83,6 @@
BE0593BD23CE9F2100B0CD3B /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
BE0AFA0C23C43EAE005CC6B2 /* CubeView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CubeView.xib; sourceTree = "<group>"; };
BE0AFA0E23C43EB8005CC6B2 /* CubeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CubeView.swift; sourceTree = "<group>"; };
BE0AFA1223C46B2B005CC6B2 /* AddGoalTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddGoalTableView.swift; sourceTree = "<group>"; };
BE0EC70E23B858150000C9C0 /* Feed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feed.swift; sourceTree = "<group>"; };
BE0EC71023B8650E0000C9C0 /* CollectionableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionableCell.swift; sourceTree = "<group>"; };
BE0EC71223B865230000C9C0 /* TableableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableableCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -174,7 +172,6 @@
children = (
C4CA5A90220E0DB900ECF768 /* GoalViewController.swift */,
BE4CFB0723120CFD0029A1D2 /* AddGoalViewController.swift */,
BE0AFA1223C46B2B005CC6B2 /* AddGoalTableView.swift */,
);
name = Goals;
sourceTree = "<group>";
Expand Down Expand Up @@ -561,7 +558,6 @@
C4CA5AB8220E189600ECF768 /* QuoteCell.swift in Sources */,
BE0EC71523B8872E0000C9C0 /* Uploadable.swift in Sources */,
C4CA5AA4220E0F9000ECF768 /* ProfileViewController.swift in Sources */,
BE0AFA1323C46B2B005CC6B2 /* AddGoalTableView.swift in Sources */,
C4ADBE4822E2711B007F8BC0 /* Util.swift in Sources */,
C4CA5AC8220E1A0700ECF768 /* Values.swift in Sources */,
BE4CFB0E23135B2B0029A1D2 /* Goals.swift in Sources */,
Expand Down Expand Up @@ -750,7 +746,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.marshall.couryleadershipprogram;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -773,7 +769,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = edu.usc.marshall.couryleadershipprogram;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import UIKit

class AddGoalViewController: UIViewController {

@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBOutlet weak var instructionLabel: UILabel!
@IBOutlet weak var datePicker: UIDatePicker!
@IBOutlet weak var promptView: UITextView!
@IBOutlet weak var goalWritingView: UITextView!

@IBOutlet weak var opaqueView: UIView!
@IBOutlet weak var opaqueViewYPosition: NSLayoutConstraint!

@IBOutlet weak var cubeView: CubeView!
internal var cubeFaces: [UIImageView] = []

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

internal var lastUpdated: Date = Date()
internal var selectedSegment: Int = 0

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

// engageTableView()
opaqueView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]

let tap = UITapGestureRecognizer(target: self, action: #selector(onCubeTap(_:)))
cubeView.addGestureRecognizer(tap)

setupCubeView()
cubeView.enableMotion()

NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
goalWritingView.delegate = self
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
goalWritingView.becomeFirstResponder()

cubeView.needsTaring = true
cubeView.trackMotion(true)

CLPProfile.shared.onFetchSuccess {
self.setupCubeView()
// self.updateTableView()
self.onCubeTap()
}
if CLPProfile.shared.basicInformation.lastModified > lastUpdated {
self.setupCubeView()
// self.updateTableView()
self.onCubeTap()
}
self.onCubeTap()
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

goalWritingView.resignFirstResponder()
cubeView.trackMotion(false)
}

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

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

// updateTableView()
updatePrompt()
}
}

private func updatePrompt() {
let prompt = Self.activeRecommendations.randomElement() ?? "What's something you've always wanted to do?"
if prompt.contains("?") {
promptView.text = prompt
goalWritingView.text = ""
}else {
promptView.text = "Personalize the given goal. It will be easier to accomplish if it's more specific."
goalWritingView.text = prompt
}

// if !goalWritingView.isFirstResponder {
// goalWritingView.textColor = .lightGray
// }
}

private func setupCubeView() {
cubeFaces = cubeView.createFaces(in: cubeView.bounds)
cubeView.situate(in: cubeView.bounds)

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

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

extension AddGoalViewController: UITextViewDelegate {
func textViewDidBeginEditing(_ textView: UITextView) {
if textView.text.contains("?") {textView.clearsOnInsertion = true}
}

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

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

func textViewDidChange(_ textView: UITextView) {
UIView.setAnimationsEnabled(false)
textView.sizeToFit()
// DispatchQueue.main.async {
// self.tableView.beginUpdates()
// self.tableView.endUpdates()
// UIView.setAnimationsEnabled(true)
// }
}
}

extension AddGoalViewController {
@objc func keyboardWillShow(_ notification: Notification) {
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
// tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height, right: 0)
self.opaqueViewYPosition.constant = keyboardSize.height
UIView.animate(withDuration: 0.1) {
self.view.layoutIfNeeded()
}
}
}
@objc func keyboardWillHide(_ notification: Notification) {
if let _ = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
// tableView.contentInset = UIEdgeInsets.zero
self.opaqueViewYPosition.constant = 0
UIView.animate(withDuration: 0.1) {
self.view.layoutIfNeeded()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,7 @@ extension GoalViewController {
let value = AddGoalViewController.activeValueForRecs
let due = addGoalController.datePicker.date

let text: String
switch addGoalController.selectedSegment {
// case 0:
// guard let indexPath = addGoalController.tableView.indexPathForSelectedRow else {
// text = ""
// break
// }
// text = AddGoalViewController.activeRecommendations[indexPath.row]
// case 1:
// guard let indexPath = addGoalController.tableView.indexPathForSelectedRow else {
// text = ""
// break
// }
// text = (addGoalController.tableView.cellForRow(at: indexPath) as! RecommendedCell).textView.text
default:
text = ""
}
let text = addGoalController.goalWritingView.text ?? ""

// Create goal
if text != "" {
Expand Down
Loading

0 comments on commit 2b700cc

Please sign in to comment.