{"id":18301443,"url":"https://github.com/dominicstop/contextmenuauxiliarypreview","last_synced_at":"2025-04-05T14:30:59.881Z","repository":{"id":198860294,"uuid":"701691763","full_name":"dominicstop/ContextMenuAuxiliaryPreview","owner":"dominicstop","description":"A library to add an auxiliary view to the edge of the context menu preview.","archived":false,"fork":false,"pushed_at":"2024-12-15T07:20:11.000Z","size":12597,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-16T14:37:27.460Z","etag":null,"topics":["context-menu","swift","uikit"],"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/dominicstop.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":"2023-10-07T09:31:08.000Z","updated_at":"2025-02-10T19:19:37.000Z","dependencies_parsed_at":"2023-11-13T04:22:57.899Z","dependency_job_id":"e2c188bd-c234-47bb-b96c-bffc8282c22b","html_url":"https://github.com/dominicstop/ContextMenuAuxiliaryPreview","commit_stats":null,"previous_names":["dominicstop/contextmenuauxiliarypreview"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicstop%2FContextMenuAuxiliaryPreview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicstop%2FContextMenuAuxiliaryPreview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicstop%2FContextMenuAuxiliaryPreview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dominicstop%2FContextMenuAuxiliaryPreview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dominicstop","download_url":"https://codeload.github.com/dominicstop/ContextMenuAuxiliaryPreview/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247352337,"owners_count":20925251,"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":["context-menu","swift","uikit"],"created_at":"2024-11-05T15:15:57.097Z","updated_at":"2025-04-05T14:30:54.870Z","avatar_url":"https://github.com/dominicstop.png","language":"Swift","funding_links":["https://github.com/sponsors/dominicstop"],"categories":[],"sub_categories":[],"readme":"# ContextMenuAuxiliaryPreview\n\nA library to add an auxiliary preview to the edge of the context menu preview.\n\n* Support for programmatically showing the context menu.\n* Preset transition for the aux. preview entrance/exit.\n* Support for showing the aux. preview as a popover.\n* This library is used in [`react-native-ios-context-menu`](https://github.com/dominicstop/react-native-ios-context-menu).\n\n\u003cbr\u003e\n\n![test-AuxPreviewTest02ViewController](./Assets/test-AuxPreviewTest02ViewController-01.gif)\n\n![test-AuxPreviewTest02ViewController-02](./Assets/test-AuxPreviewTest02ViewController-02.gif)\n\n\u003cbr\u003e\u003cbr\u003e\n\n### Acknowledgements\n\nDevelopment and maintenance of this library was generously sponsored by [beatgig](https://beatgig.com/) from `11/15/2023` to ` 04/30/2024` at `$1,535`/month (totaling ≈ `$9,100` over the course of 6 months)\n\n\u003cbr\u003e\n\nFurther fixes to this library was made possible through a generous `$3,750` sponsorship by [natew](https://github.com/natew) + [tamagui](https://github.com/tamagui/tamagui) over the course of 4 months (from: `05/27/24` to `09/30/24`) 🐦✨\n\n\u003cbr\u003e\n\nvery special thanks to: [junzhengca](https://github.com/junzhengca), [brentvatne](https://github.com/brentvatne), [expo](https://github.com/expo), [EvanBacon](https://github.com/EvanBacon), [corasan](https://github.com/corasan), [lauridskern](https://github.com/lauridskern), and [ronintechnologies](https://github.com/ronintechnologies) for becoming a monthly sponsor and [fobos531](https://github.com/fobos531) for being a one time sponsor 🥺 (if you have the means to do so, please considering sponsoring [here](https://github.com/sponsors/dominicstop))\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Installation\n\n### Cocoapods\n\n`ContextMenuAuxiliaryPreview` is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your `Podfile`:\n\n```ruby\npod 'ContextMenuAuxiliaryPreview'\n```\n\n\u003cbr\u003e\n\n### Swift Package Manager (SPM)\n\nMethod: #1: Via Xcode GUI:\n\n1. File \u003e Swift Packages \u003e Add Package Dependency\n2. Add `https://github.com/dominicstop/ContextMenuAuxiliaryPreview.git`\n\n\u003cbr\u003e\n\nMethod: #2: Via `Package.swift`:\n\n* Open your project's `Package.swift` file.\n* Update `dependencies` in `Package.swift`, and add the following:\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/dominicstop/ContextMenuAuxiliaryPreview.git\",\n  .upToNextMajor(from: \"0.3.0\"))\n]\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Basic Usage\n\n[🔗 Full Example](./Example/Examples/AuxiliaryPreviewBasicUsage01Controller.swift)\n\n```swift\n// ✨ Some code ommmitted for brevity\n\nimport UIKit\nimport ContextMenuAuxiliaryPreview\n\nclass AuxiliaryPreviewBasicUsage01Controller: UIViewController, ContextMenuManagerDelegate {\n\n  var interaction: UIContextMenuInteraction?;\n  var contextMenuManager: ContextMenuManager?;\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n    self.view.backgroundColor = .white;\n    \n    let boxView: UIView = {\n      let view = UIView();\n      view.backgroundColor = .systemPink;\n      view.layer.cornerRadius = 10;\n      \n      let interaction = UIContextMenuInteraction(delegate: self);\n      self.interaction = interaction;\n      \n      view.addInteraction(interaction);\n      \n      let contextMenuManager = ContextMenuManager(\n        contextMenuInteraction: interaction,\n        menuTargetView: self.view\n      );\n      \n      self.contextMenuManager = contextMenuManager;\n      contextMenuManager.delegate = self;\n      \n      contextMenuManager.auxiliaryPreviewConfig = AuxiliaryPreviewConfig(\n        verticalAnchorPosition: .automatic,\n        horizontalAlignment: .targetCenter,\n        preferredWidth: .constant(100),\n        preferredHeight: .constant(100),\n        marginInner: 10,\n        marginOuter: 10,\n        transitionConfigEntrance: .syncedToMenuEntranceTransition(),\n        transitionExitPreset: .fade\n      );\n\n      return view;\n    }();\n    \n    boxView.translatesAutoresizingMaskIntoConstraints = false;\n    self.view.addSubview(boxView);\n    \n    NSLayoutConstraint.activate([\n      boxView.centerXAnchor.constraint(\n        equalTo: self.view.centerXAnchor\n      ),\n      boxView.centerYAnchor.constraint(\n        equalTo: self.view.centerYAnchor\n      ),\n      boxView.widthAnchor.constraint(\n        equalToConstant: 100\n      ),\n      boxView.heightAnchor.constraint(\n        equalToConstant: 100\n      ),\n    ]);\n  };\n};\n\nextension AuxiliaryPreviewBasicUsage01Controller: UIContextMenuInteractionDelegate {\n\n  func contextMenuInteraction(\n    _ interaction: UIContextMenuInteraction,\n    configurationForMenuAtLocation location: CGPoint\n  ) -\u003e UIContextMenuConfiguration? {\n  \n    self.contextMenuManager!.notifyOnContextMenuInteraction(\n      interaction,\n      configurationForMenuAtLocation: location\n    );\n    \n    return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ -\u003e UIMenu? in\n      let shareAction = UIAction(\n        title: \"Share\",\n        image: UIImage(systemName: \"square.and.arrow.up\")\n      ) { _ in\n        // no-op\n      };\n      \n      return UIMenu(title: \"\", children: [shareAction]);\n    };\n  };\n  \n  func contextMenuInteraction(\n    _ interaction: UIContextMenuInteraction,\n    willDisplayMenuFor configuration: UIContextMenuConfiguration,\n    animator: UIContextMenuInteractionAnimating?\n  ) {\n    \n    self.contextMenuManager!.notifyOnContextMenuInteraction(\n      interaction,\n      willDisplayMenuFor: configuration,\n      animator: animator\n    );\n  };\n  \n  func contextMenuInteraction(\n    _ interaction: UIContextMenuInteraction,\n    willEndFor configuration: UIContextMenuConfiguration,\n    animator: UIContextMenuInteractionAnimating?\n  ) {\n    \n    self.contextMenuManager!.notifyOnContextMenuInteraction(\n      interaction,\n      willEndFor: configuration,\n      animator: animator\n    );\n  };\n  \n  func onRequestMenuAuxiliaryPreview(sender: ContextMenuManager) -\u003e UIView? {\n    let menuAuxiliaryPreview = UIView(frame: .zero);\n    menuAuxiliaryPreview.backgroundColor = .red;\n    \n    return menuAuxiliaryPreview;\n  };\n};\n\n```\n\n![AuxiliaryPreviewBasicUsage01](./Assets/example-AuxiliaryPreviewBasicUsage01.gif)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdominicstop%2Fcontextmenuauxiliarypreview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdominicstop%2Fcontextmenuauxiliarypreview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdominicstop%2Fcontextmenuauxiliarypreview/lists"}