Tokamak icon indicating copy to clipboard operation
Tokamak copied to clipboard

GeometryReader extends after setting inner view size to it's provided value

Open shial4 opened this issue 3 years ago • 5 comments

Going further. If i place Text inside GeometryReader It won't adjust it's size. It is not multiline. and setting frame(maxWidth: proxy.size.width) base on Geometry reader will stretch my view in consecutive view updates increasing GeometryReader size till texts inside Text object will exhaust it's size.

shial4 avatar Dec 13 '20 22:12 shial4

@shial4 thanks for reporting the issue! Could you provide a code snippet for reproduction?

MaxDesiatov avatar Dec 19 '20 19:12 MaxDesiatov

@MaxDesiatov sure. Will follow up on it and provide example in few days. Moving places right now. Have no way to pull out my computer. :/ Sorry for delay.

shial4 avatar Dec 20 '20 23:12 shial4

No pressure at all, whenever is more convenient for you! Good luck with the move 🙂

MaxDesiatov avatar Dec 21 '20 10:12 MaxDesiatov

I think this will be enough Make sure you do have someVeryLongString equal to value of 1-2 pages A4

GeometryReader { proxy in
       Text(someVeryLongString).frame(width: proxy.size.width)
}

shial4 avatar Jan 06 '21 09:01 shial4

Another example:

import TokamakDOM

struct TokamakApp: App {
    var body: some Scene {
        WindowGroup("Geometry jumps") {
            ContentView()
        }
    }
}

// @main attribute is not supported in SwiftPM apps.
// See https://bugs.swift.org/browse/SR-12683 for more details.
TokamakApp.main()




struct ContentView: View {
    var body: some View {
          ScrollView(.vertical, showsIndicators: false) {
               ZStack {
                  BodyView()
            }
        }
    }
}

struct HeaderView: View {
    var body: some View {
         Text("Header")
    }
}

struct BodyView: View {

    var body: some View {
        VStack {
            HeaderView(coordinator: coordinator)
            GeometryReader { proxy in
                Color.green
                    .frame(height: proxy.size.height - 200)
            }
            FooterView()
        }
    }
}

struct FooterView: View {
    var body: some View {
         Text("Footer")
    }
}

shial4 avatar Jan 12 '21 08:01 shial4