{"id":13466373,"url":"https://github.com/canalesb93/MantleModal","last_synced_at":"2025-03-25T21:32:10.648Z","repository":{"id":47603181,"uuid":"46036794","full_name":"canalesb93/MantleModal","owner":"canalesb93","description":"A draggable modal for iOS Applications.","archived":true,"fork":false,"pushed_at":"2019-04-09T21:18:14.000Z","size":107,"stargazers_count":90,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T23:03:44.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/canalesb93.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":"2015-11-12T07:30:11.000Z","updated_at":"2023-04-28T20:26:29.000Z","dependencies_parsed_at":"2022-09-10T15:52:07.912Z","dependency_job_id":null,"html_url":"https://github.com/canalesb93/MantleModal","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canalesb93%2FMantleModal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canalesb93%2FMantleModal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canalesb93%2FMantleModal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canalesb93%2FMantleModal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canalesb93","download_url":"https://codeload.github.com/canalesb93/MantleModal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245548235,"owners_count":20633546,"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":[],"created_at":"2024-07-31T15:00:43.157Z","updated_at":"2025-03-25T21:32:10.181Z","avatar_url":"https://github.com/canalesb93.png","language":"Swift","funding_links":[],"categories":["Libs","UI [🔝](#readme)"],"sub_categories":["UI"],"readme":"# Mantle Modal\nDraggable Modal, PopUp or Menu written in Swift.\n## Description\nA simple modal resource that uses a UIScrollView to allow the user to close the view by removing it from the screen.\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"http://imgur.com/0qsFWtS.gif\" width=31%\u003e\n\u003cimg src=\"http://i.imgur.com/QXaRUF8.gif\" width=31%\u003e\n\u003cimg src=\"http://i.imgur.com/4QVNkgf.gif\" width=31%\u003e\n\u003c/div\u003e\n\n## Install Instructions\n\n#### CocoaPods\nMantleModal is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\nuse_frameworks!\n\ntarget 'ProjectName' do\n  pod 'MantleModal'\nend\n```\n\nThen, run `pod install`\n\nIn case you haven't installed CocoaPods yet, run the following command\n\n```ruby\n$ gem install cocoapods\n```\n\n#### Manual\nDrag the file named `RCMantleViewController.swift` into your project.\n\n## Usage\n\nSetup is faily simple, but I have plans to make it even easier later.\n### Step 1\nAdd a new View Controler into your storyboard and set the **Class** to `RCMantleViewController` and the **Storyboard ID** to `MantleViewController`.\n\n\u003cdiv align=\"center\"\u003e\u003cimg src=\"http://imgur.com/PEwQ2dA.png\" width=300\u003e\u003c/div\u003e\n### Step 2\nAdd your own view into your storyboard which will represent the modal. Also set a unique **Storyboard ID** to it.\n\u003cdiv align=\"center\"\u003e\u003cimg src=\"http://imgur.com/R3P0fN4.png\"\u003e\u003c/div\u003e\nIf you are gonna use a PopUp set the background view color transparent.\n\n### Step 3 \nImport the module to your parent controller(if your using CocoaPods)\n\n```swift\n  import MantleModal\n```\n\nActivate the modal like this in your parent controller.\n\n```swift\n  // Create the MantleViewController from the Storyboard using the ID\n  let mantleViewController = storyboard!.instantiateViewControllerWithIdentifier(\"MantleViewController\") as! RCMantleViewController\n  // Create your modal controller with your storyboard ID\n  let popUpViewController = storyboard!.instantiateViewControllerWithIdentifier(\"YourUniqueStoryboardID\") as! YourViewController\n  // Set it's delegate to be able to call 'delegate.dismissView(animated: Bool)'\n  popUpViewController.delegate = mantleViewController\n  // Initialize Mantle\n  mantleViewController.setUpScrollView()\n  // Add your modal to Mantle\n  mantleViewController.addToScrollViewNewController(popUpViewController)\n  // Present the modal through the MantleViewController\n  self.presentViewController(mantleViewController, animated: false, completion: nil)\n```\n### Step 4\nIn your modal's controller also import:\n\n```swift\n  import MantleModal\n```\n\nThen define your delegate helper.\n\n```swift\n  var delegate: RCMantleViewDelegate!\n```\nAnd then dismiss the modal using this:\n\n```swift\n  delegate.dismissView(true)\n```\n\n## Configuration\nMantleModal currently includes some configuration which you must call before `mantleViewController.setUpScrollView()`.\nThe current configuration available includes:\n\n```swift\n\n  // Allows you to dismiss the view by dragging up\n  mantleViewController.bottomDismissible = false\n  // Allows you to dismiss the view by dragging down\n  mantleViewController.topDismissable = true\n  // Allows you to drag to the sides to close\n  mantleViewController.draggableToSides = false\n\n  // 'appearOffset' moves the menu closer to the edge so that it appears quicker\n  mantleViewController.appearOffset = CGFloat(290)\n  // '290' could be the distance between the top of the popup and the top of the screen \n  \n  // Makes the view present from the top, can be set multiple times before presenting\n  // Also makes it hide to the top.\n  mantleViewController.appearFromTop = true // // default = false\n```\n\nYou can also access the ScrollView and modify its options, just make sure you do it after calling `mantleViewController.setUpScrollView()`\n\n```swift\n  mantleViewController.scrollView.bounces = false\n```\n\n## How it works\nThe view you are actually presenting is actually a `UIScrollView` with a larger `UIView` inside that contains your own view along with extra empty space that is fully created by `RCMantleViewController`. `RCMantleViewController` will then detect when your view is no longer centered in the ScrollView and dismiss the complete view. It does not use native modal animations and uses the `UIScrollView`'s *scroll to content* animation.\n\n## Pending\n* Orientation change support.\n* More...\n\n## Credits\n\nMostly done by myself - **Ricardo Canales**\n\nI am still have many things to learn about iOS development so any suggestions and contributions are welcome.\n\nInitial code inspired by this [StackOverflow](http://stackoverflow.com/questions/24687140/snapchat-like-swipe-navigation-between-views-in-xcode-6-and-swift) post.\nCredit to [lbrendanl](https://github.com/lbrendanl) and [Poql](http://stackoverflow.com/users/3857555/poql)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanalesb93%2FMantleModal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanalesb93%2FMantleModal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanalesb93%2FMantleModal/lists"}