MainSelection: Test autoscroll when a cell is expanded or collapsed

This commit is contained in:
Antonio 2022-04-27 18:27:47 +02:00
parent 184c41f92d
commit 016ef8c403
3 changed files with 25 additions and 13 deletions

View file

@ -123,7 +123,9 @@ struct SelectionView: View {
.padding(.vertical,30)
ForEach(model.pdemos) { demo in
DemoViewCell(result: demo, isConnected: $inConnectedInSelectionView, bootOne: $boardBootInfo)
DemoViewCell(result: demo, isConnected: $inConnectedInSelectionView, bootOne: $boardBootInfo, onViewGeometryChanged: {
// TODO
})
}
}

View file

@ -11,10 +11,15 @@ import Foundation
struct DemoViewCell: View {
let result : ResultItem
@State private var isExpanded: Bool = false
@State private var isExpanded: Bool = false {
didSet {
onViewGeometryChanged()
}
}
@Binding var isConnected: Bool
@Binding var bootOne: String
let onViewGeometryChanged: ()->Void
var body: some View {
content

View file

@ -30,18 +30,23 @@ struct MainSelectionView: View {
VStack{
ScrollView {
HStack {
Text("Browse all of the available PyLeap Projects")
.multilineTextAlignment(/*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.font(Font.custom("ReadexPro-Regular", size: 25))
ScrollViewReader { scroll in
HStack {
}
.padding(.vertical,30)
ForEach(model.pdemos) { demo in
DemoViewCell(result: demo, isConnected: $isConnected, bootOne: $test)
Text("Browse all of the available PyLeap Projects")
.multilineTextAlignment(/*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.font(Font.custom("ReadexPro-Regular", size: 25))
}
.padding(.vertical,30)
ForEach(model.pdemos) { demo in
DemoViewCell(result: demo, isConnected: $isConnected, bootOne: $test, onViewGeometryChanged: {
withAnimation {
scroll.scrollTo(demo.id)
}
})
}
}
}
.toolbar {