From 4a577f94b3a3b0d16bcd88feb1a6e5e86bc6a0f5 Mon Sep 17 00:00:00 2001 From: David <62899351+davidclaveau@users.noreply.github.com> Date: Tue, 13 Feb 2024 08:44:32 -0800 Subject: [PATCH 1/2] only allow city if other waterbody, tweak for new validation --- ipad.xcodeproj/project.pbxproj | 16 ++++ ipad/Utilities/Theme.swift | 3 + .../BasicCollectionViewCell.swift | 15 +++- .../BasicCollectionViewCell.xib | 55 ++++++++---- .../Blank/BlankCollectionViewCell.swift | 23 +++++ .../Blank/BlankCollectionViewCell.xib | 42 +++++++++ .../Button/FormButtonCollectionViewCell.swift | 49 ++++++++++- .../WatercraftInspectionViewController.swift | 86 +++++++++++++++++-- .../Waterbody picker/WaterbodyPicker.xib | 35 +++++--- 9 files changed, 278 insertions(+), 46 deletions(-) create mode 100644 ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.swift create mode 100644 ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.xib diff --git a/ipad.xcodeproj/project.pbxproj b/ipad.xcodeproj/project.pbxproj index 556e776e..a29e9ed0 100644 --- a/ipad.xcodeproj/project.pbxproj +++ b/ipad.xcodeproj/project.pbxproj @@ -214,6 +214,8 @@ 5C82D404237B31C200B065BA /* WatercraftRiskAssessmentAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C82D403237B31C200B065BA /* WatercraftRiskAssessmentAPI.swift */; }; 9620B078298849BF0084268C /* NullSwitchInputCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9620B076298849BF0084268C /* NullSwitchInputCollectionViewCell.swift */; }; 9620B079298849BF0084268C /* NullSwitchInputCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9620B077298849BF0084268C /* NullSwitchInputCollectionViewCell.xib */; }; + 966B0B782B7AA1BD00B33478 /* BlankCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966B0B762B7AA1BD00B33478 /* BlankCollectionViewCell.swift */; }; + 966B0B792B7AA1BD00B33478 /* BlankCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 966B0B772B7AA1BD00B33478 /* BlankCollectionViewCell.xib */; }; 96CDB9632B4886FF009A45C7 /* NewBlowbyModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CDB9612B4886FF009A45C7 /* NewBlowbyModal.swift */; }; 96CDB9642B4886FF009A45C7 /* NewBlowbyModal.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96CDB9622B4886FF009A45C7 /* NewBlowbyModal.xib */; }; A7AE5275237CC3660044DBB7 /* unapproved-cross.json in Resources */ = {isa = PBXBuildFile; fileRef = A7AE5272237CC3660044DBB7 /* unapproved-cross.json */; }; @@ -459,6 +461,8 @@ 763C8716EF742F6764FFE7D7 /* Pods-ipad.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ipad.debug.xcconfig"; path = "Target Support Files/Pods-ipad/Pods-ipad.debug.xcconfig"; sourceTree = ""; }; 9620B076298849BF0084268C /* NullSwitchInputCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NullSwitchInputCollectionViewCell.swift; sourceTree = ""; }; 9620B077298849BF0084268C /* NullSwitchInputCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NullSwitchInputCollectionViewCell.xib; sourceTree = ""; }; + 966B0B762B7AA1BD00B33478 /* BlankCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlankCollectionViewCell.swift; sourceTree = ""; }; + 966B0B772B7AA1BD00B33478 /* BlankCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BlankCollectionViewCell.xib; sourceTree = ""; }; 96CDB9612B4886FF009A45C7 /* NewBlowbyModal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewBlowbyModal.swift; sourceTree = ""; }; 96CDB9622B4886FF009A45C7 /* NewBlowbyModal.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NewBlowbyModal.xib; sourceTree = ""; }; 987374CFF5F2318652AA2FCC /* Pods-ipadTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ipadTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ipadTests/Pods-ipadTests.release.xcconfig"; sourceTree = ""; }; @@ -1243,6 +1247,7 @@ 29DB4E3A23870B1F00B13646 /* Shared cells */ = { isa = PBXGroup; children = ( + 966B0B752B7AA1A300B33478 /* Blank */, 29DB010B2371EE2F0046E605 /* Basic (header + Input group) */, 29E4BBE5237211F10079475F /* Divider */, 29DB0113237206B90046E605 /* Header */, @@ -1467,6 +1472,15 @@ path = "Null Switch Input"; sourceTree = ""; }; + 966B0B752B7AA1A300B33478 /* Blank */ = { + isa = PBXGroup; + children = ( + 966B0B762B7AA1BD00B33478 /* BlankCollectionViewCell.swift */, + 966B0B772B7AA1BD00B33478 /* BlankCollectionViewCell.xib */, + ); + path = Blank; + sourceTree = ""; + }; 96CDB9602B4886FF009A45C7 /* New Blowby Modal */ = { isa = PBXGroup; children = ( @@ -1600,6 +1614,7 @@ 299BF01923FC9045001732CD /* JourneyHeaderCollectionViewCell.xib in Resources */, 29DB4E4F2387131000B13646 /* InspectionsTableCollectionViewCell.xib in Resources */, 2950510A2374D764000FBD6E /* DoubleInputCollectionViewCell.xib in Resources */, + 966B0B792B7AA1BD00B33478 /* BlankCollectionViewCell.xib in Resources */, 29E4BBE92372120F0079475F /* DividerCollectionViewCell.xib in Resources */, 296DEC21238C53930035E7FA /* NewShiftModal.xib in Resources */, 299BF01E23FC9D20001732CD /* PDFViewer.xib in Resources */, @@ -1844,6 +1859,7 @@ 5C82D3F52374D09000B065BA /* UtilityObjC.m in Sources */, 298BF7CC2395D45C0072AA28 /* PreviousWaterBodyModel.swift in Sources */, 5C82D3DE2374B9D700B065BA /* RemoteAPI.swift in Sources */, + 966B0B782B7AA1BD00B33478 /* BlankCollectionViewCell.swift in Sources */, 5C82D3F92376036700B065BA /* WorkflowAPI.swift in Sources */, 41CAEC7D2B45C538002B2960 /* ShiftBlowbysHeaderCollectionViewCell.swift in Sources */, 29BAC51C2367B5B500A620F4 /* RealmRequests.swift in Sources */, diff --git a/ipad/Utilities/Theme.swift b/ipad/Utilities/Theme.swift index 10c3f43c..cd5bf6e8 100644 --- a/ipad/Utilities/Theme.swift +++ b/ipad/Utilities/Theme.swift @@ -193,4 +193,7 @@ extension Theme { public func styleDividerGrey(view: UIView) { view.backgroundColor = Colors.Status.LightGray } + public func styleTopDivider(view: UIView) { + view.backgroundColor = Colors.secondary + } } diff --git a/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.swift b/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.swift index e06c9375..f126c5b5 100644 --- a/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.swift +++ b/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.swift @@ -16,6 +16,7 @@ class BasicCollectionViewCell: UICollectionViewCell, Theme { @IBOutlet weak var divider: UIView! @IBOutlet weak var leadingMargin: NSLayoutConstraint! @IBOutlet weak var trailingMargin: NSLayoutConstraint! + @IBOutlet weak var topDivider: UIView! weak var inputGroup: UIView? @@ -25,6 +26,7 @@ class BasicCollectionViewCell: UICollectionViewCell, Theme { var showBox = false var showDivider = true + var showTopDivider = false var extraPadding: CGFloat = 0 var boxPadding: CGFloat = 8 @@ -33,12 +35,13 @@ class BasicCollectionViewCell: UICollectionViewCell, Theme { style() } - public func setup(title: String, input items: [InputItem], delegate: InputDelegate, boxed: Bool? = false, showDivider: Bool? = true, padding: CGFloat? = 0, buttonName: String? = nil, buttonIcon: String? = nil, onButtonClick: (()->Void)? = nil) { + public func setup(title: String, input items: [InputItem], delegate: InputDelegate, boxed: Bool? = false, showDivider: Bool? = true, showTopDivider: Bool? = false, padding: CGFloat? = 0, buttonName: String? = nil, buttonIcon: String? = nil, onButtonClick: (()->Void)? = nil) { self.inputGroup?.removeFromSuperview() self.extraPadding = padding ?? 0 self.showBox = boxed ?? false self.showDivider = showDivider ?? true + self.showTopDivider = showTopDivider ?? false button.alpha = 0 if let btnName = buttonName { @@ -71,6 +74,7 @@ class BasicCollectionViewCell: UICollectionViewCell, Theme { styleSectionTitle(label: titleLabel) styleBox() styleDivider() + styleTopDivider() } private func styleBox() { @@ -96,4 +100,13 @@ class BasicCollectionViewCell: UICollectionViewCell, Theme { } } + private func styleTopDivider() { + if showTopDivider { + topDivider.alpha = 1 + styleTopDivider(view: topDivider) + } else { + topDivider.alpha = 0 + } + } + } diff --git a/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.xib b/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.xib index fb371433..b5a7af42 100644 --- a/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.xib +++ b/ipad/ViewControllers/Shared cells/Basic (header + Input group)/BasicCollectionViewCell.xib @@ -1,40 +1,45 @@ - - + + - + + + - - + + - + + + + + + + + - - - - - - + + + + + + + @@ -52,14 +62,17 @@ + + + - - + + + - @@ -67,9 +80,15 @@ + - + + + + + + diff --git a/ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.swift b/ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.swift new file mode 100644 index 00000000..19716af0 --- /dev/null +++ b/ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.swift @@ -0,0 +1,23 @@ +// +// BlankCollectionViewCell.swift +// ipad +// +// Created by Claveau, David LWRS:EX on 2024-02-12. +// Copyright © 2024 Amir Shayegh. All rights reserved. +// + +import UIKit + +class BlankCollectionViewCell: UICollectionViewCell, Theme { + + @IBOutlet weak var blank: UIView! + + override func awakeFromNib() { + super.awakeFromNib() + } + + func setup(visible: Bool) { + blank.alpha = visible ? 1 : 0 + } + +} diff --git a/ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.xib b/ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.xib new file mode 100644 index 00000000..032686ee --- /dev/null +++ b/ipad/ViewControllers/Shared cells/Blank/BlankCollectionViewCell.xib @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ipad/ViewControllers/Watercraft Inspections/Cells/Button/FormButtonCollectionViewCell.swift b/ipad/ViewControllers/Watercraft Inspections/Cells/Button/FormButtonCollectionViewCell.swift index f0f12c6b..b6c4a28b 100644 --- a/ipad/ViewControllers/Watercraft Inspections/Cells/Button/FormButtonCollectionViewCell.swift +++ b/ipad/ViewControllers/Watercraft Inspections/Cells/Button/FormButtonCollectionViewCell.swift @@ -29,6 +29,8 @@ class FormButtonCollectionViewCell: UICollectionViewCell, Theme { var isPreviousJourney: Bool = false var displaySwitch: Bool = false var displayUnknowSwitch: Bool = false + var otherWaterbodyPrev: Bool = false + var otherWaterbodyDest: Bool = false } @@ -47,12 +49,38 @@ class FormButtonCollectionViewCell: UICollectionViewCell, Theme { @objc weak var target: NSObject? @objc var _selector: Selector? + var configuration = Config() + var disableButton: Bool { - return (dryStorageSwitch?.isOn ?? false) || (unknownWaterBodySwitch?.isOn ?? false) || (commercialManufacturerSwitch?.isOn ?? false) + if configuration.otherWaterbodyPrev || configuration.otherWaterbodyDest { + return true + } + + if (dryStorageSwitch?.isOn ?? false) { + return false + } else if (unknownWaterBodySwitch?.isOn ?? false) { + return false + } else if (commercialManufacturerSwitch?.isOn ?? false) { + return false + } else { + return true + } } var disableMajorCityButton: Bool { - return false + if configuration.otherWaterbodyPrev || configuration.otherWaterbodyDest { + return true + } + + if (dryStorageSwitch?.isOn ?? true) { + return false + } else if (unknownWaterBodySwitch?.isOn ?? true) { + return false + } else if (commercialManufacturerSwitch?.isOn ?? true) { + return false + } else { + return true + } } var result: Result { @@ -64,6 +92,8 @@ class FormButtonCollectionViewCell: UICollectionViewCell, Theme { @IBAction func buttonAction(_ sender: UIButton) { // let _ = self.target?.perform(_selector, with: [:]) guard let onClick = self.completion else {return} + self.set(status: disableButton) + self.set(status: disableMajorCityButton) return onClick(.add) } @@ -111,12 +141,21 @@ class FormButtonCollectionViewCell: UICollectionViewCell, Theme { func set(status: Bool) { self.button?.isEnabled = !status + self.majorCityButton?.isEnabled = status; if status { styleDisable(button: self.button) styleHollowButton(button: self.majorCityButton) } else { styleHollowButton(button: button) - styleHollowButton(button: self.majorCityButton) + styleDisable(button: majorCityButton) + } + + // if the user has entered an otherWaterbody, we set both buttons as available + if configuration.otherWaterbodyPrev || configuration.otherWaterbodyDest { + self.button?.isEnabled = true + self.majorCityButton?.isEnabled = true + styleHollowButton(button: button) + styleHollowButton(button: majorCityButton) } } @@ -124,6 +163,8 @@ class FormButtonCollectionViewCell: UICollectionViewCell, Theme { self.dryStorageSwitch?.isHidden = !config.displaySwitch self.switchLabel?.isHidden = !config.displaySwitch self.dryStorageSwitch?.isOn = config.status + self.configuration.otherWaterbodyPrev = config.otherWaterbodyPrev + self.configuration.otherWaterbodyDest = config.otherWaterbodyDest if config.isPreviousJourney { self.switchLabel?.text = "Previously Stored" } else { @@ -135,7 +176,7 @@ class FormButtonCollectionViewCell: UICollectionViewCell, Theme { self.commercialManufacturerSwitch?.isOn = config.commercialManufacturerStatus if config.displaySwitch || config.displayUnknowSwitch { - set(status: (config.status || config.unknownWaterBodyStatus || config.commercialManufacturerStatus)) + set(status: (config.status || config.unknownWaterBodyStatus || config.commercialManufacturerStatus || config.otherWaterbodyPrev || config.otherWaterbodyDest)) } else { set(status: true) } diff --git a/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift b/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift index 290f91c8..ca8ca606 100644 --- a/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift +++ b/ipad/ViewControllers/Watercraft Inspections/WatercraftInspectionViewController.swift @@ -20,6 +20,7 @@ private enum JourneyDetailsSectionRow { case PreviousHeader case DestinationHeader case Divider + case Blank } public enum WatercraftFromSection: Int, CaseIterable { @@ -49,7 +50,8 @@ class WatercraftInspectionViewController: BaseViewController { "PreviousWaterBodyCollectionViewCell", "JourneyHeaderCollectionViewCell", "PreviousMajorCityCollectionViewCell", - "DestinationMajorCityCollectionViewCell" + "DestinationMajorCityCollectionViewCell", + "BlankCollectionViewCell" ] // MARK: Variables @@ -274,6 +276,8 @@ class WatercraftInspectionViewController: BaseViewController { case previousMajorCities case destinationWaterBodies case destinationMajorCities + case prevOtherWaterbodyNoCity + case destOtherWaterbodyNoCity // Inspection Outcomes (High Risk form) case decontaminationPerformed @@ -313,6 +317,8 @@ class WatercraftInspectionViewController: BaseViewController { case errorPreviousMajorCities = "Closest Major City for Previous Waterbody." case errorDestinationWaterBodies = "Destination Waterbody\n(or toggle New, Unknown, or Stored)." case errorDestinationMajorCities = "Closest Major City for Destination Waterbody." + case errorPrevOtherWaterbodyNoCity = "To improve identification for the 'Other' Waterbody, add a Previous Closest Major City." + case errorDestOtherWaterbodyNoCity = "To improve identification for the 'Other' Waterbody, add a Destination Closest Major City." // Inspection Outcomes (High Risk form) case errorDecontaminationPerformed = "Record of Decontamination number." @@ -386,6 +392,9 @@ class WatercraftInspectionViewController: BaseViewController { } } + let prevHasNonEmptyOtherWaterbody = model.previousWaterBodies.contains { !$0.otherWaterbody.isEmpty } + let destHasNonEmptyOtherWaterbody = model.destinationWaterBodies.contains { !$0.otherWaterbody.isEmpty } + // Set values for High Risk form, if it exists var highRiskDecontaminationPerformedInteracted: Bool = false var highRiskDecontaminationOrderIssuedInteracted: Bool = false @@ -532,7 +541,7 @@ class WatercraftInspectionViewController: BaseViewController { ), // Journey Details validation - // Note: Prev and Dest Major City are required on all submissions + // Note: Prev and Dest Major City are required on all otherWaterbody submissions Validation( type: .previousWaterBodies, errorMessage: .errorPreviousWaterBodies, @@ -543,7 +552,8 @@ class WatercraftInspectionViewController: BaseViewController { Validation( type: .previousMajorCities, errorMessage: .errorPreviousMajorCities, - condition: model.previousMajorCities.isEmpty, + condition: !isPreviousWaterbody + && model.previousMajorCities.isEmpty, section: .journeyDetails ), Validation( @@ -556,7 +566,8 @@ class WatercraftInspectionViewController: BaseViewController { Validation( type: .destinationMajorCities, errorMessage: .errorDestinationMajorCities, - condition: model.destinationMajorCities.isEmpty, + condition: !isDestinationWaterbody + && model.destinationMajorCities.isEmpty, section: .journeyDetails ), Validation( @@ -566,6 +577,20 @@ class WatercraftInspectionViewController: BaseViewController { && previousNumberOfDays.isEmpty, section: .journeyDetails ), + Validation( + type: .prevOtherWaterbodyNoCity, + errorMessage: .errorPrevOtherWaterbodyNoCity, + condition: prevHasNonEmptyOtherWaterbody + && model.previousMajorCities.isEmpty, + section: .journeyDetails + ), + Validation( + type: .destOtherWaterbodyNoCity, + errorMessage: .errorDestOtherWaterbodyNoCity, + condition: destHasNonEmptyOtherWaterbody + && model.destinationMajorCities.isEmpty, + section: .journeyDetails + ), // Inspection Details // K9 inspection and time of inspection are the only @@ -908,6 +933,27 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl DestinationMajorCityCollectionViewCell } + func getBlankCell(indexPath: IndexPath) -> BlankCollectionViewCell { + return collectionView!.dequeueReusableCell(withReuseIdentifier: "BlankCollectionViewCell", for: indexPath as IndexPath) as! + BlankCollectionViewCell + } + + private func arePreviousTogglesChecked(ref: WatercraftInspectionModel) -> Bool { + if ref.commercialManufacturerAsPreviousWaterBody || ref.unknownPreviousWaterBody || ref.previousDryStorage { + return true + } else { + return false + } + } + + private func areDestinationTogglesChecked(ref: WatercraftInspectionModel) -> Bool { + if ref.commercialManufacturerAsDestinationWaterBody || ref.unknownDestinationWaterBody || ref.destinationDryStorage { + return true + } else { + return false + } + } + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { guard let sectionType = WatercraftFromSection(rawValue: Int(section)), let model = self.model else {return 0} @@ -963,7 +1009,7 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl return getJourneyDetailsCell(for: indexPath) case .InspectionDetails: let cell = getBasicCell(indexPath: indexPath) - cell.setup(title: "Inspection Details", input: model.getInputputFields(for: sectionType, editable: isEditable), delegate: self, showDivider: false, buttonName: "View Map", buttonIcon: "map", onButtonClick: { [weak self] in + cell.setup(title: "Inspection Details", input: model.getInputputFields(for: sectionType, editable: isEditable), delegate: self, showDivider: false, showTopDivider: true, buttonName: "View Map", buttonIcon: "map", onButtonClick: { [weak self] in guard let strongSelf = self else {return} strongSelf.showPDFMap() }) @@ -1185,6 +1231,7 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl return cell case .AddPreviousWaterBody: + let hasNonEmptyOtherWaterbody = model.previousWaterBodies.contains { !$0.otherWaterbody.isEmpty } let cell = getButtonCell(indexPath: indexPath) cell.setup( with: "Add Previous Water Body", @@ -1195,7 +1242,8 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl commercialManufacturerStatus: self.model?.commercialManufacturerAsPreviousWaterBody ?? false, isPreviousJourney: true, displaySwitch: true, - displayUnknowSwitch: true) + displayUnknowSwitch: true, + otherWaterbodyPrev: hasNonEmptyOtherWaterbody) ) { [weak self] action in guard let strongSelf = self else {return} /// ----- Switch Action ------ @@ -1242,6 +1290,7 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl } return cell case .AddDestinationWaterBody: + let hasNonEmptyOtherWaterbody = model.destinationWaterBodies.contains { !$0.otherWaterbody.isEmpty } let cell = getButtonCell(indexPath: indexPath) cell.setup( with: "Add Destination Water Body", @@ -1252,7 +1301,8 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl commercialManufacturerStatus: self.model?.commercialManufacturerAsDestinationWaterBody ?? false, isPreviousJourney: false, displaySwitch: true, - displayUnknowSwitch: true) + displayUnknowSwitch: true, + otherWaterbodyDest: hasNonEmptyOtherWaterbody) ) { [weak self] action in guard let strongSelf = self else {return} @@ -1309,6 +1359,10 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl let cell = getHeaderCell(indexPath: indexPath) cell.setup(with: "Destination Waterbody *") return cell + case .Blank: + let blankCell = getBlankCell(indexPath: indexPath) + blankCell.setup(visible: true) + return blankCell } } @@ -1337,6 +1391,8 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl return CGSize(width: width, height: 50) case .DestinationHeader: return CGSize(width: width, height: 50) + case .Blank: + return CGSize(width: width, height: 1) } } @@ -1352,6 +1408,16 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl private func getJourneyDetailsCellType(for indexPath: IndexPath) -> JourneyDetailsSectionRow { guard let model = self.model else {return .Divider} + // If the prev commercial/unknown/stored are toggled off, we delete the cities from model + if !arePreviousTogglesChecked(ref: model) && model.previousWaterBodies.isEmpty { + model.deleteMajorCity(isPrevious: true) + } + + // If the dest commercial/unknown/stored are toggled off, we delete the cities from model + if !areDestinationTogglesChecked(ref: model) && model.destinationWaterBodies.isEmpty { + model.deleteMajorCity(isPrevious: false) + } + // Header for "Journey Details" always at top if indexPath.row == 0 { return .Header @@ -1417,11 +1483,13 @@ extension WatercraftInspectionViewController: UICollectionViewDataSource, UIColl // We show our Destination Major City beneath the Destination Add Buttons let destinationMajorCityCount = min(indexPath.row - previousWaterBodyCount - previousMajorCityCount - destinationWaterBodyCount - 8, model.destinationMajorCities.count - 1) + if indexPath.row <= previousWaterBodyCount + previousMajorCityCount + destinationWaterBodyCount + destinationMajorCityCount + 8 { return .DestinationMajorCity } - // Finally, once everything is exhausted, we show the Divider - return .Divider + // Finally, once everything is exhausted, we show the blank spot unless we skipped it earlier + // a divider is provided as topDivider for the Inspection Details + return .Blank } } diff --git a/ipad/Views/Waterbody picker/WaterbodyPicker.xib b/ipad/Views/Waterbody picker/WaterbodyPicker.xib index fe32b525..b7683c26 100644 --- a/ipad/Views/Waterbody picker/WaterbodyPicker.xib +++ b/ipad/Views/Waterbody picker/WaterbodyPicker.xib @@ -1,9 +1,11 @@ - + - + + + @@ -14,15 +16,15 @@ - + - - + @@ -62,7 +64,7 @@ - + @@ -75,11 +77,11 @@ - - + + - + @@ -113,7 +115,7 @@ Be sure to include the Lake Name, State/Province, Country and City. -