<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Esther Carrelle Rangira on Medium]]></title>
        <description><![CDATA[Stories by Esther Carrelle Rangira on Medium]]></description>
        <link>https://medium.com/@esthcarelle?source=rss-7d681d57d670------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PtCSW68xpqjsaqglL9tS8A.jpeg</url>
            <title>Stories by Esther Carrelle Rangira on Medium</title>
            <link>https://medium.com/@esthcarelle?source=rss-7d681d57d670------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:54:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@esthcarelle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I Built an AI Travel Planner for Rwanda using Google AI Studio and It Changed How I Think About…]]></title>
            <link>https://medium.com/@esthcarelle/i-built-an-ai-travel-planner-for-rwanda-using-google-ai-studio-and-it-changed-how-i-think-about-7b7ff70a35cc?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b7ff70a35cc</guid>
            <category><![CDATA[visit-rwanda]]></category>
            <category><![CDATA[google-ai-studio]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 15:34:33 GMT</pubDate>
            <atom:updated>2026-07-19T15:34:33.063Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Built an AI Travel Planner for Rwanda using Google AI Studio and It Changed How I Think About Android Apps</h3><h3><strong>Introduction</strong></h3><p>Hello Peeps!</p><p>Long time, no Medium. 😅</p><p>I’ve been meaning to write for months, but life happened. Now that I’m back, I thought I’d come back with something that genuinely made me go, <strong>“Wait… that’s actually pretty cool.”</strong></p><p>Lately, I’ve been experimenting with AI coding tools. I’ve tried Cursor, I’ve tried Claude Code, and while they’re great, I always felt like I was playing ping-pong between the AI and Android Studio.</p><p>Copy.</p><p>Paste.</p><p>Go back.</p><p>“Oh wait… one more thing.”</p><p>And then we repeat. 😂</p><p>Then I tried <strong>Google AI Studio</strong>, and I was honestly surprised by how quickly I could go from <em>“I have an idea”</em> to <em>“Wait… I actually have an app that works.”</em></p><p>So today, let’s build an <strong>AI Travel Planner for Rwanda</strong> together.</p><p>Let‘ ’s start by opening <a href="https://aistudio.google.com/">https://aistudio.google.com/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFSeVLQL_Fikg4X1sNi28A.png" /></figure><p>Make sure <strong>“Build an Android App”</strong> is selected, then start with the following prompt:</p><blockquote>“Create a Kotlin Jetpack Compose Android app called ‘Visit Rwanda AI’. Screen 1: a text field for a travel request (destination, number of days, budget in USD) and a ‘Plan My Trip’ button. Screen 2: a results screen with a loading indicator and a space for a generated itinerary.”</blockquote><p>Now…Don’t panic if it takes a little while.</p><p>This is probably a good time to finally reply to that message you’ve been ignoring. 😅 (Sorry not sorry!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UiC6ot7uG60OLY-5fspKg.png" /></figure><p><strong>Choosing a design</strong></p><p>Once Gemini finishes generating the project, it gives you several UI themes to choose from, so you can pick the design you like best.</p><p>One thing I immediately noticed is that AI Studio’s generated Android apps already have Gemini configured server-side, which means you don’t have to manually handle API keys for this prototype.</p><p>No “Where do I put my API key?” moment.</p><p>No random Stack Overflow tab.</p><p>Just keep building.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dm_xTWlL4A2ndB0YKJ4tBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*woLqr75AgyF4VmmI1xFk3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6_lEll6R9DoVVfHwXaeiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMIm1BxFGvFbhDe6PLUMdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P0bF_b2iLQHs4r8M02LDZg.png" /></figure><p>Right now our app can generate an itinerary…</p><p>But honestly if I ask:<em>“What’s the weather like in Musanze today?”</em></p><p>Gemini isn’t secretly checking the skies over Rwanda. 😄</p><p>So let’s give it a little help.</p><p>Update the system instruction with:</p><blockquote>“You are an expert Rwanda travel planner. Given a destination, number of days, and budget in USD, generate a day-by-day itinerary.”</blockquote><p>This is much better but we’re not done yet.</p><p><strong>From chatbot to AI agent</strong></p><blockquote>“Refactor this into a TravelAgent that coordinates the user’s request, decides what information it needs, and produces the final itinerary.”</blockquote><p>I really liked this prompt because it completely changes the app’s personality. This is why you really need to know what you are prompting Gemini to do because it makes a huge difference</p><p>It’s no longer just talking.</p><p>It’s planning.</p><p><strong>Let’s give Gemini some superpowers</strong></p><p>We’ll give Gemini four tools:</p><ul><li>Weather</li><li>Budget estimation</li><li>Attractions</li><li>Packing list</li></ul><p>For the weather tool, we’ll use the Open-Meteo API, while the others can stay as mock data for now.</p><p>And the really cool part is that AI Studio writes the networking code, adds the <strong>INTERNET</strong> permission, and wires everything together.</p><p>I literally watched it happen and thought that was really time saving for me.</p><p>Let’s prompt it:</p><blockquote>“Add function calling with four tools: getWeather(city), estimateBudget(days, budgetUsd), getAttractions(city), getPackingList(weather). For getWeather, call the real Open-Meteo API: first geocode the city name using <a href="https://geocoding-api.open-meteo.com/v1/search?name=%7Bcity%7D">https://geocoding-api.open-meteo.com/v1/search?name={city}</a> to get latitude and longitude, then fetch current conditions from <a href="https://api.open-meteo.com/v1/forecast?latitude=%7Blat%7D&amp;longitude=%7Blon%7D&amp;current=temperature_2m,weathercode">https://api.open-meteo.com/v1/forecast?latitude={lat}&amp;longitude={lon}&amp;current=temperature_2m,weathercode</a>. Add the INTERNET permission if needed. If either call fails or times out, fall back to a hardcoded value instead of crashing. Use local mock data for the other three tools.”</blockquote><p><strong>My favorite feature</strong></p><p>This one genuinely impressed me.</p><p>Instead of opening the code and hunting for a composable…</p><p>You can literally click on something in the preview and say things like:</p><blockquote>“Make this card more rounded.”</blockquote><p>or</p><blockquote>“Replace this icon with a suitcase.”</blockquote><p>It really feels less like editing code… and more like giving design feedback to another developer.</p><p>Except that developer here never gets tired.</p><p>Let’s prompt it one more time to make our app look better.</p><blockquote>“Render the itinerary as Material 3 cards with icons for weather, budget, attractions, and packing, instead of raw text or JSON.”</blockquote><p><strong>Before we admire our masterpiece...</strong></p><p>Here are a few more things AI Studio can do:<br><strong>App Gallery / Prompt Gallery</strong> — a library of example apps and prompts you can browse and remix as starting points ,You can also explore the gallery to see what’s possible with the Gemini API, and remix apps to make them your own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZsiQ0jD9O9KbJBTUk38bg.png" /><figcaption>Gallery</figcaption></figure><p><strong>One-click Google Play publishing</strong> — for Android builds, you can publish straight to Google Play’s Internal Test Track through a linked developer accountOne-click publishing to Google Play’s Internal Test Track through linked Google Play Developer accounts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wy0TvvrV9nQg1xJwI0nyWA.png" /><figcaption>Publish to play store</figcaption></figure><p><strong>Cloud Run deployment / ZIP export</strong> — finished apps can be deployed to Cloud Run (key stays server-side automatically) or downloaded as a ZIP to host elsewhere, in which case you set the GEMINI_API_KEY yourself as an environment variable.</p><p><strong>API key management page</strong> — a dedicated section for creating, viewing, and restricting keys for use outside AI Studio-generated apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T8lst2iW-vzSasVt2_BVbg.png" /><figcaption>Secrets Keys</figcaption></figure><p><strong>And here’s the result 🎉</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*oL5KI3ar-m1xn1BcNttFfQ.gif" /><figcaption>Visit Rwanda AI App Demo</figcaption></figure><h3>Conclusion</h3><p>And that’s a wrap!</p><p>For me, the biggest takeaway wasn’t that AI can generate code (we’ve all seen that by now). It was mainly realizing how quickly I can go from an idea to a working prototype and spend more time improving the experience instead of writing repetitive boilerplate.</p><p>And as for the million-dollar question we all ask ourselves, will AI replace Android developers? I don’t think so.</p><p>Will it make us faster and help us experiment with ideas we might never have had time to build? Absolutely.</p><p>If you enjoyed this article, consider giving it a 👏 on Medium — it really helps more people discover it.</p><p>You can also connect with me on LinkedIn:<br> <a href="http://If you enjoyed this article, consider giving it a 👏 on Medium—it really helps more people discover it.  You can also connect with me on LinkedIn: 👉 https://www.linkedin.com/in/esther-carrelle-rangira/  I regularly share what I&#39;m building, what I&#39;m learning, and my adventures in Android development, AI, and the occasional conference talk. 😊  Until the next article... happy coding! 🚀"><strong>https://www.linkedin.com/in/esther-carrelle-rangira/</strong></a></p><p>I regularly share what I’m building, what I’m learning, and my adventures in Android development, AI, and the occasional conference talk. 😊</p><p>Until the next article… happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b7ff70a35cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Lists Scroll in Jetpack Compose: A Fun & Interactive Guide!]]></title>
            <link>https://medium.com/@esthcarelle/making-lists-scroll-in-jetpack-compose-a-fun-interactive-guide-94681be3a547?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/94681be3a547</guid>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 15:44:42 GMT</pubDate>
            <atom:updated>2025-09-12T15:44:42.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*cvO5T8_y6dIffQLVZbabJg.gif" /><figcaption>Scrolling List</figcaption></figure><p>Hi guys!!!!</p><p>Welcome back to a new episode of Learn Jetpack Compose with me.</p><p>Ever built a UI where your content just <strong>refuses</strong> to fit on the screen? 📱➡️🔥</p><p>Don’t worry — <strong>scrolling</strong> is here to save the day and Jetpack compose got our back! 🦸‍♂️</p><p>In this article, we’ll explore <strong>Jetpack Compose’s scrolling magic</strong>, from basic vertical lists to lazy-loaded performance beasts. And because learning should be <strong>fun</strong>, we’ll do it with GIFs, and interactive examples! 🎉</p><h3>🚀 Why Do We Need Scrolling?</h3><p>Imagine trying to display:</p><ul><li>A social media feed 📱</li><li>A long settings menu ⚙️</li><li>A book catalog 📚</li></ul><p><strong>Problem:</strong> Your phone screen is tiny, but your content is <strong>MASSIVE</strong>.<br><strong>Solution:</strong> <strong>Scroll it, scroll it!</strong> 🎯</p><h3>🔍 The Basics: verticalScroll &amp; horizontalScroll</h3><p>Jetpack Compose makes scrolling <strong>stupidly easy</strong>.</p><p>Let’s start by creating a new project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*EjiVmp6Cu1E0MU8wahAC4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*IhASmEejhuDWFs3zzKhv6w.png" /></figure><p>Let’s now add this block of code to our MainActivity:</p><pre>@Composable  <br>fun ScrollableList(modifier: Modifier) {  <br>    Column{  <br>        repeat(50) { index -&gt;  <br>            Text(&quot;Item $index&quot;, modifier = Modifier.padding(16.dp))  <br>        }  <br>    }  <br>}</pre><p>Let’s now replace the default Greeting composable with our ScrollableList in our MainActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*nucboNi8GGVVJNLoVWdaBA.png" /></figure><p>Let’s now run the app!!!!Yeaaahhhh!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*7S5xdEii-FmxjRRL2i6VAQ.png" /></figure><p>Okay, now that the app runs we have an issue, the list only stops to 13 yet we re displaying 50 elements, something is wrong!</p><h3>1️⃣ Vertical Scrolling (Column + verticalScroll)</h3><p>Let’s now add verticalScroll(rememberScrollState()) to our modifier.</p><pre>@Composable<br>fun ScrollableList(modifier: Modifier) {<br>    Column(modifier = modifier.verticalScroll(rememberScrollState())){<br>        repeat(50) { index -&gt;<br>            Text(&quot;Item $index&quot;, modifier = Modifier.padding(16.dp).fillMaxWidth())<br>        }<br>    }<br>}</pre><p><strong>What’s happening?</strong><br>✅ Column stacks items vertically.<br>✅ verticalScroll makes it scrollable.<br>✅ rememberScrollState() keeps track of scroll position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*cvO5T8_y6dIffQLVZbabJg.gif" /><figcaption>Vertical scroll</figcaption></figure><p><strong>Try it!</strong> 👇<br><em>(Imagine scrolling through 50 items like a boss.)</em></p><p><strong>Gotcha:</strong> If you dump <em>1000 items</em> here, your app will lag because <strong>it renders everything at once</strong>. (We’ll fix that soon.)</p><h3>2️⃣ Horizontal Scrolling :horizontalScroll (The “Netflix Carousel” Move)</h3><pre>@Composable<br>fun HorizontalList(modifier: Modifier) {<br>    Row(<br>        modifier = modifier.horizontalScroll(rememberScrollState())<br>    ) {<br>        repeat(20) { index -&gt;<br>            Card(modifier = Modifier.padding(8.dp)) {<br>                Text(&quot;Card $index&quot;, modifier = Modifier.padding(16.dp))<br>            }<br>        }<br>    }<br>}</pre><p><strong>Why use this?</strong><br>➡️ Perfect for <strong>image carousels</strong> 🖼️<br>➡️ Great for <strong>tabs or stories</strong> 📖</p><p><strong>Demo Time!</strong> <em>(Swipe right like Tinder! 💘)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*nKgbcLbBPc0wX1g-9gW87w.gif" /><figcaption>Horizontal scroll</figcaption></figure><p><strong>Pro Tip:</strong> Add flingBehavior for smoother scrolling:</p><pre>Modifier.horizontalScroll(<br>    state = rememberScrollState(),<br>    flingBehavior = ScrollableDefaults.flingBehavior()<br>)</pre><h3>⚡ Turbo Mode: LazyColumn &amp; LazyRow (The &quot;RecyclerView Killer&quot;)</h3><p><strong>Problem:</strong> What if you have <strong>THOUSANDS of items</strong>?<br><strong>Old Way:</strong> RecyclerView (XML, ViewHolders, Adapters… 😴)<br><strong>New Way:</strong> LazyColumn &amp; LazyRow (<strong>Jetpack Compose FTW!</strong>)</p><h3>🚀 LazyColumn (Vertical List)</h3><p>Let’s now add a new composable!</p><pre>@Composable<br>fun OptimizedList(modifier: Modifier) {<br>    LazyColumn(modifier = modifier) {<br>        items(1000) { index -&gt;<br>            Text(<br>                text = &quot;Optimized Item $index&quot;,<br>                modifier = Modifier.padding(16.dp)<br>            )<br>        }<br>    }<br>}</pre><p><strong>Why is this awesome?</strong><br>✅ <strong>Only composes visible items</strong> (no lag!)<br>✅ <strong>No ViewHolder nonsense</strong><br>✅ <strong>Smooth like butter</strong> 🧈</p><p><strong>Try scrolling — feel the SPEED!</strong> ⚡</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*sLJmUlXhfawYqS1PpR8zUg.gif" /><figcaption>Lazy Column</figcaption></figure><h3>🔄 LazyRow (Horizontal List)</h3><pre>@Composable<br>fun OptimizedRowList(modifier: Modifier){<br>    LazyRow(modifier = modifier) {<br>        items(50) { index -&gt;<br>            Card(modifier = Modifier.padding(8.dp)) {<br>                Text(&quot;Card $index&quot;, modifier = Modifier.padding(16.dp))<br>            }<br>        }<br>    }<br>}</pre><p><strong>Perfect for:</strong><br>📸 <strong>Photo galleries</strong><br>🎬 <strong>Netflix-style rows</strong></p><p><strong>Swipe left/right — so satisfying!</strong> 😍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*1Qh9vobkDnHSZRGC1LS2Fw.gif" /></figure><h3>Common Mistakes (And How to Avoid Them)</h3><h3>❌ Mistake 1: Using verticalScroll for Huge Lists</h3><ul><li><strong>Problem:</strong> Your app freezes because it’s rendering 10,000 items at once.</li><li><strong>Fix:</strong> Use LazyColumn instead.</li></ul><h3>❌ Mistake 2: Forgetting rememberScrollState()</h3><ul><li><strong>Problem:</strong> Scroll position resets when the screen recomposes.</li><li><strong>Fix:</strong> Always use rememberScrollState().</li></ul><h3>❌ Mistake 3: Nested Scrolls (The “Why Isn’t This Working?” Trap)</h3><ul><li><strong>Problem:</strong> You put a LazyColumn inside another LazyColumn, and scrolling gets weird.</li><li><strong>Fix:</strong> Use nestedScroll modifier or rethink your layout.</li></ul><h3>6. Quick Recap</h3><p>ScenarioSolution<strong>Small list (&lt;20 items)</strong>Column + verticalScroll<strong>Horizontal carousel</strong>Row + horizontalScroll<strong>Long lists (100+ items)</strong>LazyColumn / LazyRow<strong>Grid layouts</strong>LazyVerticalGrid (yes, it exists!)</p><h3>🚀 What’s Next?</h3><ul><li><strong>Try </strong><strong>LazyVerticalStaggeredGrid</strong> (Pinterest-style layouts!)</li><li><strong>Explore nested scrolling</strong> (Advanced but fun!)</li></ul><p><strong>Now go build something scroll-tastic!</strong> 🎢</p><p><em>(Drop a comment if you want a deep dive on any topic!)</em> 🚀</p><p><strong>Like this?</strong> ❤️ <strong>Follow me for more Jetpack Compose fun!</strong> 🚀</p><p><a href="https://github.com/esthcarelle/Scrollable-Compose">GitHub - esthcarelle/Scrollable-Compose</a></p><p>Feel free to follow me on medium and connect with Me on <a href="https://www.linkedin.com/in/esther-carrelle-rangira/">LinkedIn</a> and <a href="https://github.com/esthcarelle">Github</a> for More Insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94681be3a547" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuous Delivery for Android Using GitHub Actions: Effortless Android Testing, Building, and…]]></title>
            <link>https://medium.com/@esthcarelle/continuous-delivery-for-android-using-github-actions-effortless-android-testing-building-and-d3759ce66895?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3759ce66895</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[yaml]]></category>
            <category><![CDATA[build]]></category>
            <category><![CDATA[workflow]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Wed, 10 Apr 2024 15:38:39 GMT</pubDate>
            <atom:updated>2024-04-10T15:38:39.495Z</atom:updated>
            <content:encoded><![CDATA[<h3>Continuous Delivery for Android Using GitHub Actions: Effortless Android Testing, Building, and Signing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGQDZReW0cbCQZZ-20olIw.png" /><figcaption>CI/CD</figcaption></figure><p><strong>Introduction</strong></p><p>Hi Guyssssss!!!</p><p>We’re back with another dope topic!</p><p>GitHub Actions is GitHub’s platform for automation workflows.</p><p>A <strong>workflow</strong> is a sequence of jobs that can run either in series or in parallel. A job usually contains more than one step, where each step is a self-contained function.</p><p>In this article, you’ll use multiple first-party as well as third-party actions. To explore the different actions available, visit the <a href="https://github.com/marketplace?type=actions">GitHub Marketplace</a>.</p><h3>Creating a Workflow</h3><p>To add a new workflow, first, create a new directory with the path <strong>.github/workflows</strong> in the root of your project, either directly in your OS file system or by switching to the Project view in Android Studio. Then, create a file named <strong>check_and_deploy.yml</strong> in the <strong>workflows</strong> directory, as shown in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*ehE0RCQ8vlGC7NMAvkcETw.png" /><figcaption>Create yml file</figcaption></figure><p>All processes are written in YAML, a format often used in setup files. Remember, correct spacing is crucial in YAML, so stick to the spacing shown in the guide to ensure your processes function correctly.</p><h3>Running the Tests</h3><p>There are two ways you can run tests in your projects:</p><ol><li>Use the <strong>Run tests</strong> option inside Android Studio.</li><li>Run the <strong>Gradle</strong> task for the tests from the command line.</li></ol><p>To run tests on a remote machine, you have to go with the second option.</p><p>Run the following command from the command line to run the unit tests:</p><pre>./gradlew test</pre><p>After the tests run, you’ll see a screen like the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-INRCO6Mzo8glItTzpPgw.png" /></figure><p>For the instrumentation tests, you need to either start an emulator or connect a physical device. Once you’ve done that, run the following command to run the instrumentation tests:</p><pre>./gradlew connectedAndroidTest</pre><p>Ps: You need to have a connected device for it to run well!</p><p>Now that you know how to run the tests from the command line, let’s get started with the yml file, add the following code to <strong>check_and_deploy.yml</strong>:</p><pre>name: Test and deploy<br><br>on:<br>  push:<br>    tags:<br>      - &#39;v*&#39;<br>  pull_request:<br>    branches:<br>      - main<br><br>jobs:<br>  unit_tests:<br>    runs-on: [ubuntu-latest]<br>    steps:<br>      - uses: actions/checkout@v3<br>      - name: set up JDK<br>        uses: actions/setup-java@v3<br>        with:<br>          distribution: &#39;zulu&#39;<br>          java-version: 11<br>      - name: Unit tests<br>        run: ./gradlew testDebugUnitTest<br>  android_tests:<br>    runs-on: [ macos-12 ]<br>    steps:<br>      - uses: actions/checkout@v3<br>      - name: set up JDK<br>        uses: actions/setup-java@v3<br>        with:<br>          distribution: &#39;zulu&#39;<br>          java-version: 11<br>      - name: Instrumented Tests<br>        uses: reactivecircus/android-emulator-runner@v2<br>        with:<br>          api-level: 29<br>          script: ./gradlew connectedDebugAndroidTest</pre><p>The code above does a few things. It:</p><ol><li>Creates a workflow named <strong>Test and deploy</strong>.</li><li>Creates two parallel jobs named <strong>unit_tests</strong> and <strong>android_tests</strong>.</li><li>The <strong>unit_tests</strong> job runs on an <strong>ubuntu</strong> runner, which checks out the code and runs the unit tests.</li><li>The <strong>android_tests</strong> job runs on a macOS runner. This job also checks out the code, but runs the instrumentation tests instead. To do this, it uses the <strong>reactivecircus/android-emulator-runner</strong> action. The emulator can use hardware acceleration only on the macOS emulator. Therefore, this job needs to run on a macOS runner while others can run on Ubuntu runners.</li></ol><p>Next, you’ll see how to generate a secure release build on a remote system.</p><h3>Generating a Signed Release Build</h3><p>Generating a release build on a remote system is quite different from doing it locally. One of the main aspects is to make sure that the signing secrets remain secret.</p><h3>Creating a Keystore</h3><p>To sign your release build, you first need a keystore. If you haven’t generated a keystore for your apps yet, follow the documentation steps on how to <a href="https://developer.android.com/studio/publish/app-signing#generate-key">generate a signed key</a>. This guides you through the process of creating a new keystore.</p><h3>Storing Secrets</h3><p>For security’s sake, it’s important not to hard code secrets inside the codebase. A good way to avoid this is by using environment variables to refer to the secrets. GitHub Actions provides a similar mechanism.</p><p>Open your repository on GitHub and go to the <strong>Settings</strong> tab. On the left navigation bar, click <strong>Secrets</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HD7qLCCLeV4xSRV53rQ7w.png" /></figure><p>Click <strong>New repository secret</strong> and add the following four secrets:</p><ol><li><strong>ALIAS</strong>: Alias of your signing key.</li><li><strong>KEY_STORE_PASSWORD</strong>: The password to your signing keystore.</li><li><strong>KEY_PASSWORD</strong>: The private key password for your signing keystore.</li><li><strong>SIGNING_KEY</strong>: The base 64-encoded signing key used to sign your app.</li></ol><p>The first 3 keys will be generated once you generate your keystore, to generate the <strong>SIGNING_KEY(</strong> base 64-encoded key), run the following command in Terminal and copy the output string:</p><pre>openssl base64 &lt; path_to_signing_key | tr -d &#39;\n&#39; | tee some_signing_key.jks.base64.txt</pre><p>In the code above, replace <strong>path_to_signing_key</strong> with the actual path to your keystore.</p><p>Mine looks like this:</p><pre>openssl base64 &lt; /home/carrelle/key.jks | tr -d &#39;\n&#39; | tee key.jks.base64.txt</pre><h3>Signing the Build</h3><p>Add a new job named build to the workflow, indented below the jobs tag as shown below:</p><pre>build:<br>    needs: [unit_tests, android_tests]<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3<br>      - name: set up JDK<br>        uses: actions/setup-java@v3<br>        with:<br>          distribution: &#39;zulu&#39;<br>          java-version: 11<br>      - name: Generate Release APK<br>        run: ./gradlew assembleRelease<br>      - name: Sign APK<br>        uses: ilharp/sign-android-release@v1<br>        # ID used to access action output<br>        id: sign_app<br>        with:<br>          releaseDir: app/build/outputs/apk/release<br>          signingKey: ${{ secrets.SIGNING_KEY }}<br>          keyAlias: ${{ secrets.ALIAS }}<br>          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}<br>          keyPassword: ${{ secrets.KEY_PASSWORD }}<br>          buildToolsVersion: 33.0.0<br>      - uses: actions/upload-artifact@v3<br>        with:<br>          name: release.apk<br>          path: ${{steps.sign_app.outputs.signedFile}}<br>      - uses: actions/upload-artifact@v3<br>        with:<br>          name: mapping.txt<br>          path: app/build/outputs/mapping/release/mapping.txt</pre><p>In the code above, the build job performs multiple steps. It:</p><ol><li>Checks out the code.</li><li>Generates a release APK using the assembleRelease Gradle task.</li><li>Signs the APK using the <strong>r0adkll/sign-android-release</strong> action, which is a third party action available on the github marketplace linked earlier. This step uses the four secrets you added in the previous section. It also has an ID: <strong>sign_app</strong>.</li><li>Uploads the signed APK as an artifact to GitHub. This step uses the ID from the previous step to access its output, named signedReleaseFile.</li><li>Uploads the mapping file as an artifact. You’ll use this in a later step, when you upload to the Play Store.</li></ol><p>Commit the file to your project and push it to GitHub. Open the GitHub repository and go to the <strong>Actions</strong> tab. You’ll see that a workflow named <strong>Test and deploy</strong> is running. Wait for a few minutes and the workflow should complete successfully:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*M7oWga3c0nXvcAY7m64E_A.png" /></figure><p><em>PS: If you’re using a Windows machine, you may need to change the </em><em>gradlew file permissions such that they can executed. If your action fails with a permission error, run the following command to set the </em><em>gradlew file as executable: </em><em>git update-index --chmod=+x gradlew</em></p><p>Congrats, you’ve completed the first part of your continuous delivery pipeline.</p><p>Here is a link to the Github project used for this article:</p><p><a href="https://github.com/esthcarelle/Quote">Quote Github Project</a></p><p><strong>Conclusion</strong></p><p>This was the first part of a series of 2 articles, stay Tuned for Part 2: Unlocking Firebase Testing and Play Store Deployment with Git Actions!</p><p>Feel free to follow me on medium and connect with Me on <a href="https://www.linkedin.com/in/esther-carrelle-rangira/">LinkedIn</a> and <a href="https://github.com/esthcarelle">Github</a> for More Insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3759ce66895" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Alert Dialog with Jetpack compose: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@esthcarelle/alert-dialog-with-jetpack-compose-a-step-by-step-guide-04dc3e9dfc1d?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/04dc3e9dfc1d</guid>
            <category><![CDATA[alert-dialog-android]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 14:21:06 GMT</pubDate>
            <atom:updated>2024-03-15T14:21:06.028Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*YZ4f9YG7RmqxffE-mzph5A.png" /></figure><h3><strong>Introduction</strong></h3><p><em>Dialogs</em> are used to alert the user about an action, or to request confirmation. For example, you can use a dialog to confirm whether the user wants to delete an item, request they rate the app and so on. They are very common in apps, and are used across all operating systems — not just Android!</p><p>In this step-by-step guide, we’ll explore how to build an <em>Alert Dialog</em> using <em>Jetpack Compose</em>. We’ll delve into the core concepts of Compose, leverage its powerful declarative syntax, and harness the flexibility it offers to customize.</p><p>Whether you’re new to Compose or looking to enhance your UI skills, this tutorial will provide you with the knowledge and confidence to create an engaging <em>Alert Dialog</em> that elevate the user experience of your Android applications. Here are some screenshots about what we need to achieve:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*wzTsss0ige4V2caeQtp7gA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*XJdQsVPFvdVjUbn5YOZucw.jpeg" /></figure><p>Step 1: Create an Android Studio Project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*tPLbXfbBldebSdHWyxRyOA.png" /><figcaption>Create Android Studio Project</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*ntzZpsKs2qn2GaKIiUmKeA.png" /></figure><p>We are now all setup and ready to staaaart!!</p><h3>Implementation</h3><p>To implement an Alert Dialog, create <strong>AlertDialogScreen.kt</strong> file and add code inside MyAlertDialog :</p><pre><br>@Composable<br>fun MyAlertDialog(shouldShowDialog: MutableState&lt;Boolean&gt;) {<br>    if (shouldShowDialog.value) { // 2<br>        AlertDialog( // 3<br>            onDismissRequest = { // 4<br>                shouldShowDialog.value = false<br>            },<br>            // 5<br>            title = { Text(text = &quot;Alert Dialog&quot;) },<br>            text = { Text(text = &quot;Jetpack Compose Alert Dialog&quot;) },<br>            confirmButton = { // 6<br>                Button(<br>                    onClick = {<br>                        shouldShowDialog.value = false<br>                    }<br>                ) {<br>                    Text(<br>                        text = &quot;Confirm&quot;,<br>                        color = Color.White<br>                    )<br>                }<br>            }<br>        )<br>    }<br>}</pre><p>That is a lot of code you had to add, but it’s mostly using components you’ve previously encountered. Let’s go through it step-by-step:</p><ol><li>You add a state representing whether to show the dialog or not, and sets the initial state to true.</li><li>Using an if statement, you add logic to display the AlertDialog only if the state value is true. Because Compose renders the UI by calling functions, if the value is false, it won’t call the function — and in turn, it won’t display the dialog!</li><li>Using AlertDialog(), you create your dialog, which has a title, a text message, a <strong>dismiss request handler</strong>, and a confirmButton().</li><li>In onDismissRequest, you change the state of the dialog to dismiss it.</li><li>You set the title and text as two Text()s and use the appropriate texts to fill it.</li><li>Finally, you add a Button() as the confirmButton. Clicking the button dismisses the dialog and navigates to the main navigation screen, just like in onDismissRequest(). You add a Text() to display the text inside the button with a white color and a predefined string resource.</li></ol><p>We still need to show the dialog once we click on show button, let’s create the button and its implementation.</p><pre>@Composable<br>fun MainScreen() {<br>    val shouldShowDialog = remember { mutableStateOf(false) } // 1<br><br>    if (shouldShowDialog.value) {<br>        MyAlertDialog(shouldShowDialog = shouldShowDialog)<br>    }<br><br>    Button(<br>        onClick = { shouldShowDialog.value = true },<br>        modifier = Modifier.wrapContentSize()<br>    ) {<br>        Text(text = &quot;Show Dialog&quot;)<br>    }<br>}</pre><p>Here’s an explanation of what the code does:</p><ol><li>val shouldShowDialog = remember { mutableStateOf(false) }: This line defines a mutableStateOf variable called shouldShowDialog, initialized with a value of false. This variable is used to control the visibility of the dialog. The remember function is used to make the state remember its value across recompositions.</li><li>if (shouldShowDialog.value) { MyAlertDialog(shouldShowDialog = shouldShowDialog) }: This checks whether the value of shouldShowDialog is true. If it is, it calls the MyAlertDialog composable function to show the dialog. The shouldShowDialog state is passed as a parameter to MyAlertDialog so that it can update the state when the dialog is dismissed.</li><li>Button(onClick = { shouldShowDialog.value = true }, modifier = Modifier.wrapContentSize()) { Text(text = &quot;Show Dialog&quot;) }: This code defines a Button composable. When the button is clicked, it sets the value of shouldShowDialog to true, which triggers the display of the dialog. The button displays the text &quot;Show Dialog&quot;.</li></ol><blockquote>Let’s now call our MainScreen() composable in the MainActivity class and let’s run the project.</blockquote><p>Upon clicking on “Show Dialog” button ,an alert dialog automatically appears. It has a basic title and the text you set. Clicking outside the dialog or inside the confirm button dismisses the dialog and returns you to the previous screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*wzTsss0ige4V2caeQtp7gA.jpeg" /></figure><p>Implementing the alert dialog might have looked complicated due to the code size, but most of the code only dealt with styling the alert and handling click events.</p><p>Dialogs are easy to create in Jetpack Compose, but keep in mind that you have to handle the state, which requires more effort when you want to reuse dialogs on multiple screens.</p><h4>Exploring AlertDialog</h4><p>It’s important to note that the AlertDialog composable you used comes from the androidx.compose.material package, meaning, it is built using the Material Design specs. There are several types of dialogs but the most common type is the AlertDialog you used, so open its signature to see what it can do:</p><pre>@Composable<br>fun AlertDialog(<br>  onDismissRequest: () -&gt; Unit,<br>  confirmButton: @Composable () -&gt; Unit,<br>  modifier: Modifier = Modifier,<br>  dismissButton: @Composable (() -&gt; Unit)? = null,<br>  title: @Composable (() -&gt; Unit)? = null,<br>  text: @Composable (() -&gt; Unit)? = null,<br>  shape: Shape = MaterialTheme.shapes.medium,<br>  backgroundColor: Color = MaterialTheme.colors.surface,<br>  contentColor: Color = contentColorFor(backgroundColor),<br>  properties: DialogProperties = DialogProperties()<br>)</pre><p>There are new parameters to go through here:</p><ul><li><strong>onDismissRequest</strong>: Executes when a user clicks outside the dialog or presses the <strong>Back</strong> button.</li><li><strong>confirmButton</strong>: A button that confirms a proposed action. It’s usually a TextButton.</li><li><strong>dismissButton</strong>: This button dismisses an action. It’s also usually a TextButton.</li><li><strong>title</strong>: Sets the title text with a composable function.</li><li><strong>text</strong>: Sets the text inside the dialog with a composable function.</li><li><strong>contentColor</strong>: The color used by elements within the AlertDialog.</li><li><strong>properties</strong>: Platform-specific properties for further customization.</li></ul><p><strong>Conclusion</strong></p><p>We have successfully implemented an Alert Dialog and this is the power of Jetpack Compose, it abstracts away the unnecessary complexity and lets you focus on the important bits.</p><p>I have published other articles about jetpack compose and how to harness this capability even further to build more complex screens and UIs.</p><p>I hope this article has given you a brief introduction of how to implement an Alert Dialog with Jetpack Compose. If you have any questions, please feel free to reach out to me.</p><p>Here is the link to the Github repository:</p><p><a href="https://github.com/esthcarelle/Alert_Dialog">GitHub - esthcarelle/Alert_Dialog</a></p><p>Sources</p><p><a href="https://developer.android.com/jetpack/compose/components/dialog">Dialog | Jetpack Compose | Android Developers</a></p><p><a href="https://www.kodeco.com/books/jetpack-compose-by-tutorials/v2.0/chapters/2-learning-jetpack-compose-fundamentals#toc-chapter-008-anchor-008">https://www.kodeco.com/books/jetpack-compose-by-tutorials/v2.0/chapters/2-learning-jetpack-compose-fundamentals#toc-chapter-008-anchor-008</a></p><p>Here is my LinkedIn account:</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p>Github account:</p><p><a href="https://github.com/esthcarelle/">esthcarelle - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04dc3e9dfc1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jetpack Compose Basics: Discovering the Fun of Boxes and Surfaces]]></title>
            <link>https://medium.com/@esthcarelle/jetpack-compose-basics-discovering-the-fun-of-boxes-and-surfaces-6cea0dc7b950?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cea0dc7b950</guid>
            <category><![CDATA[box]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[surface]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Sat, 27 Jan 2024 19:59:13 GMT</pubDate>
            <atom:updated>2024-01-27T19:59:13.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*DUKlfzyBrOiwe6jx1XgxSg.png" /></figure><h3>Introduction</h3><p>Hey there! Ever wondered how to make cool stuff with Jetpack Compose? Well, your girl got you covered! In this article, we’re going to explore two things called Boxes and Surfaces. They’re like the superhero tools for creating awesome-looking screens. We’ll break down what they do and show you how to use them with some easy examples. So, if you’re ready for some UI magic, let’s dive in together! 🚀✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*fcbuMFVpjb9C4c8jfq8f6w.jpeg" /></figure><h3>Using Boxes</h3><blockquote>The Box is like the FrameLayout’s counterpart in composing UIs. Just as the FrameLayout, it helps in placing elements relative to their parent’s edges and allows you to stack them up. This comes in handy when you want elements to show up in certain spots or when dealing with elements that need to overlap, like dialogs.</blockquote><p>Here is an example:</p><pre>@Composable<br>fun MyBox(<br>  modifier: Modifier = Modifier,<br>  contentModifier: Modifier = Modifier<br>) {<br>  Box(modifier = modifier.fillMaxSize()) {<br>    Text(<br>      text = &quot;first&quot;,<br>      fontSize = 22.sp,<br>      modifier = contentModifier.align(Alignment.TopStart)<br>    )<br><br>    Text(<br>      text = &quot;second&quot;,<br>      fontSize = 22.sp,<br>      modifier = contentModifier.align(Alignment.Center)<br>    )<br><br>    Text(<br>      text = &quot;third&quot;,<br>      fontSize = 22.sp,<br>      modifier = contentModifier.align(Alignment.BottomEnd)<br>    )<br>  }<br>}</pre><p>Hold on to your coding cap! This function is like a cool DJ with two rockstar friends — meet the modifier and contentModifier! 🎧 By default, they’re chillin’ with Modifier, the empty modifier guru. Now, here’s the fun part — you can invite custom modifiers to the party, changing how the parent Box or each content piece struts its stuff. It’s like giving your UI a makeover!</p><p>And guess what? The fun doesn’t stop there! Each element can throw a modifier function call after another, adding more bling to the customization party. 🕺 Imagine passing in a custom modifier that throws a bit of padding or stylish flair to the parent modifier. It’s like fashion for your app, and you get to reuse those custom styles everywhere! Plus, the end component adds a splash of extra customization — it’s the app’s way of saying, “I’m unique, baby!”</p><p>And just when you thought it couldn’t get better, you can pull the same stunt for content-based modifiers. 🎉 Here, the Box() is the party venue with three text fields strutting their stuff. Using the align modifier, they’re like dance pros grooving in three different hotspots on the screen. Talk about a UI dance floor that knows how to move! 💃🕺</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*2lRH1JyEppEdUIhzt5IgAA.png" /></figure><p>Let’s stop the party here and let’s get serious!</p><p>The text fields appear diagonally across the screen, with the first one at the top-left corner, the second one in the center and the last one at the bottom-right corner.</p><p>Using a Box is really useful in specific situations, and they make positioning elements incredibly easy.</p><h3>Let’s explore Boxes</h3><p>When you have multiple children inside a Box, they’re rendered in the same order as you placed them inside the Box. Here’s the implementation:</p><pre>@Composable<br>fun Box(<br>  modifier: Modifier = Modifier,<br>  contentAlignment: Alignment = Alignment.TopStart,<br>  propagateMinConstraints: Boolean = false,<br>  content: @Composable BoxScope.() -&gt; Unit<br>)</pre><p>contentAlignment allows you to set the default Alignment to its children. If you want to have different Alignments between each child, you need to set Alignment by using Modifier.align() on a child.</p><p>propagateMinConstraints defines if the minimal constraints should be passed and used for the content too. By default, the constraints of the Box() won’t be taken into account when measuring the children.</p><p>You can set the Alignment to any edge of the screen as well as in relation to the center, using any of the following types of alignment:</p><ul><li><strong>TopStart</strong></li><li><strong>TopCenter</strong></li><li><strong>TopEnd</strong></li><li><strong>CenterStart</strong></li><li><strong>Center</strong></li><li><strong>CenterEnd</strong></li><li><strong>BottomStart</strong></li><li><strong>BottomCenter</strong></li><li><strong>BottomEnd</strong></li></ul><p>Where each of the alignments refers to which part of the screen the Box will attach an item to.</p><h3>Surfaces</h3><p>Surface is a new layout that serves as a central metaphor in <strong>Material Design</strong>. What’s unique about Surface is it can only hold one child at a time, but it provides many style treatments for the content of its children, such as the elevation, border and more.</p><pre>@Composable<br>fun SurfaceScreen(modifier: Modifier = Modifier) {<br><br>  Box(modifier = modifier.fillMaxSize()) {<br>    MySurface(modifier = modifier.align(Alignment.Center))<br>  }<br>}<br><br>@Composable<br>fun MySurface(modifier: Modifier) {<br>  //TODO write your code here<br>}</pre><p>To show all that the Surface can do, the example is set inside a full-screen Box() and an Alignment.Center. All that’s left is to implement the empty MySurface(). To do this, add the following code to finish it:</p><pre>@Composable<br>fun MySurface(modifier: Modifier) {<br>  Surface(<br>      modifier = modifier.size(100.dp), // 1<br>      color = Color.LightGray, // 2<br>      contentColor = colorResource(id = R.color.colorPrimary), // 2<br>      elevation = 1.dp, // 3<br>      border = BorderStroke(1.dp, Color.Black) // 4<br>  ) {<br>    MyColumn() // 5<br>  }<br>}</pre><p>There are many small steps in this code, so go over them one by one:</p><ol><li>You first set the size of the surface to 100dp in both height and width using Modifier.size().</li><li>Then you set the color of the surface to Color.LightGray and the color of its content to colorPrimary. The surface will be gray, and Surface will set the contentColor to all the elements it applies to—such as Text elements.</li><li>You add an elevation of 1dp to raise the Surface above other elements.</li><li>You also add a black border to outline the Surface.</li><li>Finally, you set the child to the Surface to be the MyColumn() you defined earlier.</li></ol><p>This is a perfect example of the power of Jetpack Compose. You can <strong>reuse</strong> each of the screens and composable functions you implemented before. This time, you reused MyColumn(), with three vertical Text elements.</p><p>Build and run and select <strong>Surface</strong> from the navigation menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*uLbnc4zECueuC1BaGdbXFQ.png" /></figure><h3>Let’s explore Surfaces</h3><p>To see what else a Surface() has to offer, open its signature:</p><pre>@Composable<br>fun Surface(<br>    modifier: Modifier = Modifier,<br>    shape: Shape = RectangleShape,<br>    color: Color = MaterialTheme.colors.surface,<br>    contentColor: Color = contentColorFor(color),<br>    border: BorderStroke? = null,<br>    elevation: Dp = 0.dp,<br>    content: @Composable () -&gt; Unit<br>)</pre><p>These parameters define Surface’s purpose. There are five purposes in total:</p><ul><li><strong>Shape</strong>: Clips the children with the defined shape.</li><li><strong>Color</strong>: Fills the shape with a color you define.</li><li><strong>Border</strong>: Draws borders, if they’re set.</li><li><strong>Elevation</strong>: Sets the elevation and draws an appropriate shadow.</li><li><strong>Content</strong>: Sets the default color for its content with the defined contentColor.</li></ul><p>The most common way to use a Surface is as the root layout of your components. Since it can hold only one child, that child is usually another layout that positions the rest of the elements. The Surface() doesn’t handle positioning—its child does.</p><p><strong><em>Note</em></strong><em>: There’s a popular custom </em><em>Surface implementation called </em><em>Card. A </em><em>Card has exactly the same five purposes and can only hold one child. The only difference between the </em><em>Card and a </em><em>Surface are its default parameters. A </em><em>Card has a predefined elevation and uses a material theme shape with rounded corners.</em></p><p><strong>Conclusion</strong></p><p>Mastering Boxes and Surfaces in Jetpack Compose opens up a world of possibilities for creating dynamic and visually appealing UIs. As you continue your journey with Jetpack Compose,. stay tuned for more insights into the evolving landscape of Jetpack Compose!</p><p>I appreciate you taking the time to read this. If you found it helpful, please consider giving it a thumbs-up and following me.</p><p>LinkedIn:</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p>Github:</p><p><a href="https://www.github.com/esthcarelle">esthcarelle - Overview</a></p><p>If you want to read more about this, here is a link to the official android documentation:</p><p><a href="https://developer.android.com/jetpack/compose/layouts/basics">Compose layout basics | Jetpack Compose | Android Developers</a></p><p>Here’s an additional link to a comprehensive course:</p><p><a href="https://www.kodeco.com/books/jetpack-compose-by-tutorials/">Jetpack Compose by Tutorials</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cea0dc7b950" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jetpack Compose Layouts: Crafting with Column and Row]]></title>
            <link>https://medium.com/@esthcarelle/jetpack-compose-layouts-crafting-with-column-and-row-117d51761d63?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/117d51761d63</guid>
            <category><![CDATA[layout]]></category>
            <category><![CDATA[jetpack-compose-tutorial]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 16:13:36 GMT</pubDate>
            <atom:updated>2023-10-22T16:13:36.925Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*G5uQS1w0vfDPCCzDFLvXFg.png" /></figure><p>In this article, you will delve into the world of layouts in Jetpack Compose. These layouts serve as the foundation for structuring and arranging UI elements in your app. You will learn how to select the right layout for your needs and position the elements effectively.</p><h3>The Role of Layouts</h3><p>In our previous article with Jetpack Compose, we focused on creating individual UI elements. Now, it’s time to master the art of arranging these elements effectively. Think of layouts as the canvases on which you’ll artfully position your UI components.</p><h3>Layouts in Jetpack Compose</h3><p>In the realm of Jetpack Compose, the concept of a ViewGroup in the traditional Android world finds its equivalent in the Layout. Layout is the new kingpin when it comes to arranging your composable functions. Take a look at the core components of Layout:</p><pre>@Composable inline fun Layout(<br>  content: @Composable () -&gt; Unit,<br>  modifier: Modifier = Modifier,<br>  measurePolicy: MeasurePolicy<br>)</pre><p>The essential components are content, where you nest your composable functions, and measurePolicy, which dictates how the layout behaves when measuring and arranging the children.</p><h3>Row</h3><p>When you think of basic layouts, it’s hard not to reminisce about the trusty LinearLayout. Its Compose counterpart is Row. Row allows you to arrange elements horizontally. Here&#39;s how to use it:</p><pre>@Composable<br>fun MyRow() {<br>  Row(<br>    artist = Artist,<br>    modifier = Modifier.fillMaxSize()<br>  ) {<br>    // Your elements go here<br>       Row(verticalAlignment = Alignment.CenterVertically) {<br>        Image(bitmap = artist.image, contentDescription = &quot;Artist image&quot;)<br>        Column {<br>            Text(artist.name)<br>            Text(artist.lastSeenOnline)<br>        }<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*K18_r8gSrDgB7VeCJHV2cw.png" /></figure><p>In this example, you’ve created a Row with specific alignment, arrangement, and sizing parameters to ensure your elements are perfectly placed.</p><h3>Deeper Dive into Rows</h3><pre>@Composable<br>inline fun Row(<br>    modifier: Modifier = Modifier,<br>    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,<br>    verticalAlignment: Alignment.Vertical = Alignment.Top,<br>    content: @Composable RowScope.() -&gt; Unit<br>)</pre><p>horizontalArrangement and verticalAlignment are your allies in controlling how the children align and arrange within the Row. You can choose from various arrangement options such as SpaceBetween, SpaceEvenly, SpaceAround, Center, Start, or End (I ‘ll explain more about these later in this article).</p><h3>Weighting the Elements</h3><p>Another powerful technique in composing your UI is using weights. You can define the weight of a child element using the weight() modifier. For example:</p><pre>@Composable<br>fun RowScope.MyRow() {<br>   Text(<br>     modifier = Modifier.weight(1 / 3f),<br>     // Other attributes here<br>   )<br>}</pre><p>By assigning weights, you control how much of the parent’s space each child occupies, creating flexible and responsive layouts.</p><h3>Columns</h3><p>If you’re dealing with a vertical arrangement, the Column comes to your rescue. Much like Row, it allows you to stack elements vertically. Here&#39;s a snippet of how to use it:</p><pre>@Composable<br>fun MyColumn() {<br>  Column(<br>    modifier = Modifier.fillMaxSize()<br>  ) {<br>    // Your elements go here<br>       Text(&quot;Alfred Sisley&quot;)<br>       Text(&quot;3 minutes ago&quot;)<br><br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Uohfdb3z4u1ylO5qy4NONg.png" /></figure><p>To fully understand the capabilities of a Column, let&#39;s peek into its signature:</p><pre>@Composable<br>inline fun Column(<br>  modifier: Modifier = Modifier,<br>  verticalArrangement: Arrangement.Vertical = Arrangement.Top,<br>  horizontalAlignment: Alignment.Horizontal = Alignment.Start,<br>  content: @Composable ColumnScope.() -&gt; Unit<br>)</pre><p>The available parameters are similar to Row, but you adjust them to work with vertical arrangements. Vertical arrangements include options like Top, CenterVertically, and Bottom.</p><p>As we mentioned it earlier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*AcweX3i0odfh9hJp2kI6hA.gif" /><figcaption>Column alignment</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*F0263XxPbXpoA9XdVL2mIw.gif" /><figcaption>Row alignment</figcaption></figure><ol><li>SpaceBetween:</li></ol><ul><li>In a Row, this option aligns the elements horizontally and places equal space between them. It pushes the first element to the start edge of the Row, the last element to the end edge, and distributes the remaining space evenly between the elements.</li><li>In a Column, it aligns the elements vertically and places equal space between them.</li></ul><p>2. SpaceEvenly:</p><ul><li>This arrangement option also ensures that space is distributed evenly between the elements, both horizontally and vertically, similar to SpaceBetween.</li><li>However, unlike SpaceBetween, SpaceEvenly adds equal spacing to the start and end edges of the layout, resulting in a consistent margin around the entire layout.</li></ul><p>3. SpaceAround:</p><ul><li>SpaceAround adds space evenly around each element, as well as at the start and end of the layout.</li><li>In a Row, it places equal space between elements and ensures there&#39;s space at the start and end.</li><li>In a Column, it aligns elements vertically with equal spacing and adds space above the first element and below the last element.</li></ul><p>4. Center:</p><ul><li>When using Center, the elements are aligned so that they are centered both horizontally and vertically in the layout.</li><li>In a Row, elements are centered horizontally with equal space at the start and end.</li><li>In a Column, elements are centered vertically with equal space above and below.</li></ul><p>5. Start:</p><ul><li>Start aligns elements to the start edge of the layout, either horizontally in a Row or vertically in a Column.</li><li>In a Row, it pushes elements to the start edge with no extra space at the start.</li><li>In a Column, it aligns elements to the top with no extra space at the top.</li></ul><p>6. End:</p><ul><li>End aligns elements to the end edge of the layout, either horizontally in a Row or vertically in a Column.</li><li>In a Row, it pushes elements to the end edge with no extra space at the end.</li><li>In a Column, it aligns elements to the bottom with no extra space at the bottom.</li></ul><h3>Let’s deep dive into columns</h3><p>To fully understand the capabilities of a Column, let&#39;s peek into its signature:</p><pre>@Composable<br>inline fun Column(<br>  modifier: Modifier = Modifier,<br>  verticalArrangement: Arrangement.Vertical = Arrangement.Top,<br>  horizontalAlignment: Alignment.Horizontal = Alignment.Start,<br>  content: @Composable ColumnScope.() -&gt; Unit<br>)</pre><p>The available parameters are similar to Row, but you adjust them to work with vertical arrangements. Vertical arrangements include options like Top, CenterVertically, and Bottom</p><h3>Conclusion</h3><p>In this article, you’ve learned how to harness the power of layouts in Jetpack Compose. Layouts are the foundation for organizing and positioning your UI elements. By utilizing the right layout and customizing its parameters, you can create visually appealing and functional interfaces.</p><p>We will deep dive into Box,Surface and Scaffold in the next article.</p><p>I appreciate you taking the time to read this. If you found it helpful, please consider giving it a thumbs-up and following me.</p><p>LinkedIn:</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p>Github:</p><p><a href="https://github.com/esthcarelle">esthcarelle - Overview</a></p><p>If you want to read more about this, here is a link to the official android documentation:</p><p><a href="https://developer.android.com/jetpack/compose/layouts">Layouts in Compose | Jetpack Compose | Android Developers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=117d51761d63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding remember and rememberSaveable in Jetpack Compose with Kotlin]]></title>
            <link>https://medium.com/@esthcarelle/understanding-remember-and-remembersaveable-in-jetpack-compose-with-kotlin-58005b10cce6?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/58005b10cce6</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 18:44:33 GMT</pubDate>
            <atom:updated>2023-09-24T18:44:33.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UCc3d5o9dHwvE7-wTRu2Mg.png" /></figure><h3>Introduction</h3><p>In the realm of Android app development, Jetpack Compose has emerged as a powerful tool for creating modern, responsive user interfaces. Within Jetpack Compose, there are two essential concepts that play a crucial role in managing state and preserving data across different scenarios: remember and rememberSaveable.</p><p>In this article, we&#39;ll delve into the differences between these two functions, exploring their significance in the world of Jetpack Compose.</p><p><strong>Section 1: remember — State Management in Composables</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pecDY_XPnUFqzMygIP3EMg.jpeg" /></figure><p>At its core, remember is a function designed to store a value that should persist across recompositions of a composable function. In essence, it allows you to remember a value, ensuring it&#39;s not recalculated unless its dependencies change.</p><p><strong>Example</strong>: Consider a simple counter app. We can use remember to store the count, and it will only be recomputed when the button is clicked.</p><pre>var count by remember { mutableStateOf(0) }<br><br>Text(&quot;Remember Example: $count&quot;)<br><br>Button(<br>    onClick = { count++ }<br>) {<br>    Text(text = &quot;Increment Count&quot;)<br>}</pre><p><strong>Section 2: rememberSaveable — Preserving State Across Configurations</strong></p><p>On the other hand, rememberSaveable takes state preservation to the next level. It&#39;s particularly useful when you want to retain a piece of state even when the app undergoes configuration changes, such as screen rotations.</p><p>Example: Imagine an app with a counter like the one above. By using rememberSaveable, the count will be saved and restored automatically across screen rotations, providing a seamless user experience.</p><pre>val savedCount by rememberSaveable { mutableStateOf(0) }<br><br>Text(&quot;RememberSaveable Example: $savedCount&quot;)<br><br>Button(<br>    onClick = { /* No operation here, the value will be saved automatically */ }<br>) {<br>    Text(text = &quot;Do Nothing&quot;)<br>}</pre><p><strong>Conclusion</strong></p><p>In the world of Jetpack Compose, remember and rememberSaveable are invaluable tools for managing state and ensuring that your app&#39;s UI remains responsive and consistent. While remember is perfect for everyday state management within a composable, rememberSaveable takes it a step further, guaranteeing that your app&#39;s critical data is preserved across configuration changes. By understanding and effectively implementing these functions, you can create robust and user-friendly Android applications with ease.</p><p>I hope this article has given you an understanding of the differences between remember and rememberSaveable. If you have any questions, please feel free to reach out to me.</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p><a href="https://github.com/esthcarelle">https://github.com/esthcarelle</a></p><p><em>References:</em></p><p><a href="https://developer.android.com/jetpack/compose/state">State and Jetpack Compose | Android Developers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58005b10cce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level Up Your UI: Exploring Progress Bars in Jetpack Compose]]></title>
            <link>https://medium.com/@esthcarelle/level-up-your-ui-exploring-progress-bars-in-jetpack-compose-cea46d47b175?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/cea46d47b175</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 18:42:52 GMT</pubDate>
            <atom:updated>2023-09-24T18:42:52.313Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*65OhWmYbku3Xr0XMNCpA_A.png" /></figure><p>When you perform long operations like fetching data from a server or a database, it’s good practice to show a progress bar. The progress bar reduces the feeling of waiting too long by displaying an <strong>animation</strong>, and it gives the user a sense something is happening.</p><p>When you only want the user to know that work is taking place, spinning animated progress bars are a good choice.</p><h3><strong>Introduction</strong></h3><p>Let’s say you are building an app with Jetpack Compose and you want to track progress and show the user how close they are to finishing the work, you want a progress bar that fills with a color as the progress occurs. This is very common when downloading or uploading files!</p><p>Jetpack Compose offers solutions to handle both cases.</p><p>Consider these three use cases where you might use a progress indicator:</p><ul><li><strong>Loading content</strong>: While fetching content from a network, such as loading an image or data for a user profile.</li><li><strong>File upload</strong>: Give the user feedback on how long the upload might take.</li><li><strong>Long processing</strong>: While an app is processing a large amount of data, convey to the user how much of the total is complete.</li></ul><h3><strong>Implementation</strong></h3><p>It’s so easy to display progress bars with Jetpack Compose that you don’t need additional custom composable functions.</p><p>Let’s try out 2 of them now.</p><p><strong>CircularProgressIndicator</strong></p><p>First, let’s build the CircularProgressIndicator, defining an indicator color and a strokeWidth. These properties serve as styling. You don’t have to define the animation yourself, it’s already pre-baked into the component!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*s82krIa5M8DYlR_bfr1pSw.gif" /><figcaption>CircularProgressBarIndicator</figcaption></figure><pre>Column(<br>   modifier = Modifier.fillMaxSize(),<br>   horizontalAlignment = Alignment.CenterHorizontally,<br>   verticalArrangement = Arrangement.Center<br>) {<br> CircularProgressIndicator(<br>     color = colorResource(id = R.color.colorPrimary),<br>     strokeWidth = 5.dp<br> )<br>}</pre><p><strong>LinearProgressIndicator</strong></p><p>Then, let’s build the LinearProgressIndicator, and let’s set its progress to be 60%. Usually, we update this progress as your operations are computed within the system, but for the sake of simplicity, let’s make it static for this exercise.</p><pre>Column(<br>   modifier = Modifier.fillMaxSize(),<br>   horizontalAlignment = Alignment.CenterHorizontally,<br>   verticalArrangement = Arrangement.Center<br>) {<br> LinearProgressIndicator(progress = 0.6f)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W2M9uHHMAJoSMN4gEJ3rcQ.png" /><figcaption>LinearProgressIndicator</figcaption></figure><h4>Exploring the Progress Indicators</h4><p>Since these are really simple components to implement, they also have very simple definitions. Open the CircularProgressIndicator signature, and you’ll see the following:</p><pre>@Composable<br>fun CircularProgressIndicator(<br>  progress: Float,<br>  modifier: Modifier = Modifier,<br>  color: Color = MaterialTheme.colors.primary,<br>  strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth<br>)</pre><p>This function offers a small range of styling. The most important parameter is the progress, which ranges from 0.0 to 1.0 — the number determines the filled ratio of the progress bar. If you don’t set the progress, the progress bar will run an infinite spinning animation.</p><p>The other styling options change the color and the stroke width. The default stroke width is <strong>4 dp</strong>.</p><p>On the other hand, the LinearProgressIndicator signature looks like this:</p><pre>@Composable<br>fun LinearProgressIndicator(<br>  /*@FloatRange(from = 0.0, to = 1.0)*/<br>  progress: Float,<br>  modifier: Modifier = Modifier,<br>  color: Color = MaterialTheme.colors.primary,<br>  backgroundColor: Color = color.copy(alpha = IndicatorBackgroundOpacity)<br>)</pre><p>The options are almost the same, except it doesn’t offer the ability to change the stroke width. Though you usually use a linear progress bar to indicate <strong>static</strong> progress, you can also use it with an infinite animation by not setting the progress parameter. The animation will then go from left to right until the operation completes.</p><p><strong>Conclusion</strong></p><p>We explored progress indicators and saw how it shows the visually surface the status of an operation. They use motion to bring to the user’s attention how near completion the process is, such as loading or processing data. They can also signify that processing is taking place, without reference to how close to completion it might be.</p><p>I hope this article has given you a brief introduction to progress bars. If you have any questions, please feel free to reach out to me.</p><p>LinkedIn:</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p>Github:</p><p><a href="https://github.com/esthcarelle">esthcarelle - Overview</a></p><p>Source:</p><ul><li><a href="https://developer.android.com/jetpack/compose/components/progress">Progress indicators | Jetpack Compose | Android Developers</a></li><li><a href="https://www.kodeco.com/books/jetpack-compose-by-tutorials/v2.0/chapters/2-learning-jetpack-compose-fundamentals#toc-chapter-008-anchor-007">Jetpack Compose by Tutorials, Chapter 2: Learning Jetpack Compose Fundamentals</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cea46d47b175" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Composable Functions: Building UI with Jetpack Composable]]></title>
            <link>https://medium.com/@esthcarelle/composable-functions-building-ui-with-jetpack-composable-50dbaeaf6a29?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/50dbaeaf6a29</guid>
            <category><![CDATA[composables]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 23:52:49 GMT</pubDate>
            <atom:updated>2023-07-17T23:52:49.017Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*Do8WL2hO-fZxF8d3Xr-88g.png" /></figure><h3><strong>Introduction</strong></h3><p>In the previous article , we learned how using XML to build UI differs from using Jetpack Compose. The biggest issues with the former approach are:</p><ul><li>The UI isn’t scalable.</li><li>It’s hard to make custom views.</li><li>State ownership is often scattered between multiple owners.</li></ul><p>If you’re familiar with building UI using XML in Android, you’ll find that Jetpack Compose offers a different approach. In the previous article, we discussed the limitations of XML-based UI, such as scalability, custom views, and scattered state ownership. To overcome these issues, Jetpack Compose introduces a new fundamental building block called a composable function.</p><p>A composable function is a basic building block in Jetpack Compose. To create a composable function, you simply annotate a function with @Composable. This annotation marks the function as a composable function, which can be composed within other composable functions.</p><pre>@Composable<br>fun MyComposableFunction() {<br>  // TODO: Content goes here<br>}</pre><p>The @Composable annotation simplifies the code by attaching metadata to it. This metadata is processed at compile time, allowing you to add behavior to classes and generate useful code without writing boilerplate code.</p><p>By annotating a function with @Composable, you change the type of the function to a Composable. This means that only other composable functions can call it, and it can only be invoked from a compose scope, similar to coroutines.</p><p>Internally, the @Composable annotation is defined as an annotation class with its own set of annotations. These annotations include @MustBeDocumented, @Retention, and @Target, which provide additional information about the annotation.</p><p>To start building the UI using Jetpack Compose, you need to call setContent(). This function binds the UI to an Activity or Fragment, similar to setContentView() in XML-based UI. However, instead of working with Views or XML resources, setContent() works with composable functions.</p><p>The signature for setContent() looks like this:</p><pre>fun ComponentActivity.setContent(<br>   parent: CompositionContext? = null,<br>   content: @Composable () -&gt; Unit<br>) { ... }</pre><p>The setContent() function is an extension function of ComponentActivity. It sets the given composable function as the root view, to which you can add any number of elements. The composable function passed to () is also annotated with @Composable, allowing you to call other composable functions and access resources and the context of Jetpack Compose.</p><h3>Text</h3><p>When you think about the UI, one of the first things that come to mind is a basic text element, or TextView. In Jetpack Compose, the composable function most similar to a TextView is called <strong>Text</strong>. Let’s see it in action.</p><pre>@Composable<br>fun MyText() {<br> Text(text = &quot;Hello World&quot;)<br>}</pre><p>If you call MyText inside the MainActivity setContent:</p><pre>override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContent {<br>          MyText()<br>        }<br>}</pre><p>You should be able to see “Hello World” displayed</p><h3>Styling Your Text</h3><p>In this section you’ll display the text in <em>italics</em> with <strong>bold</strong> weight. You’ll also change the <strong>color</strong> to use the primary color of the app and change the <strong>text size</strong> to 30 sp.</p><p>Change MyText()’s code to the following:</p><pre>@Composable<br>fun MyText() {<br> Text(text = &quot;Hello World&quot;,<br>     fontStyle = FontStyle.Italic, // 1<br>     color = colorResource(id = R.color.colorPrimary), // 2<br>     fontSize = 30.sp, // 3<br>     fontWeight = FontWeight.Bold // 4<br> )<br>}</pre><p>There are a few things happening here:</p><ol><li>Using fontStyle, you make the text <em>italicized</em> by using FontStyle.Italic.</li><li>Passing in a color, you change the color of the text. Also notice how colorResource() lets you easily fetch a color from your resources.</li><li>The fontSize parameter lets you pass in the size in <strong>scalable pixels</strong>. Notice the .sp property call. Compose has a way to transform Integer values into dp and sp by calling respective properties! These are extension properties, so make sure to add the . operator.</li><li>Finally, fontWeight makes the text <strong>bold</strong>.</li></ol><p>Now build and run the project and open the Text screen to see the new version of your styled text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0M5S5Uwf5-xRdLHQ4KOjA.png" /></figure><h3>TextField</h3><p>In the legacy Android UI toolkit, you’d use an EditText to show input fields to the user. The composable counterpart for an EditText is called a TextField.</p><pre>@Composable<br>fun MyTextField() {<br>  val textValue = remember { mutableStateOf(&quot;&quot;) }<br><br>  TextField(<br>    value = textValue.value,<br>    onValueChange = {<br>      textValue.value = it<br>    },<br>    label = {}<br>  )<br>}</pre><p>A TextField should allow the user to input text, and the entered text must not disappear or change if the TextField recomposes. For your TextField to work properly, you must provide a value that <strong>doesn’t change during recomposition</strong> — in other words, a <strong>state</strong> value. Using mutableStateOf(), you wrap an empty String into a state holder, which you’ll use to store and display the text within the input field.</p><p>You also wrapped the state into remember(), which is Compose’s way of telling the recomposer that the value should be persisted through recomposition. If you didn’t use remember() here, every time you changed the state, it would be <strong>lost and set to the default</strong> value — an empty string.</p><p><strong>Conclusion</strong></p><p>In this article, we explored the basics of composable functions in Jetpack Compose. We learned how to create a composable function, how to set the content of an Activity or Fragment using setContent(), and how to use the Text and TextField composable functions. We also learned how to style text using the fontStyle, color, fontSize, and fontWeight properties.</p><p>Here is a list of some of other composables you can explore:</p><p>RadioButton, Button, FloatingActionButton, Icon, IconButton, AlertDialog,….</p><p>I hope this article has given you a brief introduction to composables. If you have any questions, please feel free to ask me.</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p><a href="https://github.com/esthcarelle">esthcarelle - Overview</a></p><p><em>References:</em></p><p><a href="https://www.kodeco.com/books/jetpack-compose-by-tutorials/v2.0/chapters/2-learning-jetpack-compose-fundamentals">https://www.kodeco.com/books/jetpack-compose-by-tutorials/v2.0/chapters/2-learning-jetpack-compose-fundamentals</a></p><p><a href="https://developer.android.com/jetpack/compose/text">Text in Compose | Jetpack Compose | Android Developers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50dbaeaf6a29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Custom Microsoft Icon with Jetpack Compose]]></title>
            <link>https://medium.com/@esthcarelle/creating-a-custom-microsoft-icon-with-jetpack-compose-ddf3df088688?source=rss-7d681d57d670------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddf3df088688</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[icons]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Esther Carrelle Rangira]]></dc:creator>
            <pubDate>Wed, 05 Jul 2023 14:31:01 GMT</pubDate>
            <atom:updated>2023-07-05T14:31:01.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8O_V3q67e85EBCxNsqapg.jpeg" /></figure><p>Jetpack Compose is a modern toolkit for building native Android UI. It provides a declarative API that makes it easy to create complex user interfaces. In this article, we will create a custom Microsoft icon using Jetpack Compose.</p><p><strong>Prerequisites</strong></p><p>To follow along with this tutorial, make sure you have a basic understanding of Jetpack Compose</p><p>The first step is to create a new project in Android Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*fo5oWdrHWF6EqUrj6g45Pg.png" /><figcaption>Create new project</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*9KES1ugh9-fujkuBU-Ci2w.png" /><figcaption>Project description</figcaption></figure><p>Once the project is created, we need to add the following dependency to the build.gradle file:</p><pre><br>    implementation &#39;androidx.compose.material3:material3&#39;</pre><p><strong>Code</strong> <strong>Breakdown</strong></p><p>The MicrosoftIcon component is a composable function annotated with @Composable, indicating that it can be used within Compose UI hierarchy. It sets up a canvas to draw the icon using the Canvas composable.</p><pre>@Composable<br>fun MicrosoftIcon(modifier: Modifier = Modifier.size(100.dp)) {<br>    Canvas(modifier = modifier) {<br>        // Icon drawing code goes here<br>    }<br>}</pre><p>Drawing the Icon: The icon is composed of multiple colored rectangles. Each rectangle is drawn using the drawRect function.</p><pre>@Composable<br>fun MicrosoftIcon() {<br>    Canvas(modifier = Modifier.size(100.dp)) {<br>        val width = this.size.width<br>        val height = this.size.height<br><br>        drawRect(<br>            color = Color(0xFFF25022),<br>            size = Size(width * .50f, height * .45f),<br>            topLeft = Offset(width * .0f, height * 0f)<br>        )<br>        drawRect(<br>            color = Color(0xFF7FBA00),<br>            size = Size(width * .50f, height * .45f),<br>            topLeft = Offset(width * .55f, height * 0f)<br>        )<br><br>        drawRect(<br>            color = Color(0xFFFFB900),<br>            size = Size(width * .50f, height * .45f),<br>            topLeft = Offset(width * .55f, height * .50f)<br>        )<br><br>        drawRect(<br>            color = Color(0xFF00A4EF),<br>            size = Size(width * .50f, height * .45f),<br>            topLeft = Offset(width * 0f, height * .50f)<br>        )<br>    }<br>}</pre><p>In this code snippet, four rectangles are drawn with different colors. Each rectangle is defined by specifying the color, size, and position. The Color class is used to set the desired color, and the Size class defines the dimensions of the rectangle. The Offset class determines the top-left position of each rectangle within the canvas. By varying these parameters, you can customize the appearance of the icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*vLOzE6FfYNF-Ciun_t1w8w.png" /></figure><p><strong>Conclusion</strong></p><p>In this article, we explored the code snippet for creating a vibrant icon component called MicrosoftIcon using Jetpack Compose. By leveraging the Canvas composable and the drawRect function, we constructed a visually appealing icon consisting of multiple colored rectangles. With Jetpack Compose&#39;s declarative and flexible approach, it becomes effortless to create custom UI components that enhance the visual appeal of your Android applications.</p><p>By understanding the concepts demonstrated in this article, you can adapt and extend the provided code to create your own unique UI components. Let your creativity flourish and create stunning visuals with Jetpack Compose. Happy composing!</p><p>Feel free to connect with me and follow my github account.</p><p><a href="https://www.linkedin.com/in/esther-carrelle-rangira/">https://www.linkedin.com/in/esther-carrelle-rangira/</a></p><p><a href="https://github.com/esthcarelle">esthcarelle - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddf3df088688" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>