Relative Content

Tag Archive for swiftui

Update environment object on listRow click before navigation

Here I have created a observable object, which I added in environment object. On list row click I need to update some values of my environment object before navigating on DetailView. Simply I want to show detail of object based on row selection.

Update environment object on listRow click before navigation

Here I have created a observable object, which I added in environment object. On list row click I need to update some values of my environment object before navigating on DetailView. Simply I want to show detail of object based on row selection.

Update environment object on listRow click before navigation

Here I have created a observable object, which I added in environment object. On list row click I need to update some values of my environment object before navigating on DetailView. Simply I want to show detail of object based on row selection.

Update environment object on listRow click before navigation

Here I have created a observable object, which I added in environment object. On list row click I need to update some values of my environment object before navigating on DetailView. Simply I want to show detail of object based on row selection.

Update environment object on listRow click before navigation

Here I have created a observable object, which I added in environment object. On list row click I need to update some values of my environment object before navigating on DetailView. Simply I want to show detail of object based on row selection.

How to place a list cells id: into a set to use on another screen?

I am recently retired and learning Swift/SwiftUI to write a tracking program for my forty plus characters in the Star Trek Online game that I have played for years. I will have to enter the data manually as, to my knowledge STO has no API to retrieve a players accounts, character data.
I have many screens written and my SwiftData database set up. I am currently working on a screen to select the traits a character has available to them, (has available/unlocked). This data I am loading from a json file is the Master list and will not change for each trait type, (7 total). My screen has a VStack inside a ZStack which holds an HStack with a vstack and a list inside. the VStack to the left holds a button to select which Master trait list to display for selection. and boxes under it to hold the trait Images that have been selected for the characters build. (see included screen shot) The List on the right shows the selected trait type.
I am using a custom ListCell to display the info. I have a trait is active selection box that I wish to show that the trait is active and place that traits image into a Set that I can store in my data base and retrieve when I select the character it belongs to.
The problem I am trying to solve is how to send the selected trait id: String into the set and display it on the VStack side. I have tried several ways but not working. the last way I tried was to make a class that holds the sets I need and place it in the environment, but I must not fully understand how all that works properly, as it seems to make a set for each cell in my list when I only want to place the selected cell into the set. I have included sample data and the code I am working on. Note I am not trying to use the lists edit toggle feature to select my traits, but my own checkbox. Any help to point me in the right direction would be much appreciated. Thanks!