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
:Double
Scales the card to 0.8 as the defaulttitleText
:String
Main textsubText
:String
subtextcardID
-optional
:String
passed IDcolor
-optional
:String
asset color as a stringimageName
-optional
:String
image name as a string to be used in cardimageHeight
-optional
:CGFloat
image height. Defaults to 50imageHeight
-optional
:CGFloat
image width. Defaults to 50showCardAlert
:Bool
State to show alert
Binding parameters can be used with an alert
or confirmationDialog
bindingID
:String
pass State to store ID.bindingText
:String
pass State to store text. This maybe the same as titleTextbindingSubText
:String
pass 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.