Post

Replies

Boosts

Views

Activity

SWIFTU UI - Graph package similar to Neo4J GUI
Is there a good library / opensource package for Graph library similar to Neo4J GUI (pl.see attached) I tried few of the below, looking for something better https://medium.com/better-programming/building-a-graph-with-swiftui-b16dc48f7fe6 https://github.com/palle-k/Graphite
Topic: UI Frameworks SubTopic: SwiftUI
1
0
95
Aug ’25
SWIFTUI List object .onTapGesture : Continued Version 2
Trying to implement what DTS Engineer posted https://developer.apple.com/forums/thread/791837?login=true But This time with REST API & DataModel , This is an Absolute Newbie SWIFTUI question, Somehow my data model cannot get it working due to my lack of understanding !!, please help Error "Candidate requires that 'SWIFT_DBG_Workflow_Trans_Datamodel_Data_ListViewModel' conform to 'Identifiable' (requirement specified as 'Data.Element' : 'Identifiable') (SwiftUICore.ForEach)" Sorry for the long post, all of the source code listed below //Datamodel -- scripts below import Foundation struct SWIFT_DBG_Workflow_Trans_Datamodel_Response: Decodable { let SWIFT_DBG_Workflow_Trans_Datamodel_Rows: [SWIFT_DBG_Workflow_Trans_Datamodel_Data] private enum CodingKeys: String, CodingKey { case SWIFT_DBG_Workflow_Trans_Datamodel_Rows = "rows" // root tag: REST API } } struct SWIFT_DBG_Workflow_Trans_Datamodel_Data: Decodable { let mst_rec_id: Int32 let work_task:String private enum CodingKeys: String, CodingKey { case mst_rec_id = "mst_rec_id" case work_task = "work_task" } } // Script datamodel LIST import Foundation @MainActor class SWIFT_DBG_Workflow_Trans_Datamode_List_Model: ObservableObject { @Published var SWIFT_DBG_Workflow_Trans_Datamodel_Rows: [SWIFT_DBG_Workflow_Trans_Datamodel_Data_ListViewModel] = [] func search(mst_rec_id:Int32) async { do { let SWIFT_DBG_Workflow_Trans_Datamodel_Rows = try await Webservice_Workflow_Trans_Data().getWorkflow_Trans_DataList(mst_rec_id:mst_rec_id) self.SWIFT_DBG_Workflow_Trans_Datamodel_Rows = SWIFT_DBG_Workflow_Trans_Datamodel_Rows.map(SWIFT_DBG_Workflow_Trans_Datamodel_Data_ListViewModel.init) } catch { print(error) } } } struct SWIFT_DBG_Workflow_Trans_Datamodel_Data_ListViewModel { let SwiftDBGWorkflowTransDatamodelData: SWIFT_DBG_Workflow_Trans_Datamodel_Data var mst_rec_id: Int32 { SwiftDBGWorkflowTransDatamodelData.mst_rec_id } var work_task:String{ SwiftDBGWorkflowTransDatamodelData.work_task } } // WEB SERVICE code import Foundation class Webservice_Workflow_Trans_Data { func getWorkflow_Trans_DataList(mst_rec_id:Int32 ) async throws -> [SWIFT_DBG_Workflow_Trans_Datamodel_Data] { var components = URLComponents() components.scheme = "http" components.host = "localhost" // To be pulled from Global Config.. Hot patch components.path = "/GetWorkflowTransList" components.port = 5555 components.queryItems = [ URLQueryItem(name: "mst_rec_id", value: String(mst_rec_id)), // VVI Need to pass eg: ] guard let url = components.url else { throw NetworkError.badURL } let (data, response) = try await URLSession.shared.data(from: url) guard (response as? HTTPURLResponse)?.statusCode == 200 else { throw NetworkError.badID } let SWIFT_DBG_Workflow_Trans_Datamodel_Response = try? JSONDecoder().decode(SWIFT_DBG_Workflow_Trans_Datamodel_Response.self, from: data) print("WebservicePopulation_DataWorkflow_Trans_Data:URL:\(components.url)!") print("API data: \(data)") return SWIFT_DBG_Workflow_Trans_Datamodel_Response?.SWIFT_DBG_Workflow_Trans_Datamodel_Rows ?? [] } } // Main View code import SwiftUI struct SwiftUIView_Sheet_Test_Main_V2a: View { @StateObject private var WorkflowTransListVM = SWIFT_DBG_Workflow_Trans_Datamode_List_Model() @State private var selectedTransaction: SWIFT_DBG_Workflow_Trans_Datamode_List_Model? = nil var body: some View { NavigationStack{ List { Section { ForEach(WorkflowTransListVM.SWIFT_DBG_Workflow_Trans_Datamodel_Rows) { item in WorkflowTransactionRow_V2(item: item) { selectedTransaction = $0 } } } header: { ListHeaderRow_V2() .textCase(nil) } } .navigationTitle("Sheet Test Main View") .navigationBarTitleDisplayMode(.inline) .onAppear() { async { await WorkflowTransListVM.search(mst_rec_id:0) } } } } } //ROW View struct WorkflowTransactionRow_V2: View { let item: SWIFT_DBG_Workflow_Trans_Datamodel_Data let onSelect: (SWIFT_DBG_Workflow_Trans_Datamodel_Data) -> Void var body: some View { HStack { Text("\(item.mst_rec_id)") .onTapGesture { onSelect(item) } Spacer() Text(item.work_task) Spacer() Button { onSelect(item) } label: { Image(systemName: "ellipsis.circle.fill") .foregroundColor(.blue) } } } } struct ListHeaderRow_V2: View { var body: some View { HStack { Text("Rec ID").font(.title3).frame(minWidth: 70) Spacer() Text("Work Task").font(.title3).frame(minWidth: 100) Spacer() Text("Status").font(.title3).frame(minWidth: 70) Spacer() } } }
Topic: UI Frameworks SubTopic: SwiftUI
3
0
95
Jul ’25
SWIFTUI List object .onTapGesture or Click event not setting values ?. Bug or issue with way .sheet works?
SWIFTUI List object .onTapGesture or Click event not setting values ?. Bug or issue with way .sheet works? On list object .onTapGesture / selection of the row I wanted send the Index /value to another view via .Sheet option And 90% of the time I get 0 (wrong value) help / guide , a newbie Code snippets for main view & popup view below //Main view with list object: import SwiftUI struct SwiftUIView_Sheet_Test_Main: View { let workflow_trn_data:[workflow_transaction_data] = [ .init(mst_rec_id: 100, work_task: "Task 100"), .init(mst_rec_id: 101, work_task: "Task 101") ] @State private var selected_Mst_record:Int32 = 0 @State private var isPopupSheetActive:Bool = false var body: some View { Text("Sheet Test Main View") NavigationStack{ List() { ForEach(0..<workflow_trn_data.count ,id: \.self) { index in if(index == 0 ) { // heading patch HStack{ Text("Rec ID") .font(.title3) .frame(minWidth:70) Spacer() Text("work_task") .font(.title3) .frame(minWidth:100) Spacer() Text("Status") .font(.title3) .frame(minWidth:70) Spacer() } } // data HStack{ Text("\(workflow_trn_data[index].mst_rec_id)") .onTapGesture { print("onTapGesture: \(workflow_trn_data[index].mst_rec_id)") selected_Mst_record = workflow_trn_data[index].mst_rec_id isPopupSheetActive = true } Spacer() Text("\(workflow_trn_data[index].work_task)") Spacer() // button Button(action: { selected_Mst_record = workflow_trn_data[index].mst_rec_id isPopupSheetActive = true }, label: { Image(systemName:"ellipsis.circle.fill") .foregroundColor(.blue) }) } } } } .sheet(isPresented: $isPopupSheetActive) { SwiftUIView_Sheet_Test_Popup(value_from_caller:selected_Mst_record) } } } #Preview { SwiftUIView_Sheet_Test_Main() } struct workflow_transaction_data: Identifiable { let mst_rec_id: Int32 let work_task: String var id: Int32 { mst_rec_id } } // popup view import SwiftUI struct SwiftUIView_Sheet_Test_Popup: View { let value_from_caller:Int32? var body: some View { Text("Sheet Test Popup Child view") Text("value recived from caller:\(value_from_caller ?? -1)") } } #Preview { SwiftUIView_Sheet_Test_Popup(value_from_caller:100) } code-block
Topic: UI Frameworks SubTopic: SwiftUI
2
0
176
Jul ’25
SWIFT UI - HTTP POST method sending as GET method
SWIFT UI - HTTP POST method sending as GET method Where as curl post works for the same URL curl --header "Content-Type: application/json" --request POST --data '{"username":"xyz","password":"xyz"}' http://localhost:5555/post_HTTP_test // <NSHTTPURLResponse: 0x60000030a100> { URL: http://localhost:5555/post_HTTP_test } { Status Code: 404, Headers { // code-block func HTTP_POST_2_Test() { let full_path: String = "http://localhost:5555/post_HTTP_test" var decodedAnswer: String = "" if let url = URL(string: full_path) { var request = URLRequest(url: url) print("HTTP_POST_2_Test:IN") let jsonString = """ { "fld_1": "John", "Fld_2": 30 } """ let jsonData = Data(jsonString.utf8) // Convert string to Data request.httpMethod = "POST" request.httpBody = jsonData do { let task = URLSession.shared.dataTask(with: url) { data, response, error in guard let data = data, let response = response, error == nil else{ print("Something wrong?: error: \(error?.localizedDescription ?? "unkown error")") return } print(response) decodedAnswer = String(decoding: data, as: UTF8.self) print("Response:",decodedAnswer) } task.resume() } } }
Topic: UI Frameworks SubTopic: SwiftUI
2
0
217
Jul ’25
SWIFTUI: chartLegend alignment 'Centering' option
SWIFTUI : Chart control / view is there way to align the Legends to align the center I see there only 2 options, .chartLegend(position: .bottom, alignment: .leading,spacing: 10) .leading or .trailing code : Chart{ ..... SectorMark.. } .chartLegend(position: .bottom, alignment: .leading,spacing: 10)
Topic: UI Frameworks SubTopic: SwiftUI
2
0
245
Mar ’25
looking for sample code 3d wireframe (with lines ) & polygons
Looking for sample code 3d wireframe (with lines ) & polygons and should be able to rotate (set camera angles) I tried sample code seems to be complicated & getting a BLANK screen import SwiftUI import SceneKit struct SceneKitTest2: View { var body: some View { VStack{ Text("SceneKitTest2") SceneView(scene: SCNScene(named:"Earth_1_12756.scn"), options: [.autoenablesDefaultLighting,.allowsCameraControl]) .frame(width:UIScreen.main.bounds.width, height: UIScreen.main.bounds.height/2) Spacer(minLength: 0) } } }
0
0
377
Jan ’25
SWIFTUI - update an Array/property Element gives error (had to replace the Whole structure)
SWIFTUI - update an Array/property Element gives error (had to replace the Whole structure), not sure my syntax is correct and Gives Syntax error.. Cannot assign value of type 'Double' to type 'Binding' , snippet of code below BTW, I was able to use AllObjects.Replace (but it is process intensive & hanges ) .. replaceSubrange(index...index, with: [TestObjects(.. latitude:Double(-999.0) //... etc )] Perhaps My syntax has issue .. please help //code snippets //declaration @State private var AllObjects:[TestObjects] = [] func TestObjUpdateLoc(index:Int32) { AllObjects.TestObjects[index].latitude = Double(-999.0) **//error ..Cannot assign value of type 'Double' to type 'Binding' ** } // TestObjects struct TestObjects: Codable, Hashable { let seq_id:Int32 let latitude:Double let longitude:Double // Many more... }
Topic: UI Frameworks SubTopic: SwiftUI
2
0
322
Jan ’25