@istmx/skills 1.2.0 → 2.1.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/README.md +134 -40
- package/RELEASE_v2.1.0.md +69 -0
- package/bin/cli.js +95 -91
- package/context/conversation_transcript.md +768 -0
- package/context/progress.md +121 -0
- package/istm/SKILL.md +20 -11
- package/istm-animate/SKILL.md +46 -33
- package/istm-animate/core/motion-principles/SKILL.md +284 -0
- package/istm-animate/core/motion-principles/references/designers.md +127 -0
- package/istm-animate/core/motion-principles/references/easing-guide.md +231 -0
- package/istm-animate/core/motion-principles/references/enter-exit-recipes.md +466 -0
- package/istm-animate/frameworks/canvas-generative/SKILL.md +325 -0
- package/istm-animate/frameworks/canvas-generative/references/algorithms.md +925 -0
- package/istm-animate/frameworks/css-native/SKILL.md +319 -0
- package/istm-animate/frameworks/css-native/references/modern-css.md +465 -0
- package/istm-animate/frameworks/framer-motion/SKILL.md +187 -0
- package/istm-animate/frameworks/framer-motion/references/api.md +312 -0
- package/istm-animate/frameworks/gsap/SKILL.md +188 -0
- package/istm-animate/frameworks/gsap/references/core.md +218 -0
- package/istm-animate/frameworks/gsap/references/plugins.md +371 -0
- package/istm-animate/frameworks/gsap/references/scrolltrigger.md +325 -0
- package/istm-animate/frameworks/gsap/references/timeline.md +218 -0
- package/istm-animate/frameworks/threejs-r3f/SKILL.md +243 -0
- package/istm-animate/frameworks/threejs-r3f/references/scene-setup.md +392 -0
- package/istm-animate/frameworks/threejs-r3f/references/shaders.md +446 -0
- package/istm-animate/mobile/android/compose-graphics/SKILL.md +503 -0
- package/istm-animate/mobile/android/compose-graphics/references/agsl-recipes.md +356 -0
- package/istm-animate/mobile/android/compose-graphics/references/canvas-generative.md +282 -0
- package/istm-animate/mobile/android/compose-graphics/references/m3-expressive-deep.md +303 -0
- package/istm-animate/mobile/android/compose-motion/SKILL.md +359 -0
- package/istm-animate/mobile/android/compose-motion/references/gestures-compose.md +273 -0
- package/istm-animate/mobile/android/compose-motion/references/recomposition-and-anim.md +196 -0
- package/istm-animate/mobile/android/compose-motion/references/shared-transitions.md +281 -0
- package/istm-animate/mobile/android/compose-multiplatform/SKILL.md +311 -0
- package/istm-animate/mobile/android/compose-multiplatform/references/cmp-interop.md +288 -0
- package/istm-animate/mobile/android/compose-multiplatform/references/cmp-platform-quirks.md +156 -0
- package/istm-animate/mobile/apple/swiftui-graphics/SKILL.md +408 -0
- package/istm-animate/mobile/apple/swiftui-graphics/references/canvas-swiftui.md +239 -0
- package/istm-animate/mobile/apple/swiftui-graphics/references/liquid-glass-deep.md +252 -0
- package/istm-animate/mobile/apple/swiftui-graphics/references/metal-recipes.md +382 -0
- package/istm-animate/mobile/apple/swiftui-motion/SKILL.md +379 -0
- package/istm-animate/mobile/apple/swiftui-motion/references/gestures-swiftui.md +336 -0
- package/istm-animate/mobile/apple/swiftui-motion/references/phase-keyframe-deep.md +231 -0
- package/istm-animate/mobile/apple/swiftui-motion/references/springs-cheatsheet.md +129 -0
- package/istm-animate/references/animate.md +199 -0
- package/istm-animate/references/audit.md +115 -0
- package/istm-animate/references/design-engineering.md +674 -0
- package/istm-animate/references/improve.md +101 -0
- package/istm-animate/references/opportunities.md +132 -0
- package/istm-animate/references/plan-template.md +73 -0
- package/istm-animate/references/recipes.md +324 -0
- package/istm-animate/references/review.md +112 -0
- package/istm-animate/references/standards.md +187 -0
- package/istm-animate/references/vocabulary.md +173 -0
- package/istm-architecture/SKILL.md +70 -14
- package/istm-architecture/templates/agents.md +21 -2
- package/istm-awwward-designer/SKILL.md +53 -17
- package/istm-design/SKILL.md +49 -63
- package/istm-design/anti-laziness/architectural-patterns.md +55 -0
- package/istm-design/anti-laziness/parameter-tuning.md +44 -0
- package/istm-design/anti-laziness/prompt-engineering.md +52 -0
- package/istm-design/anti-laziness/reference-prompts.md +79 -0
- package/istm-design/archetypes/brandkit/SKILL.md +798 -0
- package/istm-design/archetypes/brutalist/SKILL.md +92 -0
- package/istm-design/archetypes/minimalist/SKILL.md +85 -0
- package/istm-design/archetypes/soft/SKILL.md +98 -0
- package/istm-design/core/design-audit/SKILL.md +248 -0
- package/istm-design/core/desktop-principles/SKILL.md +363 -0
- package/istm-design/core/desktop-principles/references/keyboard-patterns.md +137 -0
- package/istm-design/core/desktop-principles/references/multi-window.md +105 -0
- package/istm-design/core/mobile-principles/SKILL.md +289 -0
- package/istm-design/core/mobile-principles/references/accessibility-mobile.md +175 -0
- package/istm-design/core/mobile-principles/references/gestures-deep.md +220 -0
- package/istm-design/core/ui-ux-pro-max/SKILL.md +392 -0
- package/istm-design/core/ui-ux-pro-max/UPSTREAM.md +23 -0
- package/istm-design/core/ui-ux-pro-max/data/app-interface.csv +31 -0
- package/istm-design/core/ui-ux-pro-max/data/charts.csv +26 -0
- package/istm-design/core/ui-ux-pro-max/data/colors.csv +193 -0
- package/istm-design/core/ui-ux-pro-max/data/google-fonts.csv +1924 -0
- package/istm-design/core/ui-ux-pro-max/data/icons.csv +106 -0
- package/istm-design/core/ui-ux-pro-max/data/landing.csv +35 -0
- package/istm-design/core/ui-ux-pro-max/data/motion.csv +17 -0
- package/istm-design/core/ui-ux-pro-max/data/products.csv +193 -0
- package/istm-design/core/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/angular.csv +51 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/nuxt-ui.csv +71 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/uno.csv +60 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/winui.csv +60 -0
- package/istm-design/core/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
- package/istm-design/core/ui-ux-pro-max/data/styles.csv +85 -0
- package/istm-design/core/ui-ux-pro-max/data/typography.csv +75 -0
- package/istm-design/core/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
- package/istm-design/core/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/istm-design/core/ui-ux-pro-max/references/pro-rules.md +109 -0
- package/istm-design/core/ui-ux-pro-max/references/quick-reference.md +240 -0
- package/istm-design/core/ui-ux-pro-max/scripts/core.py +464 -0
- package/istm-design/core/ui-ux-pro-max/scripts/design_system.py +1371 -0
- package/istm-design/core/ui-ux-pro-max/scripts/search.py +162 -0
- package/istm-design/core/ui-ux-pro-max/scripts/tests/test_core.py +134 -0
- package/istm-design/core/ui-ux-pro-max/scripts/validate_data.py +114 -0
- package/istm-design/image-to-code/SKILL.md +1228 -0
- package/istm-design/imagegen/SKILL.md +987 -0
- package/istm-design/presets/airbnb/DESIGN.md +545 -0
- package/istm-design/presets/airbnb/README.md +5 -0
- package/istm-design/presets/airtable/DESIGN.md +554 -0
- package/istm-design/presets/airtable/README.md +5 -0
- package/istm-design/presets/apple/DESIGN.md +562 -0
- package/istm-design/presets/apple/README.md +5 -0
- package/istm-design/presets/binance/DESIGN.md +634 -0
- package/istm-design/presets/binance/README.md +5 -0
- package/istm-design/presets/bmw/DESIGN.md +544 -0
- package/istm-design/presets/bmw/README.md +5 -0
- package/istm-design/presets/bmw-m/DESIGN.md +503 -0
- package/istm-design/presets/bmw-m/README.md +5 -0
- package/istm-design/presets/bugatti/DESIGN.md +454 -0
- package/istm-design/presets/bugatti/README.md +5 -0
- package/istm-design/presets/cal/DESIGN.md +542 -0
- package/istm-design/presets/cal/README.md +5 -0
- package/istm-design/presets/catalog.md +127 -0
- package/istm-design/presets/claude/DESIGN.md +589 -0
- package/istm-design/presets/claude/README.md +5 -0
- package/istm-design/presets/clay/DESIGN.md +541 -0
- package/istm-design/presets/clay/README.md +5 -0
- package/istm-design/presets/clickhouse/DESIGN.md +544 -0
- package/istm-design/presets/clickhouse/README.md +5 -0
- package/istm-design/presets/cohere/DESIGN.md +451 -0
- package/istm-design/presets/cohere/README.md +5 -0
- package/istm-design/presets/coinbase/DESIGN.md +570 -0
- package/istm-design/presets/coinbase/README.md +5 -0
- package/istm-design/presets/composio/DESIGN.md +506 -0
- package/istm-design/presets/composio/README.md +5 -0
- package/istm-design/presets/cursor/DESIGN.md +537 -0
- package/istm-design/presets/cursor/README.md +5 -0
- package/istm-design/presets/dell-1996/DESIGN.md +632 -0
- package/istm-design/presets/dell-1996/README.md +5 -0
- package/istm-design/presets/elevenlabs/DESIGN.md +504 -0
- package/istm-design/presets/elevenlabs/README.md +5 -0
- package/istm-design/presets/expo/DESIGN.md +526 -0
- package/istm-design/presets/expo/README.md +5 -0
- package/istm-design/presets/ferrari/DESIGN.md +531 -0
- package/istm-design/presets/ferrari/README.md +5 -0
- package/istm-design/presets/figma/DESIGN.md +578 -0
- package/istm-design/presets/figma/README.md +5 -0
- package/istm-design/presets/framer/DESIGN.md +544 -0
- package/istm-design/presets/framer/README.md +5 -0
- package/istm-design/presets/hashicorp/DESIGN.md +575 -0
- package/istm-design/presets/hashicorp/README.md +5 -0
- package/istm-design/presets/hp/DESIGN.md +670 -0
- package/istm-design/presets/hp/README.md +5 -0
- package/istm-design/presets/ibm/DESIGN.md +550 -0
- package/istm-design/presets/ibm/README.md +5 -0
- package/istm-design/presets/intercom/DESIGN.md +546 -0
- package/istm-design/presets/intercom/README.md +5 -0
- package/istm-design/presets/kraken/DESIGN.md +125 -0
- package/istm-design/presets/kraken/README.md +5 -0
- package/istm-design/presets/lamborghini/DESIGN.md +288 -0
- package/istm-design/presets/lamborghini/README.md +5 -0
- package/istm-design/presets/linear/DESIGN.md +548 -0
- package/istm-design/presets/linear/README.md +5 -0
- package/istm-design/presets/lovable/DESIGN.md +298 -0
- package/istm-design/presets/lovable/README.md +5 -0
- package/istm-design/presets/mastercard/DESIGN.md +365 -0
- package/istm-design/presets/mastercard/README.md +5 -0
- package/istm-design/presets/meta/DESIGN.md +683 -0
- package/istm-design/presets/meta/README.md +5 -0
- package/istm-design/presets/minimax/DESIGN.md +746 -0
- package/istm-design/presets/minimax/README.md +5 -0
- package/istm-design/presets/mintlify/DESIGN.md +852 -0
- package/istm-design/presets/mintlify/README.md +5 -0
- package/istm-design/presets/miro/DESIGN.md +825 -0
- package/istm-design/presets/miro/README.md +5 -0
- package/istm-design/presets/mistral/DESIGN.md +773 -0
- package/istm-design/presets/mistral/README.md +5 -0
- package/istm-design/presets/mongodb/DESIGN.md +767 -0
- package/istm-design/presets/mongodb/README.md +5 -0
- package/istm-design/presets/nike/DESIGN.md +575 -0
- package/istm-design/presets/nike/README.md +5 -0
- package/istm-design/presets/nintendo-2001/DESIGN.md +649 -0
- package/istm-design/presets/nintendo-2001/README.md +5 -0
- package/istm-design/presets/notion/DESIGN.md +821 -0
- package/istm-design/presets/notion/README.md +5 -0
- package/istm-design/presets/nvidia/DESIGN.md +640 -0
- package/istm-design/presets/nvidia/README.md +5 -0
- package/istm-design/presets/ollama/DESIGN.md +539 -0
- package/istm-design/presets/ollama/README.md +5 -0
- package/istm-design/presets/opencode/DESIGN.md +521 -0
- package/istm-design/presets/opencode/README.md +5 -0
- package/istm-design/presets/pinterest/DESIGN.md +597 -0
- package/istm-design/presets/pinterest/README.md +5 -0
- package/istm-design/presets/playstation/DESIGN.md +661 -0
- package/istm-design/presets/playstation/README.md +5 -0
- package/istm-design/presets/posthog/DESIGN.md +690 -0
- package/istm-design/presets/posthog/README.md +5 -0
- package/istm-design/presets/raycast/DESIGN.md +669 -0
- package/istm-design/presets/raycast/README.md +5 -0
- package/istm-design/presets/renault/DESIGN.md +589 -0
- package/istm-design/presets/renault/README.md +5 -0
- package/istm-design/presets/replicate/DESIGN.md +616 -0
- package/istm-design/presets/replicate/README.md +5 -0
- package/istm-design/presets/resend/DESIGN.md +585 -0
- package/istm-design/presets/resend/README.md +5 -0
- package/istm-design/presets/revolut/DESIGN.md +636 -0
- package/istm-design/presets/revolut/README.md +5 -0
- package/istm-design/presets/runwayml/DESIGN.md +244 -0
- package/istm-design/presets/runwayml/README.md +5 -0
- package/istm-design/presets/sanity/DESIGN.md +357 -0
- package/istm-design/presets/sanity/README.md +5 -0
- package/istm-design/presets/sentry/DESIGN.md +551 -0
- package/istm-design/presets/sentry/README.md +5 -0
- package/istm-design/presets/shopify/DESIGN.md +516 -0
- package/istm-design/presets/shopify/README.md +5 -0
- package/istm-design/presets/slack/DESIGN.md +482 -0
- package/istm-design/presets/spacex/DESIGN.md +363 -0
- package/istm-design/presets/spacex/README.md +5 -0
- package/istm-design/presets/spotify/DESIGN.md +246 -0
- package/istm-design/presets/spotify/README.md +5 -0
- package/istm-design/presets/starbucks/DESIGN.md +580 -0
- package/istm-design/presets/starbucks/README.md +5 -0
- package/istm-design/presets/stripe/DESIGN.md +487 -0
- package/istm-design/presets/stripe/README.md +5 -0
- package/istm-design/presets/supabase/DESIGN.md +462 -0
- package/istm-design/presets/supabase/README.md +5 -0
- package/istm-design/presets/superhuman/DESIGN.md +448 -0
- package/istm-design/presets/superhuman/README.md +5 -0
- package/istm-design/presets/tesla/DESIGN.md +286 -0
- package/istm-design/presets/tesla/README.md +5 -0
- package/istm-design/presets/theverge/DESIGN.md +339 -0
- package/istm-design/presets/theverge/README.md +5 -0
- package/istm-design/presets/together/DESIGN.md +633 -0
- package/istm-design/presets/together/README.md +5 -0
- package/istm-design/presets/uber/DESIGN.md +636 -0
- package/istm-design/presets/uber/README.md +5 -0
- package/istm-design/presets/vercel/DESIGN.md +736 -0
- package/istm-design/presets/vercel/README.md +5 -0
- package/istm-design/presets/vodafone/DESIGN.md +538 -0
- package/istm-design/presets/vodafone/README.md +5 -0
- package/istm-design/presets/voltagent/DESIGN.md +521 -0
- package/istm-design/presets/voltagent/README.md +5 -0
- package/istm-design/presets/warp/DESIGN.md +526 -0
- package/istm-design/presets/warp/README.md +5 -0
- package/istm-design/presets/webflow/DESIGN.md +588 -0
- package/istm-design/presets/webflow/README.md +5 -0
- package/istm-design/presets/wired/DESIGN.md +497 -0
- package/istm-design/presets/wired/README.md +5 -0
- package/istm-design/presets/wise/DESIGN.md +544 -0
- package/istm-design/presets/wise/README.md +5 -0
- package/istm-design/presets/xai/DESIGN.md +465 -0
- package/istm-design/presets/xai/README.md +5 -0
- package/istm-design/presets/zapier/DESIGN.md +537 -0
- package/istm-design/presets/zapier/README.md +5 -0
- package/istm-design/references/apple-design.md +282 -0
- package/istm-design/references/generation-guide.md +209 -0
- package/istm-design/references/pick-ui-library.md +77 -0
- package/istm-design/references/picker.md +197 -0
- package/istm-design/references/prototype.md +90 -0
- package/istm-design/references/schema.md +366 -0
- package/istm-design/semantic-design/DESIGN.md +121 -0
- package/istm-design/semantic-design/SKILL.md +184 -0
- package/istm-system-design/SKILL.md +12 -5
- package/istm-workflow/istm-autoplan/SKILL.md +1905 -0
- package/istm-workflow/istm-autoplan/SKILL.md.tmpl +923 -0
- package/istm-workflow/istm-craft/SKILL.md +12 -6
- package/istm-workflow/istm-cso/ACKNOWLEDGEMENTS.md +14 -0
- package/istm-workflow/istm-cso/SKILL.md +1313 -0
- package/istm-workflow/istm-cso/SKILL.md.tmpl +407 -0
- package/istm-workflow/istm-cso/sections/audit-phases.md +253 -0
- package/istm-workflow/istm-cso/sections/audit-phases.md.tmpl +251 -0
- package/istm-workflow/istm-cso/sections/manifest.json +14 -0
- package/istm-workflow/istm-debt/SKILL.md +44 -0
- package/istm-workflow/istm-debug/SKILL.md +12 -3
- package/istm-workflow/istm-design-review/SKILL.md +2053 -0
- package/istm-workflow/istm-design-review/SKILL.md.tmpl +312 -0
- package/istm-workflow/istm-develop/SKILL.md +10 -4
- package/istm-workflow/istm-eng-review/SKILL.md +1112 -0
- package/istm-workflow/istm-eng-review/SKILL.md.tmpl +163 -0
- package/istm-workflow/istm-eng-review/sections/manifest.json +14 -0
- package/istm-workflow/istm-eng-review/sections/review-sections.md +942 -0
- package/istm-workflow/istm-eng-review/sections/review-sections.md.tmpl +225 -0
- package/istm-workflow/istm-gain/SKILL.md +50 -0
- package/istm-workflow/istm-health/SKILL.md +1104 -0
- package/istm-workflow/istm-health/SKILL.md.tmpl +320 -0
- package/istm-workflow/istm-qa/BROWSER.md +1468 -0
- package/istm-workflow/istm-qa/SKILL.md +1743 -0
- package/istm-workflow/istm-qa/SKILL.md.tmpl +354 -0
- package/istm-workflow/istm-qa/references/issue-taxonomy.md +85 -0
- package/istm-workflow/istm-qa/templates/qa-report-template.md +126 -0
- package/istm-workflow/istm-release/SKILL.md +989 -0
- package/istm-workflow/istm-release/SKILL.md.tmpl +160 -0
- package/istm-workflow/istm-release/sections/manifest.json +14 -0
- package/istm-workflow/istm-release/sections/release-body.md +547 -0
- package/istm-workflow/istm-release/sections/release-body.md.tmpl +420 -0
- package/istm-workflow/istm-review/SKILL.md +57 -0
- package/istm-workflow/istm-ship/SKILL.md +1504 -0
- package/istm-workflow/istm-ship/SKILL.md.tmpl +582 -0
- package/istm-workflow/istm-ship/sections/adversarial.md +218 -0
- package/istm-workflow/istm-ship/sections/adversarial.md.tmpl +19 -0
- package/istm-workflow/istm-ship/sections/apple-release.md +58 -0
- package/istm-workflow/istm-ship/sections/apple-release.md.tmpl +56 -0
- package/istm-workflow/istm-ship/sections/changelog.md +45 -0
- package/istm-workflow/istm-ship/sections/changelog.md.tmpl +3 -0
- package/istm-workflow/istm-ship/sections/greptile.md +51 -0
- package/istm-workflow/istm-ship/sections/greptile.md.tmpl +49 -0
- package/istm-workflow/istm-ship/sections/manifest.json +62 -0
- package/istm-workflow/istm-ship/sections/plan-completion.md +329 -0
- package/istm-workflow/istm-ship/sections/plan-completion.md.tmpl +31 -0
- package/istm-workflow/istm-ship/sections/pr-body.md +209 -0
- package/istm-workflow/istm-ship/sections/pr-body.md.tmpl +207 -0
- package/istm-workflow/istm-ship/sections/review-army.md +406 -0
- package/istm-workflow/istm-ship/sections/review-army.md.tmpl +56 -0
- package/istm-workflow/istm-ship/sections/test-coverage.md +264 -0
- package/istm-workflow/istm-ship/sections/test-coverage.md.tmpl +23 -0
- package/istm-workflow/istm-ship/sections/tests.md +403 -0
- package/istm-workflow/istm-ship/sections/tests.md.tmpl +116 -0
- package/package.json +6 -3
- package/RELEASE_v1.2.0.md +0 -40
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# Shared Element Transitions in Compose
|
|
2
|
+
|
|
3
|
+
`SharedTransitionLayout` morphs an element's bounds, position, and (with `sharedBounds`) shape between two destinations. The receiver lays out both states in the same coordinate space and interpolates between them. Stable since Compose 1.7 - this is the canonical hero / detail / picture-in-picture pattern.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
The whole machinery lives behind two scopes:
|
|
10
|
+
|
|
11
|
+
- `SharedTransitionScope` - exposes the `Modifier.sharedElement(...)` and `Modifier.sharedBounds(...)` extensions.
|
|
12
|
+
- `AnimatedVisibilityScope` - the visibility context that drives the in/out transition (every `AnimatedContent` content lambda is one; every `composable<Route>` block in `NavHost` exposes one).
|
|
13
|
+
|
|
14
|
+
Wrap the screen swap in `SharedTransitionLayout` and pass both scopes down. `Modifier.sharedElement` is for elements that keep the same shape and aspect (an image moving across screens). `Modifier.sharedBounds` is for content whose size, shape, or content meaningfully changes (a card expanding into a full panel, a button morphing into a header).
|
|
15
|
+
|
|
16
|
+
Compose 1.7+ baseline. With androidx.navigation 2.8+ on Compose, scopes are exposed directly inside `composable<Route>` lambdas.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Recipe 1 - Card to Detail
|
|
21
|
+
|
|
22
|
+
```kotlin
|
|
23
|
+
sealed interface Screen {
|
|
24
|
+
data object List : Screen
|
|
25
|
+
data class Detail(val item: Item) : Screen
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Composable
|
|
29
|
+
fun App() {
|
|
30
|
+
var current by remember { mutableStateOf<Screen>(Screen.List) }
|
|
31
|
+
|
|
32
|
+
SharedTransitionLayout {
|
|
33
|
+
AnimatedContent(
|
|
34
|
+
targetState = current,
|
|
35
|
+
label = "screen",
|
|
36
|
+
transitionSpec = { fadeIn() togetherWith fadeOut() },
|
|
37
|
+
) { screen ->
|
|
38
|
+
when (screen) {
|
|
39
|
+
Screen.List -> ListScreen(
|
|
40
|
+
onOpen = { current = Screen.Detail(it) },
|
|
41
|
+
sts = this@SharedTransitionLayout,
|
|
42
|
+
avs = this@AnimatedContent,
|
|
43
|
+
)
|
|
44
|
+
is Screen.Detail -> DetailScreen(
|
|
45
|
+
item = screen.item,
|
|
46
|
+
onBack = { current = Screen.List },
|
|
47
|
+
sts = this@SharedTransitionLayout,
|
|
48
|
+
avs = this@AnimatedContent,
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Composable
|
|
56
|
+
fun ListScreen(
|
|
57
|
+
onOpen: (Item) -> Unit,
|
|
58
|
+
sts: SharedTransitionScope,
|
|
59
|
+
avs: AnimatedVisibilityScope,
|
|
60
|
+
) {
|
|
61
|
+
LazyColumn { items(items, key = { it.id }) { item ->
|
|
62
|
+
with(sts) {
|
|
63
|
+
Card(
|
|
64
|
+
onClick = { onOpen(item) },
|
|
65
|
+
modifier = Modifier.sharedBounds(
|
|
66
|
+
sharedContentState = rememberSharedContentState("card-${item.id}"),
|
|
67
|
+
animatedVisibilityScope = avs,
|
|
68
|
+
),
|
|
69
|
+
) {
|
|
70
|
+
Image(
|
|
71
|
+
painter = item.painter,
|
|
72
|
+
contentDescription = null,
|
|
73
|
+
modifier = Modifier.sharedElement(
|
|
74
|
+
state = rememberSharedContentState("image-${item.id}"),
|
|
75
|
+
animatedVisibilityScope = avs,
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
Text(item.title)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Composable
|
|
85
|
+
fun DetailScreen(
|
|
86
|
+
item: Item,
|
|
87
|
+
onBack: () -> Unit,
|
|
88
|
+
sts: SharedTransitionScope,
|
|
89
|
+
avs: AnimatedVisibilityScope,
|
|
90
|
+
) {
|
|
91
|
+
with(sts) {
|
|
92
|
+
Column(
|
|
93
|
+
modifier = Modifier.sharedBounds(
|
|
94
|
+
sharedContentState = rememberSharedContentState("card-${item.id}"),
|
|
95
|
+
animatedVisibilityScope = avs,
|
|
96
|
+
),
|
|
97
|
+
) {
|
|
98
|
+
Image(
|
|
99
|
+
painter = item.painter,
|
|
100
|
+
contentDescription = null,
|
|
101
|
+
modifier = Modifier
|
|
102
|
+
.fillMaxWidth()
|
|
103
|
+
.height(360.dp)
|
|
104
|
+
.sharedElement(
|
|
105
|
+
state = rememberSharedContentState("image-${item.id}"),
|
|
106
|
+
animatedVisibilityScope = avs,
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
Text(item.title, style = MaterialTheme.typography.headlineLarge)
|
|
110
|
+
Text(item.description)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The card outer shape uses `sharedBounds` (different size/shape between list and detail). The image uses `sharedElement` (same content, just translated and scaled). Keys are stable per item id.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Recipe 2 - Image Hero
|
|
121
|
+
|
|
122
|
+
A photo grid that opens into a full-bleed photo detail. Same key on the `Image` composable on both sides; the framework interpolates the bounds.
|
|
123
|
+
|
|
124
|
+
```kotlin
|
|
125
|
+
// Grid:
|
|
126
|
+
Image(
|
|
127
|
+
painter = item.painter,
|
|
128
|
+
contentDescription = null,
|
|
129
|
+
modifier = Modifier
|
|
130
|
+
.aspectRatio(1f)
|
|
131
|
+
.sharedElement(
|
|
132
|
+
state = rememberSharedContentState("photo-${item.id}"),
|
|
133
|
+
animatedVisibilityScope = avs,
|
|
134
|
+
boundsTransform = { _, _ ->
|
|
135
|
+
spring(stiffness = Spring.StiffnessMediumLow, dampingRatio = 0.85f)
|
|
136
|
+
},
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
// Detail:
|
|
141
|
+
Image(
|
|
142
|
+
painter = item.painter,
|
|
143
|
+
contentDescription = null,
|
|
144
|
+
contentScale = ContentScale.Fit,
|
|
145
|
+
modifier = Modifier
|
|
146
|
+
.fillMaxWidth()
|
|
147
|
+
.sharedElement(
|
|
148
|
+
state = rememberSharedContentState("photo-${item.id}"),
|
|
149
|
+
animatedVisibilityScope = avs,
|
|
150
|
+
),
|
|
151
|
+
)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`boundsTransform` (declared on the source side typically, both is fine) controls the spring on the bounds interpolation. Default is a snappy spring; soften for a more cinematic feel.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Recipe 3 - Tab Header Morph in `HorizontalPager`
|
|
159
|
+
|
|
160
|
+
A header strip whose accent pill morphs as the user swipes between tabs. `SharedTransitionLayout` wraps the pager; each page declares its own `sharedElement` with the SAME key for the morphing element.
|
|
161
|
+
|
|
162
|
+
```kotlin
|
|
163
|
+
SharedTransitionLayout {
|
|
164
|
+
HorizontalPager(state = pagerState) { pageIndex ->
|
|
165
|
+
AnimatedContent(
|
|
166
|
+
targetState = pageIndex,
|
|
167
|
+
label = "tabPage",
|
|
168
|
+
) { page ->
|
|
169
|
+
Column {
|
|
170
|
+
Box(
|
|
171
|
+
modifier = Modifier
|
|
172
|
+
.height(48.dp)
|
|
173
|
+
.background(palette[page], RoundedCornerShape(24.dp))
|
|
174
|
+
.sharedElement(
|
|
175
|
+
state = rememberSharedContentState("tab-pill"),
|
|
176
|
+
animatedVisibilityScope = this@AnimatedContent,
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
TabContent(page)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Note: real-world tab bars usually do this with a single backing layout reading the pager's settled offset directly - shared elements shine when the morph crosses screen boundaries, not strictly within a single fixed layout.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## `rememberSharedContentState` - Keys Discipline
|
|
191
|
+
|
|
192
|
+
**Rule:** keys must be stable AND unique per logical element across the screens that share it.
|
|
193
|
+
|
|
194
|
+
```kotlin
|
|
195
|
+
// BAD - index changes when the list reorders, transition mistargets
|
|
196
|
+
items.forEachIndexed { i, item ->
|
|
197
|
+
Image(modifier = Modifier.sharedElement(rememberSharedContentState("hero-$i"), avs))
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```kotlin
|
|
202
|
+
// GOOD - id-based
|
|
203
|
+
items.forEach { item ->
|
|
204
|
+
Image(modifier = Modifier.sharedElement(rememberSharedContentState("hero-${item.id}"), avs))
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
If the same screen contains multiple shared elements, namespace them: `"image-${item.id}"`, `"title-${item.id}"`. Ambiguous keys = wrong element gets matched and you get a teleporting image.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Bound Modifiers and `sharedBounds` Knobs
|
|
213
|
+
|
|
214
|
+
`Modifier.sharedBounds(...)` accepts:
|
|
215
|
+
|
|
216
|
+
- `enter` / `exit`: `EnterTransition` / `ExitTransition` for content INSIDE the morphing bounds (default `fadeIn()` / `fadeOut()`).
|
|
217
|
+
- `boundsTransform`: spring/tween for the bounds interpolation itself.
|
|
218
|
+
- `resizeMode`: `ScaleToBounds(contentScale, alignment)` (default - scales content to match bounds, useful when content shape matches) or `RemeasureToBounds` (re-measures content at every step, useful for text reflow).
|
|
219
|
+
- `clipInOverlayDuringTransition`: an `OverlayClip(shape)` applied while the element is in the overlay. Use a rounded shape that matches your destination card to avoid hard rectangle flashes.
|
|
220
|
+
- `placeHolderSize`: how the source slot reserves space during the transition (`PlaceHolderSize.contentSize` by default, `PlaceHolderSize.animatedSize` to animate the gap).
|
|
221
|
+
|
|
222
|
+
Quick template for a card-to-screen morph:
|
|
223
|
+
|
|
224
|
+
```kotlin
|
|
225
|
+
Modifier.sharedBounds(
|
|
226
|
+
sharedContentState = rememberSharedContentState("card-${id}"),
|
|
227
|
+
animatedVisibilityScope = avs,
|
|
228
|
+
enter = fadeIn(tween(150)),
|
|
229
|
+
exit = fadeOut(tween(80)),
|
|
230
|
+
resizeMode = SharedTransitionScope.ResizeMode.RemeasureToBounds,
|
|
231
|
+
clipInOverlayDuringTransition = OverlayClip(RoundedCornerShape(24.dp)),
|
|
232
|
+
)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Compose Navigation Integration
|
|
238
|
+
|
|
239
|
+
With androidx.navigation 2.8+ for Compose, scopes are accessible directly inside `composable<Route>` lambdas via `LocalNavAnimatedVisibilityScope` and a `SharedTransitionLayout` wrapping the `NavHost`.
|
|
240
|
+
|
|
241
|
+
```kotlin
|
|
242
|
+
SharedTransitionLayout {
|
|
243
|
+
NavHost(navController, startDestination = HomeRoute) {
|
|
244
|
+
composable<HomeRoute> {
|
|
245
|
+
HomeScreen(
|
|
246
|
+
sts = this@SharedTransitionLayout,
|
|
247
|
+
avs = this, // AnimatedVisibilityScope
|
|
248
|
+
onOpen = { id -> navController.navigate(DetailRoute(id)) },
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
composable<DetailRoute> { backStackEntry ->
|
|
252
|
+
val args: DetailRoute = backStackEntry.toRoute()
|
|
253
|
+
DetailScreen(
|
|
254
|
+
id = args.id,
|
|
255
|
+
sts = this@SharedTransitionLayout,
|
|
256
|
+
avs = this,
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Pass `sts` and `avs` exactly as you would inside a manual `AnimatedContent`. The `composable` lambda IS an `AnimatedVisibilityScope`. If you ship Compose Navigation 3 (stable expected early 2026), the surface is the same - the ergonomics get a bit nicer with type-safe routes already inferred.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Gotchas
|
|
268
|
+
|
|
269
|
+
- **Mismatched keys = no animation.** Silent failure. Verify with Layout Inspector's animation panel; both sides must show the same `SharedContentState`.
|
|
270
|
+
- **Unmounted source.** Don't put a `sharedElement` inside a `LazyColumn` item that may be scrolled off when the transition starts. The framework needs the source slot to be measurable to compute origin bounds. Workaround: scroll to make the source visible before triggering navigation, or use `sharedBounds` on the entire visible row.
|
|
271
|
+
- **Performance.** Each shared element is a render pass through the overlay. Sharing 20+ elements at once tanks frame rate. Share the hero image and the title; let everything else fade.
|
|
272
|
+
- **Z-order during transition.** Shared elements render in the overlay above the rest of the layout. If you have UI that should sit above the morph (top app bar, fab), keep it OUTSIDE `SharedTransitionLayout` or accept the overlap.
|
|
273
|
+
- **Reduced motion.** Wrap shared transitions in a check (see `../SKILL.md` reduced-motion section) and replace with a `snap()` `boundsTransform` and an instant `tween(0)` enter/exit.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Sources
|
|
278
|
+
|
|
279
|
+
- [Android SharedTransitionLayout docs](https://developer.android.com/develop/ui/compose/animation/shared-elements)
|
|
280
|
+
- [skydoves/Orbital](https://github.com/skydoves/Orbital) - shared element transitions library and recipes
|
|
281
|
+
- [androidx.navigation Compose animations](https://developer.android.com/jetpack/androidx/releases/navigation)
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: compose-multiplatform
|
|
3
|
+
description: "Compose Multiplatform / KMP patterns - expect/actual composables, platform-specific code, density and font handling cross-target, iOS/Android/Desktop interop."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Compose Multiplatform
|
|
7
|
+
|
|
8
|
+
> Compose Multiplatform (CMP) and Kotlin Multiplatform (KMP) patterns for cross-platform UI.
|
|
9
|
+
> Loaded for projects with `org.jetbrains.compose` plugin.
|
|
10
|
+
> Foundation: `../compose-motion/SKILL.md` for animation API; this file covers what's specific to writing one Compose codebase for Android + iOS + Desktop + Web.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## KMP vs CMP - quick clarification
|
|
15
|
+
|
|
16
|
+
**KMP** (Kotlin Multiplatform) is the language and build infrastructure: shared Kotlin code compiled to JVM, Native (iOS, macOS, Linux, Windows), and Wasm. **CMP** (Compose Multiplatform) is the UI framework on top of KMP, built by JetBrains as a port of Jetpack Compose. You write a single Compose codebase in `commonMain` that runs on Android, iOS, Desktop (JVM), and Web (Wasm). Platform-specific code lives in `androidMain`, `iosMain`, `desktopMain`, `wasmJsMain` and is wired in via `expect`/`actual` declarations.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Project structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
composeApp/
|
|
24
|
+
├── src/
|
|
25
|
+
│ ├── commonMain/ ← shared Compose code (most of the app)
|
|
26
|
+
│ │ └── kotlin/
|
|
27
|
+
│ ├── androidMain/ ← Android-specific (uses Activity, Context)
|
|
28
|
+
│ ├── iosMain/ ← iOS-specific (uses UIKit/UIView interop)
|
|
29
|
+
│ ├── desktopMain/ ← JVM desktop (uses java.awt/swing if needed)
|
|
30
|
+
│ └── wasmJsMain/ ← Wasm web target
|
|
31
|
+
├── build.gradle.kts
|
|
32
|
+
iosApp/ ← Xcode project consuming the generated framework
|
|
33
|
+
androidApp/ ← Android Application module (often merged into composeApp)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The `commonMain` folder should hold 80-95% of your code in a well-architected CMP project. If `iosMain` or `androidMain` start growing past a few hundred lines, you're probably leaking platform concerns into UI logic that could stay shared.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## `expect`/`actual` pattern
|
|
41
|
+
|
|
42
|
+
The KMP escape hatch when you genuinely need different implementations per target. Declare the contract once in `commonMain`, implement it once per target.
|
|
43
|
+
|
|
44
|
+
```kotlin
|
|
45
|
+
// commonMain
|
|
46
|
+
expect fun openShareSheet(text: String)
|
|
47
|
+
|
|
48
|
+
// androidMain
|
|
49
|
+
actual fun openShareSheet(text: String) {
|
|
50
|
+
val intent = Intent(Intent.ACTION_SEND).apply {
|
|
51
|
+
type = "text/plain"
|
|
52
|
+
putExtra(Intent.EXTRA_TEXT, text)
|
|
53
|
+
}
|
|
54
|
+
context.startActivity(Intent.createChooser(intent, null))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// iosMain
|
|
58
|
+
actual fun openShareSheet(text: String) {
|
|
59
|
+
val activityVC = UIActivityViewController(
|
|
60
|
+
activityItems = listOf(text),
|
|
61
|
+
applicationActivities = null
|
|
62
|
+
)
|
|
63
|
+
UIApplication.sharedApplication.keyWindow
|
|
64
|
+
?.rootViewController
|
|
65
|
+
?.presentViewController(activityVC, true, null)
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`expect`/`actual` works for top-level functions, classes, type aliases, and properties. The signature in `actual` must match exactly, including modifiers and default values.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## `expect`/`actual` for composables
|
|
74
|
+
|
|
75
|
+
Composables follow the same rules. Useful when a feature needs a platform-specific Compose API (Android `RuntimeShader`, iOS `UIKitView`, Desktop `SwingPanel`).
|
|
76
|
+
|
|
77
|
+
```kotlin
|
|
78
|
+
// commonMain
|
|
79
|
+
@Composable
|
|
80
|
+
expect fun PlatformBlur(modifier: Modifier = Modifier, content: @Composable () -> Unit)
|
|
81
|
+
|
|
82
|
+
// androidMain (uses RuntimeShader on Android 13+)
|
|
83
|
+
@Composable
|
|
84
|
+
actual fun PlatformBlur(modifier: Modifier, content: @Composable () -> Unit) {
|
|
85
|
+
Box(modifier.graphicsLayer { renderEffect = blurEffect }) { content() }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// iosMain (uses UIVisualEffectView via UIKitView)
|
|
89
|
+
@Composable
|
|
90
|
+
actual fun PlatformBlur(modifier: Modifier, content: @Composable () -> Unit) {
|
|
91
|
+
Box(modifier) {
|
|
92
|
+
UIKitView(
|
|
93
|
+
factory = { UIVisualEffectView(effect = UIBlurEffect.systemMaterial()) },
|
|
94
|
+
modifier = Modifier.matchParentSize()
|
|
95
|
+
)
|
|
96
|
+
content()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Rule: `expect` composables should be the exception, not the rule. Most "platform feel" differences can be tuned via tokens (colors, corner radii, spring stiffness) in `commonMain`, not via separate code paths.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## `LocalDensity` cross-platform
|
|
106
|
+
|
|
107
|
+
On Android, `LocalDensity.current.density` reflects the device DPI bucket (1.0, 1.5, 2.0, 3.0...). On iOS, density is computed from `UIScreen.scale` (typically 2.0 or 3.0 on Retina). On Desktop, density depends on the screen scaling factor (1.0 by default; 2.0 on Retina-class displays; user-configurable on Windows). On Wasm, density follows `window.devicePixelRatio`.
|
|
108
|
+
|
|
109
|
+
Don't hardcode `Dp` to pixel ratios; trust `Dp` and `LocalDensity` to handle conversion. If you need an exact pixel value (e.g., for a `Canvas` draw operation), do the conversion explicitly:
|
|
110
|
+
|
|
111
|
+
```kotlin
|
|
112
|
+
val density = LocalDensity.current
|
|
113
|
+
val pxValue = with(density) { 16.dp.toPx() }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Avoid reading `density` inside hot loops; cache the conversion.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## `LocalConfiguration` and platform-aware UI
|
|
121
|
+
|
|
122
|
+
`LocalConfiguration.current` is **Android-only** and lives in `androidMain`. For CMP, prefer the cross-platform alternatives:
|
|
123
|
+
|
|
124
|
+
- `LocalWindowInfo.current.containerSize` - the window/screen size as `IntSize`, available in `commonMain`.
|
|
125
|
+
- `LocalDensity.current` - density, available in `commonMain`.
|
|
126
|
+
- `LocalLayoutDirection.current` - LTR / RTL.
|
|
127
|
+
- `BoxWithConstraints { ... }` - read `maxWidth` / `maxHeight` directly inside layout.
|
|
128
|
+
|
|
129
|
+
If you need real device characteristics (orientation, idiom, model), wrap the access in `expect`/`actual` and pass a typed object like `PlatformInfo` to the common layer.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Fonts cross-platform via Compose Resources
|
|
134
|
+
|
|
135
|
+
`org.jetbrains.compose.resources` is the shared resources plugin. Drop fonts in `commonMain/composeResources/font/`, and the Gradle plugin generates a typed `Res` accessor.
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
composeApp/src/commonMain/composeResources/
|
|
139
|
+
├── font/
|
|
140
|
+
│ ├── Inter-Regular.ttf
|
|
141
|
+
│ └── Inter-Bold.ttf
|
|
142
|
+
├── drawable/
|
|
143
|
+
│ └── logo.svg
|
|
144
|
+
└── values/
|
|
145
|
+
├── strings.xml ← default locale
|
|
146
|
+
└── strings.fr.xml ← French overrides
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Usage in `commonMain`:
|
|
150
|
+
|
|
151
|
+
```kotlin
|
|
152
|
+
import myproject.composeapp.generated.resources.Inter_Regular
|
|
153
|
+
import myproject.composeapp.generated.resources.Inter_Bold
|
|
154
|
+
import myproject.composeapp.generated.resources.Res
|
|
155
|
+
|
|
156
|
+
val InterFamily = FontFamily(
|
|
157
|
+
Font(Res.font.Inter_Regular, FontWeight.Normal),
|
|
158
|
+
Font(Res.font.Inter_Bold, FontWeight.Bold),
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
Text("Hello", fontFamily = InterFamily)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Same pattern for `Res.drawable.logo` (image), `Res.string.app_name` (localized string via `stringResource(...)`), `Res.file.config` (raw bytes via `Res.readBytes(...)`).
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## iOS interop with SwiftUI
|
|
169
|
+
|
|
170
|
+
CMP produces a `UIViewController` you can drop into a SwiftUI app. KMP generates a top-level Kotlin function (commonly named `MainViewController()` or `ComposeUIViewController { ... }`) that returns a `UIViewController`. Wrap it with `UIViewControllerRepresentable`.
|
|
171
|
+
|
|
172
|
+
```kotlin
|
|
173
|
+
// iosMain/kotlin/main.ios.kt
|
|
174
|
+
fun MainViewController(): UIViewController = ComposeUIViewController {
|
|
175
|
+
AppContent() // commonMain composable
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```swift
|
|
180
|
+
// iOS app target
|
|
181
|
+
import SwiftUI
|
|
182
|
+
import ComposeApp // KMP-generated framework
|
|
183
|
+
|
|
184
|
+
struct ComposeContent: UIViewControllerRepresentable {
|
|
185
|
+
func makeUIViewController(context: Context) -> UIViewController {
|
|
186
|
+
Main_iosKt.MainViewController()
|
|
187
|
+
}
|
|
188
|
+
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
struct ContentView: View {
|
|
192
|
+
var body: some View { ComposeContent().ignoresSafeArea() }
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The Kotlin function name gets mangled to `Main_iosKt.MainViewController()` because the file is `main.ios.kt`. Check the generated framework headers if the symbol name surprises you.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Android entry point
|
|
201
|
+
|
|
202
|
+
No interop ceremony on Android. The Activity hosts the common composable directly via `setContent { ... }`.
|
|
203
|
+
|
|
204
|
+
```kotlin
|
|
205
|
+
// androidApp/src/main/kotlin/MainActivity.kt
|
|
206
|
+
class MainActivity : ComponentActivity() {
|
|
207
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
208
|
+
super.onCreate(savedInstanceState)
|
|
209
|
+
setContent {
|
|
210
|
+
AppContent() // commonMain composable
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
If you need to pass `Context` or `Activity` into `commonMain`, expose it via a DI graph or an `expect class PlatformContext` in `commonMain` with `actual class PlatformContext(val context: Context)` in `androidMain`.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Embedding SwiftUI/UIKit inside a Compose iOS view (the reverse direction)
|
|
221
|
+
|
|
222
|
+
Use `UIKitView` for a `UIView` factory or `UIKitViewController` for a `UIViewController` factory.
|
|
223
|
+
|
|
224
|
+
```kotlin
|
|
225
|
+
// iosMain
|
|
226
|
+
UIKitView(
|
|
227
|
+
factory = {
|
|
228
|
+
UISwitch().apply {
|
|
229
|
+
addTarget(target, action = NSSelectorFromString("onToggle:"), forControlEvents = UIControlEventValueChanged)
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
modifier = Modifier.size(48.dp, 32.dp)
|
|
233
|
+
)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
For SwiftUI views: wrap them in a `UIHostingController` exposed via a Swift `@objc` bridge function, then call from Kotlin via the generated headers (cinterop). See `references/cmp-interop.md` for the full pattern.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Animation cross-platform
|
|
241
|
+
|
|
242
|
+
All animation APIs (`animate*AsState`, `AnimatedVisibility`, `updateTransition`, `SharedTransitionLayout`) work identically across targets in CMP 1.7+. Spring tuning written in `commonMain` produces the same physics on Android and iOS. Gestures (`Modifier.draggable`, `Modifier.pointerInput`) work cross-platform with the same API surface.
|
|
243
|
+
|
|
244
|
+
The animation primer lives in `../compose-motion/SKILL.md`. Cross-platform deltas to keep in mind:
|
|
245
|
+
- iOS first-frame is slower (Skia bootstrap); a 200ms enter animation feels tighter on Android, slightly delayed on iOS cold start.
|
|
246
|
+
- Wasm motion can stutter on first frame (JIT warmup); pre-warm critical paths or hide motion until interactive.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## What does NOT work (gotchas)
|
|
251
|
+
|
|
252
|
+
- **Drawer state on iOS**: native `ModalNavigationDrawer` swipe-to-open from the leading edge conflicts with iOS's back-swipe gesture. Use a button trigger or move the swipe area inward 30dp+.
|
|
253
|
+
- **`LayoutDirection.Rtl` quirks**: Android handles RTL natively, iOS Compose had bugs in 1.6 (text alignment, padding inversions). Improved in 1.7+ but verify with real Arabic/Hebrew strings.
|
|
254
|
+
- **Soft keyboard handling**: `imePadding()` works on Android out of the box. On iOS Compose 1.6+, it requires `IOSKeyboardEventListener` setup or a `WindowInsets` observer wired through the platform layer.
|
|
255
|
+
- **`Color.parseHex(...)`** does not exist in Compose. Use `Color(0xFFRRGGBB)` or write a tiny extension.
|
|
256
|
+
- **System fonts on iOS via Compose**: do not fallback to `FontFamily.SansSerif` and expect SF Pro. Compose on iOS ships its own font fallback chain. Either bundle SF Pro via Compose Resources (license-permitting) or use `UIKitView` to drop a native `UILabel` for system-font text.
|
|
257
|
+
- **Animations on Web (Wasm)**: heavier startup, occasional first-frame stutter; profile with browser devtools and lazy-load heavy animation graphs.
|
|
258
|
+
- **`java.util.UUID`, `java.io.File`** and other JVM-only APIs are forbidden in `commonMain` if you ship to iOS or Wasm. Use `kotlinx.uuid`, `kotlinx-io`, or the `okio` multiplatform port.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## CMP version notes
|
|
263
|
+
|
|
264
|
+
- Compose Multiplatform 1.7 stable: `SharedTransitionLayout` cross-platform, improved iOS keyboard handling, lifecycle observability via `LocalLifecycleOwner` on iOS.
|
|
265
|
+
- Kotlin 2.0+ required (K2 compiler).
|
|
266
|
+
- Some Material 3 components have platform-specific look (e.g., `Switch` on iOS auto-renders with iOS-style proportions; `DatePicker` stays Material across all targets).
|
|
267
|
+
- `compose-multiplatform-resources` plugin is the standard for assets; the older `moko-resources` is no longer recommended for new projects.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Performance considerations
|
|
272
|
+
|
|
273
|
+
- **iOS first-frame** is slower than Android (Skia bootstrapping ~150-300ms cold). Keep your splash visible until the first composition emits, or pre-warm with a transparent root composable.
|
|
274
|
+
- **Wasm bundle size**: aim for <2MB compressed. Tree-shake heavy deps, lazy-load secondary screens via `kotlinx.coroutines` deferred composition, and inspect the `.wasm` output in `wasmJsBrowserDistribution`.
|
|
275
|
+
- **Desktop**: cold start is fast on JVM; AOT compilation via Kotlin/Native is overkill for desktop unless you need a single-file binary.
|
|
276
|
+
- **Android**: same baseline as Jetpack Compose - profile with the Compose compiler stability metrics and `Layout Inspector` recomposition counts.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Anti-Patterns
|
|
281
|
+
|
|
282
|
+
| BAD | GOOD | Why |
|
|
283
|
+
|---|---|---|
|
|
284
|
+
| Reflection trick or `System.getProperty("os.name")` to detect platform inside `commonMain` | `expect`/`actual` with a typed `Platform` object | Reflection breaks on Wasm/Native; `expect`/`actual` is the contract the compiler enforces |
|
|
285
|
+
| Assuming Android `Context` is reachable in `commonMain` | Inject a typed dependency via `expect class PlatformContext` or a DI scope | `Context` does not exist on iOS/Desktop/Wasm; the code will not compile for those targets |
|
|
286
|
+
| Hardcoding Material colors that look great on Android but jarring on iOS | Define a `commonMain` design system, then optionally adjust 2-3 tokens via `actual` | Cross-platform consistency is good, but iOS users notice when a Material blue feels alien on iPhone |
|
|
287
|
+
| `LaunchedEffect(Unit) { while(true) { delay(16); ... } }` in `commonMain` | `rememberInfiniteTransition()` or scope to lifecycle events | Tight coroutine loops drain battery on iOS; infinite transitions pause when offscreen |
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Quick Reference: Loading Sub-skills
|
|
292
|
+
|
|
293
|
+
| Need | Load |
|
|
294
|
+
|---|---|
|
|
295
|
+
| iOS / Android interop deep-dive | `references/cmp-interop.md` |
|
|
296
|
+
| Per-platform behavior catalog | `references/cmp-platform-quirks.md` |
|
|
297
|
+
| Animation API | `../compose-motion/SKILL.md` |
|
|
298
|
+
| Advanced graphics (M3 Expressive, AGSL on Android only) | `../compose-graphics/SKILL.md` |
|
|
299
|
+
| iOS-side native interop with SwiftUI | `../swiftui-motion/SKILL.md` (when target is iOS and SwiftUI native blend wanted) |
|
|
300
|
+
| Mobile UX context | `../mobile-principles/SKILL.md` |
|
|
301
|
+
| Desktop UX context | `../desktop-principles/SKILL.md` |
|
|
302
|
+
| Foundation | `../motion-principles/SKILL.md` |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Sources
|
|
307
|
+
|
|
308
|
+
- [Meet-Miyani/compose-skill](https://github.com/Meet-Miyani/compose-skill) (KMP/CMP comprehensive)
|
|
309
|
+
- [JetBrains Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/)
|
|
310
|
+
- [Compose Multiplatform docs](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-multiplatform.html)
|
|
311
|
+
- [skydoves/Orbital](https://github.com/skydoves/Orbital) (KMP-aware shared transitions)
|