{"id":18269859,"url":"https://github.com/demharusnam/SwiftUIDrag","last_synced_at":"2025-04-04T23:31:39.826Z","repository":{"id":44158111,"uuid":"299456197","full_name":"demharusnam/SwiftUIDrag","owner":"demharusnam","description":"A simple, customizable, and intuitive SwiftUI wrapper-view enabling dragging, floating, and/or collapsing for its content. ","archived":false,"fork":false,"pushed_at":"2024-01-11T18:12:15.000Z","size":5106,"stargazers_count":49,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-05T11:51:45.397Z","etag":null,"topics":["ios","ios-app","swift","swiftui"],"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/demharusnam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2020-09-28T23:38:31.000Z","updated_at":"2024-08-04T16:58:18.000Z","dependencies_parsed_at":"2024-11-05T11:42:14.895Z","dependency_job_id":"94110242-dd2f-4a0e-afd6-a6d438595709","html_url":"https://github.com/demharusnam/SwiftUIDrag","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demharusnam%2FSwiftUIDrag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demharusnam%2FSwiftUIDrag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demharusnam%2FSwiftUIDrag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demharusnam%2FSwiftUIDrag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demharusnam","download_url":"https://codeload.github.com/demharusnam/SwiftUIDrag/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266476,"owners_count":20910831,"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":["ios","ios-app","swift","swiftui"],"created_at":"2024-11-05T11:37:37.080Z","updated_at":"2025-04-04T23:31:35.989Z","avatar_url":"https://github.com/demharusnam.png","language":"Swift","readme":"# SwiftUIDrag [NO LONGER MAINTAINED]\n\nA simple, customizable, and intuitive wrapper-view enabling dragging, floating, and/or collapsing for its content.  Written entirely in SwiftUI, SwiftUIDrag is inspired by iOS 14's Picture-in-Picture feature.\n\n![Floating TabView demo of SDView](README_Assets/tabview_preview.gif) ![VideoPlayer demo of SDView](README_Assets/video_preview.gif) ![Rectangle demo of SDView](README_Assets/rectangle_preview.gif)\n\n## Table of Contents\n- [Usage](#usage)\n- [Key Features](#key-features)\n    - [Alignment](#alignment)\n    - [Floating](#floating)\n    - [Collapse](#collapse)\n    - [Visible Size](#visible-size)\n    - [Content](#content)\n- [Installation](#installation)\n- [Author](#author)\n- [License](#license)\n\n## Usage \n\n```swift\nSDView(floating: .leading, collapse: .trailing) { geo, state in\n    RoundedRectangle(cornerRadius: 25)\n        .fill(Color.blue)\n        .frame(width: geo.size.width / 2, height: geo.size.height / 4)\n        .overlay(\n            HStack {\n                Image(systemName: \"chevron.left\")\n                .foregroundColor(.white)\n                .frame(width: 10, height: 20)\n                .opacity(state.isCollapsed \u0026\u0026 state.isTrailing ? 1 : 0)\n                .padding(.leading)\n                \n                Spacer()\n            }\n        )\n}\n```\nThis code enables the capabilities seen in the blue rectangle demo above.\n\n## Key Features\n\nBelow is the default initializer which ***requires*** you to enter only one parameter: the content to inherit the SDView drag, floating, and/or collapse properties. The remaining parameters all have default values that can be left as is or can be customized for your use-case.\n\n```swift\nSDView(\n    alignment: Alignment = .center,\n    floating: SDFloatingOptions = [],\n    collapse: SDCollapseOptions = .horizontal,\n    visibleSize: CGSize = CGSize(width: 60, height: 60),\n    @ViewBuilder content: @escaping (GeometryProxy, SDContentState) -\u003e Content\n)\n```\nThe quickest way to get started is with the default paramters as such:\n\n```swift\nSDView { _, _ in\n    // your content.\n}\n```\n\n### Alignment\n\nThe `alignment` parameter allows you to position your content based on SwiftUI's  `Alignment` struct. By default, it is set to `center` which positions your content in the center of SDView. Thus, you get access to the following options:\n\n| Options | \n| ----- | \n| `topLeading` |\n|`top` | \n|`topTrailing` |\n| `leading` |\n|`center` | \n|`trailing` |\n| `bottomLeading` | \n|`bottom` |\n|`bottomTrailing` |\n\n### Floating\n\nThe `floating` parameter enables you to float your content on the edges of the SDView. By default, it is set to `[]` which disables floating. Customization is at the heart of this package, thus you get access to the following options:\n\n| Option | Description |\n| -------- | ------------ |\n| `[]` | disables floating |\n| `topLeading` | enables floating content on the top-leading side of SDView |\n| `topTrailing` | enables floating content on the top-trailing side of SDView |\n| `bottomLeading` | enables floating on the bottom-leading side of SDView |\n| `bottomTrailing` | enables floating on the bottom-trailing side of SDView |\n| `top` | enables floating content on either the top-leading or top-trailing sides of SDView |\n| `bottom` | enables floating content on either the bottom-leading or bottom-trailing sides of SDView |\n| `leading `| enables floating content on either the top-leading or bottom-leading sides of SDView |\n| `trailing` | enables floating content on either the top-trailing or bottom-trailing sides of SDView |\n| `all` | enables floating content on either the top-leading, top-trailing, bottom-leading, bottom-trailing sides of SDView |\n\n\n### Collapse\n\nThe `collapse` parameter enables you to collapse your content into the sides of the SDView with a set `visibleSize`. By default, it is set to `horizontal` which only enables collapsing on the `leading` and `trailing` sides. Customization is at the heart of this package, thus you get access to the following options:\n\n| Option | Description |\n| -------- | ------------ |\n| `[]` | disables collapsing |\n| `top` | enables collapsing content on the top side of SDView |\n| `bottom` | enables collapsing content on the bottom side of SDView |\n| `leading` | enables collapsing on the leading side of SDView |\n| `trailing` | enables collapsing on the trailing side of SDView |\n| `horizontal` | enables collapsing content on either the leading or trailing sides of SDView |\n| `vertical` | enables collapsing content on either the top or bottom sides of SDView |\n| `all` | enables collapsing content on either the top, bottom, leading, trailing sides of SDView |\n\n### Visible Size\n\nThe `visibleSize` parameter determines how much width or height of your content should be visible upon collapse. By default it is set to `60` for both. \n\n### Content\n\nThe `content` parameter is  `@escaping`- and `@ViewBuilder`-wrapped which enables escaping into curly braces for you to easily describe your content in. Additionally, you get two callback parameters: `GeometryProxy` and `SDContentState`. \n\nThe `GeometryProxy` enables you to customize any framing, positioning, and/or sizing based on the SDView. \n\nThe `SDContentState` parameter indicates the state of your content. Once again, customization is at the heart of this package, so you get the following state options:\n\n| Option | Description |\n| -------- | ------------ |\n| `top` | content is collapsed on the top side of SDView |\n| `bottom` | content is collapsed on bottom side of SDView |\n| `leading `| content is collapsed on leading side of SDView |\n| `trailing` | content is collapsed on trailing side of SDView |\n| `topLeading` | content is floating on top-leading side of SDView |\n| `topTrailing` | content is floating on top-trailing side of SDView |\n| `bottomLeading` | content is floating on the bottom-leading side of SDView |\n| `bottomTrailing` | content is floating on the bottom-trailing side of SDView |\n| `expanded` | content is neither collapse nor floating on any side of SDView |\n\nTo take it a step further, you also get access to `Bool` variables that allow for *swift* verification of the content state:\n\n| Option | Description |\n| -------- | ------------ |\n| `isTop` | content is either collapsed or floating on the top side of SDView |\n| `isBottom `| content is either collapsed or floating on the bottom side of SDView |\n| `isLeading` | content is either collapsed or floating on the leading side of SDView  |\n| `isTrailing` | content is either collapsed or floating on the trailing side of SDView |\n| `isCollapsed` | content is collapsed in SDView |\n| `isFloating` | content is floating in SDView |\n| `isExpanded` | content is expanded |\n\n## Installation\n\nSwiftUIDrag can be installed via Swift Package Manager (SPM) in Xcode:\n\n1. Navigate to the SPM (**File \u003e Swift Packages \u003e Add Package Dependency...**)\n2. Either enter the URL (**https://github.com/demharusnam/SwiftUIDrag**) or the name of the package in the search bar. If you opted for the latter, select the displayed package with myself (**demharusnam**) as the owner.\n\n## Author\n\nMy name is Mansur. At the time of publishing SwiftUIDrag, I am an undergraduate computer engineering student from Toronto, Canada. I love Swift, SwiftUI, and creating software.\n\nIf you have any questions regarding SwiftUIDrag, please feel free to contact [me](https://github.com/demharusnam). \n\nHappy hacking!\n\n## License\n\nSwiftUIDrag is available under the MIT license. See LICENSE for more information.\n","funding_links":[],"categories":["swiftui"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemharusnam%2FSwiftUIDrag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemharusnam%2FSwiftUIDrag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemharusnam%2FSwiftUIDrag/lists"}