gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.53k stars 318 forks source link

How do I get the height of the Markdown change #230

Closed wscqs closed 1 year ago

wscqs commented 1 year ago

struct ContentView: View { var body: some View { Text("Hello, World!") //Markdown .background(GeometryReader { geometry in Color.clear .preference(key: ViewHeightKey.self, value: geometry.size.height) }) .onPreferenceChange(ViewHeightKey.self) { height in print("The view height is: (height)") //Markdown all is 0 } } }

struct ViewHeightKey: PreferenceKey { static var defaultValue: CGFloat = 0 static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value = nextValue() } }

wscqs commented 1 year ago

I have a demand is: ai reply is joining together to markdown, word by word and then have always scroll at the bottom of the requirements, so I hope to I can accept markdown height changes to the callback

xiaomage1478 commented 1 year ago

我有一个需求是:ai回复是拼markdown的,一个字一个字的然后一直在底部滚动的需求,所以希望能接受markdown高度变化回调

你好兄弟,这个问题你解决了吗,我有遇到过,交流一下

wscqs commented 1 year ago

我有一个需求是:ai回复是拼markdown的,一个字一个字的然后一直在底部滚动的需求,所以希望能接受markdown高度变化回调

你好兄弟,这个问题你解决了吗,我有遇到过,交流一下

自己解决方案不好,不准确。 还是等作者看能不能弄个回调

gonzalezreal commented 1 year ago

Closing this as invalid. Please use Discussions for questions, ideas and feature requests.