// // Content View.swift // Pickt // // Created by Morris Richman on 8/30/21. // import SwiftUI import Firebase //import FirebaseFirestore import Introspect import CoreLocation import ResponderChain import PopupView import CDYelpFusionKit import TMDb import SlideOverCard import LoaderUI import GoogleMobileAds import FirebaseCrashlytics import SwiftUIX struct ContentView: View { @State private var joiningParty = false @State private var code = "" @State private var textAlertMessage = "" @State private var textAlertFieldText = "" @State private var textAlertFieldPlaceholder = "" @State private var blank = "" @State private var enterLoc = false @State var joinText = "Joining Party" @State var createText = "Creating Party" @State private var search = false @State private var codeExists = false @State private var errorText = "" @State private var errorAlert = false @State private var joining = false @State private var creating = false @State private var name = "" @State var newPopup = false @State var newRefreshIndicator = false @State var whatsNew = Array<String>() { didSet { print("what's new array set, newRefreshIndicator = \(newRefreshIndicator)") newRefreshIndicator = false if !newPopup { newPopup = true } } } @State private var showCreating = false @State var join: Bool { didSet { print("Join party") } } @State var setBackground = true @State private var nameError = false @State private var joinDisabledAlert = false @State private var guide = false @State private var location = "" @Environment(\.horizontalSizeClass) var sizeClass @Environment(\.verticalSizeClass) var verticalSizeClass @State private var disabledAlert = false @State private var devTools = false @State var devToolsText = "" @State private var filter = "Dine in"//filterOpt.all @State private var cuisine = "All" @State private var price = "$$" @State var create: Bool @State var namePlaceholder = "" @State var whatsNewHeight: Double = 125 @State private var welcome = false @State private var showWelcomeAgain = true { didSet { Utilities.welcomePopup = showWelcomeAgain UserDefaults.standard.set(welcomePopup, forKey: "welcomePopup") } } @State private var noSwitch = false @State var rawPicktType = "Restaurants" @State var picktType = Utilities.picktTypeOpt.restaurants { didSet { Utilities.picktType = picktType setBackgroundImg() } } @State var showFinal = false @State var welcomePopup = UserDefaults.standard.bool(forKey: "welcomePopup") let popupColor = Color(red: 61/255, green: 90/255, blue: 128/255) let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String let build = Bundle.main.infoDictionary?["CFBundleVersion"] as! String @State var showPicker: Bool @State var switchEnabled = Utilities.switchEnabled @State private var updateApp = false @State var howTo = false @State var newListener = false @State var picktTypeOpt = ["Restaurants", "Entertainment"] @Binding var setMock: [Restaurants] { didSet { print("dataSet") // yes.restList.removeAll() joining = false print("searchRest = \(search)") print("mock = \(restMock)") search = true creating = false joining = false } } @State private var restMock = [Restaurants]() { didSet { print("dataSet") if showPicker == true || restMock != [] { yes.restList.removeAll() yes.mediaList.removeAll() no.restList.removeAll() no.mediaList.removeAll() joining = false print("searchRest = \(search)") print("mock = \(restMock)") search = true } } } @State private var mediaMock = [Media]() { didSet { yes.restList.removeAll() yes.mediaList.removeAll() no.restList.removeAll() no.mediaList.removeAll() print("dataSet") print("searchMedia = \(search)") print("mock = \(mediaMock)") if showPicker == true || mediaMock != [] { // yes.restList.removeAll() // yes.mediaList.removeAll() joining = false search = true } } } func checkForLinks() { // DispatchQueue.main.async { if create { print("creating") showCreating = true DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) { createText = "Still Creating Party" } }else { showCreating = false } if join { print("joining") if Utilities.code != "" { code = Utilities.code joinParty(enteredCode: Utilities.code, confirmName: true) }else { print("enter code") joiningParty = true } } // checkForLinks() // } } func getWhatsNew() { newListener = true db.collection("Utilities").document("Public Build").addSnapshotListener { doc, error in if error == nil { if doc != nil && doc!.exists { if let newArray = doc!.get("Whats New") as? Array<String> { if newListener != false { print("newArray = \(newArray)") if newArray == [] { whatsNew = ["Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "Etiam rutrum felis ac eros efficitur, non ornare enim porttitor.", "Donec lacus nibh, blandit id sapien eu, efficitur venenatis leo."] whatsNewHeight = Double(100 + (whatsNew.count * 55)) }else { whatsNew = newArray whatsNewHeight = Double(100 + (whatsNew.count * 55)) } print("what'sNewHeight = \(whatsNewHeight)") if whatsNewHeight > 350 { whatsNewHeight = 350 } UserDefaults.standard.set(Utilities.version, forKey: "version") } }else { whatsNew = ["Unable to load what's new"] whatsNewHeight = Double(250) UserDefaults.standard.set(Utilities.version, forKey: "version") } }else { whatsNew = ["Unable to load what's new"] whatsNewHeight = Double(250) UserDefaults.standard.set(Utilities.version, forKey: "version") } }else { whatsNew = ["Unable to load what's new"] whatsNewHeight = Double(250) UserDefaults.standard.set(Utilities.version, forKey: "version") } } } func checkWhatsNew() { print("Check for what's new") if UserDefaults.standard.double(forKey: "version") < Utilities.version! && UserDefaults.standard.double(forKey: "version") != 0 { self.getWhatsNew() }else { UserDefaults.standard.set(Utilities.version, forKey: "version") } } func checkWelcomePopup() { welcomePopup = Utilities.welcomePopup print("welcomePopup = \(welcomePopup)") if welcomePopup { welcome = true }else { welcome = false } print("switchEnabled = \(Utilities.switchEnabled)") } let db = Firestore.firestore() @State var backgroundImg = "food-1" func changeBackgroundImg() { Utilities.convertNSNumberToDouble(number: Utilities.remoteConfig["backgroundFrequency"].numberValue) { Double in DispatchQueue.main.asyncAfter(deadline: .now() + Double) { if picktType == .media { backgroundImg = "media-\(Int.random(in: 1...6))" }else { backgroundImg = "food-\(Int.random(in: 1...12))" } changeBackgroundImg() } } } func setBackgroundImg() { if picktType == .media { backgroundImg = "media-\(Int.random(in: 1...6))" }else { backgroundImg = "food-\(Int.random(in: 1...12))" } } func joinParty(enteredCode: String, confirmName: Bool) { joinText = "Joining Party" joining = true errorAlert = false print("Entered code = \(enteredCode)") Utilities.code = enteredCode print("Utilities.code = \(Utilities.code)") print("name = \(name)") // let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // name = "" // Utilities.name = "" // for _ in 0..<10 { // name.append(letters.randomElement()!) // } if !confirmName { UserDefaults.standard.setValue(name, forKey: "deviceName") Utilities.name = name if enteredCode.count == 6 { db.collection("parties").document(enteredCode).addSnapshotListener { document, error in //check for error if error == nil { //check if document exists if document != nil && document!.exists { if let DBfilter = document!.get("filter") as? String { print("filter = \(DBfilter)") filter = DBfilter Utilities.restFilter = DBfilter } if let DBtype = document!.get("type") as? String { print("type = \(DBtype)") if DBtype == "media" { picktType = .media Utilities.picktType = .media if filter == "TV Shows" { // if #available(iOS 15.0.0, *) { entertainment.searchTVShows { list in mediaMock = list } // } else { // // Fallback on earlier versions // noSwitch = true // } }else if filter == "Movies" { // if #available(iOS 15.0.0, *) { entertainment.searchMovies { list in mediaMock = list } // } else { // // Fallback on earlier versions // noSwitch = true // } } }else { picktType = .restaurants Utilities.picktType = .restaurants if let DBcuisine = document!.get("cuisine") as? String { cuisine = DBcuisine Utilities.cuisine = DBcuisine } if let DBprice = document!.get("price") as? String { price = DBprice Utilities.price = DBprice } // if let names = document!.get("devices") as? Array<String> { // if names.contains(name) { // textAlertMessage = "Please enter a different name to continue" // nameError = true // } // } if let latLong = document!.get("latLong") as? Bool { print("latLong = \(latLong)") if latLong { if let DBLat = document!.get("lat") as? Double { print("DBLat = \(DBLat)") if let DBLong = document!.get("long") as? Double { print("DBLong = \(DBLong)") var center : CLLocationCoordinate2D = CLLocationCoordinate2D() let ceo: CLGeocoder = CLGeocoder() center.latitude = DBLat center.longitude = DBLong let loc: CLLocation = CLLocation(latitude:center.latitude, longitude: center.longitude) ceo.reverseGeocodeLocation(loc, completionHandler: {(placemarks, error) in if (error != nil) { print("reverse geodcode fail: \(error!.localizedDescription)") } let pm = placemarks! as [CLPlacemark] if pm.count > 0 { let pm = placemarks![0] print(pm.country) print(pm.locality) print(pm.subLocality) print(pm.thoroughfare) print(pm.postalCode) print(pm.subThoroughfare) var addressString : String = "" if pm.subLocality != nil { addressString = addressString + pm.subLocality! + ", " } if pm.thoroughfare != nil { addressString = addressString + pm.thoroughfare! + ", " } if pm.locality != nil { addressString = addressString + pm.locality! + ", " } if pm.country != nil { addressString = addressString + pm.country! + ", " } if pm.postalCode != nil { addressString = addressString + pm.postalCode! + " " } searchYelp(loc: "\(addressString)", lat: DBLat, long: DBLong) } }) } } }else { if let loc = document!.get("loc") as? String { print("loc = \(loc)") searchYelp(loc: loc, lat: 0, long: 0) } } }else { if let loc = document!.get("loc") as? String { print("loc = \(loc)") searchYelp(loc: loc, lat: 0, long: 0) } } } } db.collection("parties").document(enteredCode).updateData(["devices" : FieldValue.arrayUnion(["\(name)"])]) }else { print("Show Error Alert with error \"Party not found, please enter a different code.\"") print("does not exist") errorText = "Party not found, please enter a different code." errorAlert = true joining = false } }else { print("Show Error Alert with error \"Party not found, please enter a different code.\"") print("does not exist") errorText = "Party not found, please enter a different code." errorAlert = true joining = false } } }else { print("Show Error Alert with error \"Incorrect number of characters, please make sure it is 6 characters.\"") errorText = "Incorrect number of characters, please make sure it is 6 characters." errorAlert = true joining = false } }else { print("No name found") print("Name Placeholder = \(namePlaceholder)") nameError = true } } func searchYelp(loc: String, lat: Double, long: Double) { print("searching") Utilities.location = loc Utilities.restFilter = filter Utilities.cuisine = cuisine let jsonDecoder = JSONDecoder() if loc == "friends" || loc == "family" || loc == "Family" || loc == "Friends" { restMock = Restaurants.viewModels }else { var finalCuisine = String() if cuisine == "All" { finalCuisine = "" }else { finalCuisine = "\(cuisine) food " } let searchTerm = "\(finalCuisine)\(filter) Restaurants" func handleResponse(businesses: [CDYelpBusiness]) { print("buisnesses = \(businesses)") var businessList: [Restaurants] = [] for buis in businesses { let finalAddress = buis.location!.displayAddress!.joined(separator: " ") print("Cats = \(buis.categories)") CDYelpFusionKitManager.checkType(of: buis.categories!) { cat in print("cat = \(cat)") print("\(Restaurants(name: buis.name!, imageUrl: buis.imageUrl ?? URL(string: Utilities.noImage)!, id: buis.id!, rating: buis.rating!, url: "\(buis.url!)", location: finalAddress, category: cat, tag: [], isClosed: buis.isClosed!, price: buis.price ?? "Unknown", reviewCount: buis.reviewCount!))") businessList.append(Restaurants(name: buis.name!, imageUrl: buis.imageUrl ?? URL(string: Utilities.noImage)!, id: buis.id!, rating: buis.rating!, url: "\(buis.url!)", location: finalAddress, category: cat, tag: [], isClosed: buis.isClosed!, price: buis.price ?? "Unknown", reviewCount: buis.reviewCount!)) if businessList.count == businesses.count { print("coninue") Utilities.restMock = businessList restMock = businessList } } } // print(businesses) } print("loc searchTerm = \(searchTerm)") print("Lat = \(lat), long = \(long)") if lat != 0 && long != 0 { print("search using LatLong") CDYelpFusionKitManager.shared.apiClient.searchBusinesses(byTerm: searchTerm, location: nil, latitude: lat, longitude: long, radius: nil, categories: nil, locale: .english_unitedStates, limit: 20, offset: 0, sortBy: CDYelpFusionKitManager.sortby, priceTiers: nil, openNow: nil, openAt: nil, attributes: nil) { response in if let response = response, let businesses = response.businesses, businesses.count > 0 { handleResponse(businesses: businesses) } } }else { print("search using location, loc = \(loc)") CDYelpFusionKitManager.shared.apiClient.searchBusinesses(byTerm: searchTerm, location: location, latitude: nil, longitude: nil, radius: nil, categories: nil, locale: .english_unitedStates, limit: 20, offset: 0, sortBy: CDYelpFusionKitManager.sortby, priceTiers: nil, openNow: nil, openAt: nil, attributes: nil) { response in if let response = response, let businesses = response.businesses, businesses.count > 0 { handleResponse(businesses: businesses) } } } } } var body: some View { NavigationView { Group { //For Added Alerts Group { //For Added Alerts VStack { Group { Text("Pickt") .font(.largeTitle) .foregroundColor(Color.black) .autoOpaqueBackground(color: .white) Group { if picktType == .restaurants { Text("For Restaurants") }else if picktType == .media { Text("For Entertainment") } } .foregroundColor(Color.black) .descreteOpaqueBackground(color: .white, diameter: 10) // HStack { // Image(systemName: "book.closed") // TextField("Enter Your Name", text: $name, onCommit: { // Utilities.name = name // UserDefaults.standard.setValue(name, forKey: "deviceName") // }) // .frame(maxWidth: 450, idealHeight: 35) // if !name.isEmpty { // Button(action: { // self.name = "" // }) { // Image(systemName: "xmark.circle") // .foregroundColor(Color.gray) // } // .padding(.trailing) // } // } // .padding(.horizontal) Group { Button(action: { creating = true showCreating = true creating = false }, label: { Image(systemName: "plus") Text("Create Party") // .font(.title) }) .autoOpaqueBackground(color: .white) Button(action: { if NetworkMonitor.shared.isConnected { disabledAlert = false Utilities.checkForUpdate { update in if update && !Utilities.ignoreUpdate { updateApp = true }else { if Utilities.joinDisabled == false { joiningParty = true }else { print("joinDisabled") joinDisabledAlert = true } } } }else { print("notConnected") disabledAlert = true } }, label: { Image(systemName: "arrowshape.turn.up.right") Text("Join Party") }) .autoOpaqueBackground(color: .white) // .alert(isPresented: $joinDisabledAlert, content: { // Alert(title: Text("Error"), message: Text("Joining a party is disabled at this time."), dismissButton: .default(Text("Ok"), action: { // joinDisabledAlert = false // })) // }) if Utilities.code == "" { Button(action: {}, label: { Image(systemName: "arrowshape.turn.up.left.2.fill") Text("Rejoin Party") }) .autoOpaqueBackground(color: .white) // .foregroundColor(.secondary) .foregroundColor(Color.gray) }else { Button(action: { if NetworkMonitor.shared.isConnected { disabledAlert = false if Utilities.joinDisabled == false { code = Utilities.code joinParty(enteredCode: Utilities.code, confirmName: true) }else { print("joinDisabled") joinDisabledAlert = true } }else { print("notConnected") disabledAlert = true } }, label: { Image(systemName: "arrowshape.turn.up.left.2.fill") Text("Rejoin Party") }) .autoOpaqueBackground(color: .white) } } // Button(action: { // // }, label: { // Text("Do it by myself") // }) // .padding() Group { if sizeClass == .compact { Button(action: { howTo = true }, label: { Image(systemName: "book.closed") Text("How To") }) }else { NavigationLink( destination: Guide(sender: .home), label: { Image(systemName: "book.closed") Text("How To") }) } } .autoOpaqueBackground(color: .white) // HStack { // Button(action: {howTo = true}, label: { // Image(systemName: "arrow.down") // Text("Dismiss") // }) // } // .foregroundColor(.blue) // .autoOpaqueBackground(color: .white) // if Utilities.appType == .Debug { // Button { // Utilities.fetchRemoteConfig() // } label: { // Text("Refresh") // .padding() // } // } Group { if creating { HStack(spacing: 5) { Text(createText) Loading(selectedType: .ballPulse, duration: 0.0) .frame(width: 20, height: 20) .padding(.top, 10) } } if joining { HStack(spacing: 5) { Text(joinText) Loading(selectedType: .ballPulse, duration: 0.0) .frame(width: 20, height: 20) .padding(.top, 10) } } } .autoOpaqueBackground(color: .white) } NavigationLink( destination: Thumbs(restData: restMock, mediaData: mediaMock, results: false, fullScreenAd: Interstitial()) // .environmentObject(firebaseRetrieve) .onDisappear(perform: { showFinal = Utilities.showFinal // creating = false // joining = false }), isActive: $search, label: { Text("Thumbs") }) .hidden() AlertControlView(textString: $name, showAlert: $nameError, textPlaceholder: .constant("Enter Your Name"), title: "Name", message: "Please enter your name to continue.", onDone: { enteredName in print("name = \(enteredName)") if enteredName != "" { name = enteredName UserDefaults.standard.setValue(name, forKey: "deviceName") joinParty(enteredCode: code, confirmName: false) DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) { joinText = "Still Joining Party" } }else { joinParty(enteredCode: code, confirmName: true) } }, onCancel: { nameError = false joining = false }) AlertControlView(textString: $blank, showAlert: $joiningParty, textPlaceholder: .constant("Enter The Party Code"), title: "Enter Code", message: "Enter the code you recieved to join a party", onDone: { enteredCode in code = enteredCode Utilities.code = enteredCode joinParty(enteredCode: enteredCode, confirmName: true) }, onCancel: { print("canceled") }) .sheet(isPresented: $showCreating, onDismiss: { switchEnabled = Utilities.switchEnabled print("switchEnabled = \(Utilities.switchEnabled)") showCreating = false name = Utilities.name DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { if Utilities.picktType == .media { mediaMock = Utilities.mediaMock }else { restMock = Utilities.restMock } Utilities.restMock = [] Utilities.mediaMock = [] } checkWhatsNew() }, content: { createParty() }) } .background ( Group { if picktType == .restaurants { Image(backgroundImg) .resizable() }else if picktType == .media { Image(backgroundImg) .resizable() } } .opacity(0.7) .ignoresSafeArea() .scaledToFill() ) .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 joiningParty = true })) }) .toolbar(content: { HStack { Button(action: { getWhatsNew() },label: { Image(systemName: "newspaper") Text("What's New") .minimumScaleFactor(0.6) }) .padding(.horizontal) .background(.white) .cornerRadius(10) .opacity(0.8) if switchEnabled { HStack { Image(systemName: "switch.2") .foregroundColor(.blue) if #available(iOS 15.0, *) { HStack { Text("Type: ") .minimumScaleFactor(0.6) Picker("", selection: $rawPicktType) { ForEach(picktTypeOpt, id: \.self) { type in Text(type) } } .pickerStyle(.menu) .minimumScaleFactor(0.6) .onChange(of: self.rawPicktType) { type in print("rawPicktType = \(type)") if type == "Entertainment" { picktType = .media }else { picktType = .restaurants } } } }else { Picker("Type: ", selection: $rawPicktType) { ForEach(picktTypeOpt, id: \.self) { type in Text(type) } } .minimumScaleFactor(0.6) .pickerStyle(.menu) .onChange(of: self.rawPicktType) { type in print("rawPicktType = \(type)") if type == "Entertainment" { picktType = .media }else { picktType = .restaurants } } } } .padding(.horizontal) .background(Color.white) .cornerRadius(5) .opacity(0.8) } } }) .alert(isPresented: $disabledAlert, content: { Alert(title: Text("Uh Oh"), message: Text("You aren't connected to the internet, please connect to use Pickt."), dismissButton: .default(Text("Ok"), action: { disabledAlert = false })) }) } // .alert(isPresented: $noSwitch, content: { // Alert(title: Text("OS Version"), message: Text("You must be on ios 15 or newer in order to use Pickt for Entertainment."), primaryButton: .default(Text("Update"), action: { // let url = NSURL(string:"App-prefs:root=General&path=SOFTWARE_UPDATE_LINK")! as URL // UIApplication.shared.open(url) // }), secondaryButton: .default(Text("Ok"), action: { // noSwitch = false // })) // }) } //Add Alerts here .alert(isPresented: $errorAlert, content: { Alert(title: Text("Error"), message: Text(errorText), dismissButton: .default(Text("Ok"), action: { errorAlert = false joining = false })) }) } .fullScreenCover(isPresented: $howTo, content: { Guide(sender: .home) }) .fullScreenCover(isPresented: $showFinal, onDismiss: { Utilities.showFinal = false showFinal = false }, content: { Final_Restaurant_View(restData: [], allRestData: [], mediaData: [], allMediaData: [], devices: [], refresh: true) }) .WelcomePopup(popupColor: .constant(popupColor), isShowing: $welcome, showWelcomeAgainButton: true, showWelcomeAgain: $showWelcomeAgain, onDismiss: { checkWelcomePopup() }) .popup(isPresented: $newPopup, type: .`default`, closeOnTap: false) { VStack(spacing: 10) { Text("What's New:") .font(.title2) .foregroundColor(.white) .fontWeight(.bold) if whatsNew != ["Unable to load what's new"] { ScrollView { Text("- " + whatsNew.joined(separator: "\n\n- ")) .multilineTextAlignment(.leading) .foregroundColor(Color(red: 0.9, green: 0.9, blue: 0.9)) } }else { Text("Unable to load what's new") .foregroundColor(Color(red: 0.9, green: 0.9, blue: 0.9)) Button(action: { newRefreshIndicator = true // getWhatsNew() }, label: { if !newRefreshIndicator { Image(systemName: "arrow.counterclockwise") }else { Loading(selectedType: .ballClipRotatePulse, duration: 1.5) .frame(width: 20, height: 20) } Text("Retry") .font(.system(size: 14)) .fontWeight(.bold) }) .foregroundColor(.black) .frame(width: 100, height: 40) .background(Color.white) .cornerRadius(20.0) } //Spacer() Button(action: { self.newListener = false self.newPopup = false }) { Text("Got it") .font(.system(size: 14)) .foregroundColor(.black) .fontWeight(.bold) } .frame(width: 100, height: 40) .background(Color.white) .cornerRadius(20.0) } .padding(EdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20)) .frame(width: 275, height: whatsNewHeight) .background(popupColor) .cornerRadius(10.0) .shadow(color: Color(.sRGBLinear, white: 0, opacity: 0.13), radius: 10.0) .onDisappear { UserDefaults.standard.set(Utilities.version, forKey: "version") } } .navigationTitle(!create ? "" : "Home") .navigationBarTitleDisplayMode(.inline) .navigationBarColor(.white) .navigationViewStyle(StackNavigationViewStyle()) .onAppear(perform: { createText = "Creating Party" joinText = "Joining Party" if !create && !join { checkWhatsNew() } changeBackgroundImg() Utilities.fetchRemoteConfig() picktType = Utilities.picktType UserDefaults.standard.set(UserDefaults.standard.integer(forKey: "homeOpenNum") + 1, forKey: "homeOpenNum") print("homeOpenNum = \(welcomePopup)") Messaging.messaging().token { token, error in if let error = error { print("Error fetching FCM registration token: \(error)") } else if let token = token { print("FCM registration token: \(token)") } } checkForLinks() name = Utilities.name if NetworkMonitor.shared.isConnected { print("checking for join") print("mock = \(restMock)") restMock = setMock if showPicker { // creating = true }else { creating = false } disabledAlert = false }else { print("Not Connected") disabledAlert = true } // switchEnabled = Utilities.remoteConfig["switchEnabled"].boolValue welcomePopup = Utilities.welcomePopup print("welcomePopup = \(welcomePopup)") DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(50)) { if welcomePopup { welcome = true }else { welcome = false } print("switchEnabled = \(Utilities.switchEnabled)") } }) } } struct Content_View_Previews: PreviewProvider { static var previews: some View { ContentView(join: false, create: false, showPicker: false, setMock: .constant([])) } }