I’ve a view which has a listing and a button. The listing could possibly be brief or lengthy because the values inside it are dynamic.
Incase of brief listing, I want to show the button under the listing, however incase of lengthy scrollable listing, the button needs to be backside of the view i.e. the button ought to all the time be seen. I attempted setting button because the footer of the part which works advantageous for a brief listing, however when listing is lengthy, button is hidden and person has to scroll to get to it.
How can I show button on the backside of the display screen when listing is lengthy?
Present code:
import SwiftUI
import Basis
struct ContentView: View {
let shortList: [String] = ["One", "Two", "Three", "Four", "Five"]
let longList: [String] = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", "Twenty One", "Twenty Two"]
@State var showSheet: Bool = false
var physique: some View {
VStack {
Checklist {
Part {
ForEach(longList, id: .hashValue) { worth in
Textual content(worth).font(.physique)
}
} header: {
Rectangle().body(top:0)
}
Part(footer: self.resetButton) {
EmptyView().body(top:0)
}
}
}
.sheet(isPresented: $showSheet) { SheetA() }
}
non-public var resetButton: some View {
VStack {
Button {
// Do one thing
} label: {
Textual content("Reset").font(.physique).daring().padding(.trailing, 5.0)
}
.body(width: UIScreen.essential.bounds.width - 50.0, top: 30.0)
.padding(8.0)
.background(Coloration.mint)
.foregroundColor(Coloration.black)
.font(.headline)
}
}
}