@devo-bmad-custom/agent-orchestration 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bmad.js +36 -0
- package/lib/cli.js +137 -0
- package/lib/filter.js +73 -0
- package/lib/installer.js +787 -0
- package/package.json +30 -0
- package/src/.agents/skills/audit-website/README.md +20 -0
- package/src/.agents/skills/audit-website/SKILL.md +470 -0
- package/src/.agents/skills/audit-website/agents/openai.yaml +6 -0
- package/src/.agents/skills/audit-website/assets/icon-small.svg +41 -0
- package/src/.agents/skills/audit-website/references/OUTPUT-FORMAT.md +250 -0
- package/src/.agents/skills/clean-code-standards/SKILL.md +105 -0
- package/src/.agents/skills/excalidraw-dark-standard/SKILL.md +282 -0
- package/src/.agents/skills/excalidraw-diagram-generator/SKILL.md +613 -0
- package/src/.agents/skills/excalidraw-diagram-generator/references/element-types.md +497 -0
- package/src/.agents/skills/excalidraw-diagram-generator/references/excalidraw-schema.md +350 -0
- package/src/.agents/skills/excalidraw-diagram-generator/scripts/README.md +193 -0
- package/src/.agents/skills/excalidraw-diagram-generator/scripts/add-arrow.py +312 -0
- package/src/.agents/skills/excalidraw-diagram-generator/scripts/add-icon-to-diagram.py +404 -0
- package/src/.agents/skills/excalidraw-diagram-generator/scripts/split-excalidraw-library.py +183 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/business-flow-swimlane-template.excalidraw +334 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/class-diagram-template.excalidraw +558 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/data-flow-diagram-template.excalidraw +279 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/er-diagram-template.excalidraw +662 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/flowchart-template.excalidraw +179 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/mindmap-template.excalidraw +244 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/relationship-template.excalidraw +145 -0
- package/src/.agents/skills/excalidraw-diagram-generator/templates/sequence-diagram-template.excalidraw +509 -0
- package/src/.agents/skills/frontend-responsive-design-standards/SKILL.md +434 -0
- package/src/.agents/skills/java-fundamentals/SKILL.md +116 -0
- package/src/.agents/skills/java-performance/SKILL.md +119 -0
- package/src/.agents/skills/next-best-practices/SKILL.md +153 -0
- package/src/.agents/skills/next-best-practices/async-patterns.md +87 -0
- package/src/.agents/skills/next-best-practices/bundling.md +180 -0
- package/src/.agents/skills/next-best-practices/data-patterns.md +297 -0
- package/src/.agents/skills/next-best-practices/debug-tricks.md +105 -0
- package/src/.agents/skills/next-best-practices/directives.md +73 -0
- package/src/.agents/skills/next-best-practices/error-handling.md +227 -0
- package/src/.agents/skills/next-best-practices/file-conventions.md +140 -0
- package/src/.agents/skills/next-best-practices/font.md +245 -0
- package/src/.agents/skills/next-best-practices/functions.md +108 -0
- package/src/.agents/skills/next-best-practices/hydration-error.md +91 -0
- package/src/.agents/skills/next-best-practices/image.md +173 -0
- package/src/.agents/skills/next-best-practices/metadata.md +301 -0
- package/src/.agents/skills/next-best-practices/parallel-routes.md +287 -0
- package/src/.agents/skills/next-best-practices/route-handlers.md +146 -0
- package/src/.agents/skills/next-best-practices/rsc-boundaries.md +159 -0
- package/src/.agents/skills/next-best-practices/runtime-selection.md +39 -0
- package/src/.agents/skills/next-best-practices/scripts.md +141 -0
- package/src/.agents/skills/next-best-practices/self-hosting.md +371 -0
- package/src/.agents/skills/next-best-practices/suspense-boundaries.md +67 -0
- package/src/.agents/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/src/.agents/skills/postgresql-optimization/SKILL.md +404 -0
- package/src/.agents/skills/python-backend/SKILL.md +153 -0
- package/src/.agents/skills/python-fundamentals/SKILL.md +234 -0
- package/src/.agents/skills/python-performance/SKILL.md +404 -0
- package/src/.agents/skills/react-expert/SKILL.md +335 -0
- package/src/.agents/skills/redis-best-practices/SKILL.md +438 -0
- package/src/.agents/skills/security-best-practices/SKILL.md +288 -0
- package/src/.agents/skills/security-review/LICENSE +22 -0
- package/src/.agents/skills/security-review/SKILL.md +312 -0
- package/src/.agents/skills/security-review/infrastructure/docker.md +432 -0
- package/src/.agents/skills/security-review/languages/javascript.md +388 -0
- package/src/.agents/skills/security-review/languages/python.md +363 -0
- package/src/.agents/skills/security-review/references/api-security.md +519 -0
- package/src/.agents/skills/security-review/references/authentication.md +353 -0
- package/src/.agents/skills/security-review/references/authorization.md +372 -0
- package/src/.agents/skills/security-review/references/business-logic.md +443 -0
- package/src/.agents/skills/security-review/references/cryptography.md +329 -0
- package/src/.agents/skills/security-review/references/csrf.md +398 -0
- package/src/.agents/skills/security-review/references/data-protection.md +378 -0
- package/src/.agents/skills/security-review/references/deserialization.md +410 -0
- package/src/.agents/skills/security-review/references/error-handling.md +436 -0
- package/src/.agents/skills/security-review/references/file-security.md +457 -0
- package/src/.agents/skills/security-review/references/injection.md +259 -0
- package/src/.agents/skills/security-review/references/logging.md +433 -0
- package/src/.agents/skills/security-review/references/misconfiguration.md +435 -0
- package/src/.agents/skills/security-review/references/modern-threats.md +475 -0
- package/src/.agents/skills/security-review/references/ssrf.md +415 -0
- package/src/.agents/skills/security-review/references/supply-chain.md +405 -0
- package/src/.agents/skills/security-review/references/xss.md +336 -0
- package/src/.agents/skills/subagent-driven-development/SKILL.md +275 -0
- package/src/.agents/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/src/.agents/skills/subagent-driven-development/implementer-prompt.md +113 -0
- package/src/.agents/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/src/.agents/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/src/.agents/skills/systematic-debugging/SKILL.md +296 -0
- package/src/.agents/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/src/.agents/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/src/.agents/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/src/.agents/skills/systematic-debugging/find-polluter.sh +63 -0
- package/src/.agents/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/src/.agents/skills/systematic-debugging/test-academic.md +14 -0
- package/src/.agents/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/src/.agents/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/src/.agents/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/src/.agents/skills/typescript-best-practices/SKILL.md +373 -0
- package/src/.agents/skills/ui-ux-pro-custom/SKILL.md +348 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/charts.csv +26 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/colors.csv +97 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/icons.csv +101 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/SKILL.md +106 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/accessibility.md +475 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/animation.md +466 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/composition-locals.md +231 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/deprecated-patterns.md +323 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/lists-scrolling.md +400 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/modifiers.md +331 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/navigation.md +416 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/performance.md +446 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/side-effects.md +516 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/source-code/foundation-source.md +13327 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/source-code/material3-source.md +19097 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/source-code/navigation-source.md +2947 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/source-code/runtime-source.md +11316 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/source-code/ui-source.md +7896 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/state-management.md +377 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/styles-experimental.md +470 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/theming-material3.md +349 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/jetpack-compose-expert-skill/references/view-composition.md +595 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/landing.csv +31 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/mobile-ui-layout.md +654 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/products.csv +97 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/react-performance.csv +45 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/astro.csv +54 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/flutter.csv +53 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/html-tailwind.csv +56 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/jetpack-compose.csv +53 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/nextjs.csv +53 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/nuxt-ui.csv +51 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/nuxtjs.csv +59 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/react-native.csv +56 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/react.csv +54 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/shadcn.csv +61 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/svelte.csv +54 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/swiftui.csv +51 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/stacks/vue.csv +50 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/styles.csv +68 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/alarmkit/SKILL.md +438 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/alarmkit/references/alarmkit-patterns.md +584 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/app-clips/SKILL.md +436 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/app-intents/SKILL.md +489 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/app-intents/references/appintents-advanced.md +1076 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/app-store-review/SKILL.md +340 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/app-store-review/references/privacy-manifest.md +90 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/app-store-review/references/review-checklists.md +106 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/apple-on-device-ai/SKILL.md +500 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/apple-on-device-ai/references/coreml-conversion.md +425 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/apple-on-device-ai/references/coreml-optimization.md +344 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/apple-on-device-ai/references/foundation-models.md +508 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/apple-on-device-ai/references/mlx-swift.md +285 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/authentication/SKILL.md +496 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/authentication/references/keychain-biometric.md +211 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/background-processing/SKILL.md +499 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/background-processing/references/background-task-patterns.md +390 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/callkit-voip/SKILL.md +461 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/callkit-voip/references/callkit-patterns.md +425 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/cloudkit-sync/SKILL.md +492 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/cloudkit-sync/references/cloudkit-patterns.md +461 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/codable-patterns/SKILL.md +467 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/contacts-framework/SKILL.md +425 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/contacts-framework/references/contacts-patterns.md +409 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/core-bluetooth/SKILL.md +491 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/core-bluetooth/references/ble-patterns.md +435 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/core-motion/SKILL.md +388 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/core-motion/references/motion-patterns.md +405 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/core-nfc/SKILL.md +495 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/core-nfc/references/nfc-patterns.md +420 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/coreml/SKILL.md +459 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/coreml/references/coreml-swift-integration.md +765 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/debugging-instruments/SKILL.md +422 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/debugging-instruments/references/instruments-guide.md +387 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/debugging-instruments/references/lldb-patterns.md +298 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/device-integrity/SKILL.md +477 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/energykit/SKILL.md +460 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/energykit/references/energykit-patterns.md +541 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/eventkit-calendar/SKILL.md +483 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/eventkit-calendar/references/eventkit-patterns.md +326 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/healthkit/SKILL.md +498 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/healthkit/references/healthkit-patterns.md +602 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/homekit-matter/SKILL.md +496 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/homekit-matter/references/matter-commissioning.md +455 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-accessibility/SKILL.md +301 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-accessibility/references/a11y-patterns.md +140 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-localization/SKILL.md +418 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-localization/references/formatstyle-locale.md +627 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-localization/references/string-catalogs.md +462 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-networking/SKILL.md +441 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-networking/references/background-websocket.md +862 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-networking/references/lightweight-clients.md +93 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-networking/references/network-framework.md +563 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-networking/references/urlsession-patterns.md +1116 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-security/SKILL.md +496 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-security/references/app-review-guidelines.md +174 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-security/references/cryptokit-advanced.md +297 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-security/references/file-storage-patterns.md +354 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/ios-security/references/privacy-manifest.md +117 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/live-activities/SKILL.md +500 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/live-activities/references/live-activity-patterns.md +868 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/mapkit-location/SKILL.md +485 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/mapkit-location/references/corelocation-patterns.md +730 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/mapkit-location/references/mapkit-patterns.md +748 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/metrickit-diagnostics/SKILL.md +479 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/musickit-audio/SKILL.md +395 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/musickit-audio/references/musickit-patterns.md +363 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/natural-language/SKILL.md +412 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/natural-language/references/translation-patterns.md +311 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/passkit-wallet/SKILL.md +398 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/passkit-wallet/references/wallet-passes.md +254 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/pencilkit-drawing/SKILL.md +387 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/pencilkit-drawing/references/paperkit-integration.md +376 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/pencilkit-drawing/references/pencilkit-patterns.md +302 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/permissionkit/SKILL.md +446 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/permissionkit/references/permissionkit-patterns.md +435 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/photos-camera-media/SKILL.md +501 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/photos-camera-media/references/av-playback.md +701 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/photos-camera-media/references/camera-capture.md +774 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/photos-camera-media/references/image-loading-caching.md +869 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/photos-camera-media/references/photospicker-patterns.md +597 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/push-notifications/SKILL.md +501 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/push-notifications/references/notification-patterns.md +677 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/push-notifications/references/rich-notifications.md +745 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/realitykit-ar/SKILL.md +479 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/realitykit-ar/references/realitykit-patterns.md +480 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/shareplay-activities/SKILL.md +483 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/shareplay-activities/references/shareplay-patterns.md +544 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/speech-recognition/SKILL.md +485 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/storekit/SKILL.md +478 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/storekit/references/app-review-guidelines.md +58 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/storekit/references/storekit-advanced.md +755 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-charts/SKILL.md +487 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-charts/references/charts-patterns.md +895 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-concurrency/SKILL.md +408 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-concurrency/references/approachable-concurrency.md +80 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-concurrency/references/swift-6-2-concurrency.md +233 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-concurrency/references/swiftui-concurrency.md +187 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-concurrency/references/synchronization-primitives.md +341 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-language/SKILL.md +498 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-language/references/swift-patterns-extended.md +505 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-testing/SKILL.md +467 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swift-testing/references/testing-patterns.md +504 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftdata/SKILL.md +334 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftdata/references/core-data-coexistence.md +504 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftdata/references/swiftdata-advanced.md +975 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftdata/references/swiftdata-queries.md +675 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-animation/SKILL.md +481 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-animation/references/animation-advanced.md +804 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-animation/references/core-animation-bridge.md +553 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-gestures/SKILL.md +450 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-gestures/references/gesture-patterns.md +425 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-layout-components/SKILL.md +336 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-layout-components/references/form.md +97 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-layout-components/references/grids.md +69 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-layout-components/references/list.md +99 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-layout-components/references/scrollview.md +147 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-liquid-glass/SKILL.md +325 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-liquid-glass/references/liquid-glass.md +387 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-navigation/SKILL.md +262 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-navigation/references/deeplinks.md +207 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-navigation/references/navigationstack.md +177 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-navigation/references/sheets.md +169 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-navigation/references/tabview.md +178 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-patterns/SKILL.md +381 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-patterns/references/architecture-patterns.md +486 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-patterns/references/deprecated-migration.md +1097 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-patterns/references/design-polish.md +780 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-patterns/references/platform-and-sharing.md +696 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-performance/SKILL.md +491 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +46 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +29 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-performance/references/understanding-hangs-in-your-app.md +33 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-performance/references/understanding-improving-swiftui-performance.md +52 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-uikit-interop/SKILL.md +428 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-uikit-interop/references/hosting-migration.md +534 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/swiftui-uikit-interop/references/representable-recipes.md +1133 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/tipkit/SKILL.md +494 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/tipkit/references/tipkit-patterns.md +782 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/SKILL.md +475 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/references/vision-requests.md +736 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/vision-framework/references/visionkit-scanner.md +738 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/weatherkit/SKILL.md +410 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/weatherkit/references/weatherkit-patterns.md +567 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/widgetkit/SKILL.md +497 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/swift-ios-skills/widgetkit/references/widgetkit-advanced.md +871 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/typography.csv +58 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/ui-reasoning.csv +101 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/ux-guidelines.csv +100 -0
- package/src/.agents/skills/ui-ux-pro-custom/data/web-interface.csv +31 -0
- package/src/.agents/skills/ui-ux-pro-custom/scripts/core.py +253 -0
- package/src/.agents/skills/ui-ux-pro-custom/scripts/design_system.py +1067 -0
- package/src/.agents/skills/ui-ux-pro-custom/scripts/search.py +114 -0
- package/src/.agents/skills/ux-audit/SKILL.md +151 -0
- package/src/.agents/skills/websocket-engineer/SKILL.md +168 -0
- package/src/.agents/skills/websocket-engineer/references/alternatives.md +391 -0
- package/src/.agents/skills/websocket-engineer/references/patterns.md +400 -0
- package/src/.agents/skills/websocket-engineer/references/protocol.md +195 -0
- package/src/.agents/skills/websocket-engineer/references/scaling.md +333 -0
- package/src/.agents/skills/websocket-engineer/references/security.md +474 -0
- package/src/.agents/skills/writing-skills/SKILL.md +655 -0
- package/src/.agents/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/src/.agents/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/src/.agents/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/src/.agents/skills/writing-skills/persuasion-principles.md +187 -0
- package/src/.agents/skills/writing-skills/render-graphs.js +168 -0
- package/src/.agents/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/src/.claude/commands/bmad-track-compact.md +19 -0
- package/src/.claude/commands/bmad-track-extended.md +19 -0
- package/src/.claude/commands/bmad-track-large.md +19 -0
- package/src/.claude/commands/bmad-track-medium.md +19 -0
- package/src/.claude/commands/bmad-track-nano.md +19 -0
- package/src/.claude/commands/bmad-track-rv.md +18 -0
- package/src/.claude/commands/bmad-track-small.md +19 -0
- package/src/_memory/config.yaml +11 -0
- package/src/_memory/master-orchestrator-sidecar/docs-index.md +3 -0
- package/src/_memory/master-orchestrator-sidecar/instructions.md +2566 -0
- package/src/_memory/master-orchestrator-sidecar/memories.md +8 -0
- package/src/_memory/master-orchestrator-sidecar/session-state.md +15 -0
- package/src/_memory/master-orchestrator-sidecar/triage-history.md +3 -0
- package/src/_memory/master-orchestrator-sidecar/workflows-overview.html +1230 -0
- package/src/_memory/skills/excalidraw/SKILL.md +78 -0
- package/src/_memory/skills/excalidraw/diagram-patterns.md +53 -0
- package/src/_memory/skills/nimbalyst-tracking/SKILL.md +103 -0
- package/src/_memory/skills/writing-skills/SKILL.md +655 -0
- package/src/bmb/agents/agent-builder.md +59 -0
- package/src/bmb/agents/module-builder.md +60 -0
- package/src/bmb/agents/workflow-builder.md +61 -0
- package/src/bmb/config.yaml +12 -0
- package/src/bmb/module-help.csv +13 -0
- package/src/bmb/workflows/agent/data/agent-architecture.md +258 -0
- package/src/bmb/workflows/agent/data/agent-compilation.md +185 -0
- package/src/bmb/workflows/agent/data/agent-menu-patterns.md +189 -0
- package/src/bmb/workflows/agent/data/agent-metadata.md +133 -0
- package/src/bmb/workflows/agent/data/agent-validation.md +111 -0
- package/src/bmb/workflows/agent/data/brainstorm-context.md +96 -0
- package/src/bmb/workflows/agent/data/communication-presets.csv +61 -0
- package/src/bmb/workflows/agent/data/critical-actions.md +75 -0
- package/src/bmb/workflows/agent/data/persona-properties.md +252 -0
- package/src/bmb/workflows/agent/data/principles-crafting.md +142 -0
- package/src/bmb/workflows/agent/data/reference/module-examples/architect.md +68 -0
- package/src/bmb/workflows/agent/data/reference/with-sidecar/journal-keeper/journal-keeper-sidecar/entries/yy-mm-dd-entry-template.md +17 -0
- package/src/bmb/workflows/agent/data/understanding-agent-types.md +126 -0
- package/src/bmb/workflows/agent/steps-c/step-01-brainstorm.md +129 -0
- package/src/bmb/workflows/agent/steps-c/step-02-discovery.md +170 -0
- package/src/bmb/workflows/agent/steps-c/step-03-sidecar-metadata.md +309 -0
- package/src/bmb/workflows/agent/steps-c/step-04-persona.md +213 -0
- package/src/bmb/workflows/agent/steps-c/step-05-commands-menu.md +179 -0
- package/src/bmb/workflows/agent/steps-c/step-06-activation.md +278 -0
- package/src/bmb/workflows/agent/steps-c/step-07-build-agent.md +316 -0
- package/src/bmb/workflows/agent/steps-c/step-08-celebrate.md +247 -0
- package/src/bmb/workflows/agent/steps-e/e-01-load-existing.md +221 -0
- package/src/bmb/workflows/agent/steps-e/e-02-discover-edits.md +195 -0
- package/src/bmb/workflows/agent/steps-e/e-03-placeholder.md +1 -0
- package/src/bmb/workflows/agent/steps-e/e-04-sidecar-metadata.md +126 -0
- package/src/bmb/workflows/agent/steps-e/e-05-persona.md +135 -0
- package/src/bmb/workflows/agent/steps-e/e-06-commands-menu.md +123 -0
- package/src/bmb/workflows/agent/steps-e/e-07-activation.md +124 -0
- package/src/bmb/workflows/agent/steps-e/e-08-edit-agent.md +197 -0
- package/src/bmb/workflows/agent/steps-e/e-09-celebrate.md +155 -0
- package/src/bmb/workflows/agent/steps-v/v-01-load-review.md +137 -0
- package/src/bmb/workflows/agent/steps-v/v-02a-validate-metadata.md +116 -0
- package/src/bmb/workflows/agent/steps-v/v-02b-validate-persona.md +124 -0
- package/src/bmb/workflows/agent/steps-v/v-02c-validate-menu.md +127 -0
- package/src/bmb/workflows/agent/steps-v/v-02d-validate-structure.md +134 -0
- package/src/bmb/workflows/agent/steps-v/v-02e-validate-sidecar.md +134 -0
- package/src/bmb/workflows/agent/steps-v/v-03-summary.md +104 -0
- package/src/bmb/workflows/agent/templates/agent-plan.template.md +5 -0
- package/src/bmb/workflows/agent/templates/agent-template.md +89 -0
- package/src/bmb/workflows/agent/workflow-create-agent.md +72 -0
- package/src/bmb/workflows/agent/workflow-edit-agent.md +75 -0
- package/src/bmb/workflows/agent/workflow-validate-agent.md +73 -0
- package/src/bmb/workflows/module/data/agent-architecture.md +179 -0
- package/src/bmb/workflows/module/data/agent-spec-template.md +79 -0
- package/src/bmb/workflows/module/data/module-standards.md +263 -0
- package/src/bmb/workflows/module/data/module-yaml-conventions.md +392 -0
- package/src/bmb/workflows/module/module-help-generate.md +254 -0
- package/src/bmb/workflows/module/steps-b/step-01-welcome.md +148 -0
- package/src/bmb/workflows/module/steps-b/step-02-spark.md +141 -0
- package/src/bmb/workflows/module/steps-b/step-03-module-type.md +149 -0
- package/src/bmb/workflows/module/steps-b/step-04-vision.md +83 -0
- package/src/bmb/workflows/module/steps-b/step-05-identity.md +97 -0
- package/src/bmb/workflows/module/steps-b/step-06-users.md +86 -0
- package/src/bmb/workflows/module/steps-b/step-07-value.md +76 -0
- package/src/bmb/workflows/module/steps-b/step-08-agents.md +97 -0
- package/src/bmb/workflows/module/steps-b/step-09-workflows.md +83 -0
- package/src/bmb/workflows/module/steps-b/step-10-tools.md +91 -0
- package/src/bmb/workflows/module/steps-b/step-11-scenarios.md +84 -0
- package/src/bmb/workflows/module/steps-b/step-12-creative.md +95 -0
- package/src/bmb/workflows/module/steps-b/step-13-review.md +105 -0
- package/src/bmb/workflows/module/steps-b/step-14-finalize.md +117 -0
- package/src/bmb/workflows/module/steps-c/step-01-load-brief.md +179 -0
- package/src/bmb/workflows/module/steps-c/step-01b-continue.md +82 -0
- package/src/bmb/workflows/module/steps-c/step-02-structure.md +105 -0
- package/src/bmb/workflows/module/steps-c/step-03-config.md +119 -0
- package/src/bmb/workflows/module/steps-c/step-04-agents.md +168 -0
- package/src/bmb/workflows/module/steps-c/step-05-workflows.md +184 -0
- package/src/bmb/workflows/module/steps-c/step-06-docs.md +401 -0
- package/src/bmb/workflows/module/steps-c/step-07-complete.md +152 -0
- package/src/bmb/workflows/module/steps-e/step-01-load-target.md +81 -0
- package/src/bmb/workflows/module/steps-e/step-02-select-edit.md +77 -0
- package/src/bmb/workflows/module/steps-e/step-03-apply-edit.md +77 -0
- package/src/bmb/workflows/module/steps-e/step-04-review.md +80 -0
- package/src/bmb/workflows/module/steps-e/step-05-confirm.md +75 -0
- package/src/bmb/workflows/module/steps-v/step-01-load-target.md +96 -0
- package/src/bmb/workflows/module/steps-v/step-02-file-structure.md +93 -0
- package/src/bmb/workflows/module/steps-v/step-03-module-yaml.md +99 -0
- package/src/bmb/workflows/module/steps-v/step-04-agent-specs.md +152 -0
- package/src/bmb/workflows/module/steps-v/step-05-workflow-specs.md +152 -0
- package/src/bmb/workflows/module/steps-v/step-06-documentation.md +143 -0
- package/src/bmb/workflows/module/steps-v/step-07-installation.md +102 -0
- package/src/bmb/workflows/module/steps-v/step-08-report.md +197 -0
- package/src/bmb/workflows/module/templates/brief-template.md +154 -0
- package/src/bmb/workflows/module/templates/workflow-spec-template.md +96 -0
- package/src/bmb/workflows/module/workflow-create-module-brief.md +71 -0
- package/src/bmb/workflows/module/workflow-create-module.md +86 -0
- package/src/bmb/workflows/module/workflow-edit-module.md +66 -0
- package/src/bmb/workflows/module/workflow-validate-module.md +66 -0
- package/src/bmb/workflows/workflow/data/architecture.md +150 -0
- package/src/bmb/workflows/workflow/data/common-workflow-tools.csv +19 -0
- package/src/bmb/workflows/workflow/data/csv-data-file-standards.md +53 -0
- package/src/bmb/workflows/workflow/data/frontmatter-standards.md +184 -0
- package/src/bmb/workflows/workflow/data/input-discovery-standards.md +191 -0
- package/src/bmb/workflows/workflow/data/intent-vs-prescriptive-spectrum.md +44 -0
- package/src/bmb/workflows/workflow/data/menu-handling-standards.md +133 -0
- package/src/bmb/workflows/workflow/data/output-format-standards.md +135 -0
- package/src/bmb/workflows/workflow/data/step-file-rules.md +235 -0
- package/src/bmb/workflows/workflow/data/step-type-patterns.md +257 -0
- package/src/bmb/workflows/workflow/data/subprocess-optimization-patterns.md +188 -0
- package/src/bmb/workflows/workflow/data/trimodal-workflow-structure.md +164 -0
- package/src/bmb/workflows/workflow/data/workflow-chaining-standards.md +222 -0
- package/src/bmb/workflows/workflow/data/workflow-examples.md +232 -0
- package/src/bmb/workflows/workflow/data/workflow-type-criteria.md +134 -0
- package/src/bmb/workflows/workflow/steps-c/step-00-conversion.md +263 -0
- package/src/bmb/workflows/workflow/steps-c/step-01-discovery.md +194 -0
- package/src/bmb/workflows/workflow/steps-c/step-01b-continuation.md +3 -0
- package/src/bmb/workflows/workflow/steps-c/step-02-classification.md +270 -0
- package/src/bmb/workflows/workflow/steps-c/step-03-requirements.md +283 -0
- package/src/bmb/workflows/workflow/steps-c/step-04-tools.md +282 -0
- package/src/bmb/workflows/workflow/steps-c/step-05-plan-review.md +243 -0
- package/src/bmb/workflows/workflow/steps-c/step-06-design.md +330 -0
- package/src/bmb/workflows/workflow/steps-c/step-07-foundation.md +239 -0
- package/src/bmb/workflows/workflow/steps-c/step-08-build-step-01.md +379 -0
- package/src/bmb/workflows/workflow/steps-c/step-09-build-next-step.md +350 -0
- package/src/bmb/workflows/workflow/steps-c/step-10-confirmation.md +322 -0
- package/src/bmb/workflows/workflow/steps-c/step-11-completion.md +191 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-01-assess-workflow.md +237 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-02-discover-edits.md +251 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-03-fix-validation.md +254 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-04-direct-edit.md +277 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-05-apply-edit.md +154 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-06-validate-after.md +190 -0
- package/src/bmb/workflows/workflow/steps-e/step-e-07-complete.md +206 -0
- package/src/bmb/workflows/workflow/steps-v/step-01-validate-max-mode.md +109 -0
- package/src/bmb/workflows/workflow/steps-v/step-01-validate.md +221 -0
- package/src/bmb/workflows/workflow/steps-v/step-01b-structure.md +152 -0
- package/src/bmb/workflows/workflow/steps-v/step-02-frontmatter-validation.md +199 -0
- package/src/bmb/workflows/workflow/steps-v/step-02b-path-violations.md +265 -0
- package/src/bmb/workflows/workflow/steps-v/step-03-menu-validation.md +164 -0
- package/src/bmb/workflows/workflow/steps-v/step-04-step-type-validation.md +211 -0
- package/src/bmb/workflows/workflow/steps-v/step-05-output-format-validation.md +200 -0
- package/src/bmb/workflows/workflow/steps-v/step-06-validation-design-check.md +195 -0
- package/src/bmb/workflows/workflow/steps-v/step-07-instruction-style-check.md +209 -0
- package/src/bmb/workflows/workflow/steps-v/step-08-collaborative-experience-check.md +199 -0
- package/src/bmb/workflows/workflow/steps-v/step-08b-subprocess-optimization.md +179 -0
- package/src/bmb/workflows/workflow/steps-v/step-09-cohesive-review.md +186 -0
- package/src/bmb/workflows/workflow/steps-v/step-10-report-complete.md +154 -0
- package/src/bmb/workflows/workflow/steps-v/step-11-plan-validation.md +237 -0
- package/src/bmb/workflows/workflow/templates/minimal-output-template.md +11 -0
- package/src/bmb/workflows/workflow/templates/step-01-init-continuable-template.md +241 -0
- package/src/bmb/workflows/workflow/templates/step-1b-template.md +224 -0
- package/src/bmb/workflows/workflow/templates/step-template.md +294 -0
- package/src/bmb/workflows/workflow/templates/workflow-template.md +102 -0
- package/src/bmb/workflows/workflow/workflow-create-workflow.md +79 -0
- package/src/bmb/workflows/workflow/workflow-edit-workflow.md +65 -0
- package/src/bmb/workflows/workflow/workflow-rework-workflow.md +65 -0
- package/src/bmb/workflows/workflow/workflow-validate-max-parallel-workflow.md +66 -0
- package/src/bmb/workflows/workflow/workflow-validate-workflow.md +65 -0
- package/src/bmm/agents/analyst.md +104 -0
- package/src/bmm/agents/architect.md +85 -0
- package/src/bmm/agents/dev.md +100 -0
- package/src/bmm/agents/pm.md +98 -0
- package/src/bmm/agents/qa.md +90 -0
- package/src/bmm/agents/quick-flow-solo-dev.md +92 -0
- package/src/bmm/agents/review-agent.md +129 -0
- package/src/bmm/agents/sm.md +90 -0
- package/src/bmm/agents/tech-writer/tech-writer.md +94 -0
- package/src/bmm/agents/ux-designer.md +124 -0
- package/src/bmm/data/project-context-template.md +26 -0
- package/src/bmm/module-help.csv +31 -0
- package/src/bmm/teams/default-party.csv +20 -0
- package/src/bmm/teams/team-fullstack.yaml +12 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/product-brief.template.md +10 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-01-init.md +115 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-01b-continue.md +107 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-02-vision.md +141 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-03-users.md +144 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-04-metrics.md +147 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-05-scope.md +161 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-06-complete.md +99 -0
- package/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +57 -0
- package/src/bmm/workflows/1-analysis/research/domain-steps/step-01-init.md +87 -0
- package/src/bmm/workflows/1-analysis/research/domain-steps/step-02-domain-analysis.md +156 -0
- package/src/bmm/workflows/1-analysis/research/domain-steps/step-03-competitive-landscape.md +165 -0
- package/src/bmm/workflows/1-analysis/research/domain-steps/step-04-regulatory-focus.md +140 -0
- package/src/bmm/workflows/1-analysis/research/domain-steps/step-05-technical-trends.md +152 -0
- package/src/bmm/workflows/1-analysis/research/domain-steps/step-06-research-synthesis.md +345 -0
- package/src/bmm/workflows/1-analysis/research/market-steps/step-01-init.md +92 -0
- package/src/bmm/workflows/1-analysis/research/market-steps/step-02-customer-behavior.md +164 -0
- package/src/bmm/workflows/1-analysis/research/market-steps/step-03-customer-pain-points.md +174 -0
- package/src/bmm/workflows/1-analysis/research/market-steps/step-04-customer-decisions.md +184 -0
- package/src/bmm/workflows/1-analysis/research/market-steps/step-05-competitive-analysis.md +105 -0
- package/src/bmm/workflows/1-analysis/research/market-steps/step-06-research-completion.md +360 -0
- package/src/bmm/workflows/1-analysis/research/research.template.md +29 -0
- package/src/bmm/workflows/1-analysis/research/technical-steps/step-01-init.md +87 -0
- package/src/bmm/workflows/1-analysis/research/technical-steps/step-02-technical-overview.md +165 -0
- package/src/bmm/workflows/1-analysis/research/technical-steps/step-03-integration-patterns.md +174 -0
- package/src/bmm/workflows/1-analysis/research/technical-steps/step-04-architectural-patterns.md +141 -0
- package/src/bmm/workflows/1-analysis/research/technical-steps/step-05-implementation-research.md +159 -0
- package/src/bmm/workflows/1-analysis/research/technical-steps/step-06-research-synthesis.md +387 -0
- package/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +54 -0
- package/src/bmm/workflows/1-analysis/research/workflow-market-research.md +54 -0
- package/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +54 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/data/domain-complexity.csv +15 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/data/prd-purpose.md +197 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/data/project-types.csv +11 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-01-init.md +139 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-01b-continue.md +100 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02-discovery.md +160 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02b-vision.md +88 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02c-executive-summary.md +99 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-03-success.md +169 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-04-journeys.md +156 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-05-domain.md +136 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-06-innovation.md +176 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-07-project-type.md +184 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-08-scoping.md +174 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-09-functional.md +175 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-10-nonfunctional.md +189 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-11-polish.md +162 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-12-complete.md +79 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-01-discovery.md +183 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-01b-legacy-conversion.md +149 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-02-review.md +187 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-03-edit.md +192 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-04-complete.md +108 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-01-discovery.md +166 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-02-format-detection.md +131 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-02b-parity-check.md +150 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-03-density-validation.md +118 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-04-brief-coverage-validation.md +155 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-05-measurability-validation.md +170 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-06-traceability-validation.md +158 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-07-implementation-leakage-validation.md +147 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-08-domain-compliance-validation.md +182 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-09-project-type-validation.md +202 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-10-smart-validation.md +148 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-11-holistic-quality-validation.md +201 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-12-completeness-validation.md +179 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-13-report-complete.md +164 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/templates/prd-template.md +10 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md +65 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +65 -0
- package/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +63 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-01-init.md +63 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-01b-continue.md +63 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-02-discovery.md +106 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-03-core-experience.md +111 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-04-emotional-response.md +115 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-05-inspiration.md +127 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-06-design-system.md +167 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-07-defining-experience.md +143 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-08-visual-foundation.md +118 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-09-design-directions.md +154 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-10-user-journeys.md +136 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-11-component-strategy.md +165 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-12-ux-patterns.md +135 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-13-responsive-accessibility.md +192 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-14-complete.md +101 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/ux-design-template.md +13 -0
- package/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +45 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-01-document-discovery.md +185 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-02-prd-analysis.md +129 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-03-epic-coverage-validation.md +130 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-04-ux-alignment.md +93 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-05-epic-quality-review.md +196 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-06-final-assessment.md +129 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/templates/readiness-report-template.md +4 -0
- package/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +54 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/architecture-decision-template.md +12 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/data/domain-complexity.csv +13 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/data/project-types.csv +7 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-01-init.md +89 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-01b-continue.md +82 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-02-context.md +106 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-03-starter.md +138 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-04-decisions.md +129 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-05-patterns.md +166 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-06-structure.md +186 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-07-validation.md +163 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-08-complete.md +38 -0
- package/src/bmm/workflows/3-solutioning/create-architecture/workflow.md +49 -0
- package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-01-validate-prerequisites.md +129 -0
- package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-02-design-epics.md +124 -0
- package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-03-create-stories.md +122 -0
- package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-04-final-validation.md +84 -0
- package/src/bmm/workflows/3-solutioning/create-epics-and-stories/templates/epics-template.md +57 -0
- package/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +58 -0
- package/src/bmm/workflows/4-implementation/code-review/checklist.md +23 -0
- package/src/bmm/workflows/4-implementation/code-review/instructions.xml +227 -0
- package/src/bmm/workflows/4-implementation/code-review/workflow.yaml +43 -0
- package/src/bmm/workflows/4-implementation/correct-course/checklist.md +288 -0
- package/src/bmm/workflows/4-implementation/correct-course/instructions.md +207 -0
- package/src/bmm/workflows/4-implementation/correct-course/workflow.yaml +53 -0
- package/src/bmm/workflows/4-implementation/create-story/checklist.md +159 -0
- package/src/bmm/workflows/4-implementation/create-story/instructions.xml +574 -0
- package/src/bmm/workflows/4-implementation/create-story/template.md +79 -0
- package/src/bmm/workflows/4-implementation/create-story/workflow.yaml +52 -0
- package/src/bmm/workflows/4-implementation/dev-story/checklist.md +80 -0
- package/src/bmm/workflows/4-implementation/dev-story/instructions.xml +493 -0
- package/src/bmm/workflows/4-implementation/dev-story/workflow.yaml +20 -0
- package/src/bmm/workflows/4-implementation/retrospective/instructions.md +1444 -0
- package/src/bmm/workflows/4-implementation/retrospective/workflow.yaml +52 -0
- package/src/bmm/workflows/4-implementation/sprint-planning/checklist.md +33 -0
- package/src/bmm/workflows/4-implementation/sprint-planning/instructions.md +232 -0
- package/src/bmm/workflows/4-implementation/sprint-planning/sprint-status-template.yaml +55 -0
- package/src/bmm/workflows/4-implementation/sprint-planning/workflow.yaml +52 -0
- package/src/bmm/workflows/4-implementation/sprint-status/instructions.md +230 -0
- package/src/bmm/workflows/4-implementation/sprint-status/workflow.yaml +25 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-01-mode-detection.md +158 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-02-context-gathering.md +122 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-03-execute.md +93 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-04-self-check.md +93 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-05-adversarial-review.md +87 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-06-resolve-findings.md +146 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +50 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-01-understand.md +204 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-02-investigate.md +152 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-03-generate.md +123 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-04-review.md +201 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/tech-spec-template.md +74 -0
- package/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +79 -0
- package/src/bmm/workflows/document-project/checklist.md +245 -0
- package/src/bmm/workflows/document-project/documentation-requirements.csv +12 -0
- package/src/bmm/workflows/document-project/instructions.md +130 -0
- package/src/bmm/workflows/document-project/templates/deep-dive-template.md +345 -0
- package/src/bmm/workflows/document-project/templates/index-template.md +169 -0
- package/src/bmm/workflows/document-project/templates/project-overview-template.md +103 -0
- package/src/bmm/workflows/document-project/templates/project-scan-report-schema.json +160 -0
- package/src/bmm/workflows/document-project/templates/source-tree-template.md +135 -0
- package/src/bmm/workflows/document-project/workflow.yaml +22 -0
- package/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +298 -0
- package/src/bmm/workflows/document-project/workflows/deep-dive.yaml +31 -0
- package/src/bmm/workflows/document-project/workflows/full-scan-instructions.md +1106 -0
- package/src/bmm/workflows/document-project/workflows/full-scan.yaml +31 -0
- package/src/bmm/workflows/generate-project-context/project-context-template.md +21 -0
- package/src/bmm/workflows/generate-project-context/steps/step-01-discover.md +184 -0
- package/src/bmm/workflows/generate-project-context/steps/step-02-generate.md +322 -0
- package/src/bmm/workflows/generate-project-context/steps/step-03-complete.md +235 -0
- package/src/bmm/workflows/generate-project-context/workflow.md +49 -0
- package/src/bmm/workflows/qa/automate/workflow.yaml +233 -0
- package/src/bmm/workflows/qa-generate-e2e-tests/checklist.md +33 -0
- package/src/bmm/workflows/qa-generate-e2e-tests/instructions.md +110 -0
- package/src/bmm/workflows/qa-generate-e2e-tests/workflow.yaml +42 -0
- package/src/core/agents/bmad-master.md +56 -0
- package/src/core/agents/master-orchestrator.md +54 -0
- package/src/core/config.yaml +9 -0
- package/src/core/module-help.csv +10 -0
- package/src/core/scripts/generate-loop-report.py +72 -0
- package/src/core/skills/prepare-to-merge/SKILL.md +77 -0
- package/src/core/tasks/editorial-review-prose.xml +102 -0
- package/src/core/tasks/editorial-review-structure.xml +208 -0
- package/src/core/tasks/help.md +86 -0
- package/src/core/tasks/index-docs.xml +65 -0
- package/src/core/tasks/review-adversarial-general.xml +66 -0
- package/src/core/tasks/review-adversarial-loop.xml +46 -0
- package/src/core/tasks/review-edge-case-hunter.xml +63 -0
- package/src/core/tasks/review-party-loop.xml +46 -0
- package/src/core/tasks/shard-doc.xml +108 -0
- package/src/core/tasks/workflow.xml +236 -0
- package/src/core/templates/review-loop-report.html +88 -0
- package/src/core/templates/review-loop-report.md +5 -0
- package/src/core/workflows/advanced-elicitation/methods.csv +51 -0
- package/src/core/workflows/advanced-elicitation/workflow.xml +118 -0
- package/src/core/workflows/brainstorming/brain-methods.csv +62 -0
- package/src/core/workflows/brainstorming/steps/step-01-session-setup.md +212 -0
- package/src/core/workflows/brainstorming/steps/step-01b-continue.md +122 -0
- package/src/core/workflows/brainstorming/steps/step-02a-user-selected.md +225 -0
- package/src/core/workflows/brainstorming/steps/step-02b-ai-recommended.md +237 -0
- package/src/core/workflows/brainstorming/steps/step-02c-random-selection.md +209 -0
- package/src/core/workflows/brainstorming/steps/step-02d-progressive-flow.md +264 -0
- package/src/core/workflows/brainstorming/steps/step-02e-deep-dive.md +68 -0
- package/src/core/workflows/brainstorming/steps/step-03-technique-execution.md +403 -0
- package/src/core/workflows/brainstorming/steps/step-04-idea-organization.md +303 -0
- package/src/core/workflows/brainstorming/template.md +15 -0
- package/src/core/workflows/brainstorming/workflow.md +60 -0
- package/src/core/workflows/extract-trackers/workflow.md +45 -0
- package/src/core/workflows/party-mode/steps/step-01-agent-loading.md +142 -0
- package/src/core/workflows/party-mode/steps/step-02-discussion-orchestration.md +187 -0
- package/src/core/workflows/party-mode/steps/step-03-graceful-exit.md +168 -0
- package/src/core/workflows/party-mode/workflow.md +194 -0
- package/src/docs/dev/tmux/actions_popup.py +291 -0
- package/src/docs/dev/tmux/actions_popup.sh +110 -0
- package/src/docs/dev/tmux/claude_usage.sh +15 -0
- package/src/docs/dev/tmux/colors.conf +34 -0
- package/src/docs/dev/tmux/cpu_usage.sh +7 -0
- package/src/docs/dev/tmux/dispatch.sh +10 -0
- package/src/docs/dev/tmux/float_init.sh +13 -0
- package/src/docs/dev/tmux/float_term.sh +23 -0
- package/src/docs/dev/tmux/open_clip.sh +14 -0
- package/src/docs/dev/tmux/paste_clipboard.sh +13 -0
- package/src/docs/dev/tmux/paste_image_wrapper.sh +83 -0
- package/src/docs/dev/tmux/ram_usage.sh +3 -0
- package/src/docs/dev/tmux/title_sync.sh +54 -0
- package/src/docs/dev/tmux/tmux-setup.md +806 -0
- package/src/docs/dev/tmux/tmux.conf +127 -0
- package/src/docs/dev/tmux/xclip +18 -0
|
@@ -0,0 +1,2947 @@
|
|
|
1
|
+
# Navigation Compose Source Reference
|
|
2
|
+
|
|
3
|
+
## File: navigation/navigation-compose/src/androidMain/kotlin/androidx/navigation/compose/NavHostController.android.kt
|
|
4
|
+
```kotlin
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 The Android Open Source Project
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
@file:JvmName("NavHostControllerKt")
|
|
22
|
+
@file:JvmMultifileClass
|
|
23
|
+
|
|
24
|
+
package androidx.navigation.compose
|
|
25
|
+
|
|
26
|
+
import android.content.Context
|
|
27
|
+
import androidx.compose.runtime.Composable
|
|
28
|
+
import androidx.compose.runtime.saveable.Saver
|
|
29
|
+
import androidx.compose.runtime.saveable.rememberSaveable
|
|
30
|
+
import androidx.compose.ui.platform.LocalContext
|
|
31
|
+
import androidx.navigation.NavDestination
|
|
32
|
+
import androidx.navigation.NavHostController
|
|
33
|
+
import androidx.navigation.Navigator
|
|
34
|
+
|
|
35
|
+
@Composable
|
|
36
|
+
public actual fun rememberNavController(
|
|
37
|
+
vararg navigators: Navigator<out NavDestination>
|
|
38
|
+
): NavHostController {
|
|
39
|
+
val context = LocalContext.current
|
|
40
|
+
return rememberSaveable(inputs = navigators, saver = NavControllerSaver(context)) {
|
|
41
|
+
createNavController(context)
|
|
42
|
+
}
|
|
43
|
+
.apply {
|
|
44
|
+
for (navigator in navigators) {
|
|
45
|
+
navigatorProvider.addNavigator(navigator)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private fun createNavController(context: Context) =
|
|
51
|
+
NavHostController(context).apply {
|
|
52
|
+
navigatorProvider.addNavigator(ComposeNavGraphNavigator(navigatorProvider))
|
|
53
|
+
navigatorProvider.addNavigator(ComposeNavigator())
|
|
54
|
+
navigatorProvider.addNavigator(DialogNavigator())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Saver to save and restore the NavController across config change and process death. */
|
|
58
|
+
private fun NavControllerSaver(context: Context): Saver<NavHostController, *> =
|
|
59
|
+
Saver(
|
|
60
|
+
save = { it.saveState() },
|
|
61
|
+
restore = { createNavController(context).apply { restoreState(it) } },
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## File: navigation/navigation-compose/src/androidMain/kotlin/androidx/navigation/compose/internal/NavComposeUtils.android.kt
|
|
66
|
+
```kotlin
|
|
67
|
+
/*
|
|
68
|
+
* Copyright 2025 The Android Open Source Project
|
|
69
|
+
*
|
|
70
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
71
|
+
* you may not use this file except in compliance with the License.
|
|
72
|
+
* You may obtain a copy of the License at
|
|
73
|
+
*
|
|
74
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
75
|
+
*
|
|
76
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
77
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
78
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
79
|
+
* See the License for the specific language governing permissions and
|
|
80
|
+
* limitations under the License.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
package androidx.navigation.compose.internal
|
|
84
|
+
|
|
85
|
+
import androidx.activity.compose.PredictiveBackHandler
|
|
86
|
+
import androidx.compose.runtime.Composable
|
|
87
|
+
import java.lang.ref.WeakReference
|
|
88
|
+
import java.util.UUID
|
|
89
|
+
import kotlinx.coroutines.flow.Flow
|
|
90
|
+
|
|
91
|
+
internal actual typealias BackEventCompat = androidx.activity.BackEventCompat
|
|
92
|
+
|
|
93
|
+
@Composable
|
|
94
|
+
internal actual fun PredictiveBackHandler(
|
|
95
|
+
enabled: Boolean,
|
|
96
|
+
onBack: suspend (progress: Flow<BackEventCompat>) -> Unit,
|
|
97
|
+
) {
|
|
98
|
+
PredictiveBackHandler(enabled, onBack)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
internal actual fun randomUUID(): String = UUID.randomUUID().toString()
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Class WeakReference encapsulates weak reference to an object, which could be used to either
|
|
105
|
+
* retrieve a strong reference to an object, or return null, if object was already destroyed by the
|
|
106
|
+
* memory manager.
|
|
107
|
+
*/
|
|
108
|
+
internal actual class WeakReference<T : Any> actual constructor(reference: T) {
|
|
109
|
+
private val weakReference = WeakReference(reference)
|
|
110
|
+
|
|
111
|
+
actual fun get(): T? = weakReference.get()
|
|
112
|
+
|
|
113
|
+
actual fun clear() = weakReference.clear()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
internal actual typealias DefaultNavTransitions = StandardDefaultNavTransitions
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/ComposeNavGraphNavigator.kt
|
|
120
|
+
```kotlin
|
|
121
|
+
/*
|
|
122
|
+
* Copyright 2023 The Android Open Source Project
|
|
123
|
+
*
|
|
124
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
125
|
+
* you may not use this file except in compliance with the License.
|
|
126
|
+
* You may obtain a copy of the License at
|
|
127
|
+
*
|
|
128
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
129
|
+
*
|
|
130
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
131
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
132
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
133
|
+
* See the License for the specific language governing permissions and
|
|
134
|
+
* limitations under the License.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
package androidx.navigation.compose
|
|
138
|
+
|
|
139
|
+
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
140
|
+
import androidx.compose.animation.EnterTransition
|
|
141
|
+
import androidx.compose.animation.ExitTransition
|
|
142
|
+
import androidx.compose.animation.SizeTransform
|
|
143
|
+
import androidx.navigation.NavBackStackEntry
|
|
144
|
+
import androidx.navigation.NavGraph
|
|
145
|
+
import androidx.navigation.NavGraphNavigator
|
|
146
|
+
import androidx.navigation.Navigator
|
|
147
|
+
import androidx.navigation.NavigatorProvider
|
|
148
|
+
import kotlin.jvm.JvmSuppressWildcards
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Custom subclass of [NavGraphNavigator] that adds support for defining transitions at the
|
|
152
|
+
* navigation graph level.
|
|
153
|
+
*/
|
|
154
|
+
@Navigator.Name("navigation")
|
|
155
|
+
internal class ComposeNavGraphNavigator(navigatorProvider: NavigatorProvider) :
|
|
156
|
+
NavGraphNavigator(navigatorProvider) {
|
|
157
|
+
override fun createDestination(): NavGraph {
|
|
158
|
+
return ComposeNavGraph(this)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
internal class ComposeNavGraph(navGraphNavigator: Navigator<out NavGraph>) :
|
|
162
|
+
NavGraph(navGraphNavigator) {
|
|
163
|
+
internal var enterTransition:
|
|
164
|
+
(@JvmSuppressWildcards
|
|
165
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
166
|
+
null
|
|
167
|
+
|
|
168
|
+
internal var exitTransition:
|
|
169
|
+
(@JvmSuppressWildcards
|
|
170
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
171
|
+
null
|
|
172
|
+
|
|
173
|
+
internal var popEnterTransition:
|
|
174
|
+
(@JvmSuppressWildcards
|
|
175
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
176
|
+
null
|
|
177
|
+
|
|
178
|
+
internal var popExitTransition:
|
|
179
|
+
(@JvmSuppressWildcards
|
|
180
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
181
|
+
null
|
|
182
|
+
|
|
183
|
+
internal var predictivePopEnterTransition:
|
|
184
|
+
(@JvmSuppressWildcards
|
|
185
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition?)? =
|
|
186
|
+
null
|
|
187
|
+
|
|
188
|
+
internal var predictivePopExitTransition:
|
|
189
|
+
(@JvmSuppressWildcards
|
|
190
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition?)? =
|
|
191
|
+
null
|
|
192
|
+
|
|
193
|
+
internal var sizeTransform:
|
|
194
|
+
(@JvmSuppressWildcards
|
|
195
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
196
|
+
null
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/ComposeNavigator.kt
|
|
202
|
+
```kotlin
|
|
203
|
+
/*
|
|
204
|
+
* Copyright 2020 The Android Open Source Project
|
|
205
|
+
*
|
|
206
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
207
|
+
* you may not use this file except in compliance with the License.
|
|
208
|
+
* You may obtain a copy of the License at
|
|
209
|
+
*
|
|
210
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
211
|
+
*
|
|
212
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
213
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
214
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
215
|
+
* See the License for the specific language governing permissions and
|
|
216
|
+
* limitations under the License.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
package androidx.navigation.compose
|
|
220
|
+
|
|
221
|
+
import androidx.compose.animation.AnimatedContentScope
|
|
222
|
+
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
223
|
+
import androidx.compose.animation.EnterTransition
|
|
224
|
+
import androidx.compose.animation.ExitTransition
|
|
225
|
+
import androidx.compose.animation.SizeTransform
|
|
226
|
+
import androidx.compose.runtime.Composable
|
|
227
|
+
import androidx.compose.runtime.mutableStateOf
|
|
228
|
+
import androidx.navigation.NavBackStackEntry
|
|
229
|
+
import androidx.navigation.NavDestination
|
|
230
|
+
import androidx.navigation.NavOptions
|
|
231
|
+
import androidx.navigation.Navigator
|
|
232
|
+
import androidx.navigation.compose.ComposeNavigator.Destination
|
|
233
|
+
import kotlin.jvm.JvmSuppressWildcards
|
|
234
|
+
import kotlinx.coroutines.flow.StateFlow
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Navigator that navigates through [Composable]s. Every destination using this Navigator must set a
|
|
238
|
+
* valid [Composable] by setting it directly on an instantiated [Destination] or calling
|
|
239
|
+
* [composable].
|
|
240
|
+
*/
|
|
241
|
+
@Navigator.Name("composable")
|
|
242
|
+
public class ComposeNavigator constructor() : Navigator<Destination>(NAME) {
|
|
243
|
+
|
|
244
|
+
/** Get the map of transitions currently in progress from the [state]. */
|
|
245
|
+
internal val transitionsInProgress
|
|
246
|
+
get() = state.transitionsInProgress
|
|
247
|
+
|
|
248
|
+
/** Get the back stack from the [state]. */
|
|
249
|
+
public val backStack: StateFlow<List<NavBackStackEntry>>
|
|
250
|
+
get() = state.backStack
|
|
251
|
+
|
|
252
|
+
internal val isPop = mutableStateOf(false)
|
|
253
|
+
|
|
254
|
+
override fun navigate(
|
|
255
|
+
entries: List<NavBackStackEntry>,
|
|
256
|
+
navOptions: NavOptions?,
|
|
257
|
+
navigatorExtras: Extras?,
|
|
258
|
+
) {
|
|
259
|
+
entries.forEach { entry -> state.pushWithTransition(entry) }
|
|
260
|
+
isPop.value = false
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
override fun createDestination(): Destination {
|
|
264
|
+
return Destination(this) {}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
override fun popBackStack(popUpTo: NavBackStackEntry, savedState: Boolean) {
|
|
268
|
+
state.popWithTransition(popUpTo, savedState)
|
|
269
|
+
isPop.value = true
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Function to prepare the entry for transition.
|
|
274
|
+
*
|
|
275
|
+
* This should be called when the entry needs to move the [androidx.lifecycle.Lifecycle.State]
|
|
276
|
+
* in preparation for a transition such as when using predictive back.
|
|
277
|
+
*/
|
|
278
|
+
public fun prepareForTransition(entry: NavBackStackEntry) {
|
|
279
|
+
state.prepareForTransition(entry)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Callback to mark a navigation in transition as complete.
|
|
284
|
+
*
|
|
285
|
+
* This should be called in conjunction with [navigate] and [popBackStack] as those calls merely
|
|
286
|
+
* start a transition to the target destination, and requires manually marking the transition as
|
|
287
|
+
* complete by calling this method.
|
|
288
|
+
*
|
|
289
|
+
* Failing to call this method could result in entries being prevented from reaching their final
|
|
290
|
+
* [androidx.lifecycle.Lifecycle.State].
|
|
291
|
+
*/
|
|
292
|
+
public fun onTransitionComplete(entry: NavBackStackEntry) {
|
|
293
|
+
state.markTransitionComplete(entry)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** NavDestination specific to [ComposeNavigator] */
|
|
297
|
+
@NavDestination.ClassType(Composable::class)
|
|
298
|
+
public class Destination(
|
|
299
|
+
navigator: ComposeNavigator,
|
|
300
|
+
internal val content:
|
|
301
|
+
@Composable
|
|
302
|
+
AnimatedContentScope.(@JvmSuppressWildcards NavBackStackEntry) -> Unit,
|
|
303
|
+
) : NavDestination(navigator) {
|
|
304
|
+
|
|
305
|
+
@Deprecated(
|
|
306
|
+
message = "Deprecated in favor of Destination that supports AnimatedContent",
|
|
307
|
+
level = DeprecationLevel.HIDDEN,
|
|
308
|
+
)
|
|
309
|
+
public constructor(
|
|
310
|
+
navigator: ComposeNavigator,
|
|
311
|
+
content: @Composable (NavBackStackEntry) -> @JvmSuppressWildcards Unit,
|
|
312
|
+
) : this(navigator, content = { entry -> content(entry) })
|
|
313
|
+
|
|
314
|
+
internal var enterTransition:
|
|
315
|
+
(@JvmSuppressWildcards
|
|
316
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
317
|
+
null
|
|
318
|
+
|
|
319
|
+
internal var exitTransition:
|
|
320
|
+
(@JvmSuppressWildcards
|
|
321
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
322
|
+
null
|
|
323
|
+
|
|
324
|
+
internal var popEnterTransition:
|
|
325
|
+
(@JvmSuppressWildcards
|
|
326
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
327
|
+
null
|
|
328
|
+
|
|
329
|
+
internal var popExitTransition:
|
|
330
|
+
(@JvmSuppressWildcards
|
|
331
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
332
|
+
null
|
|
333
|
+
|
|
334
|
+
internal var predictivePopEnterTransition:
|
|
335
|
+
(@JvmSuppressWildcards
|
|
336
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition?)? =
|
|
337
|
+
null
|
|
338
|
+
|
|
339
|
+
internal var predictivePopExitTransition:
|
|
340
|
+
(@JvmSuppressWildcards
|
|
341
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition?)? =
|
|
342
|
+
null
|
|
343
|
+
|
|
344
|
+
internal var sizeTransform:
|
|
345
|
+
(@JvmSuppressWildcards
|
|
346
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
347
|
+
null
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
internal companion object {
|
|
351
|
+
internal const val NAME = "composable"
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/ComposeNavigatorDestinationBuilder.kt
|
|
357
|
+
```kotlin
|
|
358
|
+
/*
|
|
359
|
+
* Copyright 2024 The Android Open Source Project
|
|
360
|
+
*
|
|
361
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
362
|
+
* you may not use this file except in compliance with the License.
|
|
363
|
+
* You may obtain a copy of the License at
|
|
364
|
+
*
|
|
365
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
366
|
+
*
|
|
367
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
368
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
369
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
370
|
+
* See the License for the specific language governing permissions and
|
|
371
|
+
* limitations under the License.
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
package androidx.navigation.compose
|
|
375
|
+
|
|
376
|
+
import androidx.compose.animation.AnimatedContentScope
|
|
377
|
+
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
378
|
+
import androidx.compose.animation.EnterTransition
|
|
379
|
+
import androidx.compose.animation.ExitTransition
|
|
380
|
+
import androidx.compose.animation.SizeTransform
|
|
381
|
+
import androidx.compose.runtime.Composable
|
|
382
|
+
import androidx.navigation.NavBackStackEntry
|
|
383
|
+
import androidx.navigation.NavDestinationBuilder
|
|
384
|
+
import androidx.navigation.NavDestinationDsl
|
|
385
|
+
import androidx.navigation.NavType
|
|
386
|
+
import kotlin.jvm.JvmSuppressWildcards
|
|
387
|
+
import kotlin.reflect.KClass
|
|
388
|
+
import kotlin.reflect.KType
|
|
389
|
+
|
|
390
|
+
/** DSL for constructing a new [ComposeNavigator.Destination] */
|
|
391
|
+
@NavDestinationDsl
|
|
392
|
+
public class ComposeNavigatorDestinationBuilder :
|
|
393
|
+
NavDestinationBuilder<ComposeNavigator.Destination> {
|
|
394
|
+
|
|
395
|
+
private val composeNavigator: ComposeNavigator
|
|
396
|
+
private val content: @Composable (AnimatedContentScope.(NavBackStackEntry) -> Unit)
|
|
397
|
+
|
|
398
|
+
public var enterTransition:
|
|
399
|
+
(@JvmSuppressWildcards
|
|
400
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
401
|
+
null
|
|
402
|
+
|
|
403
|
+
public var exitTransition:
|
|
404
|
+
(@JvmSuppressWildcards
|
|
405
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
406
|
+
null
|
|
407
|
+
|
|
408
|
+
public var popEnterTransition:
|
|
409
|
+
(@JvmSuppressWildcards
|
|
410
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
411
|
+
null
|
|
412
|
+
|
|
413
|
+
public var popExitTransition:
|
|
414
|
+
(@JvmSuppressWildcards
|
|
415
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
416
|
+
null
|
|
417
|
+
|
|
418
|
+
public var sizeTransform:
|
|
419
|
+
(@JvmSuppressWildcards
|
|
420
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
421
|
+
null
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* DSL for constructing a new [ComposeNavigator.Destination]
|
|
425
|
+
*
|
|
426
|
+
* @param navigator navigator used to create the destination
|
|
427
|
+
* @param route the destination's unique route
|
|
428
|
+
* @param content composable for the destination
|
|
429
|
+
*/
|
|
430
|
+
public constructor(
|
|
431
|
+
navigator: ComposeNavigator,
|
|
432
|
+
route: String,
|
|
433
|
+
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
|
|
434
|
+
) : super(navigator, route) {
|
|
435
|
+
this.composeNavigator = navigator
|
|
436
|
+
this.content = content
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* DSL for constructing a new [ComposeNavigator.Destination]
|
|
441
|
+
*
|
|
442
|
+
* @param navigator navigator used to create the destination
|
|
443
|
+
* @param route the destination's unique route from a [KClass]
|
|
444
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
445
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
446
|
+
* @param content composable for the destination
|
|
447
|
+
*/
|
|
448
|
+
public constructor(
|
|
449
|
+
navigator: ComposeNavigator,
|
|
450
|
+
route: KClass<*>,
|
|
451
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>>,
|
|
452
|
+
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
|
|
453
|
+
) : super(navigator, route, typeMap) {
|
|
454
|
+
this.composeNavigator = navigator
|
|
455
|
+
this.content = content
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
override fun instantiateDestination(): ComposeNavigator.Destination {
|
|
459
|
+
return ComposeNavigator.Destination(composeNavigator, content)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
override fun build(): ComposeNavigator.Destination {
|
|
463
|
+
return super.build().also { destination ->
|
|
464
|
+
destination.enterTransition = enterTransition
|
|
465
|
+
destination.exitTransition = exitTransition
|
|
466
|
+
destination.popEnterTransition = popEnterTransition
|
|
467
|
+
destination.popExitTransition = popExitTransition
|
|
468
|
+
destination.sizeTransform = sizeTransform
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/DialogHost.kt
|
|
475
|
+
```kotlin
|
|
476
|
+
/*
|
|
477
|
+
* Copyright 2021 The Android Open Source Project
|
|
478
|
+
*
|
|
479
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
480
|
+
* you may not use this file except in compliance with the License.
|
|
481
|
+
* You may obtain a copy of the License at
|
|
482
|
+
*
|
|
483
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
484
|
+
*
|
|
485
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
486
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
487
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
488
|
+
* See the License for the specific language governing permissions and
|
|
489
|
+
* limitations under the License.
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
package androidx.navigation.compose
|
|
493
|
+
|
|
494
|
+
import androidx.compose.runtime.Composable
|
|
495
|
+
import androidx.compose.runtime.DisposableEffect
|
|
496
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
497
|
+
import androidx.compose.runtime.collectAsState
|
|
498
|
+
import androidx.compose.runtime.getValue
|
|
499
|
+
import androidx.compose.runtime.mutableStateListOf
|
|
500
|
+
import androidx.compose.runtime.remember
|
|
501
|
+
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
|
|
502
|
+
import androidx.compose.runtime.snapshots.SnapshotStateList
|
|
503
|
+
import androidx.compose.ui.platform.LocalInspectionMode
|
|
504
|
+
import androidx.compose.ui.window.Dialog
|
|
505
|
+
import androidx.lifecycle.Lifecycle
|
|
506
|
+
import androidx.lifecycle.LifecycleEventObserver
|
|
507
|
+
import androidx.navigation.NavBackStackEntry
|
|
508
|
+
import androidx.navigation.compose.DialogNavigator.Destination
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Show each [Destination] on the [DialogNavigator]'s back stack as a [Dialog].
|
|
512
|
+
*
|
|
513
|
+
* Note that [NavHost] will call this for you; you do not need to call it manually.
|
|
514
|
+
*/
|
|
515
|
+
@Composable
|
|
516
|
+
public fun DialogHost(dialogNavigator: DialogNavigator) {
|
|
517
|
+
val saveableStateHolder = rememberSaveableStateHolder()
|
|
518
|
+
val dialogBackStack by dialogNavigator.backStack.collectAsState()
|
|
519
|
+
val visibleBackStack = rememberVisibleList(dialogBackStack)
|
|
520
|
+
visibleBackStack.PopulateVisibleList(dialogBackStack)
|
|
521
|
+
|
|
522
|
+
val transitionInProgress by dialogNavigator.transitionInProgress.collectAsState()
|
|
523
|
+
val dialogsToDispose = remember { mutableStateListOf<NavBackStackEntry>() }
|
|
524
|
+
|
|
525
|
+
visibleBackStack.forEach { backStackEntry ->
|
|
526
|
+
val destination = backStackEntry.destination as Destination
|
|
527
|
+
Dialog(
|
|
528
|
+
onDismissRequest = { dialogNavigator.dismiss(backStackEntry) },
|
|
529
|
+
properties = destination.dialogProperties,
|
|
530
|
+
) {
|
|
531
|
+
DisposableEffect(backStackEntry) {
|
|
532
|
+
dialogsToDispose.add(backStackEntry)
|
|
533
|
+
onDispose {
|
|
534
|
+
dialogNavigator.onTransitionComplete(backStackEntry)
|
|
535
|
+
dialogsToDispose.remove(backStackEntry)
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// while in the scope of the composable, we provide the navBackStackEntry as the
|
|
540
|
+
// ViewModelStoreOwner and LifecycleOwner
|
|
541
|
+
backStackEntry.LocalOwnersProvider(saveableStateHolder) {
|
|
542
|
+
destination.content(backStackEntry)
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
// Dialogs may have been popped before it was composed. To prevent leakage, we need to
|
|
547
|
+
// mark popped entries as complete here. Check that we don't accidentally complete popped
|
|
548
|
+
// entries that were composed, unless they were disposed of already.
|
|
549
|
+
LaunchedEffect(transitionInProgress, dialogsToDispose) {
|
|
550
|
+
transitionInProgress.forEach { entry ->
|
|
551
|
+
if (
|
|
552
|
+
!dialogNavigator.backStack.value.contains(entry) &&
|
|
553
|
+
!dialogsToDispose.contains(entry)
|
|
554
|
+
) {
|
|
555
|
+
dialogNavigator.onTransitionComplete(entry)
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
@Composable
|
|
562
|
+
internal fun MutableList<NavBackStackEntry>.PopulateVisibleList(
|
|
563
|
+
backStack: Collection<NavBackStackEntry>
|
|
564
|
+
) {
|
|
565
|
+
val isInspecting = LocalInspectionMode.current
|
|
566
|
+
backStack.forEach { entry ->
|
|
567
|
+
DisposableEffect(entry.lifecycle) {
|
|
568
|
+
val observer = LifecycleEventObserver { _, event ->
|
|
569
|
+
// show dialog in preview
|
|
570
|
+
if (isInspecting && !contains(entry)) {
|
|
571
|
+
add(entry)
|
|
572
|
+
}
|
|
573
|
+
// ON_START -> add to visibleBackStack, ON_STOP -> remove from visibleBackStack
|
|
574
|
+
if (event == Lifecycle.Event.ON_START) {
|
|
575
|
+
// We want to treat the visible lists as Sets but we want to keep
|
|
576
|
+
// the functionality of mutableStateListOf() so that we recompose in response
|
|
577
|
+
// to adds and removes.
|
|
578
|
+
if (!contains(entry)) {
|
|
579
|
+
add(entry)
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (event == Lifecycle.Event.ON_STOP) {
|
|
583
|
+
remove(entry)
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
entry.lifecycle.addObserver(observer)
|
|
587
|
+
onDispose { entry.lifecycle.removeObserver(observer) }
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
@Composable
|
|
593
|
+
internal fun rememberVisibleList(
|
|
594
|
+
backStack: Collection<NavBackStackEntry>
|
|
595
|
+
): SnapshotStateList<NavBackStackEntry> {
|
|
596
|
+
// show dialog in preview
|
|
597
|
+
val isInspecting = LocalInspectionMode.current
|
|
598
|
+
return remember(backStack) {
|
|
599
|
+
mutableStateListOf<NavBackStackEntry>().also {
|
|
600
|
+
it.addAll(
|
|
601
|
+
backStack.filter { entry ->
|
|
602
|
+
if (isInspecting) {
|
|
603
|
+
true
|
|
604
|
+
} else {
|
|
605
|
+
entry.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/DialogNavigator.kt
|
|
615
|
+
```kotlin
|
|
616
|
+
/*
|
|
617
|
+
* Copyright 2020 The Android Open Source Project
|
|
618
|
+
*
|
|
619
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
620
|
+
* you may not use this file except in compliance with the License.
|
|
621
|
+
* You may obtain a copy of the License at
|
|
622
|
+
*
|
|
623
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
624
|
+
*
|
|
625
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
626
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
627
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
628
|
+
* See the License for the specific language governing permissions and
|
|
629
|
+
* limitations under the License.
|
|
630
|
+
*/
|
|
631
|
+
|
|
632
|
+
package androidx.navigation.compose
|
|
633
|
+
|
|
634
|
+
import androidx.compose.runtime.Composable
|
|
635
|
+
import androidx.compose.ui.window.Dialog
|
|
636
|
+
import androidx.compose.ui.window.DialogProperties
|
|
637
|
+
import androidx.navigation.FloatingWindow
|
|
638
|
+
import androidx.navigation.NavBackStackEntry
|
|
639
|
+
import androidx.navigation.NavDestination
|
|
640
|
+
import androidx.navigation.NavOptions
|
|
641
|
+
import androidx.navigation.Navigator
|
|
642
|
+
import androidx.navigation.compose.DialogNavigator.Destination
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Navigator that navigates through [Composable]s that will be hosted within a [Dialog]. Every
|
|
646
|
+
* destination using this Navigator must set a valid [Composable] by setting it directly on an
|
|
647
|
+
* instantiated [Destination] or calling [dialog].
|
|
648
|
+
*/
|
|
649
|
+
@Navigator.Name("dialog")
|
|
650
|
+
public class DialogNavigator() : Navigator<Destination>(NAME) {
|
|
651
|
+
|
|
652
|
+
/** Get the back stack from the [state]. */
|
|
653
|
+
internal val backStack
|
|
654
|
+
get() = state.backStack
|
|
655
|
+
|
|
656
|
+
/** Get the transitioning dialogs from the [state]. */
|
|
657
|
+
internal val transitionInProgress
|
|
658
|
+
get() = state.transitionsInProgress
|
|
659
|
+
|
|
660
|
+
/** Dismiss the dialog destination associated with the given [backStackEntry]. */
|
|
661
|
+
internal fun dismiss(backStackEntry: NavBackStackEntry) {
|
|
662
|
+
popBackStack(backStackEntry, false)
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
override fun navigate(
|
|
666
|
+
entries: List<NavBackStackEntry>,
|
|
667
|
+
navOptions: NavOptions?,
|
|
668
|
+
navigatorExtras: Extras?,
|
|
669
|
+
) {
|
|
670
|
+
entries.forEach { entry -> state.push(entry) }
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
override fun createDestination(): Destination {
|
|
674
|
+
return Destination(this) {}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
override fun popBackStack(popUpTo: NavBackStackEntry, savedState: Boolean) {
|
|
678
|
+
state.popWithTransition(popUpTo, savedState)
|
|
679
|
+
// When popping, the incoming dialog is marked transitioning to hold it in
|
|
680
|
+
// STARTED. With pop complete, we can remove it from transition so it can move to RESUMED.
|
|
681
|
+
val popIndex = state.transitionsInProgress.value.indexOf(popUpTo)
|
|
682
|
+
// do not mark complete for entries up to and including popUpTo
|
|
683
|
+
state.transitionsInProgress.value.forEachIndexed { index, entry ->
|
|
684
|
+
if (index > popIndex) onTransitionComplete(entry)
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
internal fun onTransitionComplete(entry: NavBackStackEntry) {
|
|
689
|
+
state.markTransitionComplete(entry)
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/** NavDestination specific to [DialogNavigator] */
|
|
693
|
+
@NavDestination.ClassType(Composable::class)
|
|
694
|
+
public class Destination(
|
|
695
|
+
navigator: DialogNavigator,
|
|
696
|
+
internal val dialogProperties: DialogProperties = DialogProperties(),
|
|
697
|
+
internal val content: @Composable (NavBackStackEntry) -> Unit,
|
|
698
|
+
) : NavDestination(navigator), FloatingWindow
|
|
699
|
+
|
|
700
|
+
internal companion object {
|
|
701
|
+
internal const val NAME = "dialog"
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/DialogNavigatorDestinationBuilder.kt
|
|
707
|
+
```kotlin
|
|
708
|
+
/*
|
|
709
|
+
* Copyright 2024 The Android Open Source Project
|
|
710
|
+
*
|
|
711
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
712
|
+
* you may not use this file except in compliance with the License.
|
|
713
|
+
* You may obtain a copy of the License at
|
|
714
|
+
*
|
|
715
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
716
|
+
*
|
|
717
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
718
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
719
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
720
|
+
* See the License for the specific language governing permissions and
|
|
721
|
+
* limitations under the License.
|
|
722
|
+
*/
|
|
723
|
+
|
|
724
|
+
package androidx.navigation.compose
|
|
725
|
+
|
|
726
|
+
import androidx.compose.runtime.Composable
|
|
727
|
+
import androidx.compose.ui.window.DialogProperties
|
|
728
|
+
import androidx.navigation.NavBackStackEntry
|
|
729
|
+
import androidx.navigation.NavDestinationBuilder
|
|
730
|
+
import androidx.navigation.NavDestinationDsl
|
|
731
|
+
import androidx.navigation.NavType
|
|
732
|
+
import kotlin.jvm.JvmSuppressWildcards
|
|
733
|
+
import kotlin.reflect.KClass
|
|
734
|
+
import kotlin.reflect.KType
|
|
735
|
+
|
|
736
|
+
/** DSL for constructing a new [DialogNavigator.Destination] */
|
|
737
|
+
@NavDestinationDsl
|
|
738
|
+
public class DialogNavigatorDestinationBuilder :
|
|
739
|
+
NavDestinationBuilder<DialogNavigator.Destination> {
|
|
740
|
+
|
|
741
|
+
private val dialogNavigator: DialogNavigator
|
|
742
|
+
private val dialogProperties: DialogProperties
|
|
743
|
+
private val content: @Composable (NavBackStackEntry) -> Unit
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* DSL for constructing a new [DialogNavigator.Destination]
|
|
747
|
+
*
|
|
748
|
+
* @param navigator navigator used to create the destination
|
|
749
|
+
* @param route the destination's unique route
|
|
750
|
+
* @param dialogProperties properties that should be passed to
|
|
751
|
+
* [androidx.compose.ui.window.Dialog].
|
|
752
|
+
* @param content composable for the destination
|
|
753
|
+
*/
|
|
754
|
+
public constructor(
|
|
755
|
+
navigator: DialogNavigator,
|
|
756
|
+
route: String,
|
|
757
|
+
dialogProperties: DialogProperties,
|
|
758
|
+
content: @Composable (NavBackStackEntry) -> Unit,
|
|
759
|
+
) : super(navigator, route) {
|
|
760
|
+
this.dialogNavigator = navigator
|
|
761
|
+
this.dialogProperties = dialogProperties
|
|
762
|
+
this.content = content
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* DSL for constructing a new [DialogNavigator.Destination]
|
|
767
|
+
*
|
|
768
|
+
* @param navigator navigator used to create the destination
|
|
769
|
+
* @param route the destination's unique route from a [KClass]
|
|
770
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
771
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
772
|
+
* @param dialogProperties properties that should be passed to
|
|
773
|
+
* [androidx.compose.ui.window.Dialog].
|
|
774
|
+
* @param content composable for the destination
|
|
775
|
+
*/
|
|
776
|
+
public constructor(
|
|
777
|
+
navigator: DialogNavigator,
|
|
778
|
+
route: KClass<*>,
|
|
779
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>>,
|
|
780
|
+
dialogProperties: DialogProperties,
|
|
781
|
+
content: @Composable (NavBackStackEntry) -> Unit,
|
|
782
|
+
) : super(navigator, route, typeMap) {
|
|
783
|
+
this.dialogNavigator = navigator
|
|
784
|
+
this.dialogProperties = dialogProperties
|
|
785
|
+
this.content = content
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
override fun instantiateDestination(): DialogNavigator.Destination {
|
|
789
|
+
return DialogNavigator.Destination(dialogNavigator, dialogProperties, content)
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/NavBackStackEntryProvider.kt
|
|
795
|
+
```kotlin
|
|
796
|
+
/*
|
|
797
|
+
* Copyright 2021 The Android Open Source Project
|
|
798
|
+
*
|
|
799
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
800
|
+
* you may not use this file except in compliance with the License.
|
|
801
|
+
* You may obtain a copy of the License at
|
|
802
|
+
*
|
|
803
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
804
|
+
*
|
|
805
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
806
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
807
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
808
|
+
* See the License for the specific language governing permissions and
|
|
809
|
+
* limitations under the License.
|
|
810
|
+
*/
|
|
811
|
+
|
|
812
|
+
@file:JvmName("NavBackStackEntryProviderKt")
|
|
813
|
+
|
|
814
|
+
package androidx.navigation.compose
|
|
815
|
+
|
|
816
|
+
import androidx.compose.runtime.Composable
|
|
817
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
818
|
+
import androidx.compose.runtime.saveable.SaveableStateHolder
|
|
819
|
+
import androidx.lifecycle.SavedStateHandle
|
|
820
|
+
import androidx.lifecycle.ViewModel
|
|
821
|
+
import androidx.lifecycle.compose.LocalLifecycleOwner
|
|
822
|
+
import androidx.lifecycle.createSavedStateHandle
|
|
823
|
+
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
824
|
+
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
825
|
+
import androidx.navigation.NavBackStackEntry
|
|
826
|
+
import androidx.navigation.compose.internal.WeakReference
|
|
827
|
+
import androidx.navigation.compose.internal.randomUUID
|
|
828
|
+
import androidx.savedstate.compose.LocalSavedStateRegistryOwner
|
|
829
|
+
import kotlin.jvm.JvmName
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Provides [this] [NavBackStackEntry] as [LocalViewModelStoreOwner], [LocalLifecycleOwner] and
|
|
833
|
+
* [LocalSavedStateRegistryOwner] to the [content] and saves the [content]'s saveable states with
|
|
834
|
+
* the given [saveableStateHolder].
|
|
835
|
+
*
|
|
836
|
+
* @param saveableStateHolder The [SaveableStateHolder] that holds the saved states. The same holder
|
|
837
|
+
* should be used for all [NavBackStackEntry]s in the encapsulating [Composable] and the holder
|
|
838
|
+
* should be hoisted.
|
|
839
|
+
* @param content The content [Composable]
|
|
840
|
+
*/
|
|
841
|
+
@Composable
|
|
842
|
+
public fun NavBackStackEntry.LocalOwnersProvider(
|
|
843
|
+
saveableStateHolder: SaveableStateHolder,
|
|
844
|
+
content: @Composable () -> Unit,
|
|
845
|
+
) {
|
|
846
|
+
// This outer `CompositionLocalProvider` explicitly provides the owners from this
|
|
847
|
+
// `NavBackStackEntry` directly to the `SaveableStateProvider`. This prevents potential issues,
|
|
848
|
+
// such as in testing scenarios, where these owners might not be set.
|
|
849
|
+
CompositionLocalProvider(
|
|
850
|
+
LocalViewModelStoreOwner provides this,
|
|
851
|
+
LocalLifecycleOwner provides this,
|
|
852
|
+
LocalSavedStateRegistryOwner provides this,
|
|
853
|
+
) {
|
|
854
|
+
saveableStateHolder.SaveableStateProvider {
|
|
855
|
+
// This inner `CompositionLocalProvider`, located inside the `SaveableStateProvider`
|
|
856
|
+
// lambda, ensures that the `content` composable receives the correct owners
|
|
857
|
+
// from this `NavBackStackEntry`. This layering prevents unintended owner overrides
|
|
858
|
+
// by `SaveableStateProvider` and ensures the destination content correctly interacts
|
|
859
|
+
// with its navigation-scoped owners.
|
|
860
|
+
CompositionLocalProvider(
|
|
861
|
+
LocalViewModelStoreOwner provides this,
|
|
862
|
+
LocalLifecycleOwner provides this,
|
|
863
|
+
LocalSavedStateRegistryOwner provides this,
|
|
864
|
+
content = content,
|
|
865
|
+
)
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
@Composable
|
|
871
|
+
private fun SaveableStateHolder.SaveableStateProvider(content: @Composable () -> Unit) {
|
|
872
|
+
val viewModel = viewModel { BackStackEntryIdViewModel(createSavedStateHandle()) }
|
|
873
|
+
// Stash a reference to the SaveableStateHolder in the ViewModel so that
|
|
874
|
+
// it is available when the ViewModel is cleared, marking the permanent removal of this
|
|
875
|
+
// NavBackStackEntry from the back stack. Which, because of animations,
|
|
876
|
+
// only happens after this leaves composition. Which means we can't rely on
|
|
877
|
+
// DisposableEffect to clean up this reference (as it'll be cleaned up too early)
|
|
878
|
+
viewModel.saveableStateHolderRef = WeakReference(this)
|
|
879
|
+
SaveableStateProvider(viewModel.id, content)
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
internal class BackStackEntryIdViewModel(handle: SavedStateHandle) : ViewModel() {
|
|
883
|
+
|
|
884
|
+
private val IdKey = "SaveableStateHolder_BackStackEntryKey"
|
|
885
|
+
|
|
886
|
+
// we create our own id for each back stack entry to support multiple entries of the same
|
|
887
|
+
// destination. this id will be restored by SavedStateHandle
|
|
888
|
+
val id: String = (handle.get<String>(IdKey) ?: randomUUID().also { handle.set(IdKey, it) })
|
|
889
|
+
|
|
890
|
+
lateinit var saveableStateHolderRef: WeakReference<SaveableStateHolder>
|
|
891
|
+
|
|
892
|
+
// onCleared will be called on the entries removed from the back stack. here we notify
|
|
893
|
+
// SaveableStateProvider that we should remove any state is had associated with this
|
|
894
|
+
// destination as it is no longer needed.
|
|
895
|
+
override fun onCleared() {
|
|
896
|
+
super.onCleared()
|
|
897
|
+
saveableStateHolderRef.get()?.removeState(id)
|
|
898
|
+
saveableStateHolderRef.clear()
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/NavGraphBuilder.kt
|
|
904
|
+
```kotlin
|
|
905
|
+
/*
|
|
906
|
+
* Copyright 2020 The Android Open Source Project
|
|
907
|
+
*
|
|
908
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
909
|
+
* you may not use this file except in compliance with the License.
|
|
910
|
+
* You may obtain a copy of the License at
|
|
911
|
+
*
|
|
912
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
913
|
+
*
|
|
914
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
915
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
916
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
917
|
+
* See the License for the specific language governing permissions and
|
|
918
|
+
* limitations under the License.
|
|
919
|
+
*/
|
|
920
|
+
|
|
921
|
+
package androidx.navigation.compose
|
|
922
|
+
|
|
923
|
+
import androidx.compose.animation.AnimatedContentScope
|
|
924
|
+
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
925
|
+
import androidx.compose.animation.EnterTransition
|
|
926
|
+
import androidx.compose.animation.ExitTransition
|
|
927
|
+
import androidx.compose.animation.SizeTransform
|
|
928
|
+
import androidx.compose.runtime.Composable
|
|
929
|
+
import androidx.compose.ui.window.DialogProperties
|
|
930
|
+
import androidx.navigation.NamedNavArgument
|
|
931
|
+
import androidx.navigation.NavBackStackEntry
|
|
932
|
+
import androidx.navigation.NavDeepLink
|
|
933
|
+
import androidx.navigation.NavGraph
|
|
934
|
+
import androidx.navigation.NavGraphBuilder
|
|
935
|
+
import androidx.navigation.NavType
|
|
936
|
+
import androidx.navigation.get
|
|
937
|
+
import kotlin.jvm.JvmSuppressWildcards
|
|
938
|
+
import kotlin.reflect.KClass
|
|
939
|
+
import kotlin.reflect.KType
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Add the [Composable] to the [NavGraphBuilder]
|
|
943
|
+
*
|
|
944
|
+
* @param route route for the destination
|
|
945
|
+
* @param arguments list of arguments to associate with destination
|
|
946
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
947
|
+
* @param content composable for the destination
|
|
948
|
+
*/
|
|
949
|
+
@Deprecated(
|
|
950
|
+
message = "Deprecated in favor of composable builder that supports AnimatedContent",
|
|
951
|
+
level = DeprecationLevel.HIDDEN,
|
|
952
|
+
)
|
|
953
|
+
public fun NavGraphBuilder.composable(
|
|
954
|
+
route: String,
|
|
955
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
956
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
957
|
+
content: @Composable (NavBackStackEntry) -> Unit,
|
|
958
|
+
) {
|
|
959
|
+
addDestination(
|
|
960
|
+
ComposeNavigator.Destination(provider[ComposeNavigator::class]) { entry -> content(entry) }
|
|
961
|
+
.apply {
|
|
962
|
+
this.route = route
|
|
963
|
+
arguments.forEach { (argumentName, argument) ->
|
|
964
|
+
addArgument(argumentName, argument)
|
|
965
|
+
}
|
|
966
|
+
deepLinks.forEach { deepLink -> addDeepLink(deepLink) }
|
|
967
|
+
}
|
|
968
|
+
)
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Add the [Composable] to the [NavGraphBuilder]
|
|
973
|
+
*
|
|
974
|
+
* @param route route for the destination
|
|
975
|
+
* @param arguments list of arguments to associate with destination
|
|
976
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
977
|
+
* @param enterTransition callback to determine the destination's enter transition
|
|
978
|
+
* @param exitTransition callback to determine the destination's exit transition
|
|
979
|
+
* @param popEnterTransition callback to determine the destination's popEnter transition
|
|
980
|
+
* @param popExitTransition callback to determine the destination's popExit transition
|
|
981
|
+
* @param content composable for the destination
|
|
982
|
+
*/
|
|
983
|
+
@Deprecated(
|
|
984
|
+
message = "Deprecated in favor of composable builder that supports sizeTransform",
|
|
985
|
+
level = DeprecationLevel.HIDDEN,
|
|
986
|
+
)
|
|
987
|
+
public fun NavGraphBuilder.composable(
|
|
988
|
+
route: String,
|
|
989
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
990
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
991
|
+
enterTransition:
|
|
992
|
+
(@JvmSuppressWildcards
|
|
993
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
994
|
+
null,
|
|
995
|
+
exitTransition:
|
|
996
|
+
(@JvmSuppressWildcards
|
|
997
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
998
|
+
null,
|
|
999
|
+
popEnterTransition:
|
|
1000
|
+
(@JvmSuppressWildcards
|
|
1001
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1002
|
+
enterTransition,
|
|
1003
|
+
popExitTransition:
|
|
1004
|
+
(@JvmSuppressWildcards
|
|
1005
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1006
|
+
exitTransition,
|
|
1007
|
+
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
|
|
1008
|
+
) {
|
|
1009
|
+
destination(
|
|
1010
|
+
ComposeNavigatorDestinationBuilder(provider[ComposeNavigator::class], route, content)
|
|
1011
|
+
.apply {
|
|
1012
|
+
arguments.forEach { (argumentName, argument) -> argument(argumentName, argument) }
|
|
1013
|
+
deepLinks.forEach { deepLink -> deepLink(deepLink) }
|
|
1014
|
+
this.enterTransition = enterTransition
|
|
1015
|
+
this.exitTransition = exitTransition
|
|
1016
|
+
this.popEnterTransition = popEnterTransition
|
|
1017
|
+
this.popExitTransition = popExitTransition
|
|
1018
|
+
}
|
|
1019
|
+
)
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Add the [Composable] to the [NavGraphBuilder]
|
|
1024
|
+
*
|
|
1025
|
+
* @param route route for the destination
|
|
1026
|
+
* @param arguments list of arguments to associate with destination
|
|
1027
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1028
|
+
* @param enterTransition callback to determine the destination's enter transition
|
|
1029
|
+
* @param exitTransition callback to determine the destination's exit transition
|
|
1030
|
+
* @param popEnterTransition callback to determine the destination's popEnter transition
|
|
1031
|
+
* @param popExitTransition callback to determine the destination's popExit transition
|
|
1032
|
+
* @param sizeTransform callback to determine the destination's sizeTransform.
|
|
1033
|
+
* @param content composable for the destination
|
|
1034
|
+
* @sample androidx.navigation.compose.samples.SizeTransformComposable
|
|
1035
|
+
*/
|
|
1036
|
+
public fun NavGraphBuilder.composable(
|
|
1037
|
+
route: String,
|
|
1038
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
1039
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1040
|
+
enterTransition:
|
|
1041
|
+
(@JvmSuppressWildcards
|
|
1042
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1043
|
+
null,
|
|
1044
|
+
exitTransition:
|
|
1045
|
+
(@JvmSuppressWildcards
|
|
1046
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1047
|
+
null,
|
|
1048
|
+
popEnterTransition:
|
|
1049
|
+
(@JvmSuppressWildcards
|
|
1050
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1051
|
+
enterTransition,
|
|
1052
|
+
popExitTransition:
|
|
1053
|
+
(@JvmSuppressWildcards
|
|
1054
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1055
|
+
exitTransition,
|
|
1056
|
+
sizeTransform:
|
|
1057
|
+
(@JvmSuppressWildcards
|
|
1058
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
1059
|
+
null,
|
|
1060
|
+
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
|
|
1061
|
+
) {
|
|
1062
|
+
destination(
|
|
1063
|
+
ComposeNavigatorDestinationBuilder(provider[ComposeNavigator::class], route, content)
|
|
1064
|
+
.apply {
|
|
1065
|
+
arguments.forEach { (argumentName, argument) -> argument(argumentName, argument) }
|
|
1066
|
+
deepLinks.forEach { deepLink -> deepLink(deepLink) }
|
|
1067
|
+
this.enterTransition = enterTransition
|
|
1068
|
+
this.exitTransition = exitTransition
|
|
1069
|
+
this.popEnterTransition = popEnterTransition
|
|
1070
|
+
this.popExitTransition = popExitTransition
|
|
1071
|
+
this.sizeTransform = sizeTransform
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Add the [Composable] to the [NavGraphBuilder]
|
|
1078
|
+
*
|
|
1079
|
+
* @param T route from a [KClass] for the destination
|
|
1080
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1081
|
+
* [NavType]. May be empty if [T] does not use custom NavTypes.
|
|
1082
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1083
|
+
* @param enterTransition callback to determine the destination's enter transition
|
|
1084
|
+
* @param exitTransition callback to determine the destination's exit transition
|
|
1085
|
+
* @param popEnterTransition callback to determine the destination's popEnter transition
|
|
1086
|
+
* @param popExitTransition callback to determine the destination's popExit transition
|
|
1087
|
+
* @param sizeTransform callback to determine the destination's sizeTransform.
|
|
1088
|
+
* @param content composable for the destination
|
|
1089
|
+
*/
|
|
1090
|
+
public inline fun <reified T : Any> NavGraphBuilder.composable(
|
|
1091
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1092
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1093
|
+
noinline enterTransition:
|
|
1094
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1095
|
+
EnterTransition?)? =
|
|
1096
|
+
null,
|
|
1097
|
+
noinline exitTransition:
|
|
1098
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1099
|
+
ExitTransition?)? =
|
|
1100
|
+
null,
|
|
1101
|
+
noinline popEnterTransition:
|
|
1102
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1103
|
+
EnterTransition?)? =
|
|
1104
|
+
enterTransition,
|
|
1105
|
+
noinline popExitTransition:
|
|
1106
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1107
|
+
ExitTransition?)? =
|
|
1108
|
+
exitTransition,
|
|
1109
|
+
noinline sizeTransform:
|
|
1110
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1111
|
+
SizeTransform?)? =
|
|
1112
|
+
null,
|
|
1113
|
+
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
|
|
1114
|
+
) {
|
|
1115
|
+
composable(
|
|
1116
|
+
T::class,
|
|
1117
|
+
typeMap,
|
|
1118
|
+
deepLinks,
|
|
1119
|
+
enterTransition,
|
|
1120
|
+
exitTransition,
|
|
1121
|
+
popEnterTransition,
|
|
1122
|
+
popExitTransition,
|
|
1123
|
+
sizeTransform,
|
|
1124
|
+
content,
|
|
1125
|
+
)
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Add the [Composable] to the [NavGraphBuilder]
|
|
1130
|
+
*
|
|
1131
|
+
* @param route route from a [KClass] for the destination
|
|
1132
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1133
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
1134
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1135
|
+
* @param enterTransition callback to determine the destination's enter transition
|
|
1136
|
+
* @param exitTransition callback to determine the destination's exit transition
|
|
1137
|
+
* @param popEnterTransition callback to determine the destination's popEnter transition
|
|
1138
|
+
* @param popExitTransition callback to determine the destination's popExit transition
|
|
1139
|
+
* @param sizeTransform callback to determine the destination's sizeTransform.
|
|
1140
|
+
* @param content composable for the destination
|
|
1141
|
+
*/
|
|
1142
|
+
public fun <T : Any> NavGraphBuilder.composable(
|
|
1143
|
+
route: KClass<T>,
|
|
1144
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1145
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1146
|
+
enterTransition:
|
|
1147
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1148
|
+
EnterTransition?)? =
|
|
1149
|
+
null,
|
|
1150
|
+
exitTransition:
|
|
1151
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1152
|
+
ExitTransition?)? =
|
|
1153
|
+
null,
|
|
1154
|
+
popEnterTransition:
|
|
1155
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1156
|
+
EnterTransition?)? =
|
|
1157
|
+
enterTransition,
|
|
1158
|
+
popExitTransition:
|
|
1159
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1160
|
+
ExitTransition?)? =
|
|
1161
|
+
exitTransition,
|
|
1162
|
+
sizeTransform:
|
|
1163
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1164
|
+
SizeTransform?)? =
|
|
1165
|
+
null,
|
|
1166
|
+
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit,
|
|
1167
|
+
) {
|
|
1168
|
+
destination(
|
|
1169
|
+
ComposeNavigatorDestinationBuilder(
|
|
1170
|
+
provider[ComposeNavigator::class],
|
|
1171
|
+
route,
|
|
1172
|
+
typeMap,
|
|
1173
|
+
content,
|
|
1174
|
+
)
|
|
1175
|
+
.apply {
|
|
1176
|
+
deepLinks.forEach { deepLink -> deepLink(deepLink) }
|
|
1177
|
+
this.enterTransition = enterTransition
|
|
1178
|
+
this.exitTransition = exitTransition
|
|
1179
|
+
this.popEnterTransition = popEnterTransition
|
|
1180
|
+
this.popExitTransition = popExitTransition
|
|
1181
|
+
this.sizeTransform = sizeTransform
|
|
1182
|
+
}
|
|
1183
|
+
)
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Construct a nested [NavGraph]
|
|
1188
|
+
*
|
|
1189
|
+
* @sample androidx.navigation.compose.samples.NavWithArgsInNestedGraph
|
|
1190
|
+
* @param startDestination the starting destination's route for this NavGraph
|
|
1191
|
+
* @param route the destination's unique route
|
|
1192
|
+
* @param arguments list of arguments to associate with destination
|
|
1193
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1194
|
+
* @param builder the builder used to construct the graph
|
|
1195
|
+
*/
|
|
1196
|
+
@Deprecated(
|
|
1197
|
+
message = "Deprecated in favor of navigation builder that supports AnimatedContent",
|
|
1198
|
+
level = DeprecationLevel.HIDDEN,
|
|
1199
|
+
)
|
|
1200
|
+
public fun NavGraphBuilder.navigation(
|
|
1201
|
+
startDestination: String,
|
|
1202
|
+
route: String,
|
|
1203
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
1204
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1205
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1206
|
+
) {
|
|
1207
|
+
navigation(startDestination, route, arguments, deepLinks, null, null, null, null, null, builder)
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Construct a nested [NavGraph]
|
|
1212
|
+
*
|
|
1213
|
+
* @param startDestination the starting destination's route for this NavGraph
|
|
1214
|
+
* @param route the destination's unique route
|
|
1215
|
+
* @param arguments list of arguments to associate with destination
|
|
1216
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1217
|
+
* @param enterTransition callback to define enter transitions for destination in this NavGraph
|
|
1218
|
+
* @param exitTransition callback to define exit transitions for destination in this NavGraph
|
|
1219
|
+
* @param popEnterTransition callback to define pop enter transitions for destination in this
|
|
1220
|
+
* NavGraph
|
|
1221
|
+
* @param popExitTransition callback to define pop exit transitions for destination in this NavGraph
|
|
1222
|
+
* @param builder the builder used to construct the graph
|
|
1223
|
+
* @return the newly constructed nested NavGraph
|
|
1224
|
+
*/
|
|
1225
|
+
@Deprecated(
|
|
1226
|
+
message = "Deprecated in favor of navigation builder that supports sizeTransform",
|
|
1227
|
+
level = DeprecationLevel.HIDDEN,
|
|
1228
|
+
)
|
|
1229
|
+
public fun NavGraphBuilder.navigation(
|
|
1230
|
+
startDestination: String,
|
|
1231
|
+
route: String,
|
|
1232
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
1233
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1234
|
+
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1235
|
+
null,
|
|
1236
|
+
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1237
|
+
null,
|
|
1238
|
+
popEnterTransition:
|
|
1239
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1240
|
+
enterTransition,
|
|
1241
|
+
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1242
|
+
exitTransition,
|
|
1243
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1244
|
+
) {
|
|
1245
|
+
navigation(
|
|
1246
|
+
startDestination,
|
|
1247
|
+
route,
|
|
1248
|
+
arguments,
|
|
1249
|
+
deepLinks,
|
|
1250
|
+
enterTransition,
|
|
1251
|
+
exitTransition,
|
|
1252
|
+
popEnterTransition,
|
|
1253
|
+
popExitTransition,
|
|
1254
|
+
null,
|
|
1255
|
+
builder,
|
|
1256
|
+
)
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Construct a nested [NavGraph]
|
|
1261
|
+
*
|
|
1262
|
+
* @param startDestination the starting destination's route for this NavGraph
|
|
1263
|
+
* @param route the destination's unique route
|
|
1264
|
+
* @param arguments list of arguments to associate with destination
|
|
1265
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1266
|
+
* @param enterTransition callback to define enter transitions for destination in this NavGraph
|
|
1267
|
+
* @param exitTransition callback to define exit transitions for destination in this NavGraph
|
|
1268
|
+
* @param popEnterTransition callback to define pop enter transitions for destination in this
|
|
1269
|
+
* NavGraph
|
|
1270
|
+
* @param popExitTransition callback to define pop exit transitions for destination in this NavGraph
|
|
1271
|
+
* @param sizeTransform callback to define the size transform for destinations in this NavGraph
|
|
1272
|
+
* @param builder the builder used to construct the graph
|
|
1273
|
+
* @return the newly constructed nested NavGraph
|
|
1274
|
+
*/
|
|
1275
|
+
public fun NavGraphBuilder.navigation(
|
|
1276
|
+
startDestination: String,
|
|
1277
|
+
route: String,
|
|
1278
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
1279
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1280
|
+
enterTransition:
|
|
1281
|
+
(@JvmSuppressWildcards
|
|
1282
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1283
|
+
null,
|
|
1284
|
+
exitTransition:
|
|
1285
|
+
(@JvmSuppressWildcards
|
|
1286
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1287
|
+
null,
|
|
1288
|
+
popEnterTransition:
|
|
1289
|
+
(@JvmSuppressWildcards
|
|
1290
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? =
|
|
1291
|
+
enterTransition,
|
|
1292
|
+
popExitTransition:
|
|
1293
|
+
(@JvmSuppressWildcards
|
|
1294
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? =
|
|
1295
|
+
exitTransition,
|
|
1296
|
+
sizeTransform:
|
|
1297
|
+
(@JvmSuppressWildcards
|
|
1298
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
1299
|
+
null,
|
|
1300
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1301
|
+
) {
|
|
1302
|
+
addDestination(
|
|
1303
|
+
NavGraphBuilder(provider, startDestination, route).apply(builder).build().apply {
|
|
1304
|
+
arguments.forEach { (argumentName, argument) -> addArgument(argumentName, argument) }
|
|
1305
|
+
deepLinks.forEach { deepLink -> addDeepLink(deepLink) }
|
|
1306
|
+
if (this is ComposeNavGraphNavigator.ComposeNavGraph) {
|
|
1307
|
+
this.enterTransition = enterTransition
|
|
1308
|
+
this.exitTransition = exitTransition
|
|
1309
|
+
this.popEnterTransition = popEnterTransition
|
|
1310
|
+
this.popExitTransition = popExitTransition
|
|
1311
|
+
this.sizeTransform = sizeTransform
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
)
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Construct a nested [NavGraph]
|
|
1319
|
+
*
|
|
1320
|
+
* @param T the destination's unique route from a KClass
|
|
1321
|
+
* @param startDestination the starting destination's route from [KClass] for this NavGraph
|
|
1322
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1323
|
+
* [NavType]. May be empty if [T] does not use custom NavTypes.
|
|
1324
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1325
|
+
* @param enterTransition callback to define enter transitions for destination in this NavGraph
|
|
1326
|
+
* @param exitTransition callback to define exit transitions for destination in this NavGraph
|
|
1327
|
+
* @param popEnterTransition callback to define pop enter transitions for destination in this
|
|
1328
|
+
* NavGraph
|
|
1329
|
+
* @param popExitTransition callback to define pop exit transitions for destination in this NavGraph
|
|
1330
|
+
* @param sizeTransform callback to define the size transform for destinations in this NavGraph
|
|
1331
|
+
* @param builder the builder used to construct the graph
|
|
1332
|
+
* @return the newly constructed nested NavGraph
|
|
1333
|
+
* @sample androidx.navigation.compose.samples.SizeTransformNav
|
|
1334
|
+
*/
|
|
1335
|
+
public inline fun <reified T : Any> NavGraphBuilder.navigation(
|
|
1336
|
+
startDestination: KClass<*>,
|
|
1337
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1338
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1339
|
+
noinline enterTransition:
|
|
1340
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1341
|
+
EnterTransition?)? =
|
|
1342
|
+
null,
|
|
1343
|
+
noinline exitTransition:
|
|
1344
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1345
|
+
ExitTransition?)? =
|
|
1346
|
+
null,
|
|
1347
|
+
noinline popEnterTransition:
|
|
1348
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1349
|
+
EnterTransition?)? =
|
|
1350
|
+
enterTransition,
|
|
1351
|
+
noinline popExitTransition:
|
|
1352
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1353
|
+
ExitTransition?)? =
|
|
1354
|
+
exitTransition,
|
|
1355
|
+
noinline sizeTransform:
|
|
1356
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1357
|
+
SizeTransform?)? =
|
|
1358
|
+
null,
|
|
1359
|
+
noinline builder: NavGraphBuilder.() -> Unit,
|
|
1360
|
+
) {
|
|
1361
|
+
navigation(
|
|
1362
|
+
startDestination,
|
|
1363
|
+
T::class,
|
|
1364
|
+
typeMap,
|
|
1365
|
+
deepLinks,
|
|
1366
|
+
enterTransition,
|
|
1367
|
+
exitTransition,
|
|
1368
|
+
popEnterTransition,
|
|
1369
|
+
popExitTransition,
|
|
1370
|
+
sizeTransform,
|
|
1371
|
+
builder,
|
|
1372
|
+
)
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Construct a nested [NavGraph]
|
|
1377
|
+
*
|
|
1378
|
+
* @param route the destination's unique route from a KClass
|
|
1379
|
+
* @param startDestination the starting destination's route from [KClass] for this NavGraph
|
|
1380
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1381
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
1382
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1383
|
+
* @param enterTransition callback to define enter transitions for destination in this NavGraph
|
|
1384
|
+
* @param exitTransition callback to define exit transitions for destination in this NavGraph
|
|
1385
|
+
* @param popEnterTransition callback to define pop enter transitions for destination in this
|
|
1386
|
+
* NavGraph
|
|
1387
|
+
* @param popExitTransition callback to define pop exit transitions for destination in this NavGraph
|
|
1388
|
+
* @param sizeTransform callback to define the size transform for destinations in this NavGraph
|
|
1389
|
+
* @param builder the builder used to construct the graph
|
|
1390
|
+
* @return the newly constructed nested NavGraph
|
|
1391
|
+
*/
|
|
1392
|
+
public fun <T : Any> NavGraphBuilder.navigation(
|
|
1393
|
+
startDestination: KClass<*>,
|
|
1394
|
+
route: KClass<T>,
|
|
1395
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1396
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1397
|
+
enterTransition:
|
|
1398
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1399
|
+
EnterTransition?)? =
|
|
1400
|
+
null,
|
|
1401
|
+
exitTransition:
|
|
1402
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1403
|
+
ExitTransition?)? =
|
|
1404
|
+
null,
|
|
1405
|
+
popEnterTransition:
|
|
1406
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1407
|
+
EnterTransition?)? =
|
|
1408
|
+
enterTransition,
|
|
1409
|
+
popExitTransition:
|
|
1410
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1411
|
+
ExitTransition?)? =
|
|
1412
|
+
exitTransition,
|
|
1413
|
+
sizeTransform:
|
|
1414
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1415
|
+
SizeTransform?)? =
|
|
1416
|
+
null,
|
|
1417
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1418
|
+
) {
|
|
1419
|
+
addDestination(
|
|
1420
|
+
NavGraphBuilder(provider, startDestination, route, typeMap).apply(builder).build().apply {
|
|
1421
|
+
deepLinks.forEach { deepLink -> addDeepLink(deepLink) }
|
|
1422
|
+
if (this is ComposeNavGraphNavigator.ComposeNavGraph) {
|
|
1423
|
+
this.enterTransition = enterTransition
|
|
1424
|
+
this.exitTransition = exitTransition
|
|
1425
|
+
this.popEnterTransition = popEnterTransition
|
|
1426
|
+
this.popExitTransition = popExitTransition
|
|
1427
|
+
this.sizeTransform = sizeTransform
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
)
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Construct a nested [NavGraph]
|
|
1435
|
+
*
|
|
1436
|
+
* @param T the destination's unique route from a KClass
|
|
1437
|
+
* @param startDestination the starting destination's route from an Object for this NavGraph
|
|
1438
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1439
|
+
* [NavType]. May be empty if [T] does not use custom NavTypes.
|
|
1440
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1441
|
+
* @param enterTransition callback to define enter transitions for destination in this NavGraph
|
|
1442
|
+
* @param exitTransition callback to define exit transitions for destination in this NavGraph
|
|
1443
|
+
* @param popEnterTransition callback to define pop enter transitions for destination in this
|
|
1444
|
+
* NavGraph
|
|
1445
|
+
* @param popExitTransition callback to define pop exit transitions for destination in this NavGraph
|
|
1446
|
+
* @param sizeTransform callback to define the size transform for destinations in this NavGraph
|
|
1447
|
+
* @param builder the builder used to construct the graph
|
|
1448
|
+
* @return the newly constructed nested NavGraph
|
|
1449
|
+
*/
|
|
1450
|
+
public inline fun <reified T : Any> NavGraphBuilder.navigation(
|
|
1451
|
+
startDestination: Any,
|
|
1452
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1453
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1454
|
+
noinline enterTransition:
|
|
1455
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1456
|
+
EnterTransition?)? =
|
|
1457
|
+
null,
|
|
1458
|
+
noinline exitTransition:
|
|
1459
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1460
|
+
ExitTransition?)? =
|
|
1461
|
+
null,
|
|
1462
|
+
noinline popEnterTransition:
|
|
1463
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1464
|
+
EnterTransition?)? =
|
|
1465
|
+
enterTransition,
|
|
1466
|
+
noinline popExitTransition:
|
|
1467
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1468
|
+
ExitTransition?)? =
|
|
1469
|
+
exitTransition,
|
|
1470
|
+
noinline sizeTransform:
|
|
1471
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1472
|
+
SizeTransform?)? =
|
|
1473
|
+
null,
|
|
1474
|
+
noinline builder: NavGraphBuilder.() -> Unit,
|
|
1475
|
+
) {
|
|
1476
|
+
navigation(
|
|
1477
|
+
startDestination,
|
|
1478
|
+
T::class,
|
|
1479
|
+
typeMap,
|
|
1480
|
+
deepLinks,
|
|
1481
|
+
enterTransition,
|
|
1482
|
+
exitTransition,
|
|
1483
|
+
popEnterTransition,
|
|
1484
|
+
popExitTransition,
|
|
1485
|
+
sizeTransform,
|
|
1486
|
+
builder,
|
|
1487
|
+
)
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* Construct a nested [NavGraph]
|
|
1492
|
+
*
|
|
1493
|
+
* @param route the destination's unique route from a KClass
|
|
1494
|
+
* @param startDestination the starting destination's route from an Object for this NavGraph
|
|
1495
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1496
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
1497
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1498
|
+
* @param enterTransition callback to define enter transitions for destination in this NavGraph
|
|
1499
|
+
* @param exitTransition callback to define exit transitions for destination in this NavGraph
|
|
1500
|
+
* @param popEnterTransition callback to define pop enter transitions for destination in this
|
|
1501
|
+
* NavGraph
|
|
1502
|
+
* @param popExitTransition callback to define pop exit transitions for destination in this NavGraph
|
|
1503
|
+
* @param sizeTransform callback to define the size transform for destinations in this NavGraph
|
|
1504
|
+
* @param builder the builder used to construct the graph
|
|
1505
|
+
* @return the newly constructed nested NavGraph
|
|
1506
|
+
*/
|
|
1507
|
+
public fun <T : Any> NavGraphBuilder.navigation(
|
|
1508
|
+
startDestination: Any,
|
|
1509
|
+
route: KClass<T>,
|
|
1510
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1511
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1512
|
+
enterTransition:
|
|
1513
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1514
|
+
EnterTransition?)? =
|
|
1515
|
+
null,
|
|
1516
|
+
exitTransition:
|
|
1517
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1518
|
+
ExitTransition?)? =
|
|
1519
|
+
null,
|
|
1520
|
+
popEnterTransition:
|
|
1521
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1522
|
+
EnterTransition?)? =
|
|
1523
|
+
enterTransition,
|
|
1524
|
+
popExitTransition:
|
|
1525
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1526
|
+
ExitTransition?)? =
|
|
1527
|
+
exitTransition,
|
|
1528
|
+
sizeTransform:
|
|
1529
|
+
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards
|
|
1530
|
+
SizeTransform?)? =
|
|
1531
|
+
null,
|
|
1532
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1533
|
+
) {
|
|
1534
|
+
addDestination(
|
|
1535
|
+
NavGraphBuilder(provider, startDestination, route, typeMap).apply(builder).build().apply {
|
|
1536
|
+
deepLinks.forEach { deepLink -> addDeepLink(deepLink) }
|
|
1537
|
+
if (this is ComposeNavGraphNavigator.ComposeNavGraph) {
|
|
1538
|
+
this.enterTransition = enterTransition
|
|
1539
|
+
this.exitTransition = exitTransition
|
|
1540
|
+
this.popEnterTransition = popEnterTransition
|
|
1541
|
+
this.popExitTransition = popExitTransition
|
|
1542
|
+
this.sizeTransform = sizeTransform
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
)
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* Add the [Composable] to the [NavGraphBuilder] that will be hosted within a
|
|
1550
|
+
* [androidx.compose.ui.window.Dialog]. This is suitable only when this dialog represents a separate
|
|
1551
|
+
* screen in your app that needs its own lifecycle and saved state, independent of any other
|
|
1552
|
+
* destination in your navigation graph. For use cases such as `AlertDialog`, you should use those
|
|
1553
|
+
* APIs directly in the [composable] destination that wants to show that dialog.
|
|
1554
|
+
*
|
|
1555
|
+
* @param route route for the destination
|
|
1556
|
+
* @param arguments list of arguments to associate with destination
|
|
1557
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1558
|
+
* @param dialogProperties properties that should be passed to [androidx.compose.ui.window.Dialog].
|
|
1559
|
+
* @param content composable content for the destination that will be hosted within the Dialog
|
|
1560
|
+
*/
|
|
1561
|
+
public fun NavGraphBuilder.dialog(
|
|
1562
|
+
route: String,
|
|
1563
|
+
arguments: List<NamedNavArgument> = emptyList(),
|
|
1564
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1565
|
+
dialogProperties: DialogProperties = DialogProperties(),
|
|
1566
|
+
content: @Composable (NavBackStackEntry) -> Unit,
|
|
1567
|
+
) {
|
|
1568
|
+
destination(
|
|
1569
|
+
DialogNavigatorDestinationBuilder(
|
|
1570
|
+
provider[DialogNavigator::class],
|
|
1571
|
+
route,
|
|
1572
|
+
dialogProperties,
|
|
1573
|
+
content,
|
|
1574
|
+
)
|
|
1575
|
+
.apply {
|
|
1576
|
+
arguments.forEach { (argumentName, argument) -> argument(argumentName, argument) }
|
|
1577
|
+
deepLinks.forEach { deepLink -> deepLink(deepLink) }
|
|
1578
|
+
}
|
|
1579
|
+
)
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* Add the [Composable] to the [NavGraphBuilder] that will be hosted within a
|
|
1584
|
+
* [androidx.compose.ui.window.Dialog]. This is suitable only when this dialog represents a separate
|
|
1585
|
+
* screen in your app that needs its own lifecycle and saved state, independent of any other
|
|
1586
|
+
* destination in your navigation graph. For use cases such as `AlertDialog`, you should use those
|
|
1587
|
+
* APIs directly in the [composable] destination that wants to show that dialog.
|
|
1588
|
+
*
|
|
1589
|
+
* @param T route from a KClass for the destination
|
|
1590
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1591
|
+
* [NavType]. May be empty if [T] does not use custom NavTypes.
|
|
1592
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1593
|
+
* @param dialogProperties properties that should be passed to [androidx.compose.ui.window.Dialog].
|
|
1594
|
+
* @param content composable content for the destination that will be hosted within the Dialog
|
|
1595
|
+
*/
|
|
1596
|
+
public inline fun <reified T : Any> NavGraphBuilder.dialog(
|
|
1597
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1598
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1599
|
+
dialogProperties: DialogProperties = DialogProperties(),
|
|
1600
|
+
noinline content: @Composable (NavBackStackEntry) -> Unit,
|
|
1601
|
+
) {
|
|
1602
|
+
dialog(T::class, typeMap, deepLinks, dialogProperties, content)
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Add the [Composable] to the [NavGraphBuilder] that will be hosted within a
|
|
1607
|
+
* [androidx.compose.ui.window.Dialog]. This is suitable only when this dialog represents a separate
|
|
1608
|
+
* screen in your app that needs its own lifecycle and saved state, independent of any other
|
|
1609
|
+
* destination in your navigation graph. For use cases such as `AlertDialog`, you should use those
|
|
1610
|
+
* APIs directly in the [composable] destination that wants to show that dialog.
|
|
1611
|
+
*
|
|
1612
|
+
* @param route route from [KClass] of [T] for the destination
|
|
1613
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1614
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
1615
|
+
* @param deepLinks list of deep links to associate with the destinations
|
|
1616
|
+
* @param dialogProperties properties that should be passed to [androidx.compose.ui.window.Dialog].
|
|
1617
|
+
* @param content composable content for the destination that will be hosted within the Dialog
|
|
1618
|
+
*/
|
|
1619
|
+
public fun <T : Any> NavGraphBuilder.dialog(
|
|
1620
|
+
route: KClass<T>,
|
|
1621
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1622
|
+
deepLinks: List<NavDeepLink> = emptyList(),
|
|
1623
|
+
dialogProperties: DialogProperties = DialogProperties(),
|
|
1624
|
+
content: @Composable (NavBackStackEntry) -> Unit,
|
|
1625
|
+
) {
|
|
1626
|
+
destination(
|
|
1627
|
+
DialogNavigatorDestinationBuilder(
|
|
1628
|
+
provider[DialogNavigator::class],
|
|
1629
|
+
route,
|
|
1630
|
+
typeMap,
|
|
1631
|
+
dialogProperties,
|
|
1632
|
+
content,
|
|
1633
|
+
)
|
|
1634
|
+
.apply { deepLinks.forEach { deepLink -> deepLink(deepLink) } }
|
|
1635
|
+
)
|
|
1636
|
+
}
|
|
1637
|
+
```
|
|
1638
|
+
|
|
1639
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/NavHost.kt
|
|
1640
|
+
```kotlin
|
|
1641
|
+
/*
|
|
1642
|
+
* Copyright 2020 The Android Open Source Project
|
|
1643
|
+
*
|
|
1644
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1645
|
+
* you may not use this file except in compliance with the License.
|
|
1646
|
+
* You may obtain a copy of the License at
|
|
1647
|
+
*
|
|
1648
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1649
|
+
*
|
|
1650
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1651
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1652
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1653
|
+
* See the License for the specific language governing permissions and
|
|
1654
|
+
* limitations under the License.
|
|
1655
|
+
*/
|
|
1656
|
+
|
|
1657
|
+
package androidx.navigation.compose
|
|
1658
|
+
|
|
1659
|
+
import androidx.collection.mutableObjectFloatMapOf
|
|
1660
|
+
import androidx.compose.animation.AnimatedContent
|
|
1661
|
+
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
1662
|
+
import androidx.compose.animation.ContentTransform
|
|
1663
|
+
import androidx.compose.animation.EnterTransition
|
|
1664
|
+
import androidx.compose.animation.ExitTransition
|
|
1665
|
+
import androidx.compose.animation.SizeTransform
|
|
1666
|
+
import androidx.compose.animation.core.SeekableTransitionState
|
|
1667
|
+
import androidx.compose.animation.core.animate
|
|
1668
|
+
import androidx.compose.animation.core.rememberTransition
|
|
1669
|
+
import androidx.compose.animation.core.tween
|
|
1670
|
+
import androidx.compose.animation.togetherWith
|
|
1671
|
+
import androidx.compose.runtime.Composable
|
|
1672
|
+
import androidx.compose.runtime.DisposableEffect
|
|
1673
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
1674
|
+
import androidx.compose.runtime.collectAsState
|
|
1675
|
+
import androidx.compose.runtime.derivedStateOf
|
|
1676
|
+
import androidx.compose.runtime.getValue
|
|
1677
|
+
import androidx.compose.runtime.mutableFloatStateOf
|
|
1678
|
+
import androidx.compose.runtime.mutableIntStateOf
|
|
1679
|
+
import androidx.compose.runtime.mutableStateOf
|
|
1680
|
+
import androidx.compose.runtime.remember
|
|
1681
|
+
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
|
|
1682
|
+
import androidx.compose.runtime.setValue
|
|
1683
|
+
import androidx.compose.ui.Alignment
|
|
1684
|
+
import androidx.compose.ui.Modifier
|
|
1685
|
+
import androidx.lifecycle.compose.LocalLifecycleOwner
|
|
1686
|
+
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
1687
|
+
import androidx.navigation.NavBackStackEntry
|
|
1688
|
+
import androidx.navigation.NavDestination
|
|
1689
|
+
import androidx.navigation.NavDestination.Companion.hierarchy
|
|
1690
|
+
import androidx.navigation.NavGraph
|
|
1691
|
+
import androidx.navigation.NavGraphBuilder
|
|
1692
|
+
import androidx.navigation.NavHostController
|
|
1693
|
+
import androidx.navigation.NavType
|
|
1694
|
+
import androidx.navigation.Navigator
|
|
1695
|
+
import androidx.navigation.compose.internal.DefaultNavTransitions
|
|
1696
|
+
import androidx.navigation.compose.internal.PredictiveBackHandler
|
|
1697
|
+
import androidx.navigation.createGraph
|
|
1698
|
+
import androidx.navigation.get
|
|
1699
|
+
import kotlin.coroutines.cancellation.CancellationException
|
|
1700
|
+
import kotlin.jvm.JvmSuppressWildcards
|
|
1701
|
+
import kotlin.reflect.KClass
|
|
1702
|
+
import kotlin.reflect.KType
|
|
1703
|
+
import kotlinx.coroutines.launch
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
1707
|
+
*
|
|
1708
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
1709
|
+
* the provided [navController].
|
|
1710
|
+
*
|
|
1711
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
1712
|
+
* contents of the builder cannot be changed.
|
|
1713
|
+
*
|
|
1714
|
+
* @sample androidx.navigation.compose.samples.NavScaffold
|
|
1715
|
+
* @param navController the navController for this host
|
|
1716
|
+
* @param startDestination the route for the start destination
|
|
1717
|
+
* @param modifier The modifier to be applied to the layout.
|
|
1718
|
+
* @param route the route for the graph
|
|
1719
|
+
* @param builder the builder used to construct the graph
|
|
1720
|
+
*/
|
|
1721
|
+
@Deprecated(
|
|
1722
|
+
message = "Deprecated in favor of NavHost that supports AnimatedContent",
|
|
1723
|
+
level = DeprecationLevel.HIDDEN,
|
|
1724
|
+
)
|
|
1725
|
+
@Composable
|
|
1726
|
+
public fun NavHost(
|
|
1727
|
+
navController: NavHostController,
|
|
1728
|
+
startDestination: String,
|
|
1729
|
+
modifier: Modifier = Modifier,
|
|
1730
|
+
route: String? = null,
|
|
1731
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1732
|
+
) {
|
|
1733
|
+
NavHost(
|
|
1734
|
+
navController,
|
|
1735
|
+
remember(route, startDestination, builder) {
|
|
1736
|
+
navController.createGraph(startDestination, route, builder)
|
|
1737
|
+
},
|
|
1738
|
+
modifier,
|
|
1739
|
+
)
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
/**
|
|
1743
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
1744
|
+
*
|
|
1745
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
1746
|
+
* the provided [navController].
|
|
1747
|
+
*
|
|
1748
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
1749
|
+
* contents of the builder cannot be changed.
|
|
1750
|
+
*
|
|
1751
|
+
* @param navController the navController for this host
|
|
1752
|
+
* @param startDestination the route for the start destination
|
|
1753
|
+
* @param modifier The modifier to be applied to the layout.
|
|
1754
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
1755
|
+
* @param route the route for the graph
|
|
1756
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
1757
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
1758
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
1759
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
1760
|
+
* @param builder the builder used to construct the graph
|
|
1761
|
+
*/
|
|
1762
|
+
@Deprecated(
|
|
1763
|
+
message = "Deprecated in favor of NavHost that supports sizeTransform",
|
|
1764
|
+
level = DeprecationLevel.HIDDEN,
|
|
1765
|
+
)
|
|
1766
|
+
@Composable
|
|
1767
|
+
public fun NavHost(
|
|
1768
|
+
navController: NavHostController,
|
|
1769
|
+
startDestination: String,
|
|
1770
|
+
modifier: Modifier = Modifier,
|
|
1771
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
1772
|
+
route: String? = null,
|
|
1773
|
+
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1774
|
+
DefaultNavTransitions.enterTransition,
|
|
1775
|
+
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1776
|
+
DefaultNavTransitions.exitTransition,
|
|
1777
|
+
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1778
|
+
enterTransition,
|
|
1779
|
+
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1780
|
+
exitTransition,
|
|
1781
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1782
|
+
) {
|
|
1783
|
+
NavHost(
|
|
1784
|
+
navController,
|
|
1785
|
+
remember(route, startDestination, builder) {
|
|
1786
|
+
navController.createGraph(startDestination, route, builder)
|
|
1787
|
+
},
|
|
1788
|
+
modifier,
|
|
1789
|
+
contentAlignment,
|
|
1790
|
+
enterTransition,
|
|
1791
|
+
exitTransition,
|
|
1792
|
+
popEnterTransition,
|
|
1793
|
+
popExitTransition,
|
|
1794
|
+
)
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
1799
|
+
*
|
|
1800
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
1801
|
+
* the provided [navController].
|
|
1802
|
+
*
|
|
1803
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
1804
|
+
* contents of the builder cannot be changed.
|
|
1805
|
+
*
|
|
1806
|
+
* @param navController the navController for this host
|
|
1807
|
+
* @param startDestination the route for the start destination
|
|
1808
|
+
* @param modifier The modifier to be applied to the layout.
|
|
1809
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
1810
|
+
* @param route the route for the graph
|
|
1811
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
1812
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
1813
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
1814
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
1815
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
1816
|
+
* @param builder the builder used to construct the graph
|
|
1817
|
+
*/
|
|
1818
|
+
@Deprecated(
|
|
1819
|
+
message =
|
|
1820
|
+
"Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition",
|
|
1821
|
+
level = DeprecationLevel.HIDDEN,
|
|
1822
|
+
)
|
|
1823
|
+
@Composable
|
|
1824
|
+
public fun NavHost(
|
|
1825
|
+
navController: NavHostController,
|
|
1826
|
+
startDestination: String,
|
|
1827
|
+
modifier: Modifier = Modifier,
|
|
1828
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
1829
|
+
route: String? = null,
|
|
1830
|
+
enterTransition:
|
|
1831
|
+
(@JvmSuppressWildcards
|
|
1832
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1833
|
+
DefaultNavTransitions.enterTransition,
|
|
1834
|
+
exitTransition:
|
|
1835
|
+
(@JvmSuppressWildcards
|
|
1836
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1837
|
+
DefaultNavTransitions.exitTransition,
|
|
1838
|
+
popEnterTransition:
|
|
1839
|
+
(@JvmSuppressWildcards
|
|
1840
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1841
|
+
enterTransition,
|
|
1842
|
+
popExitTransition:
|
|
1843
|
+
(@JvmSuppressWildcards
|
|
1844
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1845
|
+
exitTransition,
|
|
1846
|
+
sizeTransform:
|
|
1847
|
+
(@JvmSuppressWildcards
|
|
1848
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
1849
|
+
DefaultNavTransitions.sizeTransform,
|
|
1850
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1851
|
+
) {
|
|
1852
|
+
NavHost(
|
|
1853
|
+
navController,
|
|
1854
|
+
startDestination,
|
|
1855
|
+
modifier,
|
|
1856
|
+
contentAlignment,
|
|
1857
|
+
route,
|
|
1858
|
+
enterTransition,
|
|
1859
|
+
exitTransition,
|
|
1860
|
+
popEnterTransition,
|
|
1861
|
+
popExitTransition,
|
|
1862
|
+
sizeTransform = sizeTransform,
|
|
1863
|
+
builder = builder,
|
|
1864
|
+
)
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
1869
|
+
*
|
|
1870
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
1871
|
+
* the provided [navController].
|
|
1872
|
+
*
|
|
1873
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
1874
|
+
* contents of the builder cannot be changed.
|
|
1875
|
+
*
|
|
1876
|
+
* @param navController the navController for this host
|
|
1877
|
+
* @param startDestination the route for the start destination
|
|
1878
|
+
* @param modifier The modifier to be applied to the layout.
|
|
1879
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
1880
|
+
* @param route the route for the graph
|
|
1881
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
1882
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
1883
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
1884
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
1885
|
+
* @param predictivePopEnterTransition callback to define predictivePopEnter transitions for
|
|
1886
|
+
* destination in this host
|
|
1887
|
+
* @param predictivePopExitTransition callback to define predictivePopExit transitions for
|
|
1888
|
+
* destination in this host
|
|
1889
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
1890
|
+
* @param builder the builder used to construct the graph
|
|
1891
|
+
*/
|
|
1892
|
+
@Composable
|
|
1893
|
+
public fun NavHost(
|
|
1894
|
+
navController: NavHostController,
|
|
1895
|
+
startDestination: String,
|
|
1896
|
+
modifier: Modifier = Modifier,
|
|
1897
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
1898
|
+
route: String? = null,
|
|
1899
|
+
enterTransition:
|
|
1900
|
+
(@JvmSuppressWildcards
|
|
1901
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1902
|
+
DefaultNavTransitions.enterTransition,
|
|
1903
|
+
exitTransition:
|
|
1904
|
+
(@JvmSuppressWildcards
|
|
1905
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1906
|
+
DefaultNavTransitions.exitTransition,
|
|
1907
|
+
popEnterTransition:
|
|
1908
|
+
(@JvmSuppressWildcards
|
|
1909
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1910
|
+
enterTransition,
|
|
1911
|
+
popExitTransition:
|
|
1912
|
+
(@JvmSuppressWildcards
|
|
1913
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1914
|
+
exitTransition,
|
|
1915
|
+
predictivePopEnterTransition:
|
|
1916
|
+
(@JvmSuppressWildcards
|
|
1917
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
|
|
1918
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
1919
|
+
predictivePopExitTransition:
|
|
1920
|
+
(@JvmSuppressWildcards
|
|
1921
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
|
|
1922
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
1923
|
+
sizeTransform:
|
|
1924
|
+
(@JvmSuppressWildcards
|
|
1925
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
1926
|
+
DefaultNavTransitions.sizeTransform,
|
|
1927
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
1928
|
+
) {
|
|
1929
|
+
NavHost(
|
|
1930
|
+
navController,
|
|
1931
|
+
remember(route, startDestination, builder) {
|
|
1932
|
+
navController.createGraph(startDestination, route, builder)
|
|
1933
|
+
},
|
|
1934
|
+
modifier,
|
|
1935
|
+
contentAlignment,
|
|
1936
|
+
enterTransition,
|
|
1937
|
+
exitTransition,
|
|
1938
|
+
popEnterTransition,
|
|
1939
|
+
popExitTransition,
|
|
1940
|
+
predictivePopEnterTransition,
|
|
1941
|
+
predictivePopExitTransition,
|
|
1942
|
+
sizeTransform,
|
|
1943
|
+
)
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
1948
|
+
*
|
|
1949
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
1950
|
+
* the provided [navController].
|
|
1951
|
+
*
|
|
1952
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
1953
|
+
* contents of the builder cannot be changed.
|
|
1954
|
+
*
|
|
1955
|
+
* @param navController the navController for this host
|
|
1956
|
+
* @param startDestination the route from a [KClass] for the start destination
|
|
1957
|
+
* @param modifier The modifier to be applied to the layout.
|
|
1958
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
1959
|
+
* @param route the route from a [KClass] for the graph
|
|
1960
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
1961
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
1962
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
1963
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
1964
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
1965
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
1966
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
1967
|
+
* @param builder the builder used to construct the graph
|
|
1968
|
+
*/
|
|
1969
|
+
@Deprecated(
|
|
1970
|
+
message =
|
|
1971
|
+
"Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition",
|
|
1972
|
+
level = DeprecationLevel.HIDDEN,
|
|
1973
|
+
)
|
|
1974
|
+
@Composable
|
|
1975
|
+
public fun NavHost(
|
|
1976
|
+
navController: NavHostController,
|
|
1977
|
+
startDestination: KClass<*>,
|
|
1978
|
+
modifier: Modifier = Modifier,
|
|
1979
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
1980
|
+
route: KClass<*>? = null,
|
|
1981
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
1982
|
+
enterTransition:
|
|
1983
|
+
(@JvmSuppressWildcards
|
|
1984
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1985
|
+
DefaultNavTransitions.enterTransition,
|
|
1986
|
+
exitTransition:
|
|
1987
|
+
(@JvmSuppressWildcards
|
|
1988
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1989
|
+
DefaultNavTransitions.exitTransition,
|
|
1990
|
+
popEnterTransition:
|
|
1991
|
+
(@JvmSuppressWildcards
|
|
1992
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
1993
|
+
enterTransition,
|
|
1994
|
+
popExitTransition:
|
|
1995
|
+
(@JvmSuppressWildcards
|
|
1996
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
1997
|
+
exitTransition,
|
|
1998
|
+
sizeTransform:
|
|
1999
|
+
(@JvmSuppressWildcards
|
|
2000
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2001
|
+
DefaultNavTransitions.sizeTransform,
|
|
2002
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
2003
|
+
) {
|
|
2004
|
+
NavHost(
|
|
2005
|
+
navController,
|
|
2006
|
+
startDestination,
|
|
2007
|
+
modifier,
|
|
2008
|
+
contentAlignment,
|
|
2009
|
+
route,
|
|
2010
|
+
typeMap,
|
|
2011
|
+
enterTransition,
|
|
2012
|
+
exitTransition,
|
|
2013
|
+
popEnterTransition,
|
|
2014
|
+
popExitTransition,
|
|
2015
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
2016
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
2017
|
+
sizeTransform,
|
|
2018
|
+
builder,
|
|
2019
|
+
)
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
2024
|
+
*
|
|
2025
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2026
|
+
* the provided [navController].
|
|
2027
|
+
*
|
|
2028
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
2029
|
+
* contents of the builder cannot be changed.
|
|
2030
|
+
*
|
|
2031
|
+
* @param navController the navController for this host
|
|
2032
|
+
* @param startDestination the route from a [KClass] for the start destination
|
|
2033
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2034
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
2035
|
+
* @param route the route from a [KClass] for the graph
|
|
2036
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
2037
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
2038
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
2039
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
2040
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
2041
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
2042
|
+
* @param predictivePopEnterTransition callback to define predictivePopEnter transitions for
|
|
2043
|
+
* destination in this host
|
|
2044
|
+
* @param predictivePopExitTransition callback to define predictivePopExit transitions for
|
|
2045
|
+
* destination in this host
|
|
2046
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
2047
|
+
* @param builder the builder used to construct the graph
|
|
2048
|
+
*/
|
|
2049
|
+
@Composable
|
|
2050
|
+
public fun NavHost(
|
|
2051
|
+
navController: NavHostController,
|
|
2052
|
+
startDestination: KClass<*>,
|
|
2053
|
+
modifier: Modifier = Modifier,
|
|
2054
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
2055
|
+
route: KClass<*>? = null,
|
|
2056
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
2057
|
+
enterTransition:
|
|
2058
|
+
(@JvmSuppressWildcards
|
|
2059
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2060
|
+
DefaultNavTransitions.enterTransition,
|
|
2061
|
+
exitTransition:
|
|
2062
|
+
(@JvmSuppressWildcards
|
|
2063
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2064
|
+
DefaultNavTransitions.exitTransition,
|
|
2065
|
+
popEnterTransition:
|
|
2066
|
+
(@JvmSuppressWildcards
|
|
2067
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2068
|
+
enterTransition,
|
|
2069
|
+
popExitTransition:
|
|
2070
|
+
(@JvmSuppressWildcards
|
|
2071
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2072
|
+
exitTransition,
|
|
2073
|
+
predictivePopEnterTransition:
|
|
2074
|
+
(@JvmSuppressWildcards
|
|
2075
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
|
|
2076
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
2077
|
+
predictivePopExitTransition:
|
|
2078
|
+
(@JvmSuppressWildcards
|
|
2079
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
|
|
2080
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
2081
|
+
sizeTransform:
|
|
2082
|
+
(@JvmSuppressWildcards
|
|
2083
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2084
|
+
DefaultNavTransitions.sizeTransform,
|
|
2085
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
2086
|
+
) {
|
|
2087
|
+
NavHost(
|
|
2088
|
+
navController,
|
|
2089
|
+
remember(route, startDestination, builder) {
|
|
2090
|
+
navController.createGraph(startDestination, route, typeMap, builder)
|
|
2091
|
+
},
|
|
2092
|
+
modifier,
|
|
2093
|
+
contentAlignment,
|
|
2094
|
+
enterTransition,
|
|
2095
|
+
exitTransition,
|
|
2096
|
+
popEnterTransition,
|
|
2097
|
+
popExitTransition,
|
|
2098
|
+
predictivePopEnterTransition,
|
|
2099
|
+
predictivePopExitTransition,
|
|
2100
|
+
sizeTransform,
|
|
2101
|
+
)
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
/**
|
|
2105
|
+
* Provides in place in the Compose hierarchy for self contained navigation to occur.
|
|
2106
|
+
*
|
|
2107
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2108
|
+
* the provided [navController].
|
|
2109
|
+
*
|
|
2110
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
2111
|
+
* contents of the builder cannot be changed.
|
|
2112
|
+
*
|
|
2113
|
+
* @param navController the navController for this host
|
|
2114
|
+
* @param startDestination the route from a an Object for the start destination
|
|
2115
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2116
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
2117
|
+
* @param route the route from a [KClass] for the graph
|
|
2118
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
2119
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
2120
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
2121
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
2122
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
2123
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
2124
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
2125
|
+
* @param builder the builder used to construct the graph
|
|
2126
|
+
*/
|
|
2127
|
+
@Deprecated(
|
|
2128
|
+
message =
|
|
2129
|
+
"Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition",
|
|
2130
|
+
level = DeprecationLevel.HIDDEN,
|
|
2131
|
+
)
|
|
2132
|
+
@Composable
|
|
2133
|
+
public fun NavHost(
|
|
2134
|
+
navController: NavHostController,
|
|
2135
|
+
startDestination: Any,
|
|
2136
|
+
modifier: Modifier = Modifier,
|
|
2137
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
2138
|
+
route: KClass<*>? = null,
|
|
2139
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
2140
|
+
enterTransition:
|
|
2141
|
+
(@JvmSuppressWildcards
|
|
2142
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2143
|
+
DefaultNavTransitions.enterTransition,
|
|
2144
|
+
exitTransition:
|
|
2145
|
+
(@JvmSuppressWildcards
|
|
2146
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2147
|
+
DefaultNavTransitions.exitTransition,
|
|
2148
|
+
popEnterTransition:
|
|
2149
|
+
(@JvmSuppressWildcards
|
|
2150
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2151
|
+
enterTransition,
|
|
2152
|
+
popExitTransition:
|
|
2153
|
+
(@JvmSuppressWildcards
|
|
2154
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2155
|
+
exitTransition,
|
|
2156
|
+
sizeTransform:
|
|
2157
|
+
(@JvmSuppressWildcards
|
|
2158
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2159
|
+
DefaultNavTransitions.sizeTransform,
|
|
2160
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
2161
|
+
) {
|
|
2162
|
+
NavHost(
|
|
2163
|
+
navController,
|
|
2164
|
+
startDestination,
|
|
2165
|
+
modifier,
|
|
2166
|
+
contentAlignment,
|
|
2167
|
+
route,
|
|
2168
|
+
typeMap,
|
|
2169
|
+
enterTransition,
|
|
2170
|
+
exitTransition,
|
|
2171
|
+
popEnterTransition,
|
|
2172
|
+
popExitTransition,
|
|
2173
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
2174
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
2175
|
+
sizeTransform,
|
|
2176
|
+
builder,
|
|
2177
|
+
)
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* Provides in place in the Compose hierarchy for self contained navigation to occur.
|
|
2182
|
+
*
|
|
2183
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2184
|
+
* the provided [navController].
|
|
2185
|
+
*
|
|
2186
|
+
* The builder passed into this method is [remember]ed. This means that for this NavHost, the
|
|
2187
|
+
* contents of the builder cannot be changed.
|
|
2188
|
+
*
|
|
2189
|
+
* @param navController the navController for this host
|
|
2190
|
+
* @param startDestination the route from a an Object for the start destination
|
|
2191
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2192
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
2193
|
+
* @param route the route from a [KClass] for the graph
|
|
2194
|
+
* @param typeMap map of destination arguments' kotlin type [KType] to its respective custom
|
|
2195
|
+
* [NavType]. May be empty if [route] does not use custom NavTypes.
|
|
2196
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
2197
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
2198
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
2199
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
2200
|
+
* @param predictivePopEnterTransition callback to define predictivePopEnter transitions for
|
|
2201
|
+
* destination in this host
|
|
2202
|
+
* @param predictivePopExitTransition callback to define predictivePopExit transitions for
|
|
2203
|
+
* destination in this host
|
|
2204
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
2205
|
+
* @param builder the builder used to construct the graph
|
|
2206
|
+
*/
|
|
2207
|
+
@Composable
|
|
2208
|
+
public fun NavHost(
|
|
2209
|
+
navController: NavHostController,
|
|
2210
|
+
startDestination: Any,
|
|
2211
|
+
modifier: Modifier = Modifier,
|
|
2212
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
2213
|
+
route: KClass<*>? = null,
|
|
2214
|
+
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
|
|
2215
|
+
enterTransition:
|
|
2216
|
+
(@JvmSuppressWildcards
|
|
2217
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2218
|
+
DefaultNavTransitions.enterTransition,
|
|
2219
|
+
exitTransition:
|
|
2220
|
+
(@JvmSuppressWildcards
|
|
2221
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2222
|
+
DefaultNavTransitions.exitTransition,
|
|
2223
|
+
popEnterTransition:
|
|
2224
|
+
(@JvmSuppressWildcards
|
|
2225
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2226
|
+
enterTransition,
|
|
2227
|
+
popExitTransition:
|
|
2228
|
+
(@JvmSuppressWildcards
|
|
2229
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2230
|
+
exitTransition,
|
|
2231
|
+
predictivePopEnterTransition:
|
|
2232
|
+
(@JvmSuppressWildcards
|
|
2233
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
|
|
2234
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
2235
|
+
predictivePopExitTransition:
|
|
2236
|
+
(@JvmSuppressWildcards
|
|
2237
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
|
|
2238
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
2239
|
+
sizeTransform:
|
|
2240
|
+
(@JvmSuppressWildcards
|
|
2241
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2242
|
+
DefaultNavTransitions.sizeTransform,
|
|
2243
|
+
builder: NavGraphBuilder.() -> Unit,
|
|
2244
|
+
) {
|
|
2245
|
+
NavHost(
|
|
2246
|
+
navController,
|
|
2247
|
+
remember(route, startDestination, builder) {
|
|
2248
|
+
navController.createGraph(startDestination, route, typeMap, builder)
|
|
2249
|
+
},
|
|
2250
|
+
modifier,
|
|
2251
|
+
contentAlignment,
|
|
2252
|
+
enterTransition,
|
|
2253
|
+
exitTransition,
|
|
2254
|
+
popEnterTransition,
|
|
2255
|
+
popExitTransition,
|
|
2256
|
+
predictivePopEnterTransition,
|
|
2257
|
+
predictivePopExitTransition,
|
|
2258
|
+
sizeTransform,
|
|
2259
|
+
)
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
/**
|
|
2263
|
+
* Provides in place in the Compose hierarchy for self contained navigation to occur.
|
|
2264
|
+
*
|
|
2265
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2266
|
+
* the provided [navController].
|
|
2267
|
+
*
|
|
2268
|
+
* The graph passed into this method is [remember]ed. This means that for this NavHost, the graph
|
|
2269
|
+
* cannot be changed.
|
|
2270
|
+
*
|
|
2271
|
+
* @param navController the navController for this host
|
|
2272
|
+
* @param graph the graph for this host
|
|
2273
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2274
|
+
*/
|
|
2275
|
+
@Deprecated(
|
|
2276
|
+
message = "Deprecated in favor of NavHost that supports AnimatedContent",
|
|
2277
|
+
level = DeprecationLevel.HIDDEN,
|
|
2278
|
+
)
|
|
2279
|
+
@Composable
|
|
2280
|
+
public fun NavHost(
|
|
2281
|
+
navController: NavHostController,
|
|
2282
|
+
graph: NavGraph,
|
|
2283
|
+
modifier: Modifier = Modifier,
|
|
2284
|
+
): Unit = NavHost(navController, graph, modifier)
|
|
2285
|
+
|
|
2286
|
+
/**
|
|
2287
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
2288
|
+
*
|
|
2289
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2290
|
+
* the provided [navController].
|
|
2291
|
+
*
|
|
2292
|
+
* @param navController the navController for this host
|
|
2293
|
+
* @param graph the graph for this host
|
|
2294
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2295
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
2296
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
2297
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
2298
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
2299
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
2300
|
+
*/
|
|
2301
|
+
@Deprecated(
|
|
2302
|
+
message = "Deprecated in favor of NavHost that supports sizeTransform",
|
|
2303
|
+
level = DeprecationLevel.HIDDEN,
|
|
2304
|
+
)
|
|
2305
|
+
@Composable
|
|
2306
|
+
public fun NavHost(
|
|
2307
|
+
navController: NavHostController,
|
|
2308
|
+
graph: NavGraph,
|
|
2309
|
+
modifier: Modifier = Modifier,
|
|
2310
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
2311
|
+
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2312
|
+
DefaultNavTransitions.enterTransition,
|
|
2313
|
+
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2314
|
+
DefaultNavTransitions.exitTransition,
|
|
2315
|
+
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2316
|
+
enterTransition,
|
|
2317
|
+
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2318
|
+
exitTransition,
|
|
2319
|
+
) {
|
|
2320
|
+
NavHost(
|
|
2321
|
+
navController,
|
|
2322
|
+
graph,
|
|
2323
|
+
modifier,
|
|
2324
|
+
contentAlignment,
|
|
2325
|
+
enterTransition,
|
|
2326
|
+
exitTransition,
|
|
2327
|
+
popEnterTransition,
|
|
2328
|
+
popExitTransition,
|
|
2329
|
+
sizeTransform = null, // sizeTransform
|
|
2330
|
+
)
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
/**
|
|
2334
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
2335
|
+
*
|
|
2336
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2337
|
+
* the provided [navController].
|
|
2338
|
+
*
|
|
2339
|
+
* @param navController the navController for this host
|
|
2340
|
+
* @param graph the graph for this host
|
|
2341
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2342
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
2343
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
2344
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
2345
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
2346
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
2347
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
2348
|
+
*/
|
|
2349
|
+
@Deprecated(
|
|
2350
|
+
message =
|
|
2351
|
+
"Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition",
|
|
2352
|
+
level = DeprecationLevel.HIDDEN,
|
|
2353
|
+
)
|
|
2354
|
+
@Composable
|
|
2355
|
+
public fun NavHost(
|
|
2356
|
+
navController: NavHostController,
|
|
2357
|
+
graph: NavGraph,
|
|
2358
|
+
modifier: Modifier = Modifier,
|
|
2359
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
2360
|
+
enterTransition:
|
|
2361
|
+
(@JvmSuppressWildcards
|
|
2362
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2363
|
+
DefaultNavTransitions.enterTransition,
|
|
2364
|
+
exitTransition:
|
|
2365
|
+
(@JvmSuppressWildcards
|
|
2366
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2367
|
+
DefaultNavTransitions.exitTransition,
|
|
2368
|
+
popEnterTransition:
|
|
2369
|
+
(@JvmSuppressWildcards
|
|
2370
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2371
|
+
enterTransition,
|
|
2372
|
+
popExitTransition:
|
|
2373
|
+
(@JvmSuppressWildcards
|
|
2374
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2375
|
+
exitTransition,
|
|
2376
|
+
sizeTransform:
|
|
2377
|
+
(@JvmSuppressWildcards
|
|
2378
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2379
|
+
DefaultNavTransitions.sizeTransform,
|
|
2380
|
+
) {
|
|
2381
|
+
NavHost(
|
|
2382
|
+
navController,
|
|
2383
|
+
graph,
|
|
2384
|
+
modifier,
|
|
2385
|
+
contentAlignment,
|
|
2386
|
+
enterTransition,
|
|
2387
|
+
exitTransition,
|
|
2388
|
+
popEnterTransition,
|
|
2389
|
+
popExitTransition,
|
|
2390
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
2391
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
2392
|
+
sizeTransform,
|
|
2393
|
+
)
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
/**
|
|
2397
|
+
* Provides a place in the Compose hierarchy for self contained navigation to occur.
|
|
2398
|
+
*
|
|
2399
|
+
* Once this is called, any Composable within the given [NavGraphBuilder] can be navigated to from
|
|
2400
|
+
* the provided [navController].
|
|
2401
|
+
*
|
|
2402
|
+
* @param navController the navController for this host
|
|
2403
|
+
* @param graph the graph for this host
|
|
2404
|
+
* @param modifier The modifier to be applied to the layout.
|
|
2405
|
+
* @param contentAlignment The [Alignment] of the [AnimatedContent]
|
|
2406
|
+
* @param enterTransition callback to define enter transitions for destination in this host
|
|
2407
|
+
* @param exitTransition callback to define exit transitions for destination in this host
|
|
2408
|
+
* @param popEnterTransition callback to define popEnter transitions for destination in this host
|
|
2409
|
+
* @param popExitTransition callback to define popExit transitions for destination in this host
|
|
2410
|
+
* @param predictivePopEnterTransition callback to define predictivePopEnter transitions for
|
|
2411
|
+
* destination in this host
|
|
2412
|
+
* @param predictivePopExitTransition callback to define predictivePopExit transitions for
|
|
2413
|
+
* destination in this host
|
|
2414
|
+
* @param sizeTransform callback to define the size transform for destinations in this host
|
|
2415
|
+
*/
|
|
2416
|
+
@Composable
|
|
2417
|
+
public fun NavHost(
|
|
2418
|
+
navController: NavHostController,
|
|
2419
|
+
graph: NavGraph,
|
|
2420
|
+
modifier: Modifier = Modifier,
|
|
2421
|
+
contentAlignment: Alignment = Alignment.TopStart,
|
|
2422
|
+
enterTransition:
|
|
2423
|
+
(@JvmSuppressWildcards
|
|
2424
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2425
|
+
DefaultNavTransitions.enterTransition,
|
|
2426
|
+
exitTransition:
|
|
2427
|
+
(@JvmSuppressWildcards
|
|
2428
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2429
|
+
DefaultNavTransitions.exitTransition,
|
|
2430
|
+
popEnterTransition:
|
|
2431
|
+
(@JvmSuppressWildcards
|
|
2432
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
|
|
2433
|
+
enterTransition,
|
|
2434
|
+
popExitTransition:
|
|
2435
|
+
(@JvmSuppressWildcards
|
|
2436
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
|
|
2437
|
+
exitTransition,
|
|
2438
|
+
predictivePopEnterTransition:
|
|
2439
|
+
(@JvmSuppressWildcards
|
|
2440
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
|
|
2441
|
+
DefaultNavTransitions.predictivePopEnterTransition,
|
|
2442
|
+
predictivePopExitTransition:
|
|
2443
|
+
(@JvmSuppressWildcards
|
|
2444
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
|
|
2445
|
+
DefaultNavTransitions.predictivePopExitTransition,
|
|
2446
|
+
sizeTransform:
|
|
2447
|
+
(@JvmSuppressWildcards
|
|
2448
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2449
|
+
DefaultNavTransitions.sizeTransform,
|
|
2450
|
+
) {
|
|
2451
|
+
|
|
2452
|
+
val lifecycleOwner = LocalLifecycleOwner.current
|
|
2453
|
+
val viewModelStoreOwner =
|
|
2454
|
+
checkNotNull(LocalViewModelStoreOwner.current) {
|
|
2455
|
+
"NavHost requires a ViewModelStoreOwner to be provided via LocalViewModelStoreOwner"
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
navController.setViewModelStore(viewModelStoreOwner.viewModelStore)
|
|
2459
|
+
|
|
2460
|
+
// Then set the graph
|
|
2461
|
+
navController.graph = graph
|
|
2462
|
+
|
|
2463
|
+
// Find the ComposeNavigator, returning early if it isn't found
|
|
2464
|
+
// (such as is the case when using TestNavHostController)
|
|
2465
|
+
val composeNavigator =
|
|
2466
|
+
navController.navigatorProvider.get<Navigator<out NavDestination>>(ComposeNavigator.NAME)
|
|
2467
|
+
as? ComposeNavigator ?: return
|
|
2468
|
+
|
|
2469
|
+
val currentBackStack by composeNavigator.backStack.collectAsState()
|
|
2470
|
+
|
|
2471
|
+
var progress by remember { mutableFloatStateOf(0f) }
|
|
2472
|
+
var inPredictiveBack by remember { mutableStateOf(false) }
|
|
2473
|
+
var swipeEdge by remember { mutableIntStateOf(0) }
|
|
2474
|
+
PredictiveBackHandler(currentBackStack.size > 1) { backEvent ->
|
|
2475
|
+
// This block handles the three phases of a predictive back gesture:
|
|
2476
|
+
// 1. OnStarted: When the gesture begins.
|
|
2477
|
+
// 2. OnProgressed: As the user drags their finger.
|
|
2478
|
+
// 3. OnCompleted or OnCancelled: When the gesture finishes or is cancelled.
|
|
2479
|
+
//
|
|
2480
|
+
// Always guard with `currentBackStack.size > 1`:
|
|
2481
|
+
// If `enabled` becomes stale (set false mid-frame while a gesture is in-flight),
|
|
2482
|
+
// these checks prevent IndexOutOfBounds when accessing the stack.
|
|
2483
|
+
|
|
2484
|
+
var currentBackStackEntry: NavBackStackEntry? = null
|
|
2485
|
+
|
|
2486
|
+
// --- OnStarted ---
|
|
2487
|
+
if (currentBackStack.size > 1) {
|
|
2488
|
+
progress = 0f
|
|
2489
|
+
currentBackStackEntry = currentBackStack.lastOrNull()
|
|
2490
|
+
composeNavigator.prepareForTransition(currentBackStackEntry!!)
|
|
2491
|
+
val previousEntry = currentBackStack[currentBackStack.size - 2]
|
|
2492
|
+
composeNavigator.prepareForTransition(previousEntry)
|
|
2493
|
+
}
|
|
2494
|
+
try {
|
|
2495
|
+
backEvent.collect {
|
|
2496
|
+
// --- OnProgressed ---
|
|
2497
|
+
if (currentBackStack.size > 1) {
|
|
2498
|
+
inPredictiveBack = true
|
|
2499
|
+
progress = it.progress
|
|
2500
|
+
swipeEdge = it.swipeEdge
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
// --- OnCompleted ---
|
|
2504
|
+
if (currentBackStack.size > 1) {
|
|
2505
|
+
inPredictiveBack = false
|
|
2506
|
+
composeNavigator.popBackStack(currentBackStackEntry!!, false)
|
|
2507
|
+
}
|
|
2508
|
+
} catch (_: CancellationException) {
|
|
2509
|
+
// --- OnCancelled ---
|
|
2510
|
+
if (currentBackStack.size > 1) {
|
|
2511
|
+
inPredictiveBack = false
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
DisposableEffect(lifecycleOwner) {
|
|
2517
|
+
// Setup the navController with proper owners
|
|
2518
|
+
navController.setLifecycleOwner(lifecycleOwner)
|
|
2519
|
+
onDispose {}
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
val saveableStateHolder = rememberSaveableStateHolder()
|
|
2523
|
+
|
|
2524
|
+
val allVisibleEntries by navController.visibleEntries.collectAsState()
|
|
2525
|
+
|
|
2526
|
+
// Intercept back only when there's a destination to pop
|
|
2527
|
+
val visibleEntries by remember {
|
|
2528
|
+
derivedStateOf {
|
|
2529
|
+
allVisibleEntries.filter { entry ->
|
|
2530
|
+
entry.destination.navigatorName == ComposeNavigator.NAME
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
val backStackEntry: NavBackStackEntry? = visibleEntries.lastOrNull()
|
|
2536
|
+
|
|
2537
|
+
val zIndices = remember { mutableObjectFloatMapOf<String>() }
|
|
2538
|
+
|
|
2539
|
+
if (backStackEntry != null) {
|
|
2540
|
+
val finalEnter: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = {
|
|
2541
|
+
val targetDestination = targetState.destination as ComposeNavigator.Destination
|
|
2542
|
+
|
|
2543
|
+
if (inPredictiveBack) {
|
|
2544
|
+
targetDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2545
|
+
destination.createPredictivePopEnterTransition(this, swipeEdge)
|
|
2546
|
+
} ?: predictivePopEnterTransition.invoke(this, swipeEdge)
|
|
2547
|
+
} else if (composeNavigator.isPop.value) {
|
|
2548
|
+
targetDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2549
|
+
destination.createPopEnterTransition(this)
|
|
2550
|
+
} ?: popEnterTransition.invoke(this)
|
|
2551
|
+
} else {
|
|
2552
|
+
targetDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2553
|
+
destination.createEnterTransition(this)
|
|
2554
|
+
} ?: enterTransition.invoke(this)
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
val finalExit: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition = {
|
|
2559
|
+
val initialDestination = initialState.destination as ComposeNavigator.Destination
|
|
2560
|
+
|
|
2561
|
+
if (inPredictiveBack) {
|
|
2562
|
+
initialDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2563
|
+
destination.createPredictivePopExitTransition(this, swipeEdge)
|
|
2564
|
+
} ?: predictivePopExitTransition.invoke(this, swipeEdge)
|
|
2565
|
+
} else if (composeNavigator.isPop.value) {
|
|
2566
|
+
initialDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2567
|
+
destination.createPopExitTransition(this)
|
|
2568
|
+
} ?: popExitTransition.invoke(this)
|
|
2569
|
+
} else {
|
|
2570
|
+
initialDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2571
|
+
destination.createExitTransition(this)
|
|
2572
|
+
} ?: exitTransition.invoke(this)
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
val finalSizeTransform:
|
|
2577
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform? =
|
|
2578
|
+
{
|
|
2579
|
+
val targetDestination = targetState.destination as ComposeNavigator.Destination
|
|
2580
|
+
|
|
2581
|
+
targetDestination.hierarchy.firstNotNullOfOrNull { destination ->
|
|
2582
|
+
destination.createSizeTransform(this)
|
|
2583
|
+
} ?: sizeTransform?.invoke(this)
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
DisposableEffect(true) {
|
|
2587
|
+
onDispose {
|
|
2588
|
+
visibleEntries.forEach { entry -> composeNavigator.onTransitionComplete(entry) }
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
val transitionState = remember {
|
|
2593
|
+
// The state returned here cannot be nullable cause it produces the input of the
|
|
2594
|
+
// transitionSpec passed into the AnimatedContent and that must match the non-nullable
|
|
2595
|
+
// scope exposed by the transitions on the NavHost and composable APIs.
|
|
2596
|
+
SeekableTransitionState(backStackEntry)
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
val transition = rememberTransition(transitionState, label = "entry")
|
|
2600
|
+
|
|
2601
|
+
if (inPredictiveBack) {
|
|
2602
|
+
LaunchedEffect(progress) {
|
|
2603
|
+
// Update transition progress safely (same guard against stale enabled state).
|
|
2604
|
+
if (currentBackStack.size > 1) {
|
|
2605
|
+
val previousEntry = currentBackStack[currentBackStack.size - 2]
|
|
2606
|
+
transitionState.seekTo(progress, previousEntry)
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
} else {
|
|
2610
|
+
LaunchedEffect(backStackEntry) {
|
|
2611
|
+
// This ensures we don't animate after the back gesture is cancelled and we
|
|
2612
|
+
// are already on the current state
|
|
2613
|
+
if (transitionState.currentState != backStackEntry) {
|
|
2614
|
+
transitionState.animateTo(backStackEntry)
|
|
2615
|
+
} else {
|
|
2616
|
+
// convert from nanoseconds to milliseconds
|
|
2617
|
+
val totalDuration = transition.totalDurationNanos / 1000000
|
|
2618
|
+
// When the predictive back gesture is cancel, we need to manually animate
|
|
2619
|
+
// the SeekableTransitionState from where it left off, to zero and then
|
|
2620
|
+
// snapTo the final position.
|
|
2621
|
+
animate(
|
|
2622
|
+
transitionState.fraction,
|
|
2623
|
+
0f,
|
|
2624
|
+
animationSpec = tween((transitionState.fraction * totalDuration).toInt()),
|
|
2625
|
+
) { value, _ ->
|
|
2626
|
+
this@LaunchedEffect.launch {
|
|
2627
|
+
if (value > 0) {
|
|
2628
|
+
// Seek the original transition back to the currentState
|
|
2629
|
+
transitionState.seekTo(value)
|
|
2630
|
+
}
|
|
2631
|
+
if (value == 0f) {
|
|
2632
|
+
// Once we animate to the start, we need to snap to the right state.
|
|
2633
|
+
transitionState.snapTo(backStackEntry)
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
transition.AnimatedContent(
|
|
2642
|
+
modifier,
|
|
2643
|
+
transitionSpec = {
|
|
2644
|
+
// If the initialState of the AnimatedContent is not in visibleEntries, we are in
|
|
2645
|
+
// a case where visible has cleared the old state for some reason, so instead of
|
|
2646
|
+
// attempting to animate away from the initialState, we skip the animation.
|
|
2647
|
+
if (initialState in visibleEntries) {
|
|
2648
|
+
val initialZIndex = zIndices.getOrPut(initialState.id) { 0f }
|
|
2649
|
+
val targetZIndex =
|
|
2650
|
+
when {
|
|
2651
|
+
targetState.id == initialState.id -> initialZIndex
|
|
2652
|
+
composeNavigator.isPop.value || inPredictiveBack -> initialZIndex - 1f
|
|
2653
|
+
else -> initialZIndex + 1f
|
|
2654
|
+
}
|
|
2655
|
+
zIndices[targetState.id] = targetZIndex
|
|
2656
|
+
|
|
2657
|
+
ContentTransform(
|
|
2658
|
+
finalEnter(this),
|
|
2659
|
+
finalExit(this),
|
|
2660
|
+
targetZIndex,
|
|
2661
|
+
finalSizeTransform(this),
|
|
2662
|
+
)
|
|
2663
|
+
} else {
|
|
2664
|
+
EnterTransition.None togetherWith ExitTransition.None
|
|
2665
|
+
}
|
|
2666
|
+
},
|
|
2667
|
+
contentAlignment,
|
|
2668
|
+
contentKey = { it.id },
|
|
2669
|
+
) {
|
|
2670
|
+
// In some specific cases, such as clearing your back stack by changing your
|
|
2671
|
+
// start destination, AnimatedContent can contain an entry that is no longer
|
|
2672
|
+
// part of visible entries since it was cleared from the back stack and is not
|
|
2673
|
+
// animating. In these cases the currentEntry will be null, and in those cases,
|
|
2674
|
+
// AnimatedContent will just skip attempting to transition the old entry.
|
|
2675
|
+
// See https://issuetracker.google.com/238686802
|
|
2676
|
+
val isPredictiveBackCancelAnimation = transitionState.currentState == backStackEntry
|
|
2677
|
+
val currentEntry =
|
|
2678
|
+
if (inPredictiveBack || isPredictiveBackCancelAnimation) {
|
|
2679
|
+
// We have to do this because the previous entry does not show up in
|
|
2680
|
+
// visibleEntries
|
|
2681
|
+
// even if we prepare it above as part of onBackStackChangeStarted
|
|
2682
|
+
it
|
|
2683
|
+
} else {
|
|
2684
|
+
visibleEntries.lastOrNull { entry -> it == entry }
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
// while in the scope of the composable, we provide the navBackStackEntry as the
|
|
2688
|
+
// ViewModelStoreOwner and LifecycleOwner
|
|
2689
|
+
currentEntry?.LocalOwnersProvider(saveableStateHolder) {
|
|
2690
|
+
(currentEntry.destination as ComposeNavigator.Destination).content(
|
|
2691
|
+
this,
|
|
2692
|
+
currentEntry,
|
|
2693
|
+
)
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
LaunchedEffect(transition.currentState, transition.targetState) {
|
|
2697
|
+
if (
|
|
2698
|
+
transition.currentState == transition.targetState &&
|
|
2699
|
+
// There is a race condition where previous animation has completed the new
|
|
2700
|
+
// animation has yet to start and there is a navigate call before this effect.
|
|
2701
|
+
// We need to make sure we are completing only when the start is settled on the
|
|
2702
|
+
// actual entry.
|
|
2703
|
+
(navController.currentBackStackEntry == null ||
|
|
2704
|
+
transition.targetState == backStackEntry)
|
|
2705
|
+
) {
|
|
2706
|
+
visibleEntries.forEach { entry -> composeNavigator.onTransitionComplete(entry) }
|
|
2707
|
+
zIndices.removeIf { key, _ -> key != transition.targetState.id }
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
val dialogNavigator =
|
|
2713
|
+
navController.navigatorProvider.get<Navigator<out NavDestination>>(DialogNavigator.NAME)
|
|
2714
|
+
as? DialogNavigator ?: return
|
|
2715
|
+
|
|
2716
|
+
// Show any dialog destinations
|
|
2717
|
+
DialogHost(dialogNavigator)
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
private fun NavDestination.createEnterTransition(
|
|
2721
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>
|
|
2722
|
+
): EnterTransition? =
|
|
2723
|
+
when (this) {
|
|
2724
|
+
is ComposeNavigator.Destination -> this.enterTransition?.invoke(scope)
|
|
2725
|
+
is ComposeNavGraphNavigator.ComposeNavGraph -> this.enterTransition?.invoke(scope)
|
|
2726
|
+
else -> null
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
private fun NavDestination.createExitTransition(
|
|
2730
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>
|
|
2731
|
+
): ExitTransition? =
|
|
2732
|
+
when (this) {
|
|
2733
|
+
is ComposeNavigator.Destination -> this.exitTransition?.invoke(scope)
|
|
2734
|
+
is ComposeNavGraphNavigator.ComposeNavGraph -> this.exitTransition?.invoke(scope)
|
|
2735
|
+
else -> null
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
private fun NavDestination.createPopEnterTransition(
|
|
2739
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>
|
|
2740
|
+
): EnterTransition? =
|
|
2741
|
+
when (this) {
|
|
2742
|
+
is ComposeNavigator.Destination -> this.popEnterTransition?.invoke(scope)
|
|
2743
|
+
is ComposeNavGraphNavigator.ComposeNavGraph -> this.popEnterTransition?.invoke(scope)
|
|
2744
|
+
else -> null
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
private fun NavDestination.createPopExitTransition(
|
|
2748
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>
|
|
2749
|
+
): ExitTransition? =
|
|
2750
|
+
when (this) {
|
|
2751
|
+
is ComposeNavigator.Destination -> this.popExitTransition?.invoke(scope)
|
|
2752
|
+
is ComposeNavGraphNavigator.ComposeNavGraph -> this.popExitTransition?.invoke(scope)
|
|
2753
|
+
else -> null
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
private fun NavDestination.createPredictivePopEnterTransition(
|
|
2757
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>,
|
|
2758
|
+
swipeEdge: Int,
|
|
2759
|
+
): EnterTransition? =
|
|
2760
|
+
when (this) {
|
|
2761
|
+
is ComposeNavigator.Destination ->
|
|
2762
|
+
this.predictivePopEnterTransition?.invoke(scope, swipeEdge)
|
|
2763
|
+
is ComposeNavGraphNavigator.ComposeNavGraph ->
|
|
2764
|
+
this.predictivePopEnterTransition?.invoke(scope, swipeEdge)
|
|
2765
|
+
else -> null
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
private fun NavDestination.createPredictivePopExitTransition(
|
|
2769
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>,
|
|
2770
|
+
swipeEdge: Int,
|
|
2771
|
+
): ExitTransition? =
|
|
2772
|
+
when (this) {
|
|
2773
|
+
is ComposeNavigator.Destination ->
|
|
2774
|
+
this.predictivePopExitTransition?.invoke(scope, swipeEdge)
|
|
2775
|
+
is ComposeNavGraphNavigator.ComposeNavGraph ->
|
|
2776
|
+
this.predictivePopExitTransition?.invoke(scope, swipeEdge)
|
|
2777
|
+
else -> null
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
private fun NavDestination.createSizeTransform(
|
|
2781
|
+
scope: AnimatedContentTransitionScope<NavBackStackEntry>
|
|
2782
|
+
): SizeTransform? =
|
|
2783
|
+
when (this) {
|
|
2784
|
+
is ComposeNavigator.Destination -> this.sizeTransform?.invoke(scope)
|
|
2785
|
+
is ComposeNavGraphNavigator.ComposeNavGraph -> this.sizeTransform?.invoke(scope)
|
|
2786
|
+
else -> null
|
|
2787
|
+
}
|
|
2788
|
+
```
|
|
2789
|
+
|
|
2790
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/NavHostController.kt
|
|
2791
|
+
```kotlin
|
|
2792
|
+
/*
|
|
2793
|
+
* Copyright 2020 The Android Open Source Project
|
|
2794
|
+
*
|
|
2795
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2796
|
+
* you may not use this file except in compliance with the License.
|
|
2797
|
+
* You may obtain a copy of the License at
|
|
2798
|
+
*
|
|
2799
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2800
|
+
*
|
|
2801
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2802
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2803
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2804
|
+
* See the License for the specific language governing permissions and
|
|
2805
|
+
* limitations under the License.
|
|
2806
|
+
*/
|
|
2807
|
+
|
|
2808
|
+
@file:JvmName("NavHostControllerKt")
|
|
2809
|
+
@file:JvmMultifileClass
|
|
2810
|
+
|
|
2811
|
+
package androidx.navigation.compose
|
|
2812
|
+
|
|
2813
|
+
import androidx.compose.runtime.Composable
|
|
2814
|
+
import androidx.compose.runtime.MutableState
|
|
2815
|
+
import androidx.compose.runtime.State
|
|
2816
|
+
import androidx.compose.runtime.collectAsState
|
|
2817
|
+
import androidx.navigation.NavBackStackEntry
|
|
2818
|
+
import androidx.navigation.NavController
|
|
2819
|
+
import androidx.navigation.NavDestination
|
|
2820
|
+
import androidx.navigation.NavHostController
|
|
2821
|
+
import androidx.navigation.Navigator
|
|
2822
|
+
import kotlin.jvm.JvmMultifileClass
|
|
2823
|
+
import kotlin.jvm.JvmName
|
|
2824
|
+
|
|
2825
|
+
/**
|
|
2826
|
+
* Gets the current navigation back stack entry as a [MutableState]. When the given navController
|
|
2827
|
+
* changes the back stack due to a [NavController.navigate] or [NavController.popBackStack] this
|
|
2828
|
+
* will trigger a recompose and return the top entry on the back stack.
|
|
2829
|
+
*
|
|
2830
|
+
* @return a mutable state of the current back stack entry
|
|
2831
|
+
*/
|
|
2832
|
+
@Composable
|
|
2833
|
+
public fun NavController.currentBackStackEntryAsState(): State<NavBackStackEntry?> {
|
|
2834
|
+
return currentBackStackEntryFlow.collectAsState(null)
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
/**
|
|
2838
|
+
* Creates a NavHostController that handles the adding of the [ComposeNavigator] and
|
|
2839
|
+
* [DialogNavigator]. Additional [Navigator] instances can be passed through [navigators] to be
|
|
2840
|
+
* applied to the returned NavController. Note that each [Navigator] must be separately remembered
|
|
2841
|
+
* before being passed in here: any changes to those inputs will cause the NavController to be
|
|
2842
|
+
* recreated.
|
|
2843
|
+
*
|
|
2844
|
+
* @see NavHost
|
|
2845
|
+
*/
|
|
2846
|
+
@Composable
|
|
2847
|
+
public expect fun rememberNavController(
|
|
2848
|
+
vararg navigators: Navigator<out NavDestination>
|
|
2849
|
+
): NavHostController
|
|
2850
|
+
```
|
|
2851
|
+
|
|
2852
|
+
## File: navigation/navigation-compose/src/commonMain/kotlin/androidx/navigation/compose/internal/NavComposeUtils.kt
|
|
2853
|
+
```kotlin
|
|
2854
|
+
/*
|
|
2855
|
+
* Copyright 2025 The Android Open Source Project
|
|
2856
|
+
*
|
|
2857
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2858
|
+
* you may not use this file except in compliance with the License.
|
|
2859
|
+
* You may obtain a copy of the License at
|
|
2860
|
+
*
|
|
2861
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2862
|
+
*
|
|
2863
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2864
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2865
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2866
|
+
* See the License for the specific language governing permissions and
|
|
2867
|
+
* limitations under the License.
|
|
2868
|
+
*/
|
|
2869
|
+
|
|
2870
|
+
package androidx.navigation.compose.internal
|
|
2871
|
+
|
|
2872
|
+
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
2873
|
+
import androidx.compose.animation.EnterTransition
|
|
2874
|
+
import androidx.compose.animation.ExitTransition
|
|
2875
|
+
import androidx.compose.animation.SizeTransform
|
|
2876
|
+
import androidx.compose.animation.core.spring
|
|
2877
|
+
import androidx.compose.animation.core.tween
|
|
2878
|
+
import androidx.compose.animation.fadeIn
|
|
2879
|
+
import androidx.compose.animation.fadeOut
|
|
2880
|
+
import androidx.compose.animation.scaleOut
|
|
2881
|
+
import androidx.compose.runtime.Composable
|
|
2882
|
+
import androidx.navigation.NavBackStackEntry
|
|
2883
|
+
import kotlinx.coroutines.flow.Flow
|
|
2884
|
+
|
|
2885
|
+
internal expect class BackEventCompat {
|
|
2886
|
+
val touchX: Float
|
|
2887
|
+
val touchY: Float
|
|
2888
|
+
val progress: Float
|
|
2889
|
+
val swipeEdge: Int
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
@Composable
|
|
2893
|
+
internal expect fun PredictiveBackHandler(
|
|
2894
|
+
enabled: Boolean = true,
|
|
2895
|
+
onBack: suspend (progress: Flow<BackEventCompat>) -> Unit,
|
|
2896
|
+
)
|
|
2897
|
+
|
|
2898
|
+
internal expect fun randomUUID(): String
|
|
2899
|
+
|
|
2900
|
+
/**
|
|
2901
|
+
* Class WeakReference encapsulates weak reference to an object, which could be used to either
|
|
2902
|
+
* retrieve a strong reference to an object, or return null, if object was already destroyed by the
|
|
2903
|
+
* memory manager.
|
|
2904
|
+
*/
|
|
2905
|
+
internal expect class WeakReference<T : Any>(reference: T) {
|
|
2906
|
+
fun get(): T?
|
|
2907
|
+
|
|
2908
|
+
fun clear()
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
internal expect object DefaultNavTransitions {
|
|
2912
|
+
val enterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition
|
|
2913
|
+
val exitTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition
|
|
2914
|
+
val predictivePopEnterTransition:
|
|
2915
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition
|
|
2916
|
+
val predictivePopExitTransition:
|
|
2917
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition
|
|
2918
|
+
val sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
internal object StandardDefaultNavTransitions {
|
|
2922
|
+
val enterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = {
|
|
2923
|
+
fadeIn(animationSpec = tween(700))
|
|
2924
|
+
}
|
|
2925
|
+
val exitTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition = {
|
|
2926
|
+
fadeOut(animationSpec = tween(700))
|
|
2927
|
+
}
|
|
2928
|
+
val predictivePopEnterTransition:
|
|
2929
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition =
|
|
2930
|
+
{
|
|
2931
|
+
fadeIn(
|
|
2932
|
+
spring(
|
|
2933
|
+
dampingRatio = 1.0f, // reflects material3 motionScheme.defaultEffectsSpec()
|
|
2934
|
+
stiffness = 1600.0f, // reflects material3 motionScheme.defaultEffectsSpec()
|
|
2935
|
+
)
|
|
2936
|
+
)
|
|
2937
|
+
}
|
|
2938
|
+
val predictivePopExitTransition:
|
|
2939
|
+
AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition =
|
|
2940
|
+
{
|
|
2941
|
+
scaleOut(targetScale = 0.7f) // reflects material3 motionScheme.defaultEffectsSpec()
|
|
2942
|
+
}
|
|
2943
|
+
val sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
|
|
2944
|
+
null
|
|
2945
|
+
}
|
|
2946
|
+
```
|
|
2947
|
+
|