{"id":3016,"date":"2023-01-12T12:00:43","date_gmt":"2023-01-12T20:00:43","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/surface-duo\/?p=3016"},"modified":"2023-01-12T01:47:17","modified_gmt":"2023-01-12T09:47:17","slug":"jetpack-compose-relay-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/surface-duo\/jetpack-compose-relay-1\/","title":{"rendered":"Pass the design baton with Relay"},"content":{"rendered":"<p>\n  Hello Compose developers,\n<\/p>\n<p>\n  Over the holidays, I finally got the chance to test out Relay, the new tool released by Google late last year. The goal of Relay is to simplify the \u201chandoff problem\u201d between designers and developers by translating Figma designs directly into Compose code.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1992\" height=\"1376\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-application-description.png\" class=\"wp-image-3017\" alt=\"Relay example UI elements\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-application-description.png 1992w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-application-description-300x207.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-application-description-1024x707.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-application-description-768x531.png 768w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-application-description-1536x1061.png 1536w\" sizes=\"(max-width: 1992px) 100vw, 1992px\" \/><br\/><em>Figure 1. Viewing the StatusCard and Chip UI packages with the Relay for Figma plugin.<\/em>\n<\/p>\n<p>\n  This week, I\u2019d like to share my experience with learning the tool and share some introductory resources. Since Relay is still in alpha, I\u2019m sure we\u2019ll see lots of updates this year, so I highly encourage you to <a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\">try it out<\/a> and <a href=\"https:\/\/goo.gle\/relay-feedback\">send the Relay team your feedback<\/a>!\n<\/p>\n<h2>Getting started with Relay<\/h2>\n<p>\n  Overall, I found that learning to use Relay was a very doable process. The <a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\">documentation<\/a> is thorough and contains several codelab-like tutorials:\n<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\/basic-tutorial\">Basic tutorial<\/a>\n  <\/li>\n<li><a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\/advanced-tutorial\">Advanced tutorial<\/a>\n  <\/li>\n<li><a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\/1-to-1-mapping\">1-1 mapping tutorial<\/a>\n  <\/li>\n<li><a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\/mapping-with-variants\">Mapping with variants tutorial<\/a>\n  <\/li>\n<\/ul>\n<p>\n  Each tutorial has download links for pre-made Figma files and Android Studio projects, which makes it really easy to focus on learning Relay concepts, instead of struggling with setup.\n<\/p>\n<p>\n  If you\u2019re exploring Relay as an option for your team, then I would encourage you to go through tutorials together as a designer\/developer duo! That way, both parties can learn what information is needed at different points in the process.\n<\/p>\n<p>\n  For more Relay introductory material, you can check out these resources:\n<\/p>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=NOfW1-ijKe4\">Building apps with Relay, Figma, and Jetpack Compose &#8211; YouTube<\/a>\n  <\/li>\n<li><a href=\"https:\/\/touchlab.co\/under-the-hood-of-relay\/\">Under the hood of Relay, Android Studio plugin for exporting Figma components to compose \u2013 Touchlab | Kotlin Multiplatform Mobile Development Experts<\/a>\n  <\/li>\n<li><a href=\"https:\/\/medium.com\/google-developer-experts\/a-foray-into-relay-a95a899fb85f\">A Foray into Relay. Relay is a new tool from Google to\u2026 | by Jamie Sanson | Google Developer Experts | Nov, 2022 | Medium<\/a>\n  <\/li>\n<\/ul>\n<h2>Relay workflow<\/h2>\n<p>\n  I won\u2019t go into too much detail, since the <a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\/relay\/install-relay\">documentation<\/a> explains everything well, but to use Relay, you need to install three main components:\n<\/p>\n<ol>\n<li><a href=\"https:\/\/www.figma.com\/community\/plugin\/1041056822461507786\">Relay for Figma plugin<\/a>\n<\/li>\n<li>\n  Relay for Android Studio plugin\n<\/li>\n<li>\n  Relay gradle plugin\n<\/li>\n<\/ol>\n<p>\n  Once you have these components set up, the workflow is as follows:\n<\/p>\n<ol>\n<li><strong>Figma<\/strong>: Create a component\n<\/li>\n<li><strong>Figma<\/strong>: Using the Relay for Figma plugin, create a UI package from your component\n<ol type=\"a\">\n<li>\n    Add parameters, descriptions, etc.\n  <\/li>\n<\/ol>\n<\/li>\n<li><strong>Figma<\/strong>: Save to version history\n<\/li>\n<li><strong>Figma<\/strong>: Copy link to Figma file\n<\/li>\n<li><strong>Android Studio<\/strong>: Import the UI package with the Relay for Android Studio plugin and Figma file link\n<ol type=\"a\">\n<li>\n    Import style, set up mappings, etc.\n  <\/li>\n<\/ol>\n<\/li>\n<li><strong>Android Studio<\/strong>: Build the project\n<\/li>\n<li><strong>Android Studio<\/strong>: Use the generated Compose code\n<\/li>\n<\/ol>\n<p>\n  When a UI package is imported into Android Studio, it will be stored under the <code>ui-packages<\/code> directory and contain all of the image and font assets you need, as well as JSON files describing the components from Figma. All of this UI package information is meant to be checked into source control.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"656\" height=\"578\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-text-chat-or-text-messa.png\" class=\"wp-image-3018\" alt=\"\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-text-chat-or-text-messa.png 656w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-text-chat-or-text-messa-300x264.png 300w\" sizes=\"(max-width: 656px) 100vw, 656px\" \/><br\/><em>Figure 2. The <code>ui-packages<\/code> directory is where assets and JSON files are stored.<\/em>\n<\/p>\n<p>\n  After building the project, Compose code will be created in the <code>java (generated)<\/code> directory. Even though this is Compose code, it is generated every time the project is built, so these files should NOT be checked into source control.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"647\" height=\"378\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-text-application-descr.png\" class=\"wp-image-3019\" alt=\"\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-text-application-descr.png 647w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2023\/01\/graphical-user-interface-text-application-descr-300x175.png 300w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><br\/><em>Figure 3. The <code>java (generated)<\/code> directory is where Compose code is generated after building the project.<\/em>\n<\/p>\n<p>\n  In the generated code, you can get a behind-the-scenes look at how Relay converts Figma properties to composables with different modifier attributes. If you\u2019re interested in learning more about Relay translation logic, I\u2019d recommend checking out the blog post <a href=\"https:\/\/touchlab.co\/under-the-hood-of-relay\/\">Under the hood of Relay, Android Studio plugin for exporting Figma components to compose<\/a>! The author goes into more depth about how UI package data is stored in JSON files, how Relay uses custom wrappers for all of the basic composables (Column, Text, Image, etc.), and how the generated code compares to writing composables from scratch.\n<\/p>\n<h2>More Relay content next week<\/h2>\n<p>\n  That&#8217;s all for this brief introduction to Relay! We hope you have a chance to start trying out Relay this week, because our next blog post will talk more in depth about Relay tips &amp; tricks and overall impressions from the developer point of view.\n<\/p>\n<p>\n  Since this will be a two-part Relay blog post, we won\u2019t be livestreaming this week, but stay tuned for next Friday when we\u2019ll stream about all things Relay \ud83d\ude0a \n<\/p>\n<h2>Feedback and resources<\/h2>\n<p>\n  To learn more about Relay, check out the <a href=\"https:\/\/developer.android.com\/jetpack\/compose\/tooling\">documentation<\/a>. You can also provide the Relay team with feedback in <a href=\"https:\/\/goo.gle\/relay-feedback\">Google\u2019s public issue tracker<\/a>.\n<\/p>\n<p>\n  If you have any questions, or would like to tell us about your apps, use the <a href=\"http:\/\/aka.ms\/SurfaceDuoSDK-Feedback\">feedback forum<\/a> or message us on <a href=\"https:\/\/twitter.com\/surfaceduodev\">Twitter @surfaceduodev<\/a>.\n<\/p>\n<p>\n Finally, you can check out the <a href=\"https:\/\/youtube.com\/c\/surfaceduodev\">livestream archives on YouTube<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Compose developers, Over the holidays, I finally got the chance to test out Relay, the new tool released by Google late last year. The goal of Relay is to simplify the \u201chandoff problem\u201d between designers and developers by translating Figma designs directly into Compose code. Figure 1. Viewing the StatusCard and Chip UI packages [&hellip;]<\/p>\n","protected":false},"author":72597,"featured_media":3017,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[710],"tags":[709,692],"class_list":["post-3016","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-surface-duo-design","tag-design","tag-jetpack-compose"],"acf":[],"blog_post_summary":"<p>Hello Compose developers, Over the holidays, I finally got the chance to test out Relay, the new tool released by Google late last year. The goal of Relay is to simplify the \u201chandoff problem\u201d between designers and developers by translating Figma designs directly into Compose code. Figure 1. Viewing the StatusCard and Chip UI packages [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/3016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/users\/72597"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/comments?post=3016"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/3016\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media\/3017"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media?parent=3016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/categories?post=3016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/tags?post=3016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}