79593481

Date: 2025-04-26 01:00:21
Score: 7 🚩
Natty:
Report link

Thank you to everyone but especially @malhal because I finally got it working with his fix! However, I did have to change that fix a little and wanted to update for anyone having a similar issue.

First of all, I used environmentObject and restructured my BeginWorkoutView, CreateTemplateView, and ContentView as suggested.

I originally had my WorkoutTemplate as a class, but name was NOT published. I tried using a struct but did not have success. I saw a different post(which i will link if i can find it again) point out that even if a view has an object that reacts to state changes (like my environment object in beginWorkoutView), the subview still might not react. BeginWorkoutView has a list of templateRowViews which show the template names. Originally, the template var was NOT an observedobject, so i updated that. i also decided to change WorkoutTemplate back to a class/conform to ObservableObject. Here are those additional changes/reversion


struct TemplateRowView: View {
    @ObservedObject var template: WorkoutTemplate //now an @ObservedObject

        var body: some View {

            VStack{
                Text(template.name).bold()
               
               //other stuff
        
        }
    }
 }
//kept as a class conforming to ObservableObject, made variable @Published
class WorkoutTemplate: Identifiable, Codable, Hashable, ObservableObject {
    var id = UUID()
    @Published var name: String
    var workoutModules: [WorkoutModule]
    var note: String?
    
//additional functions
    
    }

I want to note, on the main screen where you see the template previews, name is only thing you see for each template, which is why it's the only thing i have published.

I hope this helps! I know theres a lot here and a lot I didnt include so please let me know if I can clarify something or you have a similar issue and want to see more code!

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Whitelisted phrase (-1): hope this helps
  • RegEx Blacklisted phrase (2.5): please let me know
  • RegEx Blacklisted phrase (1): I want
  • RegEx Blacklisted phrase (1): I know theres a lot here and a lot I didnt include so please
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): having a similar issue
  • Me too answer (0): have a similar issue
  • User mentioned (1): @malhal
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: whyDoICodeFrontEnd