{"id":20555459,"url":"https://github.com/ivkuznetsov/coordinators","last_synced_at":"2025-04-14T12:44:39.617Z","repository":{"id":188261326,"uuid":"678421882","full_name":"ivkuznetsov/Coordinators","owner":"ivkuznetsov","description":"This repository contains an implementation of the Coordinator pattern for SwiftUI, providing a structured way to manage complex navigation flows, including handling both navigation stacks and modal presentations.","archived":false,"fork":false,"pushed_at":"2024-11-14T11:45:20.000Z","size":30,"stargazers_count":31,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T01:53:34.326Z","etag":null,"topics":["coordinator","ios","modals","navigation","swift","swiftui","user-interface","userexperience","ux-ui"],"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/ivkuznetsov.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-08-14T14:11:08.000Z","updated_at":"2025-03-27T17:36:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"c04ea126-4fbb-4ce4-83b7-f9e3224b0d8c","html_url":"https://github.com/ivkuznetsov/Coordinators","commit_stats":null,"previous_names":["ivkuznetsov/coordinators"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkuznetsov%2FCoordinators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkuznetsov%2FCoordinators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkuznetsov%2FCoordinators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivkuznetsov%2FCoordinators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivkuznetsov","download_url":"https://codeload.github.com/ivkuznetsov/Coordinators/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248883390,"owners_count":21177204,"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":["coordinator","ios","modals","navigation","swift","swiftui","user-interface","userexperience","ux-ui"],"created_at":"2024-11-16T03:18:29.139Z","updated_at":"2025-04-14T12:44:39.576Z","avatar_url":"https://github.com/ivkuznetsov.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coordinators\n\nThis repository contains an implementation of the Coordinator pattern for SwiftUI, providing a structured way to manage complex navigation flows, including handling both navigation stacks and modal presentations.\n\n## Overview\n\nThe Coordinator pattern helps manage navigation in a more structured and maintainable way by centralizing navigation logic. This implementation includes support for:\n\nNavigation Stack: Navigate between different screens in a push/pop style.\nModal Presentation: Present modals, including entire navigation flows inside modal views.\n\n## Example Usage\n\n### 1. Defining a Coordinator\n```swift\nfinal class SomeCoordinator: NavigationModalCoordinator {\n    \n    // Enum to define the screens that can be navigated to\n    enum Screen: ScreenProtocol {\n        case screen1\n        case screen2\n        case screen3\n    }\n    \n    // Define destination views for each screen\n    func destination(for screen: Screen) -\u003e some View {\n        switch screen {\n        case .screen1: Screen1View()\n        case .screen2: Screen2View()\n        case .screen3: Screen3View()\n        }\n    }\n    \n    // Enum to define modal flows that can be presented\n    enum ModalFlow: ModalProtocol {\n        case modalScreen1\n        case modalFlow(ChildCoordinator = .init())\n    }\n    \n    // Define destination views for each modal flow\n    func destination(for flow: ModalFlow) -\u003e some View {\n        switch flow {\n        case .modalScreen1: Modal1View()\n        case .modalFlow(let coordinator): coordinator.view(for: .rootScreen)\n        }\n    }\n}\n```\n\n### 2. Using the Coordinator\nYou can use the coordinator to push views onto the navigation stack or present modals.\n\nDisplaying a screen as the root view:\n```swift\ncoordinator.view(for: .screen1)\n```\n\nPushing a new screen onto the navigation stack:\n```swift\ncoordinator.present(.screen1)\n```\n\nPresenting a modal flow:\n```swift\ncoordinator.present(.modalFlow())\n```\n\n### 3. Accessing the Coordinator in Views\n\nYou can access the current coordinator inside any view by injecting it as an environment object:\n```swift\n@EnvironmentObject var coordinator: Navigation\u003cSomeCoordinator\u003e\n```\nThis allows you to trigger navigation actions directly from views, maintaining a clean and decoupled architecture.\n\n## Meta\n\nIlya Kuznetsov – i.v.kuznecov@gmail.com\n\nDistributed under the MIT license. See ``LICENSE`` for more information.\n\n[https://github.com/ivkuznetsov](https://github.com/ivkuznetsov)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivkuznetsov%2Fcoordinators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivkuznetsov%2Fcoordinators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivkuznetsov%2Fcoordinators/lists"}