{"id":13778353,"url":"https://github.com/EnesKaraosman/SwipeCell","last_synced_at":"2025-05-11T11:35:30.182Z","repository":{"id":43474114,"uuid":"262656447","full_name":"EnesKaraosman/SwipeCell","owner":"EnesKaraosman","description":"Swipe Left2Right \u0026 Right2Left, pure SwiftUI implementation","archived":false,"fork":false,"pushed_at":"2022-09-16T13:01:13.000Z","size":1997,"stargazers_count":271,"open_issues_count":0,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-07-12T04:36:51.635Z","etag":null,"topics":["custom-cell","left-to-right","swiftui","swipe","swipecell","swipecellkit"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EnesKaraosman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"enesKaraosman","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-05-09T20:49:24.000Z","updated_at":"2024-04-10T14:33:56.000Z","dependencies_parsed_at":"2023-01-18T10:37:08.360Z","dependency_job_id":null,"html_url":"https://github.com/EnesKaraosman/SwipeCell","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnesKaraosman%2FSwipeCell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnesKaraosman%2FSwipeCell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnesKaraosman%2FSwipeCell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnesKaraosman%2FSwipeCell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EnesKaraosman","download_url":"https://codeload.github.com/EnesKaraosman/SwipeCell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213837544,"owners_count":15645729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-cell","left-to-right","swiftui","swipe","swipecell","swipecellkit"],"created_at":"2024-08-03T18:00:53.214Z","updated_at":"2024-08-03T18:04:44.581Z","avatar_url":"https://github.com/EnesKaraosman.png","language":"Swift","funding_links":["https://github.com/sponsors/enesKaraosman"],"categories":["List","Swift"],"sub_categories":["Content"],"readme":"# SwipeCell\n\n### Preview\n![](https://github.com/EnesKaraosman/SwipeCell/blob/master/Sources/SwipeCell/Resources/swipe_cell_both.png)\n\n### Features\n\n- [x] Swipe cell from Left2Right \u0026 Right2Left.\n- [ ] Destructive swipe\n\n### Usage\n\n* Simply add `onSwipe(leading, trailing)` method to your list item\n\n```swift\nList {\n    HStack {\n        Text(\"Enes Karaosman\")\n        Spacer()\n    }\n    .listRowInsets(EdgeInsets())\n    .onSwipe(leading: [\n      .. // here add slots\n    ])\n    \n}\n```\n\nBut what is `Slot`? \u003cbr\u003e\nIt's just a container that wraps your elements\n\n```swift\npublic struct Slot: Identifiable {\n    \n    /// The Icon will be displayed.\n    public let image: () -\u003e Image\n    \n    /// To allow modification on Text, wrap it with AnyView.\n    public let title: () -\u003e AnyView\n    \n    /// Tap Action\n    public let action: () -\u003e Void\n    \n    /// Style\n    public let style: SlotStyle\n}\n\npublic struct SlotStyle {\n    \n    /// Background color of slot.\n    public let background: Color\n    \n    /// Image tint color\n    public let imageColor: Color // default = .white\n    \n    /// Individual slot width\n    public let slotWidth: CGFloat // default = 60\n}\n```\n\nThat's it, here is full working example\n\n```swift\nstruct SwipeCellDemoView: View {\n    \n    var slidableContent: some View {\n        HStack(spacing: 16) {\n            Image(systemName: \"person.crop.circle.fill\")\n            .resizable()\n            .scaledToFit()\n            .foregroundColor(.secondary)\n            .frame(height: 60)\n            \n            VStack(alignment: .leading) {\n                Text(\"Enes Karaosman\")\n                .fontWeight(.semibold)\n            \n                Text(\"eneskaraosman53@gmail.com\")\n                .foregroundColor(.secondary)\n            }\n        }.padding()\n    }\n    \n    var slots = [\n        // First item\n        Slot(\n            image: {\n                Image(systemName: \"envelope.open.fill\")\n            },\n            title: {\n                Text(\"Read\")\n                .foregroundColor(.white)\n                .font(.footnote)\n                .fontWeight(.semibold)\n                .embedInAnyView()\n            },\n            action: { print(\"Read Slot tapped\") },\n            style: .init(background: .orange)\n        ),\n        // Second item\n        Slot(\n            image: {\n                Image(systemName: \"hand.raised.fill\")\n            },\n            title: {\n                Text(\"Block\")\n                .foregroundColor(.white)\n                .font(.footnote)\n                .fontWeight(.semibold)\n                .embedInAnyView()\n            },\n            action: { print(\"Block Slot Tapped\") },\n            style: .init(background: .blue, imageColor: .red)\n        )\n    ]\n    \n    var left2Right: some View {\n        slidableContent\n        .frame(height: 60)\n        .padding()\n        .onSwipe(leading: slots)\n    }\n    \n    var right2Left: some View {\n        slidableContent\n        .frame(height: 60)\n        .padding()\n        .onSwipe(trailing: slots)\n    }\n    \n    var leftAndRight: some View {\n        slidableContent\n        .frame(height: 60)\n        .padding()\n        .onSwipe(leading: slots, trailing: slots)\n    }\n    \n    var items: [AnyView] {\n        [\n            left2Right.embedInAnyView(),\n            right2Left.embedInAnyView(),\n            leftAndRight.embedInAnyView()\n        ]\n    }\n    \n    var body: some View {\n        NavigationView {\n            List {\n                ForEach(items.indices, id: \\.self) { idx in\n                    self.items[idx]\n                }.listRowInsets(EdgeInsets())\n            }.navigationBarTitle(\"Messages\")\n        }\n    }\n    \n}\n```\n\n### Custom\n\nIn demo I used system images, but using local image is allowed as well.\n\n```swift\nListItem\n    .onSwipe(leading: [\n        Slot(\n            image: {\n                Image(\"localImageName\")\n                    // To allow colorifying\n                    .renderingMode(.template)\n            },\n            title: {\n                Text(\"Title\").embedInAnyView()\n            },\n            action: { print(\"Slot tapped\") },\n            style: .init(background: .orange)\n        )\n    ])\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEnesKaraosman%2FSwipeCell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEnesKaraosman%2FSwipeCell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEnesKaraosman%2FSwipeCell/lists"}