var body: some View { NavigationView { VStack { Text("Create Party") .font(.largeTitle) .padding(.bottom) if Utilities.picktType == .media { Text("Please Note: This search has no filter and will show a range of content.") .font(.footnote) .padding(.horizontal) }else { Text("Please Note: Restaurants are shown in order of distance among other things, filters may work in certain places better than others.") .font(.footnote) .padding(.horizontal) } VStack { HStack { Group { Image(systemName: "book.closed") TextField("Enter Your Name", text: $name, onCommit: { Utilities.name = name UserDefaults.standard.setValue(name, forKey: "deviceName") }) .frame(minHeight: 35) if !name.isEmpty { Button(action: { self.name = "" }) { Image(systemName: "xmark.circle") .foregroundColor(Color.gray) } .padding(.trailing) } } .padding([.top, .leading, .bottom], 5.0) } .background(Color.gray.opacity(0.3)) .clipShape(RoundedRectangle(cornerRadius: 15)) .padding([.top, .horizontal]) if picktType == .media { HStack { if #available(iOS 15, *) { Text("Media Type: ") .lineLimit(2) // .padding(.trailing) Picker("", selection: $mediaType) { ForEach(mediaOpt, id: \.self) { Text($0) } } }else { Picker("Media Type: ", selection: $mediaType) { ForEach(mediaOpt, id: \.self) { Text($0) } } } } .padding(.horizontal) .pickerStyle(.menu) }else { HStack { Group { Image(systemName: "magnifyingglass") TextField("Enter Location", text: $location, onCommit: { print("locIf = \(locIf), loc = \(location)") if locIf.contains(location.lowercased()) { Utilities.latLong = true }else { Utilities.latLong = false } }) .frame(minHeight: 35) .minimumScaleFactor(0.6) if !location.isEmpty { Button(action: { self.location = "" }) { Image(systemName: "xmark.circle") .foregroundColor(Color.gray) } } if devToolsIf.contains(location) { Button { location = "" } label: { Image(systemName: "server.rack") } } if shareIf.contains(location.lowercased()) { Button { location = "" } label: { Image(systemName: "square.and.arrow.up.fill") } } if helpIf.contains(location) { Button { location = "" } label: { Image(systemName: "questionmark.circle.fill") } } if Utilities.currentLocationEnabled { Button(action: { if location == "Current Location" { location = "" Utilities.latLong = false }else { locManager.requestWhenInUseAuthorization() print("locManager authStatus = \(locManager.authorizationStatus)") if locManager.authorizationStatus == .denied { allowLocation = true } // if locManager.authorizationStatus == .authorizedWhenInUse || locManager.authorizationStatus == .authorizedAlways { location = "Current Location" Utilities.latLong = true // }else { // allowLocation = true // } } }, label: { if locIf.contains(location) { Image(systemName: "location.fill") }else { Image(systemName: "location") } }) .padding(.trailing) } } .padding([.top, .leading, .bottom], 5.0) } .background(Color.gray.opacity(0.3)) .clipShape(RoundedRectangle(cornerRadius: 15)) .padding([.bottom, .horizontal]) Group { if horizantalSizeClass == .regular { HStack { if #available(iOS 15, *) { Text("Restaurant Filter: ") .lineLimit(2) // .padding(.trailing) Picker("", selection: $filter) { ForEach(filterOpt, id: \.self) { Text($0) } } Spacer() .frame(width: 30) Text("Cuisine: ") // .padding(.trailing) Picker("", selection: $cuisine) { Section { ForEach(nonCuisineOpt, id: \.self) { Text($0) } } Section { ForEach(desertOpt.sorted(), id: \.self) { Text($0) } } Section { ForEach(cuisineOpt.sorted(), id: \.self) { Text($0) } } } // Spacer() // .frame(width: 30) // HStack { // Text("Price: ") // // .padding(.trailing) // Picker("", selection: $price) { // ForEach(priceOpt.sorted(), id: \.self) { // Text($0) // } // } // } }else { Picker("Restaurant Filter", selection: $filter) { ForEach(filterOpt, id: \.self) { Text($0) } } Spacer() .frame(width: 30) Picker("Cuisine", selection: $cuisine) { Section { ForEach(nonCuisineOpt, id: \.self) { Text($0) } } Section { ForEach(desertOpt.sorted().reversed(), id: \.self) { Text($0) } } Section { ForEach(cuisineOpt.sorted(), id: \.self) { Text($0) } } } // Spacer() // .frame(width: 30) // Picker("Price", selection: $price) { // ForEach(priceOpt.sorted(), id: \.self) { // Text($0) // } // } } } }else { VStack { if #available(iOS 15, *) { HStack { Text("Restaurant Filter: ") .lineLimit(2) // .padding(.trailing) Picker("", selection: $filter) { ForEach(filterOpt, id: \.self) { Text($0) } } } HStack { Text("Cuisine: ") // .padding(.trailing) Picker("", selection: $cuisine) { Section { ForEach(cuisineOpt.sorted().reversed(), id: \.self) { Text($0) } } Section { ForEach(desertOpt.sorted().reversed(), id: \.self) { Text($0) } } Section { ForEach(nonCuisineOpt.reversed(), id: \.self) { Text($0) } } } } // HStack { // Text("Price: ") // // .padding(.trailing) // Picker("", selection: $price) { // ForEach(priceOpt.sorted(), id: \.self) { // Text($0) // } // } // } }else { Picker("Restaurant Filter", selection: $filter) { ForEach(filterOpt, id: \.self) { Text($0) } } Picker("Cuisine", selection: $cuisine) { Section { ForEach(cuisineOpt.sorted().reversed(), id: \.self) { Text($0) } } Section { ForEach(desertOpt.sorted().reversed(), id: \.self) { Text($0) } } Section { ForEach(nonCuisineOpt.reversed(), id: \.self) { Text($0) } } } // Picker("Price", selection: $price) { // ForEach(priceOpt.sorted(), id: \.self) { // Text($0) // } // } } } } } .padding(.horizontal) .pickerStyle(.menu) } HStack { Button("Done") { if locIf.contains(location) { Utilities.latLong = true }else { Utilities.latLong = false } print("done") Utilities.checkForUpdate { update in print("update = \(update)") if update && !Utilities.ignoreUpdate { updateApp = true }else { create() } } } Spacer() .frame(width: 40) Button("Cancel") { print("Cancel") presentationMode.wrappedValue.dismiss() } } .padding() } if creating { Text("Creating Party...") .padding(.top) } AlertControlView(textString: $blank, showAlert: $enterLoc, textPlaceholder: $textAlertFieldPlaceholder, title: "Error", message: "Please enter location to continue.", onDone: { loc in location = loc create() }, onCancel: { enterLoc = false creating = false }) } .fullScreenCover(isPresented: $startPicker, content: { ContentView(join: false, create: false, showPicker: true, setMock: $restMock) }) .sheet(isPresented: $howTo, content: { Guide(sender: .create) }) .toolbar { Group { if horizantalSizeClass == .compact { Button(action: {howTo = true}, label: { Image(systemName: "book.closed") Text("How To") }) }else { NavigationLink( destination: Guide(sender: .create), label: { Image(systemName: "book.closed") Text("How To") }) } } } .alert(isPresented: $disabledAlert, content: { Alert(title: Text("Network Error"), message: Text("You aren't connected to the internet, please connect to use Pickt."), dismissButton: .default(Text("Ok"), action: { disabledAlert = false presentationMode.wrappedValue.dismiss() })) }) .alert(isPresented: $devTools, content: { Alert(title: Text("DevTools"), message: Text(devToolsText), dismissButton: .default(Text("Done"), action: { devTools = false })) }) .alert(isPresented: $allowLocation, content: { Alert(title: Text("Uh Oh"), message: Text("We're not able to find your location, please open settings to enable it."), primaryButton: .destructive(Text("Cancel"), action: { creating = false allowLocation = false }), secondaryButton: .default(Text("Open Settings"), action: { creating = false allowLocation = false if let appSettings = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(appSettings) } })) }) .alert(isPresented: $codeExists, content: { Alert(title: Text("Error"), message: Text("Please try again"), dismissButton: .default(Text("Ok"), action: { codeExists = false creating = false })) }) .alert(isPresented: $updateApp, content: { Alert(title: Text("Warning!"), message: Text("Pickt is not up to date, some things may not work if you are on different versions of Pickt."), primaryButton: .default(Text("Update"), action: { print("update, type = \(Utilities.appType)") if Utilities.appType == .TestFlight { print("opening testflight") if let url = URL(string: "itms-beta://") { UIApplication.shared.open(url) } }else { print("opening app store") if let url = URL(string: "https://apps.apple.com/us/app/pickt/id1584491007") { UIApplication.shared.open(url) } } updateApp = false }), secondaryButton: .destructive(Text("Ignore"), action: { Utilities.ignoreUpdate = true updateApp = false create() })) }) } .padding(.bottom) .onAppear { if Utilities.picktType == .media { picktType = .media }else { picktType = .restaurants } if let dineIn = Utilities.remoteConfig["dineIn"].stringValue { if let takeout = Utilities.remoteConfig["takeout"].stringValue { if let foodTrucks = Utilities.remoteConfig["foodTrucks"].stringValue { print("dineIn = \(dineIn), takeout = \(takeout), foodTrucks = \(foodTrucks)") filterOpt = [dineIn, takeout, foodTrucks] filter = dineIn } } } name = UserDefaults.standard.string(forKey: "deviceName") ?? "" if NetworkMonitor.shared.isConnected { disabledAlert = false }else { disabledAlert = true } if Utilities.latLong { location = "Current Location" }else { location = Utilities.location } } .navigationViewStyle(StackNavigationViewStyle()) }