SHORT QUESTIONS

How i will swipe list item in swiftUI?

// // ListSwipeView.swift // BeginerLabelAllDemo // // Created by JOYNAL ABEDIN on 22/10/22. // import SwiftUI struct ListSwipeView: View { @State var fruits = [\"Apple\", \"Banana\", \"Orange\"]...

J
Joynal Abedin
4
//
//  ListSwipeView.swift
//  BeginerLabelAllDemo
//
//  Created by JOYNAL ABEDIN on 22/10/22.
//

import SwiftUI

struct ListSwipeView: View {
    
    @State var fruits = [\"Apple\", \"Banana\", \"Orange\"]
    
    var body: some View {
        List {
            ForEach(fruits, id: \.self) { fruit in
                Text(fruit)
                    .swipeActions(edge: .trailing, allowsFullSwipe: false) { //left side swipe
                        Button {
                            //action here
                        } label: {
                            VStack {
                                Image(systemName: \"trash.circle\")
                                    .resizable()
                            }
                        }
                        .tint(.yellow)
                    }
                    .swipeActions(edge: .leading, allowsFullSwipe: false) { //right side swipe
                        Button {
                            //action here
                        } label: {
                            VStack {
                                Text(\"Remove\")
                                    .foregroundColor(.red)
                            }
                        }
                        .tint(.yellow)
                    }
            }
        }
    }
}
J

Written by Joynal Abedin

Passionate about technology, code, and sharing knowledge.

0 Comments

Leave a Comment