diff --git a/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift b/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift index 9462ec0..2ab1ab9 100644 --- a/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift +++ b/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift @@ -40,11 +40,11 @@ public enum WatercraftFromSection: Int, CaseIterable { extension String { var readableSection: String { let sectionTitles: [String: String] = [ - "basicInformation": "--- BASIC INFORMATION ---", - "watercraftDetails": "--- WATERCRAFT DETAILS ---", - "journeyDetails": "--- JOURNEY DETAILS ---", - "inspectionDetails": "--- INSPECTION DETAILS ---", - "inspectionOutcomes": "--- INSPECTION OUTCOMES ---" + "basicInformation": "- BASIC INFORMATION -", + "watercraftDetails": "- WATERCRAFT DETAILS -", + "journeyDetails": "- JOURNEY DETAILS -", + "inspectionDetails": "- INSPECTION DETAILS -", + "inspectionOutcomes": "- INSPECTION OUTCOMES -" ] return sectionTitles[self] ?? self.capitalized } @@ -185,9 +185,27 @@ class WatercraftInspectionViewController: BaseViewController { setGradiantBackground(navigationBar: navigation.navigationBar) if let model = self.model, model.getStatus() == .Draft { setRightNavButtons() + setLeftNavButtons() } } + private func setLeftNavButtons() { + // Create a UIButton to hold the back icon and text + let backButton = UIButton(type: .custom) + backButton.setTitle(" Shift Overview", for: .normal) + backButton.setTitleColor(UIColor.white, for: .normal) + backButton.setImage(UIImage(systemName: "chevron.backward"), for: .normal) + backButton.addTarget(self, action: #selector(didTapBackButton(sender:)), for: .touchUpInside) + backButton.contentHorizontalAlignment = .left + backButton.semanticContentAttribute = .forceLeftToRight + + backButton.sizeToFit() + + let backBarButtonItem = UIBarButtonItem(customView: backButton) + + navigationItem.leftBarButtonItem = backBarButtonItem + } + private func setRightNavButtons() { let deleteIcon = UIImage(systemName: "trash") let deleteButton = UIBarButtonItem(image: deleteIcon, style: .plain, target: self, action: #selector(self.didTapDeleteButton(sender:))) @@ -198,6 +216,16 @@ class WatercraftInspectionViewController: BaseViewController { navigationItem.rightBarButtonItems = [saveButton, deleteButton] } + @objc func didTapBackButton(sender: UIBarButtonItem) { + self.dismissKeyboard() + + if canSubmit() { + self.navigationController?.popViewController(animated: true) + } else { + Alert.show(title: "Incomplete", message: validationMessage()) + } + } + // Navigation bar right button action @objc func didTapDeleteButton(sender: UIBarButtonItem) { guard let model = self.model else {return}