Created
September 3, 2020 00:05
-
-
Save Samywamy10/6aba259f6567a7378c66bdd35e7c227e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct FacilitiesView: CICView { | |
| @StateObject var viewModel = FacilitiesViewModel() | |
| @EnvironmentObject var userDetails: UserDetails | |
| @State var showModal = false | |
| @State var shownModal = 0 | |
| @Namespace private var facilitiesViewNamespace | |
| var body: some View { | |
| NavigationView { | |
| VStack { | |
| ZStack { | |
| if !self.showModal { | |
| ScrollView { | |
| FacilitiesLoop(facilitiesToDisplay: viewModel.facilitiesToDisplay, showModal: $showModal, shownModal: $shownModal, animationNamespace: facilitiesViewNamespace) | |
| } | |
| } else { | |
| FacilityView(facility: viewModel.facilitiesToDisplay[shownModal], animationNamespace: facilitiesViewNamespace) | |
| .onTapGesture { | |
| withAnimation(.spring()) { | |
| self.showModal.toggle() | |
| } | |
| } | |
| .hiddenNavigationBarStyle() | |
| .edgesIgnoringSafeArea(.top) | |
| } | |
| } | |
| .background(CustomColors.ItemList) | |
| .navigationBarTitle("Facilities", displayMode: .large) | |
| .navigationBarTitle("Facilities") | |
| .navigationBarItems(trailing: Menu("Filter") { | |
| ForEach(FacilityType.allCases) { facilityType in | |
| Button(action: {viewModel.selectedFacilityType = facilityType}) { | |
| HStack { | |
| Text(facilityType.description) | |
| Spacer() | |
| if viewModel.selectedFacilityType == facilityType { | |
| Image(systemName: "checkmark") | |
| } | |
| } | |
| } | |
| } | |
| }) | |
| .onChange(of: self.userDetails.homeCIC) { homeCIC in | |
| self.viewModel.changeCIC(parentGroup: homeCIC!.description) | |
| } | |
| .onAppear { | |
| self.viewModel.onScreenAppear(parentGroup: self.userDetails.homeCIC!.description) | |
| } | |
| .onDisappear { | |
| self.viewModel.onScreenDissapear() | |
| } | |
| }.navigationViewStyle(StackNavigationViewStyle()) | |
| } | |
| .navigationViewStyle(StackNavigationViewStyle()) | |
| .onChange(of: self.userDetails.homeCIC) { homeCIC in | |
| self.viewModel.changeCIC(parentGroup: homeCIC!.description) | |
| } | |
| .onAppear { | |
| self.viewModel.onScreenAppear(parentGroup: self.userDetails.homeCIC!.description) | |
| } | |
| .onDisappear { | |
| self.viewModel.onScreenDissapear() | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment