https://github.com/arbyruns/AnimatedSwipeCard/edit/main/README.md#license

AnimatedSwipeCard

AnimatedSwipeCard 是一个带有动画效果的自定义滑动卡片,可以与 confirmationDialogalert 一起使用。

Simulator.Screen.Recording.-.iPhone.13.Pro.-.2022-03-30.at.08.46.50.mp4

安装

AnimatedSwipeCard 可以通过 Swift Package Manager 安装。

用法

使用 AnimatedSwipeCard 很简单

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)
    }
}

参数

绑定参数可以与 alertconfirmationDialog 一起使用。

例子

   .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()
            )
        }

鸣谢

感谢 https://lukaszadam.com/ 提供的火箭图片

作者

Rob Evans, robert.evansii@gmail.com

许可

CloudKitStatus 在 MIT 许可下可用。请参阅 LICENSE 文件以获取更多信息。