Post

Replies

Boosts

Views

Activity

Reply to NavigationLink/Picker
Hi Sydney, There is an initial NavigationStack in the leading view ; VStack(alignment: .leading) { HStack { NavigationLink(destination: MultiSelectPartialView(selectedProcedures: $selectedPartial)) { Text("Partial") } .frame(width: 75) Text("Selected are:") Text(selectedPartial.joined(separator: ",")) .foregroundColor(Color(.red)) .font(.subheadline) Spacer() } HStack { Text("Base Material (Non-Metal)") .font(.subheadline) Picker("",selection: $selectedBaseMaterial) { ForEach(basematareials, id: \.self ) { base in Text(base.description) .tag(base.description) } } .frame(width: 150) .pickerStyle(.automatic) .bold() .foregroundColor(Color(.red)) Spacer() Text("Metal Framework") .font(.subheadline) Picker("",selection: $selectedMetal) { ForEach(metalFramework, id: \.self ) { metal in Text(metal.description) .tag(metal.description) } } .frame(width: 150) .pickerStyle(.automatic) .bold() .foregroundColor(Color(.red)) }
Jul ’24
Reply to NavigationLink/Picker
Thanks Sydney, I did try to split the sections but didn't seem to work , but will try again. Didn't think of list but will try that as well. The NavigationLink is for a multiselect list so may rethink the interface for multiple selections Joel
Jul ’24
Reply to NavigationLink/Picker
Tested both Substituted List for Stack, no errors but same issue Separated by sections ( code given ) , no errors but same issue VStack(alignment: .leading) { Section(header: Text("List")){ // Test section 1 HStack { NavigationLink(destination: MultiSelectPartialView(selectedProcedures: $selectedPartial)) { Text("Partial") } .frame(width: 75) Text("Selected are:") Text(selectedPartial.joined(separator: ",")) .foregroundColor(Color(.red)) .font(.subheadline) Spacer() } Section(header: Text("Pickers")) { // Test section 2 HStack { Text("Base Material (Non-Metal)") .font(.subheadline) Picker("",selection: $selectedBaseMaterial) { ForEach(basematareials, id: \.self ) { base in Text(base.description) .tag(base.description) } } .frame(width: 150) .pickerStyle(.automatic) .bold() .foregroundColor(Color(.red)) //Spacer() Text("Metal Framework") .font
Jul ’24
Reply to NavigationLink/Picker
Both recommendations I couldn't get to work. Switched to toggle controls which was accepted by SwiftUI. Just curious why the navlink is not contained and leaks into the picker control VStack(alignment: .leading) { /* HStack { // NOT Working NavigationLink(destination: MultiSelectPartialView(selectedProcedures: $selectedPartial)) { Text("Partial") } .frame(width: 75) Text("Selected are:") Text(selectedPartial.joined(separator: ",")) .foregroundColor(Color(.red)) .font(.subheadline) Spacer() }*/ HStack { Text("Selected are:") .font(.subheadline) Toggle("Upper", isOn: $upper) .font(.subheadline) Toggle("Lower", isOn: $lower) .font(.subheadline) Toggle("Both", isOn: $both) .font(.subheadline) Toggle("Custom Tray", isOn: $customTray) .font(.subheadline) ```Joel
Jul ’24
Reply to NavigationLink/Picker
With toggle controls if the text toggle description is clicked the initial picker list is displayed. No problem if the actual toggle is clicked. Is there an issue in mixing controls in a form container ? A specific order ?
Jul ’24
Reply to SwiftData multiple loop entries not inserting
import Foundation import SwiftData import TabularData @Model class Catagory { var id: UUID @Attribute(.unique)var name: String var instrument: [Instrument] = [Instrument]() init(id: UUID, name: String, instrument: [Instrument]) { self.id = id self.name = name self.instrument = instrument } } @Environment(.modelContext) private var context @Environment(.dismiss) private var dismiss var catagory: Catagory var model = DataModel.shared @State private var overWrite: Bool = true @State private var name: String = "" Button("Save") { if overWrite { deleteModel(modelContext: context) } for index in 0..<model.dataTable!.rows.count { let row = model.dataTable!.rows[index] catagory.name = row["Catagory"] as! String context.insert(catagory) print(catagory.name) } dismiss() } .buttonStyle(.borderedProminent) .tint(.green) func deleteModel(modelContext: ModelContext) { do { try modelContext.delete(model: Catagory.self) } catch { fatalError(error.localizedDescription) } }
Aug ’24