{"id":18115127,"url":"https://github.com/jtcodes/swipingmediaview","last_synced_at":"2025-04-14T10:36:22.657Z","repository":{"id":107334444,"uuid":"534827483","full_name":"jtCodes/SwipingMediaView","owner":"jtCodes","description":"Photos like media swiping for SwiftUI","archived":false,"fork":false,"pushed_at":"2024-07-04T05:37:52.000Z","size":48,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T23:51:05.510Z","etag":null,"topics":["gifs","image","media","package","photo","photos","swift-package-manager","swiftui","uipageviewcontroller","video"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtCodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-09-09T22:43:51.000Z","updated_at":"2025-02-11T09:57:02.000Z","dependencies_parsed_at":"2024-02-05T17:44:08.730Z","dependency_job_id":null,"html_url":"https://github.com/jtCodes/SwipingMediaView","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtCodes%2FSwipingMediaView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtCodes%2FSwipingMediaView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtCodes%2FSwipingMediaView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtCodes%2FSwipingMediaView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtCodes","download_url":"https://codeload.github.com/jtCodes/SwipingMediaView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248863756,"owners_count":21174068,"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":["gifs","image","media","package","photo","photos","swift-package-manager","swiftui","uipageviewcontroller","video"],"created_at":"2024-11-01T03:08:43.897Z","updated_at":"2025-04-14T10:36:22.403Z","avatar_url":"https://github.com/jtCodes.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwipingMediaView\n\n### Photos like media swiping for SwiftUI\n\n![RPReplay_Final1662876842 2022-09-11 02_21_24](https://user-images.githubusercontent.com/23707104/189515150-98464eb3-def0-4214-beea-ed9105a13a20.gif)\n\n### Features\n- Supports images, gifs and videos\n- Pinch to zoom\n- Drag to dismiss\n- Download images (Important: you must add Privacy - Photo Library Additions Usage Description to info.plist in order to get the download button to work)\n\n### Installation via Swift Package Manager\n\nYou can install `SwipingMediaView` using Swift Package Manager in Xcode:\n\n1. Open your Xcode project.\n2. Navigate to `File` \u003e `Swift Packages` \u003e `Add Package Dependency`.\n3. Enter the repository URL: `https://github.com/jtCodes/SwipingMediaView.git`\n4. Specify the version you want to use. You can specify a version number, a branch name, or a commit hash.\n5. Once added, you can import `SwipingMediaView` in your SwiftUI files and start using it.\n\n### Simple example\n```Swift\n\nimport SwiftUI\nimport SwipingMediaView\n\nstruct ContentView: View {\n    @State var isPresented: Bool = false\n    @State var currentIndex: Int = 1\n    var mediaItems: [SwipingMediaItem] = []\n\n    init() {\n        self.mediaItems =  [SwipingMediaItem(url: \"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4\",\n                                             type: .video),\n                            SwipingMediaItem(url: \"https://i.redd.it/8t6vk567khm91.jpg\",\n                                             type: .image,\n                                             shouldShowDownloadButton: true),\n                            SwipingMediaItem(url: \"https://i.redd.it/gczavw14bfm91.gif\",\n                                             type: .gif)]\n    }\n\n    var body: some View {\n        ZStack {\n            Color.green\n            VStack() {\n                Text(String(currentIndex))\n                Spacer()\n                Button(\"Present gallery view\") {\n                    isPresented = true\n                }\n            }.padding(100)\n        }\n        .background(Color.blue)\n        // FullScreenCover works well in presenting SwipingMediaView\n        .fullScreenCover(isPresented: $isPresented) {\n            ZStack{\n                SwipingMediaView(mediaItems: mediaItems,\n                                 isPresented: $isPresented,\n                                 currentIndex: $currentIndex,\n                                 startingIndex: currentIndex)\n            }\n            // Adding a clear background helper here to achieve on drag fading background effect\n            .background(BackgroundCleanerView())\n            // Ignoring safe area so pinch to zoom don't get cut off\n            .ignoresSafeArea(.all)\n        }\n        .ignoresSafeArea(.all)\n    }\n}\n```\n### Example with horizontal scrolled images and on swipe handling\n```Swift\n\nstruct ContentView: View {\n    @State var isPresented: Bool = false\n    @State var currentIndex: Int = 1\n    var images: [String] = []\n    var mediaItems: [SwipingMediaItem] = []\n\n    init() {\n        for i in 0..\u003c64 {\n            images.append(\"https://picsum.photos/250?image=\" + String(i))\n            mediaItems.append(SwipingMediaItem(url: \"https://picsum.photos/250?image=\" + String(i),\n                                                                                        type: .image,\n                                                                                        title: \"Image \" + String(i)))\n        }\n    }\n\n    var body: some View {\n        ZStack {\n            Color.green.opacity(0.5)\n            VStack() {\n                Text(\"Current index: \" + String(currentIndex))\n                Spacer()\n            }.padding(100)\n\n            // Horizontal scrolled image view.\n            // This is responsible for bringing up the full screen SwipingMediaView.\n            ScrollViewReader { proxy in\n                ScrollView(.horizontal, showsIndicators: false) {\n                    HStack {\n                        ForEach(0..\u003cimages.count) { index in\n                            WebImage(url: URL(string: images[index]))\n                                .resizable()\n                                .scaledToFit()\n                                .frame(width: 300, height: 300, alignment: .center)\n                                .id(index)\n                                .onTapGesture {\n                                    currentIndex = index\n                                    isPresented = true\n                                }\n                        }\n                        // Scrolling the view to the image that's being shown on SwipingMediaView\n                        .onChange(of: currentIndex) { newIndex in\n                            proxy.scrollTo(newIndex, anchor: .top)\n                        }\n                    }\n                }\n            }\n        }\n        // FullScreenCover works well in presenting SwipingMediaView\n        .fullScreenCover(isPresented: $isPresented) {\n            ZStack{\n                SwipingMediaView(mediaItems: mediaItems,\n                                 isPresented: $isPresented,\n                                 currentIndex: $currentIndex,\n                                 startingIndex: currentIndex)\n            }\n            // Adding a clear background helper here to achieve on drag fading background effect\n            .background(BackgroundCleanerView())\n            // Ignoring safe area so pinch to zoom don't get cut off\n            .ignoresSafeArea(.all)\n        }\n        .ignoresSafeArea(.all)\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtcodes%2Fswipingmediaview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtcodes%2Fswipingmediaview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtcodes%2Fswipingmediaview/lists"}