ENH: Fixed sizing of the main window. #1

Open
eroesch wants to merge 8 commits from eroesch/msg-desktop:main into main
Showing only changes of commit 2b61760d94 - Show all commits

View file

@ -40,51 +40,57 @@ struct ContentView: View {
.onPreferenceChange(ViewHeightKey.self) { height in .onPreferenceChange(ViewHeightKey.self) { height in
self.imageHeight = height self.imageHeight = height
} }
// ScrollView fills remaining height ZStack {
ScrollViewReader { proxy in Color.black
ScrollView { .ignoresSafeArea()
LazyVStack(alignment: .leading, spacing: 0) {
let lines = appState.output.components(separatedBy: .newlines) // ScrollView fills remaining height
ScrollViewReader { proxy in
ForEach(lines.indices, id: \.self) { index in ScrollView {
Text(lines[index]) LazyVStack(alignment: .leading, spacing: 0) {
.font(.system(.body, design: .monospaced)) let lines = appState.output.components(separatedBy: .newlines)
.frame(maxWidth: .infinity, alignment: .leading)
ForEach(lines.indices, id: \.self) { index in
Text(lines[index])
.font(.system(.body, design: .monospaced))
.frame(maxWidth: .infinity, alignment: .leading)
}
Color.clear.frame(height: 1).id("bottom")
} }
.padding()
Color.clear.frame(height: 1).id("bottom")
} }
.padding() .onChange(of: appState.output) { _, _ in
} trimLinesIfNeeded()
.onChange(of: appState.output) { _, _ in withAnimation {
trimLinesIfNeeded() proxy.scrollTo("bottom", anchor: .bottom)
withAnimation { }
proxy.scrollTo("bottom", anchor: .bottom)
} }
// ScrollView {
// VStack(alignment: .leading) {
// TextEditor(text: $appState.output)
// .font(.system(.body, design: .monospaced))
// .frame(
// width: geometry.size.width - 60,
// height: max(0, geometry.size.height - imageHeight - 120) // - rough height of button row and padding
// )
// .padding()
// .disabled(true)
//
// Text("")
// .id("bottom")
// }
// }
// .onChange(of: appState.output) { _, _ in
// trimLinesIfNeeded()
// withAnimation {
// proxy.scrollTo("bottom", anchor: .bottom)
// }
// }
} }
// ScrollView {
// VStack(alignment: .leading) {
// TextEditor(text: $appState.output)
// .font(.system(.body, design: .monospaced))
// .frame(
// width: geometry.size.width - 60,
// height: max(0, geometry.size.height - imageHeight - 120) // - rough height of button row and padding
// )
// .padding()
// .disabled(true)
//
// Text("")
// .id("bottom")
// }
// }
// .onChange(of: appState.output) { _, _ in
// trimLinesIfNeeded()
// withAnimation {
// proxy.scrollTo("bottom", anchor: .bottom)
// }
// }
} }
// Buttons // Buttons