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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,22 +3,4 @@
uuid = "5632179B-7279-4079-A847-17839EB4ABAC"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "33622DC4-508A-4D05-AA73-50EFF34B3AD4"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PlayDate/Views/UserProfileCells/UserProfileHeaderCell.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "134"
endingLineNumber = "134"
landmarkName = "didTapLogout(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line numberDiff line numberDiff line change
Expand Up@@ -192,38 +192,61 @@ class PetProfileSetupViewController: UIViewController, UIImagePickerControllerDe
addPicturesButton.addTarget(self, action: #selector(uploadPetPictures(_:)), for: .touchUpInside)

// Done Button
doneButton.setContentHuggingPriority(.required, for: .vertical)
doneButton.setContentCompressionResistancePriority(.required, for: .vertical)
verticalStackView.addArrangedSubview(doneButton)
doneButton.addTarget(self, action: #selector(doDoneButton(_:)), for: .touchUpInside)

}

@objc func doDoneButton(_ sender: UIButton) {
let petName = petNameTextField.text!
let petBio = petBioTextField.text!
let petAge = Int(petAgeTextField.text!)!
let petType = petTypeTextField.text!
let petSex = petSexTextField.text!

let id = AuthManager.id!
let user = User(userID: id)

guard let petName = petNameTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Pet Name blank. Please fix and try again.")
return
}
guard let petBio = petBioTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Pet Bio blank. Please fix and try again.")
return
}
guard let petAge = petAgeTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Pet Age blank. Please fix and try again.")
return
}
guard let petAgeNum = Int(petAge) else {
self.presentAlert(title: "Oops!", message: "Pet Age needs to be a number. Please fix and try again.")
return
}
guard let petType = petTypeTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Pet Type blank. Please fix and try again.")
return
}
guard let petSex = petSexTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Pet Sex blank. Please fix and try again.")
return
}
guard let userId = AuthManager.id else {
self.presentAlert(title: "Oops!", message: "Something went wrong with registering. Please close app and try again.")
return
}

// Need to update/add the user's pet here
let user = User(userID: userId)
let pet = Pet()
pet.updateName(name: petName)
pet.updateBio(bio: petBio)
pet.updateAge(age: petAge)
pet.updateAge(age: petAgeNum)
pet.updateType(type: petType)
pet.updateSex(sex: petSex)
//user.addPet(petID: pet)

let petSetupVC = PetProfileSetupViewController()
petSetupVC.modalPresentationStyle = .fullScreen
self.navigationController?.show(petSetupVC, sender: self)
let homeTBC = HomeTabBarController()
homeTBC.modalPresentationStyle = .fullScreen
self.navigationController?.present(homeTBC, animated: true)
}

@objc func doSkipButton(_ sender: UIButton) {
let homeTBC = HomeTabBarController()
homeTBC.modalPresentationStyle = .fullScreen
self.navigationController?.show(homeTBC, sender: self)
self.navigationController?.present(homeTBC, animated: true)
}

@objc func uploadPetPictures(_ sender: UIButton) {
Expand DownExpand Up@@ -276,4 +299,9 @@ class PetProfileSetupViewController: UIViewController, UIImagePickerControllerDe
view.endEditing(true)
}

private func presentAlert(title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
self.present(alert, animated: true)
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,16 +151,31 @@ class UserProfileSetupViewController: UIViewController, UIImagePickerControllerD

//This needs some kind of error handling ***GUS
@objc func userToPetSetup(_ sender: UIButton) {

let username:String = userSetupLabel.text!
let bio:String = userBioTextField.text!
let age:Int = Int(userAgeTextField.text!)!

let id = AuthManager.id!
let user = User(userID: id)
guard let username = userSetupLabel.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Username blank. Please fix and try again.")
return
}
guard let bio = userBioTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Bio blank. Please fix and try again.")
return
}
guard let age = userAgeTextField.text else {
self.presentAlert(title: "Oops!", message: "Looks like you left Age blank. Please fix and try again.")
return
}
guard let ageNum = Int(age) else {
self.presentAlert(title: "Oops!", message: "Age is supposed to be a number. Please fix and try again.")
return
}
guard let userId = AuthManager.id else {
self.presentAlert(title: "Oops!", message: "Something went wrong with registering. Please close app and try again.")
return
}

let user = User(userID: userId)
user.updateName(name: username)
user.updateBio(bio: bio)
user.updateAge(age: age)
user.updateAge(age: ageNum)

let petSetupVC = PetProfileSetupViewController()
petSetupVC.modalPresentationStyle = .fullScreen
Expand DownExpand Up@@ -216,5 +231,10 @@ class UserProfileSetupViewController: UIViewController, UIImagePickerControllerD
@objc func dismissKeyboard() {
view.endEditing(true)
}


private func presentAlert(title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
self.present(alert, animated: true)
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -184,7 +184,9 @@ class UserRegisterViewController: UIViewController {

let userSetupVC = UserProfileSetupViewController()
userSetupVC.modalPresentationStyle = .fullScreen
strongSelf.present(userSetupVC, animated: true)
let navVC = UINavigationController(rootViewController: userSetupVC)
navVC.modalPresentationStyle = .fullScreen
strongSelf.navigationController?.present(navVC, animated: true)
} else {
// Need additional error labels for
// other failure conditions.
Expand Down