42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
|
|
|
|
import SwiftUI
|
|
|
|
|
|
struct BikeSwipeView: TabContent {
|
|
static var title = "BikeSwipe"
|
|
static var image = "bicycle"
|
|
|
|
|
|
@State var bikes = Bike.all
|
|
|
|
var body: some View {
|
|
VStack{
|
|
List {
|
|
Section {
|
|
ForEach(bikes) { bike in
|
|
HStack{
|
|
Label(bike.name, systemImage: "bicycle")
|
|
.foregroundStyle(.white)
|
|
.padding(5)
|
|
.background(bike.color)
|
|
Text(bike.id.uuidString.components(separatedBy: "-").first!)
|
|
}
|
|
}.onDelete { bikes.remove(atOffsets: $0)}
|
|
.navigationTitle(Text("Bikes"))
|
|
} footer: {
|
|
Button("Add Bike"){
|
|
bikes.append(Bike(name: "New Bike", price: 1.00, color: Color.blue))
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
BikeSwipeView()
|
|
}
|