$ show douban/FRDIntent
FRDIntent is an iOS library designed to decouple view controller navigation through two primary mechanisms: an Intent-like system for internal app navigation (inspired by Android's Intent) and a URL router for handling deep links and app-to-app communication. The library separates these two concerns to avoid the limitations of tightly coupled navigation code, allowing developers to register view controllers against intent actions or URL patterns and launch them without direct dependencies. The architecture employs a protocol-oriented design where view controllers conform to protocols like `FRDIntentReceivable` to declare their ability to handle incoming intents. Core components include a singleton `FRDControllerManager` for managing internal navigation and a `FRDURLRoutes` singleton for processing incoming URLs. The URL routing system utilizes a Trie data structure (implemented in `Trie.swift`) for efficient pattern matching, supporting dynamic placeholders in URL paths (e.g., `/post/:postId`). Additionally, the library provides mechanisms for passing data between view controllers and handling results via callbacks, mirroring Android's `startActivityForResult` pattern. While the library demonstrates solid engineering practicesβsuch as the reusable Trie implementation and clear separation of internal/external navigation concernsβit relies on singletons that may complicate testing and dependency injection. Recent updates (as indicated by the last commit in 2026) show the adoption of modern Swift concurrency features (`@MainActor`, `Task`), though some documentation and configuration files (like the README and podspec) exhibit inconsistencies regarding supported iOS and Swift versions. The inclusion of a demo app and unit tests aids in understanding and verifying the library's functionality.
The LLM identified 1 files worth highlighting for reuse:
This file contains a generic, self-contained implementation of a Trie (prefix tree) data structure in Swift. It supports storing values at nodes and efficient prefix-based searching, which is used by the library's URL routing system to match URL patterns with placeholders (e.g., '/user/:userId'). The implementation is decoupled from the rest of the library and can be reused in other contexts requiring efficient string prefix matching, such as autocomplete systems or routing in other frameworks.