Bike List + Foreach mit swipe - löschen
This commit is contained in:
parent
76e74d6729
commit
f6da6702a2
5 changed files with 39 additions and 1 deletions
32
BikeSwipeView.swift
Normal file
32
BikeSwipeView.swift
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
|
||||||
|
struct BikeSwipeView: TabContent {
|
||||||
|
static var title = "BikeSwipe"
|
||||||
|
static var image = "bicycle"
|
||||||
|
|
||||||
|
|
||||||
|
@State var bikes = Bike.all
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack{
|
||||||
|
List {
|
||||||
|
ForEach(bikes) { bike in
|
||||||
|
Label(bike.name, systemImage: "bicycle")
|
||||||
|
.foregroundStyle(.white)
|
||||||
|
.padding(5)
|
||||||
|
.background(bike.color)
|
||||||
|
}.onDelete { bikes.remove(atOffsets: $0)}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
BikeSwipeView()
|
||||||
|
}
|
||||||
|
|
@ -45,9 +45,11 @@ struct ContentView: View {
|
||||||
tab(ListView.self)
|
tab(ListView.self)
|
||||||
tab(CountView.self)
|
tab(CountView.self)
|
||||||
tab(BikeView.self)
|
tab(BikeView.self)
|
||||||
|
tab(BikeSwipeView.self)
|
||||||
tab(TrainView.self)
|
tab(TrainView.self)
|
||||||
tab(SwapperView.self)
|
tab(SwapperView.self)
|
||||||
tab(PaddingView.self)
|
tab(PaddingView.self)
|
||||||
|
tab(RangeView.self)
|
||||||
}.tabViewStyle(.sidebarAdaptable)
|
}.tabViewStyle(.sidebarAdaptable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ struct Bike: @MainActor Vehicle, CustomStringConvertible {
|
||||||
func emptyBasket() {
|
func emptyBasket() {
|
||||||
print("emptied", Date())
|
print("emptied", Date())
|
||||||
}
|
}
|
||||||
static let all = [
|
static var all: [Bike] = [
|
||||||
Bike(name: "Specialized",price: 100000.00, color: .purple ),
|
Bike(name: "Specialized",price: 100000.00, color: .purple ),
|
||||||
Bike(name: "Giant",price: 120000.00, color: .red ),
|
Bike(name: "Giant",price: 120000.00, color: .red ),
|
||||||
Bike(name: "Cannondale",price: 110000.00, color: .green )
|
Bike(name: "Cannondale",price: 110000.00, color: .green )
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
0CC14A892E92EEA900271E8D /* Playground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC14A882E92EEA900271E8D /* Playground.swift */; };
|
0CC14A892E92EEA900271E8D /* Playground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC14A882E92EEA900271E8D /* Playground.swift */; };
|
||||||
FB2F07E92EA7CB25002BD499 /* ListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB2F07E82EA7CB25002BD499 /* ListView.swift */; };
|
FB2F07E92EA7CB25002BD499 /* ListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB2F07E82EA7CB25002BD499 /* ListView.swift */; };
|
||||||
FB79FE462EA8CFD20011678F /* RangeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB79FE452EA8CFD20011678F /* RangeView.swift */; };
|
FB79FE462EA8CFD20011678F /* RangeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB79FE452EA8CFD20011678F /* RangeView.swift */; };
|
||||||
|
FB79FE482EA8F74F0011678F /* BikeSwipeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB79FE472EA8F74F0011678F /* BikeSwipeView.swift */; };
|
||||||
FBA00D6D2EA78411006F8B9A /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */; };
|
FBA00D6D2EA78411006F8B9A /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */; };
|
||||||
FBA00D6F2EA78853006F8B9A /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D6E2EA78850006F8B9A /* Color.swift */; };
|
FBA00D6F2EA78853006F8B9A /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D6E2EA78850006F8B9A /* Color.swift */; };
|
||||||
FBA00D712EA7A839006F8B9A /* PaddingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D702EA7A830006F8B9A /* PaddingView.swift */; };
|
FBA00D712EA7A839006F8B9A /* PaddingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D702EA7A830006F8B9A /* PaddingView.swift */; };
|
||||||
|
|
@ -30,6 +31,7 @@
|
||||||
0CC14A882E92EEA900271E8D /* Playground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Playground.swift; sourceTree = "<group>"; };
|
0CC14A882E92EEA900271E8D /* Playground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Playground.swift; sourceTree = "<group>"; };
|
||||||
FB2F07E82EA7CB25002BD499 /* ListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListView.swift; sourceTree = "<group>"; };
|
FB2F07E82EA7CB25002BD499 /* ListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListView.swift; sourceTree = "<group>"; };
|
||||||
FB79FE452EA8CFD20011678F /* RangeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RangeView.swift; sourceTree = "<group>"; };
|
FB79FE452EA8CFD20011678F /* RangeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RangeView.swift; sourceTree = "<group>"; };
|
||||||
|
FB79FE472EA8F74F0011678F /* BikeSwipeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BikeSwipeView.swift; sourceTree = "<group>"; };
|
||||||
FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
|
||||||
FBA00D6E2EA78850006F8B9A /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
|
FBA00D6E2EA78850006F8B9A /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
|
||||||
FBA00D702EA7A830006F8B9A /* PaddingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingView.swift; sourceTree = "<group>"; };
|
FBA00D702EA7A830006F8B9A /* PaddingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingView.swift; sourceTree = "<group>"; };
|
||||||
|
|
@ -67,6 +69,7 @@
|
||||||
FBA6FA5F2EA66C2E00C373EC /* Assets.xcassets */,
|
FBA6FA5F2EA66C2E00C373EC /* Assets.xcassets */,
|
||||||
0CC14A882E92EEA900271E8D /* Playground.swift */,
|
0CC14A882E92EEA900271E8D /* Playground.swift */,
|
||||||
FBA6FA612EA76AAD00C373EC /* BikeView.swift */,
|
FBA6FA612EA76AAD00C373EC /* BikeView.swift */,
|
||||||
|
FB79FE472EA8F74F0011678F /* BikeSwipeView.swift */,
|
||||||
FBA6FA652EA7725A00C373EC /* TrainView.swift */,
|
FBA6FA652EA7725A00C373EC /* TrainView.swift */,
|
||||||
FB2F07E82EA7CB25002BD499 /* ListView.swift */,
|
FB2F07E82EA7CB25002BD499 /* ListView.swift */,
|
||||||
FB79FE452EA8CFD20011678F /* RangeView.swift */,
|
FB79FE452EA8CFD20011678F /* RangeView.swift */,
|
||||||
|
|
@ -160,6 +163,7 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
FBA6FA5E2EA63EA300C373EC /* Models.swift in Sources */,
|
FBA6FA5E2EA63EA300C373EC /* Models.swift in Sources */,
|
||||||
|
FB79FE482EA8F74F0011678F /* BikeSwipeView.swift in Sources */,
|
||||||
FB79FE462EA8CFD20011678F /* RangeView.swift in Sources */,
|
FB79FE462EA8CFD20011678F /* RangeView.swift in Sources */,
|
||||||
FBA6FA662EA7725A00C373EC /* TrainView.swift in Sources */,
|
FBA6FA662EA7725A00C373EC /* TrainView.swift in Sources */,
|
||||||
FBA00D752EA7ACE1006F8B9A /* SwapperView.swift in Sources */,
|
FBA00D752EA7ACE1006F8B9A /* SwapperView.swift in Sources */,
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue