Closed ebeneezer closed 6 months ago
Updating state or binding from within a view's body is indeed not supported in SwiftUI or SwiftTUI. In this case you might want to see if you can achieve what you want by putting the GeometryReader in the root view.
Dear Rens,
Thank you so much for your reply.
I am returning to Swift coding after being absend for 3 years. Still trying to get along with this SwiftUI stuff. SwiftUI is far from being straight forward in my optinion.
Anyways as i have retired now i wanted to code a text mode programmers editor and found your superb piece of work with SwiftTUI. Its a rewrite of American Cybernetics MultiEdit from the 90s for DOS under MacOS. So SwiftTUI seems a bullseye hit to me.
As the docs and examples for SwiftTUI are somewhat sparse i am trying to transpone SwiftUI docs towards SwiftTUI to understand what is going on. Indeed i found your comment in the sources of SwifTUI stating that there are no hierarchical view updates for Binding chained views.
I will do as adviced but am asking if you see any chance to implement upwards hierarchical updating for Binding views?
When i am fluently again with the new concepts i maybe try to make a pull request from your work and will tryto help. But alas i do need more time to exercise the new language mechanics..
Regards and please continue SwiftTUIs development.
Michael
Rens Breur @.***> schrieb am Do., 23. Mai 2024, 18:54:
Updating state or binding from within a view's body is indeed not supported in SwiftUI or SwiftTUI. In this case you might want to see if you can achieve what you want by putting the GeometryReader in the root view.
— Reply to this email directly, view it on GitHub https://github.com/rensbreur/SwiftTUI/issues/35#issuecomment-2127638097, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHSRFRM6ZRMQST34BWNGKTZDYNNHAVCNFSM6AAAAABIDLHT2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRXGYZTQMBZG4 . You are receiving this because you authored the thread.Message ID: @.***>
I close this issue as its a feature (for now) not an issue.
I have a workSpaceView that fills the terminal like so:
`import SwiftTUI
struct workSpaceView: View {
}`
and a main scrren that consists of a menu bar and the workSpaceView. This should become a simple textfile editor ...
`struct mainScr: View {
}`
`import SwiftTUI
struct menuBarView: View {
}`
When I resize the terminal the GeometryReader updates correctly ond writes its Size in every line on the screen (just for debugging) but the bound menuBarView does never get the new value of workSpaceSize and does not redraw.
Its like mainScreen / \ workSpaceView menuBarView
The value is changed inside workSpaceView goes up through the Binding into mainScreen and triggers redraw of menuBarView.
But it does not.