{"id":13466248,"url":"https://github.com/phimage/CustomSegue","last_synced_at":"2025-03-25T21:31:48.486Z","repository":{"id":56906972,"uuid":"64055237","full_name":"phimage/CustomSegue","owner":"phimage","description":"Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)","archived":false,"fork":false,"pushed_at":"2019-04-09T13:58:28.000Z","size":504,"stargazers_count":123,"open_issues_count":1,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-15T13:56:55.788Z","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/phimage.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":"2016-07-24T08:04:03.000Z","updated_at":"2024-01-09T19:45:44.000Z","dependencies_parsed_at":"2022-08-20T19:50:22.999Z","dependency_job_id":null,"html_url":"https://github.com/phimage/CustomSegue","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/phimage%2FCustomSegue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FCustomSegue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FCustomSegue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phimage%2FCustomSegue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phimage","download_url":"https://codeload.github.com/phimage/CustomSegue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222091991,"owners_count":16929761,"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:41.507Z","updated_at":"2024-10-29T18:31:27.387Z","avatar_url":"https://github.com/phimage.png","language":"Swift","readme":"# CustomSegue\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n            )](http://mit-license.org)\n[![Platform](http://img.shields.io/badge/platform-osx-lightgrey.svg?style=flat\n             )](https://developer.apple.com/resources/)\n[![Language](http://img.shields.io/badge/language-swift-orange.svg?style=flat\n             )](https://developer.apple.com/swift)\n[![Issues](https://img.shields.io/github/issues/phimage/CustomSegue.svg?style=flat\n           )](https://github.com/phimage/CustomSegue/issues)\n[![Cocoapod](http://img.shields.io/cocoapods/v/CustomSegue.svg?style=flat)](http://cocoadocs.org/docsets/CustomSegue/)\n\n[\u003cimg align=\"left\" src=\"logo.png\" hspace=\"20\"\u003e](#logo)\nCustom segue for OSX Storyboards. Slide and cross fade effects, new customized window.\n\n```swift\nclass MyViewController: NSViewController {\n\n  override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?)\n      if segue.identifier == \"configured\" {\n          if let segue = segue as? PresentWithAnimatorSegue, animator = segue.animator as? TransitionAnimator {\n              animator.duration = 1\n              animator.transition = [.SlideDown, .Crossfade]\n          }\n      }\n  }\n```\n\n`TransitionAnimator` transition is configured via [NSViewControllerTransitionOptions](https://developer.apple.com/reference/appkit/nsviewcontrollertransitionoptions), and suppress the need to use a parent controller with `transitionFromViewController` function.\n\n## Demo\nIn [Example](Example) folder you can launch `pod install` and open `Example.xcworkspace`\n\n\u003cimg src=\"screen.gif\"\u003e\n\n## How to use\nUse `PresentWithAnimatorSegue` in your storyboard or use one of already configured segue: `SlideDownSegue`, `SlideUpSegue`, `SlideLeftSegue`, `SlideRightSegue`, `ChildWindowSegue`, ...\n\n\n### Configure segue\nIn your storyboard add an storyboard identifier to the segue.\n\n\u003cimg src=\"SB_H_set_segue_identifier_2x.png\" width=\"301\" height=\"229\"\u003e\n\nThen in your source view controller, you can configure the segue in `prepare(for segue` function.\n\n```swift\nclass MyViewController: NSViewController {\n  override func prepare(for segue: NSStoryboardSegue, sender: AnyObject?) {\n    if segue.identifier?.rawValue == \"PetDetail\" {\n    ...\n```\n\nYou can use [Natalie](https://github.com/krzyzanowskim/Natalie) to generate code about segue for your controller.\nWith this generate code you can do\n```swift\n  override func prepare(for segue: NSStoryboardSegue, sender: AnyObject?) {\n    if segue.identifier == \"PetDetail\" {\n    // or better the constant generated\n    if segue == MyViewController.Segue.petDetail {\n```\n\nYou can change the duration, the transition type, ... on `animator` object of type `TransitionAnimator`\n```swift\nif let segue = segue as? PresentWithAnimatorSegue, animator = segue.animator as? TransitionAnimator {\n  animator.duration = 1\n  animator.transition = [.SlideDown, .Crossfade]\n}\n```\n\nFor `ChildWindowSegue` you can customize the `NSWindow`, which display the destination controller\n```swift\nif let segue = segue as? ChildWindowSegue, animator = segue.animator as? ChildWindowAnimator {\n    animator.windowCustomizer = { window in\n      window.styleMask = NSBorderlessWindowMask\n      window.setFrameOrigin(NSPoint(...))\n    }\n}\n```\n\n\n:bulb: You can also put your own custom animator.\n```swift\nif let segue = segue as? PresentWithAnimatorSegue {\n  segue.animator = MyAnimator()\n}\n```\n\n## Others segues\n### ReplaceWindowContentSegue\nReplace `contentViewController` of `sourceController` parent `NSWindow` by `destinationController`\n\n:bulb: You can store this segue into `destinationController` and call `unperform` on it to restore `sourceController`\n\n### SplitViewSegue\nSegue that replace the last split view item or add a new one into the `sourceController` parent (`NSSplitViewController`)\n\nSet `replace` to `false` on segue, to add a new split view item.\n\n### DismissSegue\nSegue to dismiss current from controller\n\nAllow to display in storyboard the action as segue instead of simple `IBAction`\n\n### TransitionFromViewSegue\nSegue using parent controller of source and `transitionFromViewController` function\n\n:warning: `parentViewController` must be set and the same for the `sourceController` and `destinationController`\n\n### TablePopoverSegue\nShow `destinationController` in a popover with a position relative to the selected table row\n\n:warning: You must set the `tableView` into segue object (do it in `prepareForSegue`)\n\n:bulb: You can display detail about selected row in a nice way. So in `prepareForSegue` get table view selected row and pass data to `destinationController`\n\n## Present view controller utility method\nLittle utility method added to `NSViewController` using new enum `PresentationMode`.\n```swift\nviewController.present(.asSheet)\nviewController.present(.asModalWindow)\nviewController.present(.segue(segueIdentifier: \"id\"))\nviewController.present(.animator(animator: MyAnimator()))\nviewController.present(.asPopover(...\n\n```\n:warning: `parentViewController` must be set\n\n## Installation\n\n## Using CocoaPods ##\n[CocoaPods](https://cocoapods.org/) is a centralized dependency manager for\nObjective-C and Swift. Go [here](https://guides.cocoapods.org/using/index.html)\nto learn more.\n\n1. Add the project to your [Podfile](https://guides.cocoapods.org/using/the-podfile.html).\n\n    ```ruby\n    use_frameworks!\n\n    pod 'CustomSegue'\n    ```\n\n2. Run `pod install` and open the `.xcworkspace` file to launch Xcode.\n\n\n## Using Carthage ##\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager for Objective-C and Swift.\n\n1. Add the project to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).\n\n    ```\n    github \"phimage/CustomSegue\"\n    ```\n\n2. Run `carthage update` and follow [the additional steps](https://github.com/Carthage/Carthage#getting-started)\n   in order to add Prephirences to your project.\n","funding_links":[],"categories":["Libs","UI [🔝](#readme)"],"sub_categories":["UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphimage%2FCustomSegue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphimage%2FCustomSegue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphimage%2FCustomSegue/lists"}