{"id":15288696,"url":"https://github.com/edudnyk/solidscroll","last_synced_at":"2025-04-13T05:34:46.451Z","repository":{"id":50398403,"uuid":"419158669","full_name":"edudnyk/SolidScroll","owner":"edudnyk","description":"A liberated _ScrollView and _PagingView of SwiftUI.","archived":false,"fork":false,"pushed_at":"2021-10-20T03:13:02.000Z","size":18,"stargazers_count":92,"open_issues_count":3,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T11:36:49.472Z","etag":null,"topics":["carousel","pagination","scrollview","swiftui","tabbar"],"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/edudnyk.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}},"created_at":"2021-10-20T02:25:19.000Z","updated_at":"2024-12-03T21:26:28.000Z","dependencies_parsed_at":"2022-08-16T01:30:27.417Z","dependency_job_id":null,"html_url":"https://github.com/edudnyk/SolidScroll","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edudnyk%2FSolidScroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edudnyk%2FSolidScroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edudnyk%2FSolidScroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edudnyk%2FSolidScroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edudnyk","download_url":"https://codeload.github.com/edudnyk/SolidScroll/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670517,"owners_count":21142896,"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":["carousel","pagination","scrollview","swiftui","tabbar"],"created_at":"2024-09-30T15:52:07.161Z","updated_at":"2025-04-13T05:34:46.179Z","avatar_url":"https://github.com/edudnyk.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ``SolidScroll``\n\nA liberated `_ScrollView` and `_PagingView` of **SwiftUI**.\n\n## Overview\n\n**SolidScroll** allows to unlock the potential of the scroll view in SwiftUI.\n\nUnlike the regular SwiftUI `ScrollView` and `ScrollViewProxy`, the hidden SwiftUI `_ScrollView` and `_ScrollViewProxy` types allow to get near-UIScrollView control over the status of scrolling in real time, content insets, animate content offset, and much more.\n\n**SolidScroll** is a set of type aliases to SwiftUI hidden types, and couple of helper initializers for the convinience.\n\nAlso, the library contains docc-compatible documentation where each type alias is represented with the hidden interface of the aliased type.\n\n### Advanced scroll view use-cases\n\nSwiftUI has a hidden `_ContainedScrollViewKey` type, which is actually a not-publicly-conformed `PreferenceKey` type.\nThis preference reports the `_ScrollViewProxy` where all functionality of the `_ScrollView` is unlocked.\nIn order to get the proxy, simply create `SolidScrollView` in the `body` of your view, then store the proxy in a `@State`, as shown in the following example:\n\n```swift\nimport SolidScroll\n\nstruct ContentView: View {\n  var config = ScrollViewConfig()\n  @State var scrollViewProxy: SolidScrollViewProxy?\n\n  var body: some View {\n    VStack(spacing: 0) {\n      SolidScrollView(config) {\n        VStack(spacing: 0) {\n          Color.red.frame(height: 200)\n          Color.green.frame(height: 200)\n          Color.blue.frame(height: 200)\n          Color.black.frame(height: 200)\n        }\n      }\n      Button(\"Scroll to 3/4 of the content height via proxy\") {\n        guard let scrollViewProxy = scrollViewProxy else { return }\n        let contentOffset = CGPoint(x: 0, y: min(scrollViewProxy.contentSize.height * 3.0 / 4, scrollViewProxy.maxContentOffset.y))\n        scrollViewProxy.setContentOffset(contentOffset, animated: true, completion: { completed in\n          print(\"Scrolled via proxy to \\(contentOffset)! Completed: \\(completed)\")\n        })\n      }\n    }\n    .onPreferenceChange(ContainedScrollViewKey.self) {\n      scrollViewProxy = $0\n    }\n  }\n}\n```\n\n### Advanced scroll view use-cases with paging\n\nFor paging, SwiftUI has a different hidden type called `_PagingView`. It's a wrapper on scroll view that supports paging.\nThe direction of the scrolling and the size of the page in the scrolling direction is controlled by `_PagingViewConfig`.\nAll pages take the same size. If size is `nil`, page takes the full available width or height on the screen (in correspondance with the scroll direction).\nIt's useful for implementation of custom tab bar, image carousel or other pagination behavior.\nThe usage example is shown below.\n\n```swift\nimport SolidScroll\n\nstruct PagingContentView: View {\n  @State var currentPage: Int = 0\n  let config: PagingViewConfig\n\n  init() {\n    var config = PagingViewConfig()\n    config.direction = .horizontal\n    config.size = 100\n    config.margin = 0\n    config.spacing = 0\n    self.config = config\n  }\n\n  var body: some View {\n    PagingView(config: config, page: $currentPage, views: Array(0...10).map { page(at: $0) })\n  }\n\n  @ViewBuilder\n  func page(at index: Int) -\u003e some View {\n    Text(\"Page \\(index)\")\n      .frame(maxWidth: .infinity, maxHeight: .infinity)\n      .background(backgroundColor(at: index))\n  }\n\n  func backgroundColor(at index: Int) -\u003e Color {\n    let indexMod = (index % 3)\n    switch indexMod {\n    case 0: return Color.red\n    case 1: return Color.green\n    case 2: return Color.blue\n    default: return Color.clear\n    }\n  }\n}\n```\n\n## Demo of the library \n\n[![SolidScroll Demo on YouTube](https://img.youtube.com/vi/pFJ6qUyZ43E/sddefault.jpg)](https://youtu.be/pFJ6qUyZ43E)\n\n\n## Installation\n\n### Xcode 13\n\n1. Select your project in File Navigator, then select the project again on top of the list of targets. You'll see list of packages.\n2. Press ＋ button.\n3. In the appeared window, press ＋ button in the bottom left corner.\n4. In the appeared menu, select \"Add Swift Package Collection\"\n5. In the appeared dialog, enter package collection URL: [https://swiftpackageindex.com/edudnyk/collection.json](https://swiftpackageindex.com/edudnyk/collection.json)\n6. Press \"Add Collection\"\n7. Select **SolidScroll** package from the collection.\n\n\nIf you want to use **SolidScroll** in any other project that uses SwiftPM, add the package as a dependency in `Package.swift`:\n\n```swift\ndependencies: [\n  .package(name: \"SolidScroll\", url: \"https://github.com/edudnyk/SolidScroll.git\", from: \"0.0.1\"),\n]\n```\n\nNext, add **SolidScroll** as a dependency of your test target:\n\n```swift\ntargets: [\n  .target(name: \"MyApp\", dependencies: [\"SolidScroll\"], path: \"Sources\"),\n]\n```\n\n### Carthage\n\nIf you use Carthage, you can add the following dependency to your Cartfile:\n\n```\ngithub \"edudnyk/SolidScroll\" ~\u003e 0.0.1\n```\n\n### CocoaPods\n\nIf your project uses CocoaPods, add the pod to any applicable targets in your Podfile:\n\n```ruby\ntarget 'MyApp' do\n  pod 'SolidScroll', '~\u003e 0.0.1'\nend\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedudnyk%2Fsolidscroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedudnyk%2Fsolidscroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedudnyk%2Fsolidscroll/lists"}