How to call a function on original view when modal view is dismissed

I have a SwiftUI puzzle game. I store played puzzles and show in the history view. History view is displayed as a sheet when a button is tapped. In the history view, I want to have a button ("Replay puzzle") which should 1) dismiss the history view, and 2) run a function in the main… Read More How to call a function on original view when modal view is dismissed

Is it possible to define a RoundedRectangle with some properties as a variable for later usage in SwiftUI?

I want to reuse a RoundedRectangle that has certain properties multiple times in my View. Is defining it as a variable possible? And while my code is pretty much like this Struct ContentView: View { var body: some View { RoundedRectangle(cornerRadius: 24) .frame(width: 180, height: 240) .foregroundColor(Color(.white)) RoundedRectangle(cornerRadius: 24) .frame(width: 180, height: 240) .foregroundColor(Color(.white)) RoundedRectangle(cornerRadius:… Read More Is it possible to define a RoundedRectangle with some properties as a variable for later usage in SwiftUI?

SwiftUI Can't Change Color Button from Class Method

i’ve created a KetupatButton class with 2 method like this: class KetupatButton { var condition = false @State var colorToShow = Color(UIColor(red: 183/255, green: 191/255, blue: 150/255, alpha: 100)) func colorChange() { if condition == false { colorToShow = Color(UIColor(red: 183/255, green: 191/255, blue: 150/255, alpha: 100)) } else { colorToShow = Color(UIColor(red: 19/255, green:… Read More SwiftUI Can't Change Color Button from Class Method

how to change ui color to color set

can someone please tell me if I can change the color on below format using Color Set. For example, Instead of .blue, I want to use my own color set such as Color("colorname"). Is this possible .onAppear { UITableView.appearance().backgroundColor = .blue } >Solution : UITableView.appearance().backgroundColor = UIColor(named: "your set here")

SwiftUI: How can I set a color to .foregroundColor() by using a String? i.e. "green" –> Color.green

So I have this String "green" inside a constant (lernset.color). I would like to set a .foregroundColor() to a symbol (systemName: "folder") inside of a list, so that it has the same color as written inside the constant (lernset.color). The problem I get: I dont know how to convert this constant (lernset.color) which has the… Read More SwiftUI: How can I set a color to .foregroundColor() by using a String? i.e. "green" –> Color.green