【发布时间】:2021-01-25 10:48:56
【问题描述】:
我是一名新手程序员,正在学习 SwiftUI。
点击“添加练习”按钮时,我希望圆角矩形和内容在下面重复。
我正在使用 Firebase 的 Cloud Firestore 来存储这些数据。随着习题数量的变化,表格的内容如何构成?
谢谢,这是我设置表单的基本代码:
var body: some View {
ScrollView {
VStack (alignment: .leading, spacing: 4) {
Text("Injury Exercises")
.font(.largeTitle)
.bold()
}.frame(maxWidth: .infinity, alignment: .leading)
.padding()
VStack (spacing: 16){
TextField("Workout Title (optional)", text: $text)
.autocapitalization(.words)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
.lineLimit(1)
TextField("Add Warmup", text: $text)
.font(.subheadline)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
VStack{
TextField("Exercise Title (required)", text: $text)
.autocapitalization(.words)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
.lineLimit(1)
TextField("Sets, Reps, Tempo, Rest etc.", text: $text)
.font(.subheadline)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
}
.padding(8)
.foregroundColor(Color("card4"))
.background(Color.white).opacity(0.8)
.clipShape(RoundedRectangle(cornerRadius: 16, style: /*@START_MENU_TOKEN@*/.continuous/*@END_MENU_TOKEN@*/))
HStack {
Image(systemName: "plus")
Text("Exercise")
}
.font(.subheadline)
.padding(8)
.foregroundColor(Color("card4"))
.background(Color.white).opacity(0.8)
.clipShape(Capsule())
TextField("Add Cooldown", text: $text)
.font(.subheadline)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
}
.padding(.horizontal)
.navigationBarTitle("Add Injury Exercise")
.navigationBarHidden(true)
}
.background(
VisualEffectBlur()
.edgesIgnoringSafeArea(.all))
}
}
【问题讨论】:
标签: swift firebase forms google-cloud-firestore swiftui