Skip to content

Commit 694bbef

Browse files
authored
Merge pull request #190 from akaktus/Submit/Cancel-record-should-go-back-to-home-screen
Cancel record should go back to home screen
2 parents fda6f6c + f7bed5c commit 694bbef

File tree

13 files changed

+77
-194
lines changed

13 files changed

+77
-194
lines changed

o-fish-ios.xcodeproj/project.pbxproj

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@
193193
BCE4814543022D42A642CA4A /* KeyboardController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE486CABA40FF0D6D14E5F9 /* KeyboardController.swift */; };
194194
BCE4815F88C024AD476B8DE2 /* DutyState.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48D936613848423BBAF33 /* DutyState.swift */; };
195195
BCE4817B0B89F5D95768925A /* CountryPickerView.swif.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE486BCBC428C8539A22A9D /* CountryPickerView.swif.swift */; };
196-
BCE481FC2E1771F65073C0A6 /* ReportSummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE483CAE164B70D857A62B0 /* ReportSummaryView.swift */; };
197196
BCE4820A7E5A15B8AA93DB4A /* TextPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48555D654177BE1259C7B /* TextPickerView.swift */; };
198197
BCE4825F4A971D6F6F24D571 /* CatchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48E5B87FCD1126A5C26C4 /* CatchView.swift */; };
199198
BCE48275C134A902EF0293D4 /* GlassIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48B8D8932DF568200B811 /* GlassIconView.swift */; };
@@ -249,7 +248,6 @@
249248
BCE48B02D6D3331545500562 /* ChooseSpeciesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48FAB856639D53CABC76C /* ChooseSpeciesView.swift */; };
250249
BCE48B088018D82ECFC5F7A9 /* MultiRowPickerWithButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE4817C8B123F01E50A23D9 /* MultiRowPickerWithButton.swift */; };
251250
BCE48B09547E88D2E76107BB /* Collection+EnumeratedArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48EFBBE1997660C4F1EE6 /* Collection+EnumeratedArray.swift */; };
252-
BCE48B31FB9BEA734058DAA9 /* ReportListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48A5038A2E43FE839DC80 /* ReportListView.swift */; };
253251
BCE48B41FAB47CB8B9B0AE61 /* SearchBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48D44A5E464AA9AC620E8 /* SearchBarView.swift */; };
254252
BCE48B59A51E4AF79D2FAEE1 /* TextLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE4871B39646A85F047F256 /* TextLabel.swift */; };
255253
BCE48B9CAD5B8F1EB27C60BD /* ChooseEMSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48E42E19241E2A8EC419F /* ChooseEMSView.swift */; };
@@ -491,7 +489,6 @@
491489
BCE482F2C7BF11E33FA5E862 /* StartStopDatePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartStopDatePicker.swift; sourceTree = "<group>"; };
492490
BCE483315BCBE777464D2FF4 /* ViolationPickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViolationPickerView.swift; sourceTree = "<group>"; };
493491
BCE483BB45A7BCD0ADC62551 /* PopoverManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverManager.swift; sourceTree = "<group>"; };
494-
BCE483CAE164B70D857A62B0 /* ReportSummaryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportSummaryView.swift; sourceTree = "<group>"; };
495492
BCE48456167E25D77C838694 /* CrewMemberShortView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrewMemberShortView.swift; sourceTree = "<group>"; };
496493
BCE484CE2776AE6F4E5A5791 /* ChooseBusinessView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseBusinessView.swift; sourceTree = "<group>"; };
497494
BCE484E6974BBB4F08413A3E /* InputField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputField.swift; sourceTree = "<group>"; };
@@ -531,7 +528,6 @@
531528
BCE489F610C0078AE3ED2944 /* TopTabBarContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TopTabBarContainerView.swift; sourceTree = "<group>"; };
532529
BCE489F75FEB031E1F2AAC20 /* ScrollableTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollableTabBar.swift; sourceTree = "<group>"; };
533530
BCE489FD715E47C868F5D581 /* PatrolSummaryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatrolSummaryView.swift; sourceTree = "<group>"; };
534-
BCE48A5038A2E43FE839DC80 /* ReportListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportListView.swift; sourceTree = "<group>"; };
535531
BCE48AB036DA398FBFF3E3B4 /* SectionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionButton.swift; sourceTree = "<group>"; };
536532
BCE48AB83BB50A193A6B4113 /* CallToActionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallToActionButton.swift; sourceTree = "<group>"; };
537533
BCE48AF913D1F963F18F6FAF /* KeyboardControllingScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardControllingScrollView.swift; sourceTree = "<group>"; };
@@ -807,7 +803,6 @@
807803
493CDFB923FEB86D00516048 /* LoginView.swift */,
808804
3013CA782424AF1300D2FF60 /* PatrolBoat */,
809805
BCE483F917662257CAB7586F /* ReportFlow */,
810-
BCE48B378C5953371739F735 /* ReportList */,
811806
);
812807
path = Views;
813808
sourceTree = "<group>";
@@ -1196,15 +1191,6 @@
11961191
path = Country;
11971192
sourceTree = "<group>";
11981193
};
1199-
BCE48B378C5953371739F735 /* ReportList */ = {
1200-
isa = PBXGroup;
1201-
children = (
1202-
BCE48A5038A2E43FE839DC80 /* ReportListView.swift */,
1203-
BCE483CAE164B70D857A62B0 /* ReportSummaryView.swift */,
1204-
);
1205-
path = ReportList;
1206-
sourceTree = "<group>";
1207-
};
12081194
BCE48B73700857DD26654AED /* Popover */ = {
12091195
isa = PBXGroup;
12101196
children = (
@@ -1711,9 +1697,7 @@
17111697
3013CA802424B07300D2FF60 /* TextToggle.swift in Sources */,
17121698
BCE48BFCEE413835DEB14DC0 /* RowView.swift in Sources */,
17131699
BCE48B59A51E4AF79D2FAEE1 /* TextLabel.swift in Sources */,
1714-
BCE48B31FB9BEA734058DAA9 /* ReportListView.swift in Sources */,
17151700
49B83EDB2489546D00027B8C /* SafetyLevel.swift in Sources */,
1716-
BCE481FC2E1771F65073C0A6 /* ReportSummaryView.swift in Sources */,
17171701
BCE4856F6CE56291D9BCB13E /* VesselView.swift in Sources */,
17181702
BCE483F97684587434E8421E /* ReportNavigationRootView.swift in Sources */,
17191703
BCE482FC535CCA17C9D9F30A /* EMSInputView.swift in Sources */,

o-fish-ios/Views/Components/BoardVesselButton.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct BoardVesselButton: View {
1212
@ObservedObject var onDuty: DutyState
1313
var report = ReportViewModel()
1414
var onHeader = true
15+
@Binding var rootIsActive: Bool
1516

1617
@State private var showingReportRootView = false
1718
@State private var showingGoOnDutyAlert = false
@@ -49,7 +50,8 @@ struct BoardVesselButton: View {
4950
}
5051

5152
NavigationLink(destination: ReportNavigationRootView(report: prefilledReport,
52-
prefilledVesselAvailable: true),
53+
prefilledVesselAvailable: true,
54+
rootIsActive: $rootIsActive),
5355
isActive: $showingReportRootView) {
5456
EmptyView()
5557
}
@@ -69,6 +71,7 @@ struct BoardVesselButton: View {
6971

7072
struct BoardVesselButton_Previews: PreviewProvider {
7173
static var previews: some View {
72-
BoardVesselButton(onDuty: .sample)
74+
BoardVesselButton(onDuty: .sample,
75+
rootIsActive: .constant(true))
7376
}
7477
}

o-fish-ios/Views/PatrolBoat/PatrolBoatView.swift

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ struct PatrolBoatView: View {
1414
var isLoggedIn: Binding<Bool>
1515

1616
@State private var location = LocationViewModel(LocationHelper.currentLocation)
17-
@State private var showingPreboardingView = false
18-
@State private var showingSearchView = false
19-
@State private var showingPatrolSummaryView = false
17+
@State private var isActiveRootFromPreboardingView = false
18+
@State private var isActiveRootFromSearchView = false
19+
@State private var isActiveRootFromShowingPatrolSummaryView = false
2020
@State private var resetLocation = {}
2121

2222
@State private var dutyReports = [ReportViewModel]()
@@ -41,10 +41,18 @@ struct PatrolBoatView: View {
4141
var body: some View {
4242
VStack {
4343
SearchBarButton(title: "Find records", action: {
44-
self.showingSearchView.toggle()
44+
self.isActiveRootFromSearchView.toggle()
4545
})
4646
.padding(.vertical, Dimensions.topPadding)
4747

48+
NavigationLink(destination: PreboardingView(viewType: .searchRecords,
49+
onDuty: onDuty,
50+
rootIsActive: $isActiveRootFromSearchView),
51+
isActive: $isActiveRootFromSearchView) {
52+
EmptyView()
53+
}
54+
.isDetailLink(false)
55+
4856
ZStack(alignment: .bottom) {
4957
MapComponentView(location: self.$location,
5058
reset: self.$resetLocation,
@@ -62,7 +70,7 @@ struct PatrolBoatView: View {
6270
Spacer()
6371
BoardButtonView {
6472
if self.onDuty.onDuty {
65-
self.showingPreboardingView.toggle()
73+
self.isActiveRootFromPreboardingView.toggle()
6674
} else {
6775
self.showGoOnDutyAlert()
6876
}
@@ -71,27 +79,25 @@ struct PatrolBoatView: View {
7179
.padding(.horizontal, Dimensions.allCoordPadding)
7280

7381
NavigationLink(
74-
destination: PreboardingView(viewType: .preboarding, onDuty: onDuty),
75-
isActive: self.$showingPreboardingView) {
76-
EmptyView()
82+
destination: PreboardingView(viewType: .preboarding,
83+
onDuty: onDuty,
84+
rootIsActive: $isActiveRootFromPreboardingView),
85+
isActive: self.$isActiveRootFromPreboardingView) {
86+
EmptyView()
7787
}
78-
}
79-
80-
NavigationLink(destination: PreboardingView(viewType: .searchRecords,
81-
onDuty: onDuty),
82-
isActive: self.$showingSearchView) {
83-
EmptyView()
88+
.isDetailLink(false)
8489
}
8590

8691
NavigationLink(destination:
8792
PatrolSummaryView(dutyReports: dutyReports,
8893
startDuty: startDuty,
8994
onDuty: onDuty,
90-
plannedOffDutyTime: plannedOffDutyTime),
91-
92-
isActive: self.$showingPatrolSummaryView) {
95+
plannedOffDutyTime: plannedOffDutyTime,
96+
rootIsActive: $isActiveRootFromShowingPatrolSummaryView),
97+
isActive: $isActiveRootFromShowingPatrolSummaryView) {
9398
EmptyView()
9499
}
100+
.isDetailLink(false)
95101
}
96102
.edgesIgnoringSafeArea(.all)
97103
.navigationBarItems(
@@ -247,7 +253,7 @@ struct PatrolBoatView: View {
247253
self.startDuty = startDuty
248254
self.plannedOffDutyTime = endDutyTime
249255
dutyReports = dutyReportsForCurrentUser(startDutyTime: startDuty.date, endDutyTime: endDutyTime)
250-
showingPatrolSummaryView = true
256+
isActiveRootFromShowingPatrolSummaryView = true
251257
}
252258

253259
/// Logic

o-fish-ios/Views/PatrolBoat/PatrolSummary/PatrolSummaryView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct PatrolSummaryView: View {
1414
@ObservedObject var startDuty: DutyChangeViewModel
1515
@ObservedObject var onDuty: DutyState
1616
@State var plannedOffDutyTime: Date
17+
@Binding var rootIsActive: Bool
1718

1819
@State private var showingBoardingRecordView = false
1920
@State private var selectedReport = ReportViewModel()
@@ -68,7 +69,10 @@ struct PatrolSummaryView: View {
6869
.compositingGroup()
6970
.bottomShadow()
7071

71-
NavigationLink(destination: BoardingRecordView(report: selectedReport, onDuty: onDuty), isActive: $showingBoardingRecordView) {
72+
NavigationLink(destination: BoardingRecordView(report: selectedReport,
73+
onDuty: onDuty,
74+
rootIsActive: $rootIsActive),
75+
isActive: $showingBoardingRecordView) {
7276
EmptyView()
7377
}
7478
}
@@ -103,6 +107,7 @@ struct PatrolSummaryView_Previews: PreviewProvider {
103107
PatrolSummaryView(dutyReports: [.sample, .sample, .sample],
104108
startDuty: .sample,
105109
onDuty: .sample,
106-
plannedOffDutyTime: Date())
110+
plannedOffDutyTime: Date(),
111+
rootIsActive: .constant(true))
107112
}
108113
}

o-fish-ios/Views/PreboardingFlow/PreboardingView/PreboardingLoadedStateView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct PreboardingLoadedStateView: View {
1111
@ObservedObject var onDuty: DutyState
1212
@Binding var storedReports: [ReportViewModel]
1313
@Binding var showingRecentBoardings: Bool
14+
@Binding var rootIsActive: Bool
1415

1516
@State private var showingReport: ReportViewModel = .sample
1617
@State private var showingLoadingVesselRecordsView = false
@@ -44,7 +45,7 @@ struct PreboardingLoadedStateView: View {
4445
}
4546
}
4647

47-
NavigationLink(destination: LoadingVesselRecordView(report: showingReport, onDuty: self.onDuty),
48+
NavigationLink(destination: LoadingVesselRecordView(report: showingReport, onDuty: self.onDuty, rootIsActive: $rootIsActive),
4849
isActive: $showingLoadingVesselRecordsView) {
4950
EmptyView()
5051
}
@@ -64,6 +65,7 @@ struct PreboardingLoadedStateView_Previews: PreviewProvider {
6465
PreboardingLoadedStateView(
6566
onDuty: DutyState.shared,
6667
storedReports: .constant([.sample, .sample]),
67-
showingRecentBoardings: .constant(true))
68+
showingRecentBoardings: .constant(true),
69+
rootIsActive: .constant(true))
6870
}
6971
}

o-fish-ios/Views/PreboardingFlow/PreboardingView/PreboardingView.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct PreboardingView: View {
1919

2020
var viewType: ViewType = .preboarding
2121
@ObservedObject var onDuty: DutyState
22+
@Binding var rootIsActive: Bool
2223

2324
@State private var searchText = ""
2425
@State private var showingDismissAlert = false
@@ -45,7 +46,7 @@ struct PreboardingView: View {
4546
searchBar
4647

4748
if showingAddVessel {
48-
NavigationLink(destination: ReportNavigationRootView()) {
49+
NavigationLink(destination: ReportNavigationRootView(rootIsActive: $rootIsActive)) {
4950
VStack(spacing: Dimension.noSpacing) {
5051
IconLabel(imagePath: "plus", title: "Add New Vessel")
5152
.padding(.vertical, Dimension.padding)
@@ -106,7 +107,8 @@ struct PreboardingView: View {
106107
return AnyView(PreboardingLoadedStateView(
107108
onDuty: onDuty,
108109
storedReports: $storedReports,
109-
showingRecentBoardings: $showingRecentBoardings)
110+
showingRecentBoardings: $showingRecentBoardings,
111+
rootIsActive: $rootIsActive)
110112
)
111113

112114
case .loading:
@@ -196,10 +198,12 @@ struct PreboardingView_Previews: PreviewProvider {
196198
static var previews: some View {
197199
VStack {
198200
PreboardingView(viewType: .preboarding,
199-
onDuty: .sample)
201+
onDuty: .sample,
202+
rootIsActive: .constant(true))
200203
Divider()
201204
PreboardingView(viewType: .searchRecords,
202-
onDuty: .sample)
205+
onDuty: .sample,
206+
rootIsActive: .constant(true))
203207
}
204208
}
205209
}

o-fish-ios/Views/PreboardingFlow/VesselRecordView/LoadingVesselRecordView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct LoadingVesselRecordView: View {
1313
@Environment(\.presentationMode) var presentationMode
1414
@ObservedObject var report: ReportViewModel
1515
@ObservedObject var onDuty: DutyState
16+
@Binding var rootIsActive: Bool
1617
@State private var storedReports: [ReportViewModel] = []
1718
@State private var loading = true
1819

@@ -23,7 +24,7 @@ struct LoadingVesselRecordView: View {
2324
if loading {
2425
LoadingIndicatorView(isAnimating: self.$loading, style: .large)
2526
} else {
26-
VesselRecordView(reports: storedReports, onDuty: onDuty)
27+
VesselRecordView(reports: storedReports, onDuty: onDuty, rootIsActive: $rootIsActive)
2728
}
2829
}
2930
.navigationBarTitle("Vessel", displayMode: .inline)
@@ -52,6 +53,7 @@ struct LoadingVesselRecordView: View {
5253
struct LoadingVesselRecordView_Previews: PreviewProvider {
5354
static var previews: some View {
5455
LoadingVesselRecordView(report: .sample,
55-
onDuty: .sample)
56+
onDuty: .sample,
57+
rootIsActive: .constant(true))
5658
}
5759
}

o-fish-ios/Views/PreboardingFlow/VesselRecordView/VesselRecordHeaderView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct VesselRecordHeaderView: View {
1414
var boardings: Int
1515
var warnings: Int
1616
var citations: Int
17+
@Binding var rootIsActive: Bool
1718

1819
@State private var vesselImages: [AnyView] = []
1920

@@ -51,7 +52,7 @@ struct VesselRecordHeaderView: View {
5152
}
5253
.padding(.horizontal, Dimensions.padding)
5354

54-
BoardVesselButton(onDuty: onDuty, report: report)
55+
BoardVesselButton(onDuty: onDuty, report: report, rootIsActive: $rootIsActive)
5556
}
5657
.onAppear(perform: onAppear)
5758
}
@@ -108,6 +109,7 @@ struct VesselRecordHeaderView_Previews: PreviewProvider {
108109
onDuty: .sample,
109110
boardings: 5,
110111
warnings: 0,
111-
citations: 2)
112+
citations: 2,
113+
rootIsActive: .constant(true))
112114
}
113115
}

o-fish-ios/Views/PreboardingFlow/VesselRecordView/VesselRecordView.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct VesselRecordView: View {
1111

1212
@State var reports: [ReportViewModel]
1313
@ObservedObject var onDuty: DutyState
14+
@Binding var rootIsActive: Bool
1415
@State private var showingBoardingRecordView = false
1516
@State private var selectedReport = ReportViewModel()
1617
@State private var stillLoading = true
@@ -55,7 +56,8 @@ struct VesselRecordView: View {
5556
onDuty: onDuty,
5657
boardings: numberOfBoardings,
5758
warnings: numberOfWarnings,
58-
citations: numberOfCitations)
59+
citations: numberOfCitations,
60+
rootIsActive: $rootIsActive)
5961
.background(Color.white)
6062
.compositingGroup()
6163
.defaultShadow()
@@ -83,7 +85,10 @@ struct VesselRecordView: View {
8385
}
8486

8587
//TODO Need to replace to ForEach. For now it's unexpected behavior with showing mapViewImage.
86-
NavigationLink(destination: BoardingRecordView(report: selectedReport, onDuty: onDuty), isActive: $showingBoardingRecordView) {
88+
NavigationLink(destination: BoardingRecordView(report: selectedReport,
89+
onDuty: onDuty,
90+
rootIsActive: $rootIsActive),
91+
isActive: $showingBoardingRecordView) {
8792
EmptyView()
8893
}
8994
}
@@ -102,7 +107,8 @@ struct VesselRecordView_Previews: PreviewProvider {
102107
static var previews: some View {
103108
NavigationView {
104109
VesselRecordView(reports: [.sample, .sample, .sample],
105-
onDuty: .sample)
110+
onDuty: .sample,
111+
rootIsActive: .constant(true))
106112
}
107113
}
108114
}

0 commit comments

Comments
 (0)