Portugalraamcosta/compose-destinations
Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
🧭 Compose Destinations: Điều hướng Jetpack Compose type-safe, hết sạch boilerplate
Chỉ cần annotation, mọi thứ còn lại tự sinh — không route string, không NavType, không bundle thủ công.
Compose Destinations là thư viện Kotlin dùng KSP xử lý annotation để sinh code điều hướng dựa trên Official Jetpack Compose Navigation. Thay vì viết hàng loạt code lặp lại và dễ sai, bạn chỉ cần đánh dấu các Composable screen bằng @Destination và để thư viện lo phần còn lại. API gần giống Jetpack Navigation gốc, không cần học framework mới.
✨ Điểm nổi bật
- Navigation arguments type-safe: Khai báo tham số trực tiếp trong function Composable —
Int,String?,Boolean,Parcelable,Serializable,Enum,@Serializable, cả Array/ArrayList đều hoạt động ngay. - Tự sinh Destination classes: Sau khi build, mỗi screen có một class riêng với
invokenhận đúng kiểu argument — gọiProfileScreenDestination(id = 7, groupName = "Kotlin")là điều hướng xong. - Cấu hình navigation graph linh hoạt: Dùng
@Destination<RootGraph>hoặc tự định nghĩa graph riêng; fileNavGraphssinh tự động. - Navigate back kèm kết quả: Trả dữ liệu về màn hình trước một cách type-safe, không cần xử lý bundle thủ công.
- Lấy argument từ
SavedStateHandlevàNavBackStackEntry: An toàn kiểu dữ liệu, tiện khi dùng ViewModel. - Hỗ trợ animation, bottom sheet screens, deep linking: Tất cả tính năng của Jetpack Navigation gốc, nhưng đơn giản và an toàn hơn.
- Wear OS support: Dùng được trên đồng hồ thông minh từ phiên bản 1.x.30.
- Destination wrappers: Tái sử dụng logic Compose cho nhiều màn hình.
💡 Vì sao đáng chú ý
Điểm mạnh nhất là loại bỏ hoàn toàn phần code dễ sai: route string, NavType, bundle, arguments mapping. Thư viện sinh tất cả từ annotation, nên khi đổi tên hay thêm argument, compiler bắt lỗi ngay — không còn lỗi runtime do sai chuỗi route hay sai kiểu dữ liệu. API quen thuộc với người dùng Jetpack Navigation, nên học nhanh, migrate dễ.
Phù hợp cho dự án Android Compose cần điều hướng nhiều màn hình, đặc biệt khi có argument phức tạp hoặc nhiều nav graph. Bản v2 đã ra mắt với migration guide và docs đầy đủ, cộng đồng hỗ trợ qua Slack.
#KSP #JetpackCompose #Android #Navigation #TypeSafe #TiniX
Similar Projects
Discover other similar projects and AI models.
基于无障碍,高级选择器,订阅规则的自定义屏幕点击安卓应用 | An Android APP with custom screen tapping based on Accessibility, Advanced Selectors, and Subscription Rules
A curated list of awesome Kotlin related stuff Inspired by awesome-java.
Termux - a terminal emulator application for Android OS extendible by variety of packages.
Reverse engineer anything with agents, from app behavior down to native binaries.