Post

Replies

Boosts

Views

Activity

Reply to How to pass data from a TextField to a List (SwiftUI)
....you need to hold a collection containing name, id, cname and qrcode. How do you want to have it? I want an HStack with qrcode on the left while on the right there is a VStack showing cname, name, and id respectively. It would just show that data in the CardRow. The list is calling CardRow with the data: List { ForEach(cards) { cards in NavigationLink(destination: CardFullView(cname: [how AddView() provides cname])) { CardRow(cname: [how AddView() provides cname], name: [how AddView() provides name], id: [how AddView() provides id])                    }                }                .onDelete(perform: onDelete)                .onMove(perform: onMove)            } CardRow automatically generates a QR code from what id provides.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to How to pass data from a TextField to a List (SwiftUI)
Sorry for the late reply. Where is the button? Where is the list? In AddView, the "Create" button is located at the bottom. Here it is with all its modifiers: Button(action: {}) { Text("Create") .bold() }.disabled(self.cardInfo.name.isEmpty	self.cardInfo.id.isEmpty	self.cardInfo.cname.isEmpty) .foregroundColor(.white) .padding() .padding(.horizontal, 100) .background(Color.accentColor) .cornerRadius(10) The disabled modifier is disabling it entirely, even if I add a value to the TextFields. I need some way to change that. The || dividers aren't showing because it screws up the code block. On my second thing, there is no action specified. That's what I'd like to replace with something to have the now completed (and, correct me if I'm wrong) cardInfo to pass through CardRow and end up in the List that is located in CardsView: List { ForEach(cards) { cards in NavigationLink(destination: CardFullView(cname: cardsInfo.newCard.cname)) { CardRow(cname: cardsInfo.newCard.cname, name: cardsInfo.newCard.name, id: cardsInfo.newCard.id) } } .onDelete(perform: onDelete) .onMove(perform: onMove) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to How to pass data from a TextField to a List (SwiftUI)
The disabled modifier is disabling it entirely, even if I add a value to the TextFields. I need some way to change that.  There's another bug happening with this, as well. Though when initially putting in the info, it doesn't enable the Create button, nor does it update the card preview (CardView) and navigationTitle. But when dismissing it and tapping the add button again, it shows that information and enables the Create button. On another note, I figured out a way to show the cardInfo data in the list, but it's not the way I want it. I want some way to make it so the Create button executes the onAdd function...and it seems finished from what I've tested. I've changed it so AddView shows as a Sheet, so it's no longer a NavigationLink. All I need to do is call onAdd, but that function is embedded in CardsView, where the List is located. I want to call that function from AddView, but it's only available in CardsView.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to How to pass data from a TextField to a List (SwiftUI)
Most parts get cleared, but it seems you have touched your code since then. You're correct, as I was revamping some views and disregarded important parts. That's entirely my fault. I think it's time for you to start your new thread to solve such another thing. I agree, I feel I've strayed away from what I've been trying to solve...I will start another thread to expand. Edit: Here is the new thread: https://developer.apple.com/forums/thread/670536
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to I have a function in one view, but a button that should call it in another
This didn't work. I put showSheetView into a shared object, SheetInfo, and called it in both CardsView and AddView as sheetInfo. I changed every declaration of $showSheetView to $sheetInfo.showSheetView. Still didn't work. Is there something I missed? Here's the code: SheetInfo: class SheetInfo: ObservableObject { @Published var showSheetView = false } CardsView: struct CardsView: View {     @StateObject var cardsInfo = CardsInfo()     @StateObject var sheetInfo = SheetInfo() // <-     @State private var editMode = EditMode.inactive          var body: some View { (...) ToolbarItem(placement: .navigationBarTrailing) {         Button(action: {             self.sheetInfo.showSheetView.toggle()                 }) {                     Image(systemName: "plus")                     }.sheet(isPresented: $sheetInfo.showSheetView) {                     AddView(cardsInfo: cardsInfo, sheetInfo: sheetInfo, isShowing: $sheetInfo.showSheetView)                     }                 } (...) } AddView: struct AddView: View {     @ObservedObject var cardsInfo: CardsInfo     @ObservedObject var sheetInfo: SheetInfo     @Binding var isShowing: Bool   var body: some View { (...) Button(action: { cardsInfo.add() isShowing = false }) { Text("Create") .bold() } (...) }
Topic: App & System Services SubTopic: General Tags:
Jan ’21
Reply to Force color scheme at the press of a button
Please show your latest code if you cannot solve the issue yourself. ContentView: // //  ContentView.swift //  Shared // //  Created by Joshua Srery on 12/17/20. //  Additional code by OOPer on Apple Developer Forums // import SwiftUI struct ContentView: View {     @Environment(\.colorScheme) var systemColorScheme     @State var myColorScheme: ColorScheme?     var body: some View {         TabView {             CardsView()                 .tabItem {                     Image(systemName: "person.crop.square.fill.and.at.rectangle")                     Text("Cards")                 }             SettingsView(colorScheme: $myColorScheme)                 .tabItem {                     Image(systemName: "gear")                     Text("Settings")                 }         }         .colorScheme(myColorScheme ?? systemColorScheme)     } } SettingsView: // //  SettingsView.swift //  Lunch Card (iOS) // //  Created by Joshua Srery on 12/21/20. //  Additional code by OOPer on Apple Developer Forums. // import SwiftUI struct SettingsView: View {     @State private var selectedAppearance = 1     @Binding var colorScheme: ColorScheme?     var body: some View {         NavigationView {             Form {                 Section(header: Text("Customization")) {                     Picker(selection: $selectedAppearance, label: Text("Appearance")) {                         Text("System Default").tag(1)                         Text("Light").tag(2)                         Text("Dark").tag(3)                     }                     .onAppear {                         switch colorScheme {                         case .none:                             selectedAppearance = 1                         case .light:                             selectedAppearance = 2                         case .dark:                             selectedAppearance = 3                         default:                             break                         }                     }                     .onChange(of: selectedAppearance) { value in                         //print(selectedAppearance)                         switch selectedAppearance {                         case 1:                             //print("System Default")                             colorScheme = nil                         case 2:                             //print("Light")                             colorScheme = .light                         case 3:                             //print("Dark")                             colorScheme = .dark                         default:                             break                         }                     } ///... }
Topic: App & System Services SubTopic: General Tags:
Jan ’21