AnimatedSwipeCard is a custom swipe card with animation and can be used with confirmationDialog or alert.
Simulator.Screen.Recording.-.iPhone.13.Pro.-.2022-03-30.at.08.46.50.mp4
AnimatedSwipeCard is available through Swift Package Manager.
Using AnimatedSwipeCard is easy
struct ContentView: View {
@State var showCardAlert = false
@State var selectedText = ""
@State var bindingID = ""
@State var bindingText = ""
@State var bindingSubText = ""
var body: some View {
VStack {
List {
ForEach(RowItems, id:\.self){ item in
//add binding for a string for ID that can be passed
CardRowView(animationShakeAmount: 5.0,
titleText: item.text,
subText: item.subText,
cardID: String(bindingID),
color: "StatusCard",
imageName: "rocket_green",
showCardAlert: $showCardAlert,
bindingID: $bindingID,
bindingText: $bindingText,
bindingSubText: $bindingSubText)
.frame(height: 150)
.padding(.vertical)
.listRowBackground(Color.clear)
}
}
.alert(isPresented: $showCardAlert) {
Alert(
title: Text("Greatest Band Is: \(bindingText)"),
message: Text(bindingSubText)
)
}
}
.listStyle(.plain)
}
}animationShakeAmount-optional: higher the number the more of an angle of the card. Defaults at 5.0swipeScale-optional:DoubleScales the card to 0.8 as the defaulttitleText:StringMain textsubText:StringsubtextcardID-optional:Stringpassed IDcolor-optional:Stringasset color as a stringimageName-optional:Stringimage name as a string to be used in cardimageHeight-optional:CGFloatimage height. Defaults to 50imageHeight-optional:CGFloatimage width. Defaults to 50showCardAlert:BoolState to show alert
Binding parameters can be used with an alert or confirmationDialog
bindingID:Stringpass State to store ID.bindingText:Stringpass State to store text. This maybe the same as titleTextbindingSubText:Stringpass State to store text. This maybe the same as subText
.alert(isPresented:$showCardAlert) {
Alert(
title: Text("Are you sure you want to delete \(bindingText)?"),
message: Text("There is no undo"),
primaryButton: .destructive(Text("Delete")) {
deleteitem(bindingID)
},
secondaryButton: .cancel()
)
}Credit to https://lukaszadam.com/ for rocket image
Rob Evans, robert.evansii@gmail.com
CloudKitStatus is available under the MIT license. See the LICENSE file for more info.