Post

Replies

Boosts

Views

Activity

Reply to List and MysqlDB
I have a View called "HomeUser" in which I have an "if statement" that checks the email ... if the email is equal to "email@email.com" then call barberview passing f as parameter. HomeUser.swift: import SwiftUI struct HomeUser: View {     @State var barberid:Int = 0     @Binding var email: String     @State var flagView = false     var dateFormatter: DateFormatter {             let formatter = DateFormatter()         formatter.dateFormat = "dd\\\\MM\\\\yyyy"         formatter.locale = Locale(identifier: "it_IT")             return formatter         }         @State private var date = Date()     @State var valore:String = ""               @State public var f = ""               var body: some View {         NavigationView{             VStack{                 Spacer()                                  if email == "Marcomeola@gmail.com" {                                          DatePicker("SELEZIONA LA DATA", selection: $date, displayedComponents: .date)                                     .datePickerStyle(GraphicalDatePickerStyle())                                     .frame(maxHeight: 400)                                          var formatter = dateFormatter.string(from: date)                                                                                   NavigationLink(                         destination: BarberView(f: $f), isActive: $flagView,                         label:{                             Button(action: {                                 f = formatter                                                                  flagView = true                             }, label: {                                 Text("MOSTRA")                             })                         })                                                                                                                          }else{                     NavigationLink(                         destination: PrenotazioneView(barberid: $barberid, email:$email), isActive: $flagView,                         label:{                             Button(action: {                                 barberid = 1                                 print("hai cliccato marco ID: \(barberid)")                                 flagView = true                             }, label: {                                 Image("card_marco")                                     .resizable()                                     .frame(width: 400.0, height: 250)                             })                         })                     NavigationLink(                         destination: PrenotazioneView(barberid: $barberid, email:$email), isActive: $flagView,                         label:{                             Button(action: {                                 barberid = 2                                 print("hai cliccato peppe ID: \(barberid)")                                 flagView = true                             }, label: {                                 Image("card_peppe")                                     .resizable()                                     .frame(width: 400.0, height: 250)                             })                         })                 }                 Spacer()             }.background(                 Image("sfondo")                     .resizable()                     .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)                     .edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)                 )         }.navigationBarHidden(true)     } } func showappointment(format:String) -> String{     // inizializzo semaforo     let semaphore = DispatchSemaphore(value: 0)     var responseString = ""            let request = NSMutableURLRequest(url: NSURL(string: "http://familyverde.ddns.net/prova/showappoointment.php")! as URL)            request.httpMethod = "POST"                        let postString = "data=\(format)"            request.httpBody = postString.data(using: String.Encoding.utf8)                 let task = URLSession.shared.dataTask(with: request as URLRequest) {                data, response, error in                                if error != nil {                    print("error=\(error)")                                     return                }else{                 print("response = \(response)")                                  responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue) as! String                 print("responseString = \(responseString)")                                                                                    // tolgo semaforo                 semaphore.signal()                                                  }            }            task.resume()          // attivo semaforo     _ = semaphore.wait(timeout: .distantFuture)     print("VALORE: \(responseString)")     return responseString }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’21
Reply to List and MysqlDB
I have a HomeUser to which I apply an "if" ... "if email == email@email.it" then I call BarberView passing as argument "f" ... BarberView will have to show me a List containing the lines of the result of the query shown above
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20