Skip to content

Commit

Permalink
Cancel record should go back to home screen
Browse files Browse the repository at this point in the history
[-] Added transition to PatrolBoatView.
[-] Removed unused screens
  • Loading branch information
ArtemKutasevych committed Aug 10, 2020
1 parent fda6f6c commit f7bed5c
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 194 deletions.
16 changes: 0 additions & 16 deletions o-fish-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
BCE4814543022D42A642CA4A /* KeyboardController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE486CABA40FF0D6D14E5F9 /* KeyboardController.swift */; };
BCE4815F88C024AD476B8DE2 /* DutyState.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48D936613848423BBAF33 /* DutyState.swift */; };
BCE4817B0B89F5D95768925A /* CountryPickerView.swif.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE486BCBC428C8539A22A9D /* CountryPickerView.swif.swift */; };
BCE481FC2E1771F65073C0A6 /* ReportSummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE483CAE164B70D857A62B0 /* ReportSummaryView.swift */; };
BCE4820A7E5A15B8AA93DB4A /* TextPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48555D654177BE1259C7B /* TextPickerView.swift */; };
BCE4825F4A971D6F6F24D571 /* CatchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48E5B87FCD1126A5C26C4 /* CatchView.swift */; };
BCE48275C134A902EF0293D4 /* GlassIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48B8D8932DF568200B811 /* GlassIconView.swift */; };
Expand Down Expand Up @@ -249,7 +248,6 @@
BCE48B02D6D3331545500562 /* ChooseSpeciesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48FAB856639D53CABC76C /* ChooseSpeciesView.swift */; };
BCE48B088018D82ECFC5F7A9 /* MultiRowPickerWithButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE4817C8B123F01E50A23D9 /* MultiRowPickerWithButton.swift */; };
BCE48B09547E88D2E76107BB /* Collection+EnumeratedArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48EFBBE1997660C4F1EE6 /* Collection+EnumeratedArray.swift */; };
BCE48B31FB9BEA734058DAA9 /* ReportListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48A5038A2E43FE839DC80 /* ReportListView.swift */; };
BCE48B41FAB47CB8B9B0AE61 /* SearchBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48D44A5E464AA9AC620E8 /* SearchBarView.swift */; };
BCE48B59A51E4AF79D2FAEE1 /* TextLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE4871B39646A85F047F256 /* TextLabel.swift */; };
BCE48B9CAD5B8F1EB27C60BD /* ChooseEMSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCE48E42E19241E2A8EC419F /* ChooseEMSView.swift */; };
Expand Down Expand Up @@ -491,7 +489,6 @@
BCE482F2C7BF11E33FA5E862 /* StartStopDatePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartStopDatePicker.swift; sourceTree = "<group>"; };
BCE483315BCBE777464D2FF4 /* ViolationPickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViolationPickerView.swift; sourceTree = "<group>"; };
BCE483BB45A7BCD0ADC62551 /* PopoverManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverManager.swift; sourceTree = "<group>"; };
BCE483CAE164B70D857A62B0 /* ReportSummaryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportSummaryView.swift; sourceTree = "<group>"; };
BCE48456167E25D77C838694 /* CrewMemberShortView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrewMemberShortView.swift; sourceTree = "<group>"; };
BCE484CE2776AE6F4E5A5791 /* ChooseBusinessView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseBusinessView.swift; sourceTree = "<group>"; };
BCE484E6974BBB4F08413A3E /* InputField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputField.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -531,7 +528,6 @@
BCE489F610C0078AE3ED2944 /* TopTabBarContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TopTabBarContainerView.swift; sourceTree = "<group>"; };
BCE489F75FEB031E1F2AAC20 /* ScrollableTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollableTabBar.swift; sourceTree = "<group>"; };
BCE489FD715E47C868F5D581 /* PatrolSummaryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatrolSummaryView.swift; sourceTree = "<group>"; };
BCE48A5038A2E43FE839DC80 /* ReportListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReportListView.swift; sourceTree = "<group>"; };
BCE48AB036DA398FBFF3E3B4 /* SectionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionButton.swift; sourceTree = "<group>"; };
BCE48AB83BB50A193A6B4113 /* CallToActionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallToActionButton.swift; sourceTree = "<group>"; };
BCE48AF913D1F963F18F6FAF /* KeyboardControllingScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardControllingScrollView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -807,7 +803,6 @@
493CDFB923FEB86D00516048 /* LoginView.swift */,
3013CA782424AF1300D2FF60 /* PatrolBoat */,
BCE483F917662257CAB7586F /* ReportFlow */,
BCE48B378C5953371739F735 /* ReportList */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -1196,15 +1191,6 @@
path = Country;
sourceTree = "<group>";
};
BCE48B378C5953371739F735 /* ReportList */ = {
isa = PBXGroup;
children = (
BCE48A5038A2E43FE839DC80 /* ReportListView.swift */,
BCE483CAE164B70D857A62B0 /* ReportSummaryView.swift */,
);
path = ReportList;
sourceTree = "<group>";
};
BCE48B73700857DD26654AED /* Popover */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1711,9 +1697,7 @@
3013CA802424B07300D2FF60 /* TextToggle.swift in Sources */,
BCE48BFCEE413835DEB14DC0 /* RowView.swift in Sources */,
BCE48B59A51E4AF79D2FAEE1 /* TextLabel.swift in Sources */,
BCE48B31FB9BEA734058DAA9 /* ReportListView.swift in Sources */,
49B83EDB2489546D00027B8C /* SafetyLevel.swift in Sources */,
BCE481FC2E1771F65073C0A6 /* ReportSummaryView.swift in Sources */,
BCE4856F6CE56291D9BCB13E /* VesselView.swift in Sources */,
BCE483F97684587434E8421E /* ReportNavigationRootView.swift in Sources */,
BCE482FC535CCA17C9D9F30A /* EMSInputView.swift in Sources */,
Expand Down
7 changes: 5 additions & 2 deletions o-fish-ios/Views/Components/BoardVesselButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct BoardVesselButton: View {
@ObservedObject var onDuty: DutyState
var report = ReportViewModel()
var onHeader = true
@Binding var rootIsActive: Bool

@State private var showingReportRootView = false
@State private var showingGoOnDutyAlert = false
Expand Down Expand Up @@ -49,7 +50,8 @@ struct BoardVesselButton: View {
}

NavigationLink(destination: ReportNavigationRootView(report: prefilledReport,
prefilledVesselAvailable: true),
prefilledVesselAvailable: true,
rootIsActive: $rootIsActive),
isActive: $showingReportRootView) {
EmptyView()
}
Expand All @@ -69,6 +71,7 @@ struct BoardVesselButton: View {

struct BoardVesselButton_Previews: PreviewProvider {
static var previews: some View {
BoardVesselButton(onDuty: .sample)
BoardVesselButton(onDuty: .sample,
rootIsActive: .constant(true))
}
}
42 changes: 24 additions & 18 deletions o-fish-ios/Views/PatrolBoat/PatrolBoatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ struct PatrolBoatView: View {
var isLoggedIn: Binding<Bool>

@State private var location = LocationViewModel(LocationHelper.currentLocation)
@State private var showingPreboardingView = false
@State private var showingSearchView = false
@State private var showingPatrolSummaryView = false
@State private var isActiveRootFromPreboardingView = false
@State private var isActiveRootFromSearchView = false
@State private var isActiveRootFromShowingPatrolSummaryView = false
@State private var resetLocation = {}

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

NavigationLink(destination: PreboardingView(viewType: .searchRecords,
onDuty: onDuty,
rootIsActive: $isActiveRootFromSearchView),
isActive: $isActiveRootFromSearchView) {
EmptyView()
}
.isDetailLink(false)

ZStack(alignment: .bottom) {
MapComponentView(location: self.$location,
reset: self.$resetLocation,
Expand All @@ -62,7 +70,7 @@ struct PatrolBoatView: View {
Spacer()
BoardButtonView {
if self.onDuty.onDuty {
self.showingPreboardingView.toggle()
self.isActiveRootFromPreboardingView.toggle()
} else {
self.showGoOnDutyAlert()
}
Expand All @@ -71,27 +79,25 @@ struct PatrolBoatView: View {
.padding(.horizontal, Dimensions.allCoordPadding)

NavigationLink(
destination: PreboardingView(viewType: .preboarding, onDuty: onDuty),
isActive: self.$showingPreboardingView) {
EmptyView()
destination: PreboardingView(viewType: .preboarding,
onDuty: onDuty,
rootIsActive: $isActiveRootFromPreboardingView),
isActive: self.$isActiveRootFromPreboardingView) {
EmptyView()
}
}

NavigationLink(destination: PreboardingView(viewType: .searchRecords,
onDuty: onDuty),
isActive: self.$showingSearchView) {
EmptyView()
.isDetailLink(false)
}

NavigationLink(destination:
PatrolSummaryView(dutyReports: dutyReports,
startDuty: startDuty,
onDuty: onDuty,
plannedOffDutyTime: plannedOffDutyTime),

isActive: self.$showingPatrolSummaryView) {
plannedOffDutyTime: plannedOffDutyTime,
rootIsActive: $isActiveRootFromShowingPatrolSummaryView),
isActive: $isActiveRootFromShowingPatrolSummaryView) {
EmptyView()
}
.isDetailLink(false)
}
.edgesIgnoringSafeArea(.all)
.navigationBarItems(
Expand Down Expand Up @@ -247,7 +253,7 @@ struct PatrolBoatView: View {
self.startDuty = startDuty
self.plannedOffDutyTime = endDutyTime
dutyReports = dutyReportsForCurrentUser(startDutyTime: startDuty.date, endDutyTime: endDutyTime)
showingPatrolSummaryView = true
isActiveRootFromShowingPatrolSummaryView = true
}

/// Logic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct PatrolSummaryView: View {
@ObservedObject var startDuty: DutyChangeViewModel
@ObservedObject var onDuty: DutyState
@State var plannedOffDutyTime: Date
@Binding var rootIsActive: Bool

@State private var showingBoardingRecordView = false
@State private var selectedReport = ReportViewModel()
Expand Down Expand Up @@ -68,7 +69,10 @@ struct PatrolSummaryView: View {
.compositingGroup()
.bottomShadow()

NavigationLink(destination: BoardingRecordView(report: selectedReport, onDuty: onDuty), isActive: $showingBoardingRecordView) {
NavigationLink(destination: BoardingRecordView(report: selectedReport,
onDuty: onDuty,
rootIsActive: $rootIsActive),
isActive: $showingBoardingRecordView) {
EmptyView()
}
}
Expand Down Expand Up @@ -103,6 +107,7 @@ struct PatrolSummaryView_Previews: PreviewProvider {
PatrolSummaryView(dutyReports: [.sample, .sample, .sample],
startDuty: .sample,
onDuty: .sample,
plannedOffDutyTime: Date())
plannedOffDutyTime: Date(),
rootIsActive: .constant(true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct PreboardingLoadedStateView: View {
@ObservedObject var onDuty: DutyState
@Binding var storedReports: [ReportViewModel]
@Binding var showingRecentBoardings: Bool
@Binding var rootIsActive: Bool

@State private var showingReport: ReportViewModel = .sample
@State private var showingLoadingVesselRecordsView = false
Expand Down Expand Up @@ -44,7 +45,7 @@ struct PreboardingLoadedStateView: View {
}
}

NavigationLink(destination: LoadingVesselRecordView(report: showingReport, onDuty: self.onDuty),
NavigationLink(destination: LoadingVesselRecordView(report: showingReport, onDuty: self.onDuty, rootIsActive: $rootIsActive),
isActive: $showingLoadingVesselRecordsView) {
EmptyView()
}
Expand All @@ -64,6 +65,7 @@ struct PreboardingLoadedStateView_Previews: PreviewProvider {
PreboardingLoadedStateView(
onDuty: DutyState.shared,
storedReports: .constant([.sample, .sample]),
showingRecentBoardings: .constant(true))
showingRecentBoardings: .constant(true),
rootIsActive: .constant(true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct PreboardingView: View {

var viewType: ViewType = .preboarding
@ObservedObject var onDuty: DutyState
@Binding var rootIsActive: Bool

@State private var searchText = ""
@State private var showingDismissAlert = false
Expand All @@ -45,7 +46,7 @@ struct PreboardingView: View {
searchBar

if showingAddVessel {
NavigationLink(destination: ReportNavigationRootView()) {
NavigationLink(destination: ReportNavigationRootView(rootIsActive: $rootIsActive)) {
VStack(spacing: Dimension.noSpacing) {
IconLabel(imagePath: "plus", title: "Add New Vessel")
.padding(.vertical, Dimension.padding)
Expand Down Expand Up @@ -106,7 +107,8 @@ struct PreboardingView: View {
return AnyView(PreboardingLoadedStateView(
onDuty: onDuty,
storedReports: $storedReports,
showingRecentBoardings: $showingRecentBoardings)
showingRecentBoardings: $showingRecentBoardings,
rootIsActive: $rootIsActive)
)

case .loading:
Expand Down Expand Up @@ -196,10 +198,12 @@ struct PreboardingView_Previews: PreviewProvider {
static var previews: some View {
VStack {
PreboardingView(viewType: .preboarding,
onDuty: .sample)
onDuty: .sample,
rootIsActive: .constant(true))
Divider()
PreboardingView(viewType: .searchRecords,
onDuty: .sample)
onDuty: .sample,
rootIsActive: .constant(true))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct LoadingVesselRecordView: View {
@Environment(\.presentationMode) var presentationMode
@ObservedObject var report: ReportViewModel
@ObservedObject var onDuty: DutyState
@Binding var rootIsActive: Bool
@State private var storedReports: [ReportViewModel] = []
@State private var loading = true

Expand All @@ -23,7 +24,7 @@ struct LoadingVesselRecordView: View {
if loading {
LoadingIndicatorView(isAnimating: self.$loading, style: .large)
} else {
VesselRecordView(reports: storedReports, onDuty: onDuty)
VesselRecordView(reports: storedReports, onDuty: onDuty, rootIsActive: $rootIsActive)
}
}
.navigationBarTitle("Vessel", displayMode: .inline)
Expand Down Expand Up @@ -52,6 +53,7 @@ struct LoadingVesselRecordView: View {
struct LoadingVesselRecordView_Previews: PreviewProvider {
static var previews: some View {
LoadingVesselRecordView(report: .sample,
onDuty: .sample)
onDuty: .sample,
rootIsActive: .constant(true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct VesselRecordHeaderView: View {
var boardings: Int
var warnings: Int
var citations: Int
@Binding var rootIsActive: Bool

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

Expand Down Expand Up @@ -51,7 +52,7 @@ struct VesselRecordHeaderView: View {
}
.padding(.horizontal, Dimensions.padding)

BoardVesselButton(onDuty: onDuty, report: report)
BoardVesselButton(onDuty: onDuty, report: report, rootIsActive: $rootIsActive)
}
.onAppear(perform: onAppear)
}
Expand Down Expand Up @@ -108,6 +109,7 @@ struct VesselRecordHeaderView_Previews: PreviewProvider {
onDuty: .sample,
boardings: 5,
warnings: 0,
citations: 2)
citations: 2,
rootIsActive: .constant(true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct VesselRecordView: View {

@State var reports: [ReportViewModel]
@ObservedObject var onDuty: DutyState
@Binding var rootIsActive: Bool
@State private var showingBoardingRecordView = false
@State private var selectedReport = ReportViewModel()
@State private var stillLoading = true
Expand Down Expand Up @@ -55,7 +56,8 @@ struct VesselRecordView: View {
onDuty: onDuty,
boardings: numberOfBoardings,
warnings: numberOfWarnings,
citations: numberOfCitations)
citations: numberOfCitations,
rootIsActive: $rootIsActive)
.background(Color.white)
.compositingGroup()
.defaultShadow()
Expand Down Expand Up @@ -83,7 +85,10 @@ struct VesselRecordView: View {
}

//TODO Need to replace to ForEach. For now it's unexpected behavior with showing mapViewImage.
NavigationLink(destination: BoardingRecordView(report: selectedReport, onDuty: onDuty), isActive: $showingBoardingRecordView) {
NavigationLink(destination: BoardingRecordView(report: selectedReport,
onDuty: onDuty,
rootIsActive: $rootIsActive),
isActive: $showingBoardingRecordView) {
EmptyView()
}
}
Expand All @@ -102,7 +107,8 @@ struct VesselRecordView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
VesselRecordView(reports: [.sample, .sample, .sample],
onDuty: .sample)
onDuty: .sample,
rootIsActive: .constant(true))
}
}
}
Loading

0 comments on commit f7bed5c

Please sign in to comment.