<?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 Upscalix on Medium]]></title>
        <description><![CDATA[Stories by Upscalix on Medium]]></description>
        <link>https://medium.com/@upscalix?source=rss-91e68ea8f31f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RYkKetUaEEWU-OVIRMbA7w.png</url>
            <title>Stories by Upscalix on Medium</title>
            <link>https://medium.com/@upscalix?source=rss-91e68ea8f31f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 19:40:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@upscalix/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[How to build Shopify Store with Liquid: From Local Development to Production Deployment]]></title>
            <link>https://upscalix.medium.com/how-to-build-shopify-store-with-liquid-from-local-development-to-production-deployment-078bc35d1521?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/078bc35d1521</guid>
            <category><![CDATA[shopify-development]]></category>
            <category><![CDATA[shopify]]></category>
            <category><![CDATA[liquid]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Wed, 19 Jun 2024 01:59:13 GMT</pubDate>
            <atom:updated>2024-06-19T01:59:13.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gt0ttp42tImUG_LC8Eedg.png" /><figcaption>(Dawn theme illustration — shopify.dev)</figcaption></figure><p>In this comprehensive guide, we will walk you through the process of building a Shopify store using Liquid, from setting up your local development environment to deploying your site to production. Whether it’s your first time</p><p><strong>Introduction:</strong> Whether you&#39;re working with Shopify or looking to expand your development skills, this article will provide you with the essential steps and insights to get started. Let’s jump right in!</p><h3>Understanding Liquid</h3><p>Liquid is the backbone of Shopify theme development. It’s a simple yet powerful templating language that allows you to create dynamic content and customise the appearance of your online store. It helps us make our Shopify store work just the way we want. We can use different values to do cool things like loops and if-else conditions.</p><p>It’s like magic! We can also use the same code repeatedly, which saves us time and makes things easier. For those of you who come from WordPress or PHP development, liquid is something like twig template language.</p><p>Liquid reference: <a href="https://shopify.dev/docs/api/liquid">https://shopify.dev/docs/api/liquid</a></p><h3>Exploring Shopify 2.0 Themes</h3><p>Shopify 2.0 themes offer enhanced flexibility and functionality compared to their predecessors (liquid or static templates).</p><p>These themes give you more freedom to make your store look exactly how you want it—and they run faster, too! Using Shopify 2.0 themes, we can customise and reuse almost every section in our theme, making theme development easier and simpler.</p><p>We can leverage JSON files to adjust our sections in the Shopify Page editor. With the new 2.0, users with zero coding experience can edit how they want and add much content to improve their store appearance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O4eaMdqY-34-J4mjDBQajw.png" /><figcaption>(Shopify page builder)</figcaption></figure><h3>Setting Up Your Local Environment</h3><p>Before diving into Shopify theme development, you must set up a local development environment. Shopify CLI (Command Line Interface) is a powerful tool streamlining theme development tasks.</p><p>Shopify CLI is a tool to build extensions and themes for your Shopify store. Using Shopify CLI, you can easily create a starter project, so you don’t have to start from scratch. They also provide a local development server, allowing you to freely develop a theme, just like building apps using modern stacks like React, Next.js, or Vue.js.</p><p>We will not be giving you step by step guide on how to set up Shopify CLI, because the Shopify team itself already covered really good tutorials here: <a href="https://shopify.dev/docs/themes/tools/cli/install">https://shopify.dev/docs/themes/tools/cli/install</a></p><h3>Theme structure on Shopify</h3><p>Shopify uses a theme as their native storefront appearance, so they also have guidance and example of folder and file structure that we should follow, it is to ensure all themes that we developed are compatible with any integrations and no vendor locking issue in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/169/1*uitr3-htnf59wb0BxfB6mA.png" /><figcaption>(Shopify theme structure)</figcaption></figure><p>Here is the Shopify theme structure (2024)</p><p>├── assets</p><p>├── config</p><p>├── layout</p><p>├── locales</p><p>├── sections</p><p>├── snippets</p><p>└── templates</p><p>└── customers</p><p>For the explanation of each folder and file, you can find here: <a href="https://shopify.dev/docs/themes/architecture#directory-structure-and-component-types">https://shopify.dev/docs/themes/architecture#directory-structure-and-component-types</a></p><h3>Developing and Testing Your Theme Locally</h3><p>This section will dive into the practical steps of starting a theme using Shopify CLI commands.</p><p>We will learn how to initiate a new theme using ‘Shopify theme init’ and pull it from the Shopify Dawn theme as the starter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*LS-HigzqYH3O0F4_GJmzKw.png" /><figcaption>(theme init command)</figcaption></figure><p>Shopify theme init</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bcd4429605b6946f9aec49177d8e8320/href">https://medium.com/media/bcd4429605b6946f9aec49177d8e8320/href</a></iframe><p>We will explore how to develop a theme locally with a specific store connected to your partner account (<a href="https://www.shopify.com/partners">https://www.shopify.com/partners</a>) using ‘shopify theme dev’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*V4ewtoYp48m9mr20j9WCIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*cbGdAbIXcxbcvwrxuMgR7w.png" /><figcaption>(theme dev command)</figcaption></figure><p>shopify theme dev</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4229b7355dbb4aea05a4b3540c295e35/href">https://medium.com/media/4229b7355dbb4aea05a4b3540c295e35/href</a></iframe><p>Additionally, we will cover ‘shopify theme pull’, a crucial command to get all updates made on the store Shopify site, as these updates are only stored within Shopify. Regularly performing this command ensures you have the latest updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*VYCVGj3YjbAA6jkuhIJlvw.png" /><figcaption>(shopify theme pull command)</figcaption></figure><p>shopify theme pull</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e735ef485f24841874f6b7fc3e66f39c/href">https://medium.com/media/e735ef485f24841874f6b7fc3e66f39c/href</a></iframe><p>Lastly, we will discuss ‘shopify theme push’, which allows you to push your local changes into the store. This ensures that visitors or clients can see the updates from the live link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*ibsIULSAW5bIat8Xj59a4A.png" /><figcaption>(shopify theme push command)</figcaption></figure><p>shopify theme push</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97ac64a29c003304e9b27c1583f40482/href">https://medium.com/media/97ac64a29c003304e9b27c1583f40482/href</a></iframe><p>Reference of Shopify CLI command: <a href="https://shopify.dev/docs/themes/tools/cli/commands">https://shopify.dev/docs/themes/tools/cli/commands</a></p><p>An alternative way if you already have a GitHub account and want to store your theme in a GitHub repository is to leverage Shopify infrastructure to push changes into commit every time someone changes content, settings, or adds a section in the live site theme. This is a more convenient way to keep everything synchronised.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*1GQaR0d6OK3bHPtnno4WeA.png" /><figcaption>(GitHub integration with theme)</figcaption></figure><p>Reference GitHub integration: <a href="https://shopify.dev/docs/themes/tools/github/getting-started">https://shopify.dev/docs/themes/tools/github/getting-started</a></p><h3>Deploying Your Theme to a Live Shopify Site</h3><p>Once you’ve built and tested your theme locally, it’s time to deploy it to a live Shopify site. Leveraging either GitHub or Shopify CLI to push a theme to production is easier than doing it manually.</p><p>However, please be careful when updating your theme if you push to the live site, as Shopify may prompt you to confirm the update.</p><p>To do this, you can use ‘shopify theme push’. Afterward, a list of themes in your store will be displayed. You can then decide which theme on the live site you want to update.</p><p>shopify theme push <a href="https://gist.github.com/Wijayaac/f1ac3ca682bc658a9aa6adfc4022b249">https://gist.github.com/Wijayaac/f1ac3ca682bc658a9aa6adfc4022b249</a></p><h3>Common Issues When First Time Developing a Theme</h3><p><strong>Cannot see the store preview on the live site</strong></p><ul><li>Make sure your developed theme has already been pushed.</li><li>Make sure your theme is published as a live theme. Check this if there is no published theme: use this command to publish a theme: “Shopify theme publish”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*HmLQyQ_K7IiXu1w6qwQtOw.png" /><figcaption>(theme publish command)</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcc506b0019e19bd09107a08575e444f/href">https://medium.com/media/dcc506b0019e19bd09107a08575e444f/href</a></iframe><p><strong>Made a change from Shopify Editor but did not see it on my development</strong></p><ul><li>Try to pull updates from the theme you are changing, usually the theme has a name on the top left corner, and when pulling a theme you can select it. To do pulling, use the command shopify theme pull.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*VYCVGj3YjbAA6jkuhIJlvw.png" /><figcaption>(theme pull terminal)</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e735ef485f24841874f6b7fc3e66f39c/href">https://medium.com/media/e735ef485f24841874f6b7fc3e66f39c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*f4UWcwaazk_nrdzYRCDDaA.png" /><figcaption>(and theme name editor)</figcaption></figure><p><strong>Local Development Port already used</strong></p><ul><li>If you want to develop multiple stores at the same time, make sure you are using different ports when running the ‘shopify theme dev’ command since the default port is 9292, and if some application or service is already using it, there is no fallback or alternative port is, but you can assign the custom port you want by adding (–port) parameter for example 9191 ( any port that is not conflict with existing services or applications)</li></ul><h3>Conclusion</h3><p>In conclusion, learning Shopify theme development and Liquid can bring many exciting opportunities for anyone interested in creating online stores. By mastering the Liquid basics, using the new Shopify 2.0 theme structure, and mastering the development process, you’ll be ready to create amazing online stores that really work. So, get ready to jump into Shopify development and let your creativity shine in the e-commerce universe!</p><p><em>This article is written by </em><a href="https://www.linkedin.com/in/kadek-wijaya/"><em>Kadek</em></a><em>, Upscalix CMS Developer.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=078bc35d1521" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing WordPress with AlpineJS: A Lightweight Approach to Interactive Elements]]></title>
            <link>https://upscalix.medium.com/enhancing-wordpress-with-alpinejs-a-lightweight-approach-to-interactive-elements-a85ac200b79f?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a85ac200b79f</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[alpine]]></category>
            <category><![CDATA[alpinejs]]></category>
            <category><![CDATA[js]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 07:25:56 GMT</pubDate>
            <atom:updated>2024-04-24T07:25:56.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3aWJhi_YCN0AaFw9HpngpQ.jpeg" /></figure><h3>Introduction</h3><p>WordPress, a versatile web content management system (CMS), has continuously evolved since its inception as a blogging platform. Over the years, it has expanded its capabilities to cater to various web content needs, ranging from traditional websites to complex e-commerce platforms and learning management systems. With its extensive plugin ecosystem, developers can extend WordPress functionalities to meet specific requirements.</p><p>While WordPress excels at creating static web pages, dynamic and interactive experiences often require the use of JavaScript frameworks. One such powerful yet lightweight tool is <strong>Alpine.js</strong>. This unobtrusive JavaScript library seamlessly integrates with WordPress, offering a pragmatic approach to adding interactivity without sacrificing performance or simplicity.</p><p><strong>Alpine.js: A Minimalist Powerhouse</strong></p><p>Alpine.js is a JavaScript framework designed for simplicity. Unlike larger frameworks, it focuses on adding interactivity without the complexity. This makes it ideal for projects where performance and a clean codebase are essential. Alpine.js avoids the need for build tools or complex setups, making it perfect for quick wins.</p><p><strong>Benefits of Integrating Alpine.js with WordPress</strong></p><p>There are several advantages to using Alpine.js with WordPress:</p><ul><li><strong>Lightweight and Performant:</strong> Alpine.js adds interactivity without significant code bloat, ensuring fast loading times and a smooth user experience. This can lead to improved SEO and higher user engagement.</li><li><strong>Easy Integration:</strong> Alpine.js integrates smoothly with WordPress themes and plugins thanks to its simple syntax and existing JavaScript library compatibility. Developers can add interactive features without major codebase changes, saving time and effort.</li><li><strong>Enhanced User Experience:</strong> By introducing interactive elements like dynamic forms, modal dialogues, and live search, Alpine.js improves user engagement and satisfaction. This can lead to increased conversion rates and better overall user experience.</li><li><strong>Reduced Complexity:</strong> Alpine.js prioritises ease of use. Developers can achieve complex interactions with minimal code, making learning and maintenance easier in the long run. This can save development time and resources in the future.</li></ul><p><strong>Important Alpine.js Directives</strong></p><p>Here are some key Alpine.js directives that demonstrate its power and ease of use:</p><ul><li><strong>x-data:</strong> This directive defines reactive data properties within your Alpine.js components. It allows you to store and manipulate data used by your interactive elements.</li></ul><p><strong>HTML</strong></p><pre>&lt;div x-data=&quot;{ isOpen: false }&quot;&gt;<br>  &lt;button @click=&quot;isOpen = !isOpen&quot;&gt;Toggle Content&lt;/button&gt;<br>  &lt;div x-show=&quot;isOpen&quot;&gt;This content is hidden by default and toggled on click.&lt;/div&gt;<br>&lt;/div&gt;</pre><ul><li><strong>x-show:</strong> This directive controls the visibility of an element based on a reactive data property. In the above example, the content is only shown when isOpen is true.</li><li><strong>x-model:</strong> This directive provides two-way data binding for form elements like input fields and text areas. It simplifies keeping your form data in sync with the UI and vice versa.</li></ul><p><strong>HTML</strong></p><pre>&lt;input type=&quot;text&quot; x-model=&quot;name&quot; placeholder=&quot;Enter your name&quot;&gt;<br>&lt;p&gt;Hello, {{ name }}!&lt;/p&gt;</pre><ul><li><strong>x-on:</strong> This directive binds event listeners to DOM elements. It allows you to execute JavaScript code in response to user interactions like clicks, hovers, or form submissions.</li></ul><p><strong>HTML</strong></p><pre>&lt;button x-on:click=&quot;alert(&#39;Button Clicked!&#39;)&quot;&gt;Click Me&lt;/button&gt;</pre><ul><li><strong>x-text:</strong> This directive sets the text content of an element based on a reactive data property or JavaScript expression.</li></ul><p><strong>HTML</strong></p><pre>&lt;span x-text=&quot;counter&quot;&gt;0&lt;/span&gt;<br>&lt;button @click=&quot;counter++&quot;&gt;Increment&lt;/button&gt;</pre><p>These are just a few examples, and Alpine.js offers many more directives for various functionalities. Its simple syntax makes it easy to learn and integrate into your WordPress projects.</p><p><strong>Integration Options for Alpine.js with WordPress</strong></p><p>There are several ways to integrate Alpine.js with WordPress, each with its own advantages:</p><ul><li><strong>Direct Inclusion:<br></strong>This method is suitable for small-scale use cases where Alpine.js is only needed for specific components within a theme or plugin. Here’s how to do it:</li></ul><ol><li><strong>Locate your theme’s functions.php file</strong> (for theme integration) or plugin’s main file.</li><li><strong>Use the </strong><strong>wp_enqueue_script function</strong> to include the Alpine.js library. Here&#39;s an example:</li></ol><p><strong>PHP</strong></p><pre>function enqueue_alpine_script() {<br>  wp_enqueue_script( &#39;alpinejs&#39;, &#39;https://unpkg.com/alpinejs@3.x.x/dist/alpine.min.js&#39;, array(), &#39;3.x.x&#39;, true );<br>}<br>add_action( &#39;wp_enqueue_scripts&#39;, &#39;enqueue_alpine_script&#39; );</pre><p>This code snippet enqueues the Alpine.js library from a CDN with version 3.x.x. Replace “3.x.x” with the specific version you want to use.<br><br><strong>Write your Alpine.js code directly in your theme files</strong> (for theme integration) or plugin templates, targeting the specific elements where you want interactivity.</p><ul><li><strong>Enqueueing Scripts:<br></strong>This method is ideal for integrating Alpine.js across your entire WordPress site or specific sections. It ensures proper dependency management and avoids conflicts with other scripts. Here’s how:</li></ul><ol><li>Follow steps 1 and 2 from the “Direct Inclusion” method to enqueue the Alpine.js library.</li><li><strong>Use conditional tags</strong> (optional) to load Alpine.js only on specific pages or templates where it’s needed. For example:</li></ol><p><strong>PHP</strong></p><pre>if ( is_page_template( &#39;my-custom-template.php&#39; ) ) {<br>  // Enqueue Alpine.js script here (code from step 1 &amp; 2)<br>}</pre><p><strong>Gutenberg Blocks (Optional):</strong></p><p>If you’re using WordPress with the Gutenberg block editor, you can potentially leverage it for Alpine.js integration. This approach involves creating custom Gutenberg blocks that utilise Alpine.js for interactivity within the block itself.</p><ul><li><strong>Important Note:</strong> While technically possible, integrating Alpine.js directly within Gutenberg blocks is still an emerging approach. There might be limitations or compatibility issues to consider. It’s recommended to research and test this method thoroughly before implementing it in a production environment.</li></ul><p><strong>Replacing jQuery with Alpine.js (Frontend Only)</strong></p><p>If you’re currently using jQuery in your WordPress themes for interactive elements, Alpine.js can be a compelling alternative for the frontend. Here’s why:</p><ul><li><strong>Smaller Footprint:</strong> Alpine.js is significantly lighter than jQuery, leading to faster loading times and improved website performance.</li><li><strong>Simpler Syntax:</strong> Alpine.js uses directives and attributes for interactivity, offering a cleaner and more concise approach compared to jQuery’s code structure.</li><li><strong>Modern JavaScript:</strong> Alpine.js leverages modern JavaScript features, promoting better code maintainability and compatibility with future advancements.</li></ul><p>While Alpine.js offers compelling advantages over jQuery, there are some downsides to consider before replacing it entirely in your WordPress frontend:</p><ul><li><strong>Learning Curve:</strong> If your team is comfortable with jQuery, there will be a learning curve associated with Alpine.js syntax and directives.</li><li><strong>Plugin Ecosystem:</strong> jQuery has a vast ecosystem of plugins, while Alpine.js is still growing. You might need to find alternative solutions or write custom code for functionalities previously achieved with jQuery plugins.</li><li><strong>Backward Compatibility:</strong> If your theme relies heavily on jQuery and caters to older browsers, a complete switch to Alpine.js might introduce compatibility issues. Thorough testing is crucial.</li></ul><p><strong>Disabling jQuery in the Frontend</strong></p><p>To disable jQuery in the frontend while keeping it in the admin, you can leverage the wp_scripts function and conditional tags. Here&#39;s how:</p><p><strong>PHP</strong></p><pre>function dequeue_jquery_frontend() {<br>  if ( !is_admin() ) { // Check if it&#39;s not the admin area<br>    wp_dequeue_script( &#39;jquery&#39; );<br>  }<br>}<br>add_action( &#39;wp_enqueue_scripts&#39;, &#39;dequeue_jquery_frontend&#39;, 100 ); // Priority 100 ensures it runs after core scripts are enqueued</pre><p>This code snippet checks if the current page is not the admin area using is_admin(). If it&#39;s not the admin, it dequeues the default jQuery script</p><p><strong>Migrating from jQuery to Alpine.js</strong></p><p>Transitioning from jQuery to Alpine.js for frontend functionalities requires careful planning and execution. Here’s a general approach:</p><ol><li><strong>Identify jQuery Dependencies:</strong> Start by auditing your theme’s code to pinpoint all functionalities currently relying on jQuery in the frontend.</li><li><strong>Gradual Replacement:</strong> It’s recommended to replace jQuery functionalities one by one. Begin with simpler interactions and gradually progress towards more complex ones</li></ol><p><strong>Choosing the Right Method</strong></p><p>The best integration method depends on your project’s needs and comfort level. For small, targeted interactions, direct inclusion might be sufficient. For larger projects or managing Alpine.js usage across your site, enqueueing scripts offers a more robust approach.</p><p><strong>Conclusion</strong></p><p>WordPress has become a powerful platform for creating dynamic and engaging websites. While plugins offer extensive functionality, Alpine.js emerges as a lightweight JavaScript framework that seamlessly integrates with WordPress. Its focus on simplicity and performance makes it ideal for adding interactivity without compromising website speed or code complexity.</p><p><strong>Key Takeaways</strong></p><p><strong>Alpine.js Benefits:</strong></p><ul><li>Lightweight and performant for fast loading times.</li><li>Easy integration with existing WordPress themes and plugins.</li><li>Enhanced user experience through interactive elements.</li><li>Reduced complexity with a focus on clean and maintainable code.</li></ul><p><strong>Integration Options:</strong></p><ul><li><strong>Direct Inclusion:</strong> Suitable for small-scale use cases within themes or plugins.</li><li><strong>Enqueueing Scripts:</strong> Ideal for integrating Alpine.js across your entire site or specific sections, ensuring proper dependency management.</li><li><strong>Gutenberg Blocks (Optional):</strong> Potential for creating custom Gutenberg blocks with Alpine.js for interactivity within the block itself (still an emerging approach).</li></ul><p><strong>Replacing jQuery with Alpine.js (Optional):</strong></p><ul><li><strong>Advantages:</strong> Smaller footprint, simpler syntax, modern JavaScript.</li><li><strong>Considerations:</strong> Learning curve, plugin ecosystem, backward compatibility.</li></ul><p><strong>Choosing the Right Method</strong></p><p>The ideal integration method depends on your project’s specific needs.</p><ul><li><strong>Direct Inclusion:</strong> For small, targeted interactions.</li><li><strong>Enqueueing Scripts:</strong> For larger projects or managing Alpine.js usage across the site.</li></ul><p><strong>Considering a Migration from jQuery</strong></p><p>If you’re currently using jQuery for frontend interactivity, Alpine.js presents a compelling alternative. However, a migration requires careful planning:</p><ul><li><strong>Identify jQuery Dependencies:</strong> Audit your theme’s code to pinpoint functionalities relying on jQuery.</li><li><strong>Gradual Replacement:</strong> Start with simpler interactions and gradually replace more complex ones. This minimises risks and ensures a smooth transition.</li></ul><p><strong>The Future of Alpine.js with WordPress</strong></p><p>Alpine.js is a rising star in the WordPress development landscape. Its simplicity and performance make it a valuable tool for creating interactive experiences. As the framework matures and its ecosystem grows, we can expect even deeper integration with WordPress, offering developers a powerful and efficient way to build dynamic and engaging websites.</p><p><em>This article is written by </em><a href="https://www.linkedin.com/in/zakaria-wicaksono-69363b84?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=ios_app"><em>Zakaria</em></a><em>, Upscalix Fullstack Developer.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a85ac200b79f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Implement Google OAuth 2 with Passport in Express Application]]></title>
            <link>https://upscalix.medium.com/how-to-implement-google-oauth-2-with-passport-in-express-application-cb37ea118f44?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb37ea118f44</guid>
            <category><![CDATA[full-stack-development]]></category>
            <category><![CDATA[passportjs]]></category>
            <category><![CDATA[google-oauth]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 03:00:59 GMT</pubDate>
            <atom:updated>2024-03-06T03:00:59.742Z</atom:updated>
            <content:encoded><![CDATA[<p>OAuth (Open Authorization) protocol is an open standard commonly used for users to provide information to a website or application from other websites or applications without giving them their credentials.</p><p>In this discussion, we will implement Google OAuth in our application with Passport JS. This flexible and modular authentication middleware will simplify the OAuth implementation process in our node-based application.</p><h3>1. Create a Google Client ID and Secret</h3><p>The first step to add Google OAuth to our application is to create a Google OAuth client ID through Google Console: <a href="https://developers.google.com/identity/protocols/oauth2">https://developers.google.com/identity/protocols/oauth2</a>. You can go to this link to read an overview of what Google OAuth 2.0 is and also go to the Google API console through the provided step that Google is giving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODs_vUu7WsWxbCUZ3kZW6A.png" /></figure><p>Once in the console, go to the credential tab, click the “CREATE CREDENTIAL” button, and choose the OAuth client ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*5-9NAROgEfRKQ5Bqs8zJCg.png" /></figure><p>On the form, we will choose web application as our application type and then fill out the application name and add redirect URI as the path that Google will redirect after they authenticate the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*gHOzeLdWrrw5f-qT4TMHPQ.png" /></figure><p>After creation, Google will show us the client ID and client secret we will use in our application. Please. We can check the client ID and secret later by clicking on your application name in a credential tab in the Google Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*35DPDLmB4AvQWHXBjtEgfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*cumo9snU-HYcKOu1TPIBUA.png" /></figure><p>After we create the client ID and secret, we need to add information on the tab OAuth consent screen, like the application name, support email, logo, and application domain, which will show up in the consent screen when the user logs in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*duxAo9S2UsS_IAAVojYVBQ.png" /></figure><h3>2. Implement Google OAuth 2.0 with a Passport in the Express App</h3><p>Now that we have the Google client ID and secret, we can continue implementing it with a passport in our application. We can check passport documentation on Google OAuth 2.0 strategy here: <a href="https://www.passportjs.org/packages/passport-google-oauth20/">https://www.passportjs.org/packages/passport-google-oauth20/</a></p><p>To implement Google Oauth with a passport in our application, we need to add a couple of dependencies: express-session, passport, and Google Oauth passport. To add these dependencies, we can use npm I express-session passport passport-google-oauth20.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*gy2YXBEJgrqtPMvINciOFA.png" /></figure><p>First, we need to set the passport to our application and configure passport strategies for Google OAuth; in this example, I will add a passport.js file on util to add our configuration for the passport.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*NO6TY3uwRSoaHkWwnY0alw.png" /></figure><pre>const passport = require(&#39;passport&#39;); <br>const GoogleStrategy = require(&#39;passport-google-oauth20&#39;).Strategy; </pre><p>Then we can add our passport strategy for Google OAuth, user serialize and deserialize.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*HHLMxvX38APReNAGYls96g.png" /></figure><pre>const passport = require(&#39;passport&#39;); <br>const GoogleStrategy = require(&#39;passport-google-oauth20&#39;).Strategy;<br><br>const googleClientId = &#39;your google client id&#39; <br>const googleClientSecret = &#39;your google client secret&#39; <br><br>passport.use( <br>  new GoogleStrategy( <br>    { <br>      clientID: googleClientId, <br>      clientSecret: googleClientSecret, <br>      callbackURL: `http://localhost:3001/auth/google/redirect`, <br>    }, <br><br>    function (accessToken, refreshToken, profile, done) { <br>      // User find or create to db <br>      return done(null, profile); <br>    } <br>  ) <br>); <br><br>passport.serializeUser((user, done) =&gt; { <br>  done(null, user); <br>}); <br><br>passport.deserializeUser((user, done) =&gt; { <br>  done(null, user);<br>}); </pre><p>The callback URI in the Google OAuth strategy is the same as the one we add in the Google Console for redirecting URI and note that Google Client ID and secret are not to be hardcoded in the application and should be added in environment variables.</p><p>We can also add code to search or create a user into a database to save the login information of our user, or we can add the code as middleware later in the authentication route.</p><p>Now that we have set up our passport configuration and strategy, we need to initialise the passport on the index root of our application. Note that the session secret should also be placed on environment variables and not hardcoded in the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*ybs4m9aINxnQ9caCodlmIQ.png" /></figure><pre>const express = require(&#39;express&#39;) <br><br>const session = require(&#39;express-session&#39;) <br>const passport = require(&#39;passport&#39;) <br>require(&#39;./utils/passport&#39;) <br><br>const app = express() <br>app.use( <br>  session({ <br>    resave: false, <br>    saveUninitialized: false, <br>    secret: &#39;sesion secret&#39;, <br>  }) <br>); <br><br>app.use(passport.initialize()) <br>app.use(passport.session()); <br><br>// routes <br>app.get(&#39;/&#39;, (req, res) =&gt; { <br>  res.send(&#39;&lt;a href=&quot;auth/google&quot;&gt;Authenticate with google&lt;/a&gt;&#39;) <br>}) <br><br>app.listen(3001, () =&gt; console.log(&#39;listening on 3001&#39;)) </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*o1aFYdwhsqbbAo7LKCKDVw.png" /></figure><p>After we set the passport configuration, we need to add routes for Google Authentication and redirect after authentication.</p><pre>const express = require(&#39;express&#39;) <br>const session = require(&#39;express-session&#39;) <br>const passport = require(&#39;passport&#39;) <br><br>require(&#39;./utils/passport&#39;) <br><br>const app = express() <br>app.use( <br>  session({ <br>    resave: false, <br>    saveUninitialized: false, <br>    secret: &#39;sesion secret&#39;, <br>  }) <br>); <br><br>app.use(passport.initialize()) <br>app.use(passport.session()); <br><br>// routes <br>app.get(&#39;/&#39;, (req, res) =&gt; { <br>  res.send(&#39;&lt;a href=&quot;auth/google&quot;&gt;Authenticate with google&lt;/a&gt;&#39;) <br>}) <br><br>app.get( <br>  &#39;/auth/google&#39;, <br>  passport.authenticate(&#39;google&#39;, { <br>    scope: [&#39;profile&#39;, &#39;email&#39;], <br>    prompt: &#39;select_account&#39;, <br>  }) <br>) <br><br>app.get( <br>  &#39;/auth/google/redirect&#39;, <br>  passport.authenticate(&#39;google&#39;, { <br>    failureRedirect: &#39;/&#39; <br>  }), <br>  // middleware for user add or create <br>  function(req, res) { <br>    res.send(&#39;success&#39;) <br>  } <br>); <br><br>app.listen(3001, () =&gt; console.log(&#39;listening on 3001&#39;))</pre><p>You can make a more sophisticated login page on the client side, but for this example, we will send a link to our Google login URI “/auth/google”.</p><p>In the first URI, we need to add scope on the authentication to let Google know what user info we want Google to send us back, and on the redirect URI, we can add middleware after authentication if we add other functionalities in our authentication.</p><p>Now that the implementation is done, we can go to the login page to test if Google OAuth is working on our application; in this example, we need to go to <a href="http://localhost:3001/">http://localhost:3001/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*sArtjeysy3szc5JgTRCqYw.png" /></figure><p>When we click authenticate, we should be directed to the Google consent screen to choose which user to log in to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*duxAo9S2UsS_IAAVojYVBQ.png" /></figure><p>After completing Google authentication, the user will be redirected to the URI we provided before.</p><p>Passport also provides other strategies for other OAuth and another type of authentication like jwt that you can check at <a href="https://www.passportjs.org/packages/">https://www.passportjs.org/packages/</a>.</p><p><em>This article is written by </em><a href="https://www.linkedin.com/in/hamzah-ay/"><em>Hamzah</em></a><em>, Upscalix’s Fullstack Developer.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb37ea118f44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Key to Success: Programmer Discipline Over High Skills]]></title>
            <link>https://upscalix.medium.com/the-key-to-success-programmer-discipline-over-high-skills-59efd743c699?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/59efd743c699</guid>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 02:09:46 GMT</pubDate>
            <atom:updated>2024-02-23T02:11:43.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvL6TGfFaPmEOtw1dzPDFg.jpeg" /></figure><p>In the fast-paced world of programming, where innovation and efficiency are paramount, the debate often revolves around whether skill or discipline is more crucial for success. While possessing high technical skills undoubtedly opens doors, it’s the discipline that ultimately paves the way for sustainable success in the long run.</p><p>In today’s digital landscape, the demand for skilled programmers is ever-growing. Employers often seek individuals with proficiency in various programming languages, frameworks, and technologies. However, what sets exceptional programmers apart isn’t just their technical prowess but their commitment to discipline.</p><p>Discipline in programming encompasses several key aspects:</p><ol><li><strong>Consistency</strong>: A disciplined programmer adheres to coding standards and best practices consistently. They write clean, maintainable code that is easy to understand and debug. Consistency in coding style and practices fosters collaboration within teams and ensures smoother project workflows.</li><li><strong>Time Management</strong>: Meeting deadlines and delivering projects on time is essential in the tech industry. A disciplined programmer manages their time efficiently, prioritising tasks effectively to meet project milestones. They understand the importance of estimating project timelines accurately and strive to deliver quality work within the specified timeframe.</li><li><strong>Continuous Learning</strong>: Technology evolves rapidly, and a disciplined programmer recognises the importance of lifelong learning. They invest time in expanding their knowledge base, staying updated with the latest trends, tools, and methodologies in the field. By embracing continuous learning, they remain adaptable and resilient in an ever-changing industry.</li><li><strong>Problem-Solving Skills</strong>: Programming is inherently problem-solving. A disciplined programmer approaches challenges systematically, breaking down complex problems into manageable components. They leverage their analytical skills and logical thinking to devise effective solutions, often thinking outside the box to overcome obstacles.</li><li><strong>Attention to Detail</strong>: In programming, even a minor error can have significant consequences. A disciplined programmer pays meticulous attention to detail, thoroughly reviewing their code for bugs and potential vulnerabilities. They conduct rigorous testing and debugging to ensure the reliability and robustness of their applications.</li></ol><p>While technical skills are undeniably important, they can be acquired and honed over time with practice and experience. On the other hand, discipline is a mindset — an innate trait that drives individuals to excel in their craft consistently.</p><p>In the pursuit of success in the tech industry, it’s crucial to prioritise discipline alongside technical proficiency. Companies value disciplined programmers not only for their ability to write efficient code but also for their reliability, professionalism, and commitment to excellence.</p><p>In conclusion, while high technical skills may open doors, it’s the discipline that keeps them open. By cultivating discipline in their approach to programming, individuals can set themselves on a path to long-term success and fulfillment in the ever-evolving world of technology.</p><p><em>This article is written by </em><a href="https://www.linkedin.com/in/rendybiz/"><em>Rendy</em></a><em>, Upscalix Tech Lead.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59efd743c699" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Svelte Store: Writable, Readable, and Derived]]></title>
            <link>https://upscalix.medium.com/exploring-svelte-store-writable-readable-and-derived-ba881f881cae?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba881f881cae</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[svelte]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 07:02:11 GMT</pubDate>
            <atom:updated>2023-10-23T07:02:11.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*8MJ3BiUB1TYxUn-kjqAoPg.png" /></figure><h3>Section 1: Writable — Managing State in Svelte Store</h3><p>Svelte is a popular JavaScript framework known for its simplicity and efficient handling of state management. The Svelte Store is a powerful tool for managing the state of your applications. This article will explore three critical concepts in Svelte Store: <strong>Writable</strong>, <strong>Readable</strong>, and <strong>Derived</strong>.</p><h4>Writable Stores</h4><p>Writable stores in Svelte create and manage mutable states that can be updated from various parts of your application. They act as a single source of truth for your data, making sharing and updating state across components easy.</p><p>Here’s a simple example of how to create and use a writable store in Svelte:</p><pre>&lt;script&gt;<br>  import { writable } from &#39;svelte/store&#39;;<br><br>  // Create a writable store with an initial value<br>  const count = writable(0);<br><br>  // Subscribe to changes in the store<br>  const unsubscribe = count.subscribe(value =&gt; {<br>    console.log(&#39;Count:&#39;, value);<br>  });<br><br>  // Update the store value<br>  count.set(5);<br><br>  // Unsubscribe when no longer needed<br>  unsubscribe();<br>&lt;/script&gt;</pre><p>In this code, we import the <em>writable</em> function from the ‘svelte/store’ package and create a writable store called <em>count</em> with an initial value of 0. We then subscribe to changes in the store and update its value with <em>count.set(5)</em>.</p><h3>Section 2: Readable — Accessing State Safely</h3><p>While writable stores allow you to modify a state, readable stores provide a way to access and observe that state without the ability to modify it. This is useful for scenarios where you want to ensure data consistency and prevent unintended changes.</p><h4>Readable Stores</h4><p>Here’s a simple example of how to create and use a readable store in Svelte:</p><pre>&lt;script&gt;<br>  import { readable } from &#39;svelte/store&#39;;<br><br>  // Create a readable store with an initial value<br>  const message = readable(&#39;Hello, Svelte!&#39;);<br><br>  // Subscribe to changes in the store<br>  const unsubscribe = message.subscribe(value =&gt; {<br>    console.log(&#39;Message:&#39;, value);<br>  });<br>&lt;/script&gt;</pre><p>In this code, we use the <em>readable</em> function to create a readable store called <em>message</em> with an initial value. We then subscribe to changes in the store and log the message value whenever it changes. You must note that you cannot update a readable store directly.</p><h3>Section 3: Derived — Computed State in Svelte</h3><p>Derived stores allow you to compute new values based on one or more other stores. These derived stores automatically update whenever the dependencies change, making them perfect for creating computed states in your Svelte applications.</p><h4>Derived Stores</h4><p>Here’s an example of how to create and use a derived store in Svelte:</p><pre>&lt;script&gt;<br>  import { writable, derived } from &#39;svelte/store&#39;;<br><br>  // Create two writable stores<br>  const width = writable(10);<br>  const height = writable(5);<br><br>  // Create a derived store that calculates area<br>  const area = derived([width, height], ([$width, $height]) =&gt; $width * $height);<br><br>  // Subscribe to changes in the derived store<br>  const unsubscribe = area.subscribe(value =&gt; {<br>    console.log(&#39;Area:&#39;, value);<br>  });<br><br>  // Update the width and height<br>  width.set(12);<br>  height.set(6);<br>&lt;/script&gt;</pre><p>In this code, we create two writable stores for <em>width</em> and <em>height</em>. Then, we make a derived store called <em>area</em> that computes the area based on the <em>width</em> and <em>height</em> values. The derived store updates automatically when its dependencies change, as demonstrated by the log output when we update width and height.</p><p>In summary, Svelte Store provides a powerful and flexible way to manage the state in Svelte applications. Writable stores allow you to create a mutable state, readable stores offer a way to access the state safely, and derived stores enable you to compute new values from the existing state. These features make Svelte Store a valuable tool for building efficient and maintainable applications.</p><p>In <a href="http://upscalix.com.au/"><em>Upscalix</em></a>, we always try to use the newest technology and trend to make digital solution for our client.</p><p>This article is written by <a href="https://www.linkedin.com/in/rendybiz/"><em>Rendy</em></a>, Upscalix Tech Lead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba881f881cae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Booking App UIs Using React Native — UIs Completion (Part 4)]]></title>
            <link>https://upscalix.medium.com/create-a-booking-app-uis-using-react-native-uis-completion-part-4-e7b8dcb17dc0?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7b8dcb17dc0</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 05:31:33 GMT</pubDate>
            <atom:updated>2023-10-20T05:31:33.348Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Create a Booking App UIs Using React Native — UIs Completion (Part 4)</strong></h3><p>Please read <a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-project-initiation-part-1-97d86876dd7e">part 1</a>, <a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-stack-navigator-bottom-tab-navigator-part-2-1c8b6fc051cb">part 2</a>, and <a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-layouting-uis-part-3-cb6d4c98cfa6">part 3</a> before read this article.</p><p>Continuing to the fourth part of the article, in this section, we will proceed with the layout process for the remaining design.</p><p>The design we will implement in this article section is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BW_UEr0zctUA6AeVS8xCxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sp9JAVaqx9VYvck2vWyA-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OWyZUtbDepSlhVG4WNH0A.png" /></figure><ol><li><strong>Layouting Order Form</strong></li></ol><p>We will break it down into 3 parts; the header, fields and submit section. Let’s open and edit the file <strong>PersonalInformation.js</strong>.</p><p><strong>1a. Header Order Form</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qZOCw9z-Tw7BB8AKHLNCDg.png" /></figure><p>In the header section, there is a back button, page title and a plus (+) button, which will be used to add people.</p><p>Here is the code for the header section.</p><pre>import React from &#39;react&#39;;<br>import {<br>  SafeAreaView,<br>  StyleSheet,<br>  Text,<br>  TouchableOpacity,<br>  View,<br>} from &#39;react-native&#39;;<br><br>import FontAwesome from &#39;react-native-vector-icons/FontAwesome&#39;;<br><br>const PersonalInformation = props =&gt; {<br>  return (<br>    &lt;SafeAreaView style={styles.safeArea}&gt;<br>      &lt;View style={styles.headerContainer}&gt;<br>        &lt;View style={styles.headerRightContentContainer}&gt;<br>          &lt;TouchableOpacity<br>            onPress={props.navigation.goBack}<br>            style={styles.backButton}&gt;<br>            &lt;FontAwesome name=&quot;chevron-left&quot; size={24} color=&quot;white&quot; /&gt;<br>          &lt;/TouchableOpacity&gt;<br><br>          &lt;Text style={styles.headerText}&gt;Personal Information&lt;/Text&gt;<br>        &lt;/View&gt;<br><br>        &lt;TouchableOpacity&gt;<br>          &lt;FontAwesome /&gt;<br>        &lt;/TouchableOpacity&gt;<br>      &lt;/View&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  safeArea: {<br>    backgroundColor: &#39;mediumseagreen&#39;,<br>    flex: 1,<br>  },<br>  headerContainer: {<br>    alignItems: &#39;center&#39;,<br>    flexDirection: &#39;row&#39;,<br>    padding: 20,<br>  },<br>  headerRightContentContainer: {<br>    flexDirection: &#39;row&#39;,<br>    flex: 1,<br>  },<br>  backButton: {<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>  headerText: {<br>    color: &#39;white&#39;,<br>    fontSize: 28,<br>    fontWeight: &#39;bold&#39;,<br>    marginLeft: 20,<br>  },<br>});<br><br>export default PersonalInformation;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4J_kRyc5aEKip0SumsjfqQ.png" /></figure><p><strong>1b. Fields Order Form</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0M1j1FOL-plItM2Un5BnTw.png" /></figure><p>For the fields section, since it is dynamic and can have more than one data entry, we will use <strong>useFieldArray </strong>from react-hook-form. Let’s import the module first.</p><pre>import {useFieldArray, useForm} from &#39;react-hook-form&#39;; </pre><p>Then, declare the form.</p><pre>const { <br>  control, <br>  formState: {isValid}, <br>} = useForm(); <br><br>const { <br>  fields, <br>  append, <br>  remove <br>} = useFieldArray({ control, name: &#39;list&#39;, }); </pre><p>Let’s add one state for numbering the IDs.</p><pre>const [idNumbering, setIdNumbering] = useState(0); </pre><p>And when the page is initially active, let’s add one empty data entry.</p><pre>useEffect(() =&gt; { <br>  append({ <br>    id: idNumbering, <br>    firstName: &#39;&#39;, <br>    lastName: &#39;&#39;, <br>    identityType: &#39;&#39;, <br>    identityNumber: &#39;&#39;, <br>    phoneNumber: &#39;&#39;, <br>  }); <br>}, [idNumbering, append]); </pre><p>For the UI of the fields, we place them outside the header and inside a ScrollView. Then, we iterate through the data fields, and in each iteration, we return a view containing the person’s number, a delete button, input fields for first name, last name, identity type, identity number, and phone number.</p><pre>&lt;ScrollView<br>  style={styles.scrollView}<br>  contentContainerStyle={styles.scrollViewContentContainer}&gt;<br>  {fields.map((field, index) =&gt; {<br>    return (<br>      &lt;View style={styles.formContainer} key={field.id}&gt;<br>        &lt;View style={styles.formHeaderContainer}&gt;<br>          &lt;Text style={styles.formTitle}&gt;Person {index + 1}&lt;/Text&gt;<br><br>          &lt;TouchableOpacity onPress={() =&gt; remove(index)}&gt;<br>            &lt;FontAwesome name=&quot;trash&quot; color=&quot;red&quot; size={24} /&gt;<br>          &lt;/TouchableOpacity&gt;<br>        &lt;/View&gt;<br><br>        &lt;Input<br>          control={control}<br>          placeholder=&quot;First Name&quot;<br>          style={styles.textInput}<br>          name={`list.${index}.firstName`}<br>          required<br>        /&gt;<br><br>        &lt;Input<br>          control={control}<br>          placeholder=&quot;Last Name&quot;<br>          style={styles.textInput}<br>          name={`list.${index}.lastName`}<br>          required<br>        /&gt;<br><br>        &lt;Input<br>          control={control}<br>          placeholder=&quot;Identity Type&quot;<br>          style={styles.textInput}<br>          name={`list.${index}.identityType`}<br>          required<br>        /&gt;<br><br>        &lt;Input<br>          control={control}<br>          placeholder=&quot;Identity Number&quot;<br>          style={styles.textInput}<br>          name={`list.${index}.identityNumber`}<br>          required<br>        /&gt;<br><br>        &lt;Input<br>          control={control}<br>          placeholder=&quot;Phone Number&quot;<br>          style={styles.textInput}<br>          name={`list.${index}.phoneNumber`}<br>          required<br>        /&gt;<br>      &lt;/View&gt;<br>    );<br>  })}<br>&lt;/ScrollView&gt;</pre><pre>scrollView: {<br>  backgroundColor: &#39;white&#39;,<br>  flex: 1,<br>},<br>scrollViewContentContainer: {<br>  flexGrow: 1,<br>  padding: 20,<br>},<br>formHeaderContainer: {<br>  flexDirection: &#39;row&#39;,<br>},<br>formTitle: {<br>  flex: 1,<br>  fontSize: 20,<br>  fontWeight: &#39;bold&#39;,<br>},<br>formContainer: {<br>  padding: 20,<br>  backgroundColor: &#39;gainsboro&#39;,<br>  borderRadius: 10,<br>  marginBottom: 20,<br>},<br>textInput: {<br>  backgroundColor: &#39;white&#39;,<br>  padding: 10,<br>  marginTop: 20,<br>},</pre><p><strong>1c. Submit Section Order Form</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7N5Cjljx84ut9_PiRJKEDg.png" /></figure><p>For this section, it’s straightforward. We display two text elements and one button to navigate the user to the <strong>OrderSuccess</strong> page. We also set the button to be disabled when the form is not valid.</p><pre>&lt;View style={styles.submitSectionContainer}&gt;<br>  &lt;View&gt;<br>    &lt;Text style={styles.totalLabel}&gt;Total&lt;/Text&gt;<br><br>    &lt;Text style={styles.priceLabel}&gt;${total}&lt;/Text&gt;<br>  &lt;/View&gt;<br><br>  &lt;TouchableOpacity<br>    activeOpacity={0.6}<br>    disabled={!isValid}<br>    style={{<br>      ...styles.submitButton,<br>      backgroundColor: isValid ? &#39;goldenrod&#39; : &#39;dimgray&#39;,<br>    }}<br>    onPress={() =&gt; props.navigation.replace(&#39;OrderSuccess&#39;)}&gt;<br>    &lt;Text style={styles.submitButtonLabel}&gt;Submit&lt;/Text&gt;<br>  &lt;/TouchableOpacity&gt;<br>&lt;/View&gt;</pre><pre>submitSectionContainer: {<br>  flexDirection: &#39;row&#39;,<br>  justifyContent: &#39;space-between&#39;,<br>  padding: 20,<br>  alignItems: &#39;center&#39;,<br>},<br>totalLabel: {<br>  color: &#39;black&#39;,<br>  fontSize: 20,<br>  fontWeight: &#39;bold&#39;,<br>},<br>priceLabel: {<br>  color: &#39;white&#39;,<br>  fontSize: 20,<br>  fontWeight: &#39;bold&#39;,<br>  marginTop: 10,<br>},<br>submitButton: {<br>  paddingVertical: 10,<br>  paddingHorizontal: 15,<br>  borderRadius: 10,<br>},<br>submitButtonLabel: {<br>  fontSize: 20,<br>  color: &#39;white&#39;,<br>  fontWeight: &#39;bold&#39;,<br>},</pre><p>The <strong>OrderForm</strong> page is now complete, and finally, we add the onPress props to the plus button with the following code:</p><pre>onPress={() =&gt; setIdNumbering(idNumbering + 1)} </pre><p>This is used to increment idNumbering. When the value of idNumbering changes, it triggers the code to append new data in the useEffect, creating a new field.</p><p><strong>2. Layouting Order Success</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sp9JAVaqx9VYvck2vWyA-Q.png" /></figure><p>Open the <strong>OrderSuccess.js</strong> file. For the <strong>OrderSuccess</strong> page, we will only display a text message followed by a button that, when pressed, will take the user to the <strong>MyOrders</strong> page.</p><pre>import React from &#39;react&#39;;<br>import {<br>  SafeAreaView,<br>  StyleSheet,<br>  Text,<br>  TouchableOpacity,<br>  View,<br>} from &#39;react-native&#39;;<br><br>const OrderSuccess = props =&gt; {<br>  return (<br>    &lt;SafeAreaView style={styles.safeArea}&gt;<br>      &lt;View style={styles.container}&gt;<br>        &lt;View style={styles.icon} /&gt;<br><br>        &lt;Text style={styles.text}&gt;Order has been successfully placed!&lt;/Text&gt;<br>      &lt;/View&gt;<br><br>      &lt;TouchableOpacity<br>        activeOpacity={0.6}<br>        onPress={() =&gt; props.navigation.navigate(&#39;MyOrders&#39;)}<br>        style={styles.button}&gt;<br>        &lt;Text style={styles.buttonLabel}&gt;Go To My Orders&lt;/Text&gt;<br>      &lt;/TouchableOpacity&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  safeArea: {<br>    flex: 1,<br>  },<br>  container: {<br>    flex: 1,<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>  icon: {<br>    height: 80,<br>    width: 80,<br>    backgroundColor: &#39;mediumseagreen&#39;,<br>    borderRadius: 10,<br>  },<br>  text: {<br>    fontSize: 20,<br>    margin: 20,<br>  },<br>  button: {<br>    alignSelf: &#39;center&#39;,<br>    backgroundColor: &#39;goldenrod&#39;,<br>    paddingHorizontal: 20,<br>    paddingVertical: 15,<br>    borderRadius: 10,<br>    margin: 20,<br>  },<br>  buttonLabel: {<br>    fontWeight: &#39;bold&#39;,<br>    color: &#39;white&#39;,<br>    fontSize: 20,<br>  },<br>});<br><br>export default OrderSuccess;</pre><p><strong>3. Layouting My Orders</strong></p><p>Open the <strong>MyOrders.js</strong> file. Here, we will split it into two stages; the header and the list.</p><p><strong>3a. My Orders Header</strong></p><p>Here is the display code for the header of the <strong>MyOrders</strong> page.</p><pre>import React from &#39;react&#39;;<br>import {<br>  SafeAreaView,<br>  StyleSheet,<br>  Text,<br>  TouchableOpacity,<br>  View,<br>} from &#39;react-native&#39;;<br><br>import FontAwesome from &#39;react-native-vector-icons/FontAwesome&#39;;<br><br>const MyOrders = props =&gt; {<br>  return (<br>    &lt;SafeAreaView style={styles.safeArea}&gt;<br>      &lt;View style={styles.container}&gt;<br>        &lt;View style={styles.headerContainer}&gt;<br>          &lt;Text style={styles.headerTitle}&gt;My Orders&lt;/Text&gt;<br><br>          &lt;View style={styles.headerNameContainer}&gt;<br>            &lt;Text style={styles.headerName}&gt;John Doe&lt;/Text&gt;<br><br>            &lt;TouchableOpacity<br>              activeOpacity={0.6}<br>              onPress={() =&gt; props.navigation.replace(&#39;Login&#39;)}&gt;<br>              &lt;FontAwesome name=&quot;sign-out&quot; size={24} color=&quot;red&quot; /&gt;<br>            &lt;/TouchableOpacity&gt;<br>          &lt;/View&gt;<br>        &lt;/View&gt;<br>      &lt;/View&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  safeArea: {<br>    backgroundColor: &#39;mediumseagreen&#39;,<br>    flex: 1,<br>  },<br>  container: {<br>    backgroundColor: &#39;white&#39;,<br>    flex: 1,<br>  },<br>  headerContainer: {<br>    backgroundColor: &#39;mediumseagreen&#39;,<br>    padding: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    color: &#39;white&#39;,<br>    fontWeight: &#39;bold&#39;,<br>  },<br>  headerNameContainer: {<br>    flexDirection: &#39;row&#39;,<br>    marginTop: 10,<br>  },<br>  headerName: {<br>    flex: 1,<br>    color: &#39;black&#39;,<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>  },<br>});<br><br>export default MyOrders;</pre><p><strong>3b. List My Orders</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-B8zNeQK2OnnurCMZ5Giw.png" /></figure><p>Let’s first prepare some dummy data to display the list of My Orders.</p><pre>const orders = [<br>  {<br>    name: &#39;Padar Island&#39;,<br>    numberOfPeople: 3,<br>    priceTotal: 165,<br>  },<br>  {<br>    name: &#39;Mount Bromo&#39;,<br>    numberOfPeople: 2,<br>    priceTotal: 80,<br>  },<br>];</pre><p>The code for the list view, which uses a ScrollView, is placed outside the header.</p><pre>&lt;ScrollView<br>  style={styles.scrollView}<br>  contentContainerStyle={styles.scrollViewContentContainer}&gt;<br>  {orders.map(order =&gt; {<br>    return (<br>      &lt;TouchableOpacity<br>        disabled<br>        activeOpacity={0.6}<br>        style={styles.orderItemButton}&gt;<br>        &lt;Text style={styles.orderItemTitle}&gt;{order}&lt;/Text&gt;<br><br>        &lt;Text style={styles.orderItemSubtitle}&gt;3 Persons&lt;/Text&gt;<br><br>        &lt;Text style={styles.orderItemPrice}&gt;$165&lt;/Text&gt;<br>      &lt;/TouchableOpacity&gt;<br>    );<br>  })}<br>&lt;/ScrollView&gt;</pre><pre>scrollView: {<br>  flex: 1,<br>},<br>scrollViewContentContainer: {<br>  paddingHorizontal: 20,<br>  paddingTop: 20,<br>},<br>orderItemButton: {<br>  backgroundColor: &#39;gainsboro&#39;,<br>  borderRadius: 10,<br>  marginBottom: 20,<br>  padding: 20,<br>},<br>orderItemTitle: {<br>  fontSize: 20,<br>  color: &#39;black&#39;,<br>  fontWeight: &#39;bold&#39;,<br>},<br>orderItemSubtitle: {<br>  fontSize: 20,<br>  color: &#39;black&#39;,<br>  marginTop: 10,<br>},<br>orderItemPrice: {<br>  alignSelf: &#39;flex-end&#39;,<br>  fontSize: 20,<br>  color: &#39;green&#39;,<br>  marginTop: 50,<br>  fontWeight: &#39;bold&#39;,<br>},</pre><p><strong>4. Bottom Tabs Icons</strong></p><p>The final touch, because the Bottom Tabs still display default icons, let’s set the icons to the ones you want to use in the<strong> BottomTabs.js</strong> file.</p><p>First, import the FontAwesome module:</p><pre>import FontAwesome from &#39;react-native-vector-icons/FontAwesome&#39;; </pre><p>Then, add the title and tabBarIcon keys to the options props in each screen like this:</p><pre>&lt;BottomTabsComponent.Screen <br>  name=&quot;Home&quot; <br>  options={{ <br>    title: &#39;Home&#39;, <br>    tabBarIcon: ({color}) =&gt; ( <br>      &lt;FontAwesome name=&quot;home&quot; size={24} color={color} /&gt; <br>    ), <br>  }} <br>  component={Home} <br>/&gt; <br><br>&lt;BottomTabsComponent.Screen <br>  name=&quot;MyOrders&quot; <br>  options={{ <br>    title: &#39;My Orders&#39;, <br>    tabBarIcon: ({color}) =&gt; ( <br>      &lt;FontAwesome name=&quot;list&quot; size={24} color={color} /&gt; <br>    ), <br>  }}<br>  component={MyOrders} <br>/&gt; </pre><p>So, when saved, the Bottom Tabs will change to look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1s011-8RZ4hGXbEWGB_xg.png" /></figure><p>And that is how we create booking app UIs using React Native. To summarise, there are four steps that you can do:</p><ol><li><a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-project-initiation-part-1-97d86876dd7e">Project initiation</a></li><li><a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-stack-navigator-bottom-tab-navigator-part-2-1c8b6fc051cb">Stack navigator &amp; bottom tab navigator</a></li><li><a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-layouting-uis-part-3-cb6d4c98cfa6">Layouting UIs</a></li><li>UIs completion</li></ol><p>What do you think about these articles series? Leave a comment below!</p><p>Interested in realising your dream app to help your business and your target market? Contact <a href="https://upscalix.com.au/contact"><strong><em>Upscalix</em></strong></a> now.</p><p><em>This article is written by </em><a href="http://upscalix.com.au/"><em>Upscalix</em></a><em> Senior Frontend and Mobile Developer, </em><a href="https://www.linkedin.com/in/reynald-prabha-nova/"><em>Nova</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7b8dcb17dc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Booking App UIs Using React-Native — Layouting UIs (Part 3)]]></title>
            <link>https://upscalix.medium.com/create-a-booking-app-uis-using-react-native-layouting-uis-part-3-cb6d4c98cfa6?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb6d4c98cfa6</guid>
            <category><![CDATA[application]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[ui-design-for-mobile-apps]]></category>
            <category><![CDATA[ui-development]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 04:02:14 GMT</pubDate>
            <atom:updated>2023-10-13T04:02:14.018Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Create a Booking App UIs Using React-Native — Layouting UIs (Part 3)</strong></h3><p>We’ve talked about project initiation in <a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-project-initiation-part-1-97d86876dd7e"><strong>part 1</strong></a> and how to create stack navigator &amp; bottom tab navigator in <a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-stack-navigator-bottom-tab-navigator-part-2-1c8b6fc051cb"><strong>part 2</strong></a>. On the third part of this article, we will start the layout processes based on the existing design.<br> <br>The design that we will implement is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AIVJNTK8w8a5JBXCkrqFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7NhaJyjF4MV7ovlUcjTbA.png" /><figcaption>(left: login, right: home)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FBkGKf3DtpBCAWzfNkJ3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_BQfXogN1JBnohD8A7mPQQ.png" /><figcaption>(left: search, right: detail)</figcaption></figure><ol><li><strong>Custom Input Component</strong></li></ol><p>Because we will use react-hook-form, we will first create a custom input component. This custom input component makes it easier to use input fields without having to repeatedly configure the react-hook-form controller.</p><p>Here is the custom input component code that we will use. Save it in a new folder named <strong>components</strong> and name the file Input.js.</p><pre>import React from &#39;react&#39;;<br>import {TextInput} from &#39;react-native&#39;;<br><br>import {useController} from &#39;react-hook-form&#39;;<br><br>function Input({<br>    autoCorrect,<br>    autoComplete,<br>    name,<br>    control,<br>    placeholder,<br>    testID,<br>    style,<br>    placeholderTextColor,<br>    secureTextEntry,<br>    required<br>}) {<br>    const {field} = useController({<br>        name,<br>        control,<br>        defaultValue: &#39;&#39;,<br>        rules: {<br>            required<br>        }<br>    });<br><br>    return (<br>        &lt;TextInput<br>            autoCorrect={autoCorrect}<br>            autoComplete={autoComplete}<br>            testID={testID}<br>            value={field.value}<br>            onChangeText={field.onChange}<br>            placeholder={placeholder}<br>            style={style}<br>            placeholderTextColor={placeholderTextColor}<br>            secureTextEntry={secureTextEntry}<br>        /&gt;<br>    )<br>}<br><br>export default Input;</pre><p><strong>2. Remove Header in Stack and Bottom Tabs Navigator</strong></p><p>Since we don’t need the default header from the navigator, we will set the header to be empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*ORYXpJBDPvsWhTkoxKFQ8g.png" /></figure><p>To do this, in the declaration of <strong>&lt;Stack.Navigator&gt;</strong> in the “App.tsx” file, add the screenOptions prop as follows, and this also applies to the Bottom Tabs Navigator in <strong>screens/BottomTabs.js</strong>.</p><pre>&lt;Stack.Navigator<br>  screenOptions={{<br>    header: () =&gt; null,<br>  }}</pre><pre>&lt;ReactNavigationBottomTabs.Navigator<br>  screenOptions={{<br>    header: () =&gt; null,<br>  }}</pre><p><strong>3. Login Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AIVJNTK8w8a5JBXCkrqFQ.png" /></figure><p>Based on the existing design, there is 1 text for the title, 2 input fields and one button with text inside it. Let’s modify the code in “Login.js” to create a UI skeleton.</p><pre>import React from &#39;react&#39;;<br>import {SafeAreaView, Text, TouchableOpacity, View} from &#39;react-native&#39;;<br><br>import Input from &#39;../components/Input&#39;;<br><br>const Login = () =&gt; {<br>    return (<br>        &lt;SafeAreaView&gt;<br>            &lt;View&gt;<br>                &lt;Text&gt;&lt;/Text&gt;<br><br>                &lt;View&gt;<br>                    &lt;Input /&gt;<br>                    &lt;Input /&gt;<br>                &lt;/View&gt;<br><br>                &lt;TouchableOpacity&gt;<br>                    &lt;Text&gt;&lt;/Text&gt;<br>                &lt;/TouchableOpacity&gt;<br>            &lt;/View&gt;<br>        &lt;/SafeAreaView&gt;<br>    );<br>};<br><br>export default Login;</pre><p>Then, from this UI skeleton, we will add styles to it, matching the design and the styles we created.</p><pre>import React from &#39;react&#39;;<br>import {StyleSheet, SafeAreaView, Text, TouchableOpacity, View} from &#39;react-native&#39;;<br><br>import Input from &#39;../components/Input&#39;;<br><br>const Login = () =&gt; {<br>    return (<br>        &lt;SafeAreaView style={styles.safeArea}&gt;<br>            &lt;View style={styles.container}&gt;<br>                &lt;Text style={styles.title}&gt;Tour App&lt;/Text&gt;<br><br>                &lt;View style={styles.textInputsContainer}&gt;<br>                    &lt;Input<br>                        name=&#39;username&#39;<br>                        autocomplete=&#39;username&#39;<br>                        autoCorrect={false}<br>                        placeholder=&#39;Username&#39;<br>                        style={styles.textInput}<br>                        placeholderTextColor=&#39;darkgray&#39;<br>                    /&gt;<br><br>                    &lt;Input<br>                        name=&#39;password&#39;<br>                        autocomplete=&#39;password&#39;<br>                        autoCorrect={false}<br>                        placeholder=&#39;Password&#39;<br>                        style={styles.textInput}<br>                        placeholderTextColor=&#39;darkgray&#39;<br>                        secureTextEntry<br>                    /&gt;<br>                &lt;/View&gt;<br><br>                &lt;TouchableOpacity style={styles.button}&gt;<br>                    &lt;Text style={styles.buttonLabel}&gt;Login&lt;/Text&gt;<br>                &lt;/TouchableOpacity&gt;<br>            &lt;/View&gt;<br>        &lt;/SafeAreaView&gt;<br>    );<br>};</pre><pre>const styles = StyleSheet.create({<br>    safeArea: {<br>        flex: 1,<br>    },<br>    container: {<br>        padding: 20,<br>        flex: 1,<br>        justifyContent: &#39;space-between&#39;,<br>        alignItems: &#39;center&#39;,<br>    },<br>    title: {<br>        color: &#39;black&#39;,<br>        fontSize: 36,<br>        fontWeight: &#39;bold&#39;,<br>    },<br>    textInputsContainer: {<br>        width: &#39;100%&#39;,<br>    },<br>    textInput: {<br>        backgroundColor: &#39;white&#39;,<br>        color: &#39;black&#39;,<br>        width: &#39;100%&#39;,<br>        padding: 10,<br>        height: 40,<br>        borderRadius: 10,<br>        marginTop: 20,<br>    },<br>    button: {<br>        width: &#39;100%&#39;,<br>        padding: 15,<br>        borderRadius: 10,<br>        alignItems: &#39;center&#39;,<br>    },<br>    buttonLabel: {<br>        color: &#39;white&#39;,<br>        fontSize: 28,<br>        fontWeight: &#39;bold&#39;,<br>    },<br>});</pre><p>The login page UI has been successfully created. Now, let’s add form functionality and import useForm.</p><pre>import {useForm} from &#39;react-hook-form&#39;; <br> <br>// Declare the hooks. <br> <br>const { <br>  control, <br>  formState: {isValid}, <br>} = useForm(); </pre><p>Add control from the hooks form and set the required attribute for input values to true.</p><pre>&lt;Input<br>    control={control}<br>    name=&#39;username&#39;<br>    autocomplete=&#39;username&#39;<br>    autoCorrect={false}<br>    placeholder=&#39;Username&#39;<br>    style={styles.textInput}<br>    placeholderTextColor=&#39;darkgray&#39;<br>    required={true}<br>/&gt;<br><br>&lt;Input<br>    control={control}<br>    name=&#39;password&#39;<br>    autocomplete=&#39;password&#39;<br>    autoCorrect={false}<br>    placeholder=&#39;Password&#39;<br>    style={styles.textInput}<br>    placeholderTextColor=&#39;darkgray&#39;<br>    secureTextEntry<br>    required={true}<br>/&gt;</pre><p>Lastly, add the disabled property to control the button’sbutton’s activation only when the form is complete and valid. The onPress should contain a custom function <strong>submitLogin</strong>, where <strong>submitLogin</strong> includes the command to navigate to the <strong>BottomTabs</strong> page.</p><pre>const submitLogin = () =&gt; {<br>    props.navigation.replace(&#39;BottomTabs&#39;);<br>}</pre><pre>&lt;TouchableOpacity<br>    onPress={submitLogin}<br>    disabled={!isValid}<br>    style={[<br>        styles.button,<br>        {<br>            backgroundColor: isValid ? &#39;mediumseagreen&#39; : &#39;dimgray&#39;<br>        }<br>    ]}<br>&gt;<br>    &lt;Text style={styles.buttonLabel}&gt;Login&lt;/Text&gt;<br>&lt;/TouchableOpacity&gt;</pre><p>Remember to change const Login = () =&gt; { to const Login = props =&gt; { because we will retrieve props from the login page.</p><p><strong>4. Home Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7NhaJyjF4MV7ovlUcjTbA.png" /></figure><p>We will implement a list and react-native-swiper on this page to display slides.</p><p>We will work on it section by section, starting with the header, then the slider and finally the category list section.</p><p><strong>4a. Home Header</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*2TzQ2g20VJWQrFLr0hpIhQ.png" /></figure><p>The first part is the header of the Home page, which consists of a text input, a search button and a text title.</p><p>Here, we modify the code in Home.js to create a UI skeleton like this.</p><pre>import React from &#39;react&#39;;<br>import {SafeAreaView, TextInput, TouchableOpacity, View} from &#39;react-native&#39;;<br><br>import FontAwesome from &#39;react-native-vector-icons/FontAwesome&#39;;<br><br>const Home = () =&gt; {<br>    return (<br>        &lt;SafeAreaView&gt;<br>            &lt;View&gt;<br>                &lt;View&gt;<br>                    &lt;TextInput /&gt;<br><br>                    &lt;TouchableOpacity&gt;<br>                        &lt;FontAwesome /&gt;<br>                    &lt;/TouchableOpacity&gt;<br>                &lt;/View&gt;<br><br>                &lt;View&gt;<br>                    &lt;View&gt;<br>                        &lt;Text&gt;&lt;/Text&gt;<br>                    &lt;/View&gt;<br>                &lt;/View&gt;<br>            &lt;/View&gt;<br>        &lt;/SafeAreaView&gt;<br>    )<br>}<br><br>export default Home;</pre><p>Afterwards, we add styles to this code skeleton to match the existing design.</p><pre>&lt;SafeAreaView style={styles.safeArea}&gt;<br>    &lt;View style={styles.container}&gt;<br>        &lt;View style={styles.searchSectionContainer}&gt;<br>            &lt;TextInput<br>                placeholder=&#39;Search Destination&#39;<br>                placeholderTextColor=&#39;darkgray&#39;<br>                style={styles.searchTextInput}<br>            /&gt;<br><br>            &lt;TouchableOpacity<br>                activeOpacity={0.6}<br>                style={styles.searchSubmitButton}<br>            &gt;<br>                &lt;FontAwesome name=&#39;search&#39; color=&#39;white&#39; size={20} /&gt;<br>            &lt;/TouchableOpacity&gt;<br>        &lt;/View&gt;<br><br>        &lt;View style={styles.mainContentContainer}&gt;<br>            &lt;View style={styles.welcomeSectionContainer}&gt;<br>                &lt;Text style={styles.welcomeSectionLabel}&gt;Welcome to Tour App!&lt;/Text&gt;<br>            &lt;/View&gt;<br>        &lt;/View&gt;<br>    &lt;/View&gt;<br>&lt;/SafeAreaView&gt;</pre><pre>const styles = StyleSheet.create({<br>    safeArea: {<br>        flex: 1,<br>        backgroundColor: &#39;mediumseagreen&#39;,<br>    },<br>    container: {<br>        backgroundColor: &#39;white&#39;,<br>        flex: 1,<br>    },<br>    searchSectionContainer: {<br>        backgroundColor: &#39;mediumseagreen&#39;,<br>        flexDirection: &#39;row&#39;,<br>        padding: 15,<br>    },<br>    searchTextInput: {<br>        backgroundColor: &#39;white&#39;,<br>        color: &#39;black&#39;,<br>        flex: 1,<br>        padding: 10,<br>        borderRadius: 10,<br>    },<br>    searchSubmitButton: {<br>        backgroundColor: &#39;goldenrod&#39;,<br>        marginLeft: 15,<br>        width: 40,<br>        height: 40,<br>        borderRadius: 10,<br>        justifyContent: &#39;center&#39;,<br>        alignItems: &#39;center&#39;,<br>    },<br>    mainContentContainer: {<br>        flex: 1,<br>    },<br>    welcomeSectionContainer: {<br>        backgroundColor: &#39;mediumseagreen&#39;,<br>        padding: 20,<br>        alignItems: &#39;center&#39;,<br>        justifyContent: &#39;center&#39;,<br>    },<br>    welcomeSectionLabel: {<br>        color: &#39;white&#39;,<br>        fontSize: 20,<br>        fontWeight: &#39;bold&#39;,<br>    },<br>});</pre><p>Then, it will look like this and the Home Header section is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0ZpgpXy2DqGeJe3xsrYQw.png" /></figure><p><strong>4b. Home Slider</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*jit4r8jRttWGZtO8XG9nYQ.png" /></figure><p>Now, let’s move on to the slider. We will use react-native-swiper. First, let’s create some dummy data that we can later display in the slider.</p><pre>import React from &#39;react&#39;;<br>import {SafeAreaView, TextInput, TouchableOpacity, View} from &#39;react-native&#39;;<br><br>import FontAwesome from &#39;react-native-vector-icons/FontAwesome&#39;;<br><br>const Home = () =&gt; {<br>    return (<br>        &lt;SafeAreaView&gt;<br>            &lt;View&gt;<br>                &lt;View&gt;<br>                    &lt;TextInput /&gt;<br><br>                    &lt;TouchableOpacity&gt;<br>                        &lt;FontAwesome /&gt;<br>                    &lt;/TouchableOpacity&gt;<br>                &lt;/View&gt;<br><br>                &lt;View&gt;<br>                    &lt;View&gt;<br>                        &lt;Text&gt;&lt;/Text&gt;<br>                    &lt;/View&gt;<br>                &lt;/View&gt;<br>            &lt;/View&gt;<br>        &lt;/SafeAreaView&gt;<br>    )<br>}<br><br>export default Home;</pre><p>Then, we import the library using import Swiper from ‘’react-native-swiper’’ and declare the UI slider and its styles below the title section. We place it inside a ScrollView because the slider is part of the vertically scrollable content.</p><pre>&lt;ScrollView<br>    contentContainerStyle={styles.scrollViewContentContainer}<br>    style={styles.scrollViewContainer}<br>&gt;<br>    &lt;View style={styles.sliderContainer}&gt;<br>        &lt;Swiper<br>            showPagination={true}<br>            height={200}<br>            dotColor=&#39;gray&#39;<br>            activeDotColor=&#39;goldenrod&#39;<br>        &gt;<br>            {sliderData.map(slider =&gt; {<br>                return (<br>                    &lt;View<br>                        key={slider.id}<br>                    &gt;<br>                        &lt;Image<br>                            source={{<br>                                uri: slider.url,<br>                            }}<br>                            style={styles.sliderImage}<br>                        /&gt;<br>                    &lt;/View&gt;<br>                )<br>            })}<br>        &lt;/Swiper&gt;<br>    &lt;/View&gt;<br>&lt;/ScrollView&gt;</pre><pre>scrollViewContentContainer: {<br>  flexGrow: 1,<br>},<br>scrollViewContainer: {<br>  flex: 1,<br>},<br>sliderContainer: {<br>  height: 250,<br>},<br>sliderImage: {<br>  height: 250,<br>  width: &#39;100%&#39;<br>},</pre><p>So, we have successfully displayed the slider with the dummy data that we prepared.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rYSRsWDY-NJ-y0HsfZuH4A.png" /></figure><p><strong>4c. Categories: Home</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*1u9KuRCk6z9F8MB_72Aq-g.png" /></figure><p>We prepare dummy data to display the category list section as follows.</p><pre>const categories = [<br>  {<br>    id: 0,<br>    name: &#39;Adventure&#39;,<br>    items: [<br>      {<br>        id: 0,<br>        name: &#39;Mount Ijen&#39;,<br>        uri: &#39;https://images.unsplash.com/photo-1555058170-94d5f5016a2c?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1470&amp;q=80&#39;,<br>      },<br>      {<br>        id: 1,<br>        name: &#39;Mount Bromo&#39;,<br>        uri: &#39;https://images.unsplash.com/photo-1602154663343-89fe0bf541ab?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1631&amp;q=80&#39;,<br>      },<br>    ],<br>  },<br>  {<br>    id: 1,<br>    name: &#39;Historical&#39;,<br>    items: [<br>      {<br>        id: 0,<br>        name: &#39;Museum Fatahillah&#39;,<br>        uri: &#39;https://images.unsplash.com/photo-1642064816139-36f0f72192b0?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=2940&amp;q=80&#39;,<br>      },<br>      {<br>        id: 1,<br>        name: &#39;National Monumemnt&#39;,<br>        uri: &#39;https://images.unsplash.com/photo-1611637405506-e6e6ca710362?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=2874&amp;q=80&#39;,<br>      },<br>    ],<br>  },<br>];</pre><p>Following the declaration of UI and its styles, we display text that says “By Type,” and then we show a list with category names. Each category will display a horizontal list of items within it.</p><pre>&lt;Text style={styles.byCategoryLabel}&gt;By Type&lt;/Text&gt;<br><br>{categories.map(category =&gt; {<br>  return (<br>    &lt;View key={category.id} style={styles.categoryContainer}&gt;<br>      &lt;Text style={styles.categoryNameLabel}&gt;<br>        {category.name}<br>      &lt;/Text&gt;<br><br>      &lt;ScrollView<br>        horizontal<br>        contentContainerStyle={<br>          styles.categoryScrollViewContentContainer<br>        }&gt;<br>        {category.items.map(categoryItem =&gt; {<br>          return (<br>            &lt;TouchableOpacity<br>              key={categoryItem.id}<br>              activeOpacity={0.6}<br>              style={styles.categoryItemButton}<br>              onPress={() =&gt;<br>                props.navigation.navigate(&#39;DestinationDetail&#39;)<br>              }&gt;<br>              &lt;Image<br>                style={styles.categoryItemImage}<br>                source={{uri: categoryItem.uri}}<br>              /&gt;<br><br>              &lt;Text style={styles.categoryItemName}&gt;<br>                {categoryItem.name}<br>              &lt;/Text&gt;<br>            &lt;/TouchableOpacity&gt;<br>          );<br>        })}<br>      &lt;/ScrollView&gt;<br>    &lt;/View&gt;<br>  );<br>})}</pre><pre>byCategoryLabel: {<br>  color: &#39;black&#39;,<br>  fontSize: 20,<br>  fontWeight: &#39;bold&#39;,<br>  padding: 20,<br>},<br>categoryContainer: {<br>  backgroundColor: &#39;rgb(60, 60, 60)&#39;,<br>  paddingBottom: 20,<br>  marginBottom: 10,<br>},<br>categoryNameLabel: {<br>  color: &#39;white&#39;,<br>  fontSize: 20,<br>  fontWeight: &#39;bold&#39;,<br>  padding: 20,<br>},<br>categoryScrollViewContentContainer: {<br>  paddingRight: 20,<br>},<br>categoryItemButton: {<br>  marginLeft: 20,<br>},<br>categoryItemImage: {<br>  height: 200,<br>  width: 150,<br>  borderRadius: 10,<br>},<br>categoryItemName: {<br>  color: &#39;white&#39;,<br>  textAlign: &#39;center&#39;,<br>  marginTop: 10,<br>  fontWeight: &#39;bold&#39;,<br>},</pre><p>We have successfully displayed the category list and the list of items for each category. Notice that on each item’sitem’s button, there is onPress={() =&gt; props.navigation.navigate(‘’DestinationDetail’’)}. We set it up this way so that when users press the item button, it will take them to the <strong>DestinationDetail</strong> page. As a note, the <strong>props</strong> are taken from the Home page by declaring Home like this: const Home = props =&gt; {…}.</p><p><strong>4d. Search Home</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7NhaJyjF4MV7ovlUcjTbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FBkGKf3DtpBCAWzfNkJ3w.png" /></figure><p>The final part of the user interface for the <strong>Home</strong> page is the implementation of the search feature. This search feature is still part of the <strong>Home</strong> page, but its display is conditional. If the input is active, we will display the Home content, and if the information is not functional, we will show the search section.</p><p>Let’s start by creating two new states, one to store the search input value.</p><pre>const [search, setSearch] = useState(&#39;&#39;);<br>const [isSearchInputFocused, setIsSearchInputFocused] = useState(false);</pre><p>In the declaration of the UI input, we add the following props:</p><pre>&lt;TextInput<br>  placeholder=&quot;Search Destination&quot;<br>  placeholderTextColor=&quot;darkgray&quot;<br>  style={styles.searchTextInput}<br>  onFocus={() =&gt; setIsSearchInputFocused(true)}<br>  onBlur={() =&gt; setIsSearchInputFocused(false)}<br>  value={search}<br>  onChangeText={value =&gt; setSearch(value)}<br>  autoCorrect={false}<br>/&gt;</pre><p>We save the input’s focus state using callbacks <strong>onFocus</strong> and <strong>onBlur</strong>, and then we use the <strong>onChangeText</strong> callback to store the latest input value.</p><p>Next, we move the main content from the View with the welcomeSectionContainer style up to the closing tag of ScrollView into a variable named <strong>MainContent</strong>.</p><pre>const MainContent = (<br>  &lt;&gt;<br>    &lt;View style={styles.welcomeSectionContainer}&gt;<br>      &lt;Text style={styles.welcomeSectionLabel}&gt;Welcome Tour App&lt;/Text&gt;<br>    &lt;/View&gt;<br><br>    &lt;ScrollView<br>      contentContainerStyle={styles.scrollViewContentContainer}<br>      style={styles.scrollViewContainer}&gt;<br>      &lt;View style={styles.sliderContainer}&gt;<br>        &lt;Swiper<br>          showsPagination={true}<br>          height={200}<br>          dotColor=&quot;gray&quot;<br>          activeDotColor=&quot;goldenrod&quot;&gt;<br>          {sliderData.map(slider =&gt; {<br>            return (<br>              &lt;View key={slider.id}&gt;<br>                &lt;Image<br>                  source={{<br>                    uri: slider.uri,<br>                  }}<br>                  style={styles.sliderImage}<br>                /&gt;<br>              &lt;/View&gt;<br>            );<br>          })}<br>        &lt;/Swiper&gt;<br>      &lt;/View&gt;<br><br>      &lt;Text style={styles.byCategoryLabel}&gt;My Type&lt;/Text&gt;<br><br>      {categories.map(category =&gt; {<br>        return (<br>          &lt;View key={category.id} style={styles.categoryContainer}&gt;<br>            &lt;Text style={styles.categoryNameLabel}&gt;{category.name}&lt;/Text&gt;<br><br>            &lt;ScrollView<br>              horizontal={true}<br>              contentContainerStyle={<br>                styles.categoryScrollViewContentContainer<br>              }&gt;<br>              {category.items.map(categoryItem =&gt; {<br>                return (<br>                  &lt;TouchableOpacity<br>                    key={categoryItem.id}<br>                    activeOpacity={0.6}<br>                    style={styles.categoryItemButton}<br>                    onPress={() =&gt;<br>                      props.navigation.navigate(&#39;DestinationDetail&#39;)<br>                    }&gt;<br>                    &lt;Image<br>                      style={styles.categoryItemImage}<br>                      source={{uri: categoryItem.uri}}<br>                    /&gt;<br><br>                    &lt;Text style={styles.categoryItemName}&gt;<br>                      {categoryItem.name}<br>                    &lt;/Text&gt;<br>                  &lt;/TouchableOpacity&gt;<br>                );<br>              })}<br>            &lt;/ScrollView&gt;<br>          &lt;/View&gt;<br>        );<br>      })}<br>    &lt;/ScrollView&gt;<br>  &lt;/&gt;<br>);</pre><p>We create variable dummy destinations containing dummy search options.</p><pre>const destinations = [<br>  &#39;Mount Ijen&#39;,<br>  &#39;Mount Kerinci&#39;,<br>  &#39;Museum Fatahillah&#39;,<br>  &#39;National Monument&#39;,<br>];</pre><p>We also create a new variable called SearchSection, and the UI and code for SearchSection will look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FBkGKf3DtpBCAWzfNkJ3w.png" /></figure><pre>const SearchSection = (<br>  &lt;View style={styles.searchPageContainer}&gt;<br>    {destinations<br>      .filter(item =&gt; item.toLowerCase().includes(search.toLowerCase()))<br>      .map(item =&gt; {<br>        return (<br>          &lt;TouchableOpacity<br>            activeOpacity={0.6}<br>            onPress={() =&gt; props.navigation.navigate(&#39;DestinationDetail&#39;)}<br>            style={styles.searchItemButton}&gt;<br>            &lt;Text&gt;{item}&lt;/Text&gt;<br>          &lt;/TouchableOpacity&gt;<br>        );<br>      })}<br>  &lt;/View&gt;<br>);</pre><pre>searchPageContainer: {<br>  position: &#39;absolute&#39;,<br>  top: 0,<br>  right: 0,<br>  left: 0,<br>  bottom: 0,<br>},<br>searchItemButton: {<br>  borderBottomWidth: 1,<br>  borderColor: &#39;gray&#39;,<br>  padding: 20,<br>},</pre><p>Once we’ve created the <strong>MainContent</strong> and <strong>SearchSection</strong> separately in their respective variables, it becomes easier to describe their conditional rendering.</p><pre>&lt;View style={styles.mainContentContainer}&gt;<br>  {isSearchInputFocused ? SearchSection : MainContent}<br>&lt;/View&gt;</pre><pre>mainContentContainer: {<br>  flex: 1,<br>},</pre><p>Up to this point, we have successfully created the Home page, which includes the header, slider, categories and search sections. Next, we will make the <strong>DestinationDetail </strong>page.</p><p><strong>5. DestinationDetail Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_BQfXogN1JBnohD8A7mPQQ.png" /></figure><p>This is the last page we will create in this article. Here, we will display a slider that will show multiple photos, names, prices, descriptions and the location of the destination.</p><p>We will gradually create the layout for this page, starting with the header, then the slider, followed by the metadata along with the map and finally the order button.</p><p>Open the <strong>DestinationDetail.js </strong>file.</p><p><strong>5a. Destination Detail Header</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*9iwRl1l8COCeLq2l7i5wXw.png" /></figure><p>Here is the code we will use to create the DestinationDetail page header.</p><pre>const DestinationDetail = props =&gt; {<br>  return (<br>      &lt;SafeAreaView style={styles.safeArea}&gt;<br>        &lt;View style={styles.headerContainer}&gt;<br>          &lt;TouchableOpacity<br>            onPress={props.navigation.goBack}<br>            style={styles.backButton}&gt;<br>            &lt;FontAwesome name=&quot;chevron-left&quot; size={24} color=&quot;white&quot; /&gt;<br>          &lt;/TouchableOpacity&gt;<br>  <br>          &lt;Text style={styles.headerText}&gt;Destination Detail&lt;/Text&gt;<br>        &lt;/View&gt;<br>      &lt;/SafeAreaView&gt;<br>    )<br>}</pre><pre>const styles = StyleSheet.create({<br>  safeArea: {<br>    backgroundColor: &#39;mediumseagreen&#39;,<br>    flex: 1,<br>  },<br>  headerContainer: {<br>    alignItems: &#39;center&#39;,<br>    flexDirection: &#39;row&#39;,<br>    padding: 20,<br>  },<br>  backButton: {<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>  headerText: {<br>    color: &#39;white&#39;,<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    marginLeft: 20,<br>  },<br>});</pre><p><strong>5b. Destination Detail Slider</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*VCOEAXcguJWnK-dOuxTgiQ.png" /></figure><p>We will use the same approach as the header on the <strong>Home</strong> page for the slider section.</p><p>Let’s start by creating some dummy data, for example, images that will be displayed.</p><pre>const sliderData = [<br>  {<br>    id: 0,<br>    uri: &#39;https://images.unsplash.com/photo-1571366343168-631c5bcca7a4?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1471&amp;q=80&#39;,<br>  },<br>  {<br>    id: 1,<br>    uri: &#39;https://images.unsplash.com/photo-1684141419225-d56a858465b3?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1470&amp;q=80&#39;,<br>  },<br>];</pre><p>And here is the UI code for our slider. We will display it below the previously created header and place it within a new ScrollView.</p><pre>&lt;ScrollView style={styles.scrollView}&gt;<br>  &lt;View style={styles.sliderContainer}&gt;<br>    &lt;Swiper<br>      showsPagination<br>      activeDotColor=&quot;mediumseagreen&quot;<br>      dotColor=&quot;gray&quot;&gt;<br>      {sliderData.map(item =&gt; {<br>        return (<br>          &lt;Image<br>            key={item.id}<br>            source={{<br>              uri: item.uri,<br>            }}<br>            style={styles.sliderImage}<br>          /&gt;<br>        );<br>      })}<br>    &lt;/Swiper&gt;<br>  &lt;/View&gt;<br>&lt;/ScrollView&gt;</pre><pre>scrollView: {<br>  backgroundColor: &#39;white&#39;,<br>  flex: 1,<br>},<br>sliderContainer: {<br>  height: 250,<br>},<br>sliderImage: {<br>    height: 250,<br>  width: &#39;100%&#39;<br>},</pre><p><strong>5c. Destination Detail Metadata</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*RBQNU3_vyx54vyIp9gezUw.png" /></figure><p>In this section, we will display the destination’s name, price, description and location, which requires 3 text elements and 1 MapView.</p><p>We import the MapView from ‘’react-native-maps’’ and create a variable, e.g. const price = 55; for the price example. Here is the complete code for layouting this section.</p><pre>&lt;View style={styles.destinationLabelContainer}&gt;<br>  &lt;Text style={styles.destinationLabel}&gt;Padar Island&lt;/Text&gt;<br><br>  &lt;Text style={styles.destinationPriceLabel}&gt;${price} / pax&lt;/Text&gt;<br>&lt;/View&gt;<br><br>&lt;Text style={styles.descriptionLabel}&gt;<br>  Experience the enchanting beauty of Padar Island&#39;s lush landscape scenery<br>&lt;/Text&gt;<br><br>&lt;View style={styles.mapContainer}&gt;<br>  &lt;MapView<br>    scrollEnabled={false}<br>    rotateEnabled={false}<br>    zoomEnabled={false}<br>    initialRegion={{<br>      latitude: -6.9903587,<br>      longitude: 110.4230505,<br>      latitudeDelta: 0.005,<br>      longitudeDelta: 0.005,<br>    }}<br>    style={styles.map}<br>  /&gt;<br>&lt;/View&gt;</pre><pre>destinationLabelContainer: {<br>  alignItems: &#39;center&#39;,<br>  flexDirection: &#39;row&#39;,<br>  justifyContent: &#39;space-between&#39;,<br>  padding: 20,<br>},<br>destinationLabel: {<br>  fontSize: 20,<br>  fontWeight: &#39;bold&#39;,<br>},<br>destinationPriceLabel: {<br>  fontSize: 20,<br>  color: &#39;mediumseagreen&#39;,<br>  fontWeight: &#39;bold&#39;,<br>},<br>descriptionLabel: {<br>  paddingHorizontal: 20,<br>},<br>mapContainer: {<br>  marginHorizontal: 20,<br>  marginTop: 20,<br>},<br>map: {<br>  height: 200,<br>  width: &#39;100%&#39;,<br>},</pre><p><strong>5d. Order Button Section Destination Detail</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*asPG1HCW1yKxNJhWxVZ9bQ.png" /></figure><p>The last part is the order button section, which is quite simple. We create a static View that will always appear below and outside the ScrollView, containing a single button.</p><p>Here is the code for its appearance. Place it below and outside the ScrollView.</p><pre>&lt;View style={styles.orderNowButtonContainer}&gt;<br>  &lt;TouchableOpacity<br>    activeOpacity={0.6}<br>    style={styles.orderNowButton}<br>    onPress={() =&gt;<br>      props.navigation.navigate(&#39;PersonalInformation&#39;, {price})<br>    }&gt;<br>    &lt;Text style={styles.orderNowButtonLabel}&gt;Order Now&lt;/Text&gt;<br>  &lt;/TouchableOpacity&gt;<br>&lt;/View&gt;</pre><pre>orderNowButtonContainer: {<br>  padding: 20,<br>  backgroundColor: &#39;mediumseagreen&#39;,<br>  alignItems: &#39;flex-end&#39;,<br>},<br>orderNowButton: {<br>  backgroundColor: &#39;goldenrod&#39;,<br>  paddingVertical: 10,<br>  paddingHorizontal: 15,<br>  borderRadius: 10,<br>},<br>orderNowButtonLabel: {<br>  fontSize: 20,<br>  color: &#39;white&#39;,<br>  fontWeight: &#39;bold&#39;,<br>},</pre><p>Notice that on the “Order Now” button, an onPress navigates the user to the <strong>PersonalInformation</strong> page, followed by passing the data parameter price from this page to the destination page.</p><p>The layout of the <strong>DestinationDetail</strong> page is complete. We will continue with the following article for the design of the <strong>PersonalInformation</strong>, <strong>SuccessOrder</strong> and <strong>OrderList</strong> pages.</p><p>Continue to part 4.</p><p>Interested in realising your dream app to help your business and your target market? Contact <a href="https://upscalix.com.au/contact"><strong><em>Upscalix</em></strong></a> now.</p><p><em>This article is written by </em><a href="http://upscalix.com.au/"><em>Upscalix</em></a><em> Senior Frontend and Mobile Developer, </em><a href="https://www.linkedin.com/in/reynald-prabha-nova/"><em>Nova</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb6d4c98cfa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Booking App UIs Using React Native — Stack Navigator & Bottom Tab Navigator (Part 2)]]></title>
            <link>https://upscalix.medium.com/create-a-booking-app-uis-using-react-native-stack-navigator-bottom-tab-navigator-part-2-1c8b6fc051cb?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c8b6fc051cb</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 05:02:42 GMT</pubDate>
            <atom:updated>2023-09-27T05:02:42.579Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Create a Booking App UIs Using React Native — Stack Navigator &amp; Bottom Tab Navigator (Part 2)</strong></h3><p>Please read part 1 <a href="https://medium.com/@upscalix/create-a-booking-app-uis-using-react-native-project-initiation-part-1-97d86876dd7e"><strong><em>here</em></strong></a>.</p><p>Continuing from the part of how to create a booking app UIs using React Native, in this part 2, we will focus on compiling the Stack Navigator and Bottom Tab Navigator structure in the application.</p><p>Until the end of the second part of this article, we will not put the actual UI, but we will create application page files that contain a dummy UI first.</p><p>The points that will be discussed in the second part are as follows:</p><ul><li>Bottom Tabs Navigator implementation</li><li>Stack Navigator implementation</li></ul><p>1️⃣ <strong>Arrangement of Bottom Tabs Navigator</strong></p><p>First of all, we will create a Bottom Tabs navigation file. Bottom Tabs is a navigation system containing a list of icons at the bottom of the screen that represent the meanings of the page, and when one of the icons is clicked, it will bring and display users to the page.</p><p>The Bottom Tabs that we will create are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GaMGKUR9jhDUDmf3Lm130g.png" /></figure><p>There are two tabs: the Home tab and the My Orders tab.</p><p>Immediately, we created a new file called <strong>Home.js</strong> in a new folder called <strong>screens</strong>.</p><pre>import React from &#39;react&#39;;<br>import {Text, View} from &#39;react-native&#39;;<br><br>const Home = () =&gt; {<br>    return (<br>        &lt;View<br>            style={{<br>                alignItems: &#39;center&#39;,<br>                flex: 1,<br>                justifyContent: &#39;center&#39;<br>            }}<br>        &gt;<br>            &lt;Text<br>                style={{<br>                    fontSize: 28,<br>                    fontWeight: &#39;bold&#39;<br>                }}<br>            &gt;<br>                Home<br>            &lt;/Text&gt;<br>        &lt;/View&gt;<br>    )<br>}<br><br>export default Home;</pre><p>Then, create a new file, <strong>MyOrders.js</strong>, in the <strong>screens folder</strong>.</p><pre>import React from &#39;react&#39;;<br>import {Text, View} from &#39;react-native&#39;;<br><br>const MyOrders = () =&gt; {<br>    return (<br>        &lt;View<br>            style={{<br>                alignItems: &#39;center&#39;,<br>                flex: 1,<br>                justifyContent: &#39;center&#39;<br>            }}<br>        &gt;<br>            &lt;Text<br>                style={{<br>                    fontSize: 28,<br>                    fontWeight: &#39;bold&#39;<br>                }}<br>            &gt;<br>              My Orders<br>            &lt;/Text&gt;<br>        &lt;/View&gt;<br>    )<br>}<br><br>export default MyOrders;</pre><p>Two-page files have been created. Create one more new file in the <strong>screens folder</strong>, naming it <strong>BottomTabs.js</strong>.</p><pre>import React from &#39;react&#39;;<br><br>import {createBottomTabNavigator} from &#39;@react-navigation/bottom-tabs&#39;;<br><br>import Home from &#39;./Home&#39;;<br>import MyOrders from &#39;./MyOrders&#39;;<br><br>const ReactNavigationBottomTabs = createBottomTabNavigator();<br><br>const BottomTabs = () =&gt; {<br>    return (<br>        &lt;ReactNavigationBottomTabs.Navigator&gt;<br>            &lt;ReactNavigationBottomTabs.Screen name=&quot;Home&quot; component={Home} /&gt;<br><br>            &lt;ReactNavigationBottomTabs.Screen name=&quot;MyOrders&quot; component={MyOrders} /&gt;<br>        &lt;/ReactNavigationBottomTabs.Navigator&gt;<br>    )<br>}<br><br>export default BottomTabs;</pre><p>As can be seen in the code above, the preparation of a bottom tabs navigation can be made by creating a new navigation with <strong>createBottomTabNavigator()</strong>, then declaring the navigator in the UI with the tag <strong>&lt;NameBottomTabsNavigator.Navigator&gt; and in it declare the list screen using </strong>the tag &lt;NameBottomTabsNavigator.Screen&gt;<strong> then fill in the props name and component of each screen.</strong></p><p>2️⃣ <strong>Stacking Navigator</strong></p><p>Our code above is still not displayed in the application. We will compile a stack navigator first; a stack navigator is a screen navigation system showing stacked one page with the next. A simple example is when we are on the list item page when we press one of the items. The item detail page will be displayed above the list item page now, And when you press the back button from the item detail page, the item detail page will be discarded and returned to the list item page stack. That’s how the stack navigator works: in the form of stacks of pages.</p><p>We will compile a stack navigator in the <strong>App.tsx</strong> file. Here is the stack navigator code that we created in this experiment.</p><pre>import React from &#39;react&#39;;<br><br>import {NavigationContainer} from &#39;@react-navigation/native&#39;;<br>import {createStackNavigator} from &#39;@react-navigation/stack&#39;;<br><br>const Stack = createStackNavigator();<br><br>import BottomTabs from &#39;./screens/BottomTabs&#39;;<br><br>const App = () =&gt; {<br>    return (<br>        &lt;NavigationContainer&gt;<br>            &lt;Stack.Navigator&gt;<br>                &lt;Stack.Screen name=&quot;BottomTabs&quot; component={BottomTabs} /&gt;<br>            &lt;/Stack.Navigator&gt;<br>        &lt;/NavigationContainer&gt;<br>    )<br>}<br><br>export default App;</pre><p>We declare &lt;<strong>NavigationContainer</strong>&gt;, create a new stack navigator, and declare it by &lt;<strong>NameStackNavigator.Navigator</strong>&gt; and in it display the list screen using the tag &lt;<strong>NameStackNavigator.Screen</strong>&gt; then fill in the props name and component of each screen. <br> <br>We still only have a BottomTabs page to display in the Stack Navigator. The result can already be run like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*6b3kuf2jQ2Z2HgdW_-5iLw.png" /></figure><p>Next, we will create the login page as the first active page when entering the application. Create a Login file.js in the screens folder and type the code below.</p><pre>import React from &#39;react&#39;;<br>import {Text, TouchableOpacity, View} from &#39;react-native&#39;;<br><br>const Login = props =&gt; {<br>    return (<br>        &lt;View<br>            style={{<br>                alignItems: &#39;center&#39;,<br>                flex: 1,<br>                justifyContent: &#39;center&#39;<br>            }}<br>        &gt;<br>            &lt;Text<br>                style={{<br>                    fontSize: 28,<br>                    fontWeight: &#39;bold&#39;<br>                }}<br>            &gt;<br>                Login<br>            &lt;/Text&gt;<br><br>            &lt;TouchableOpacity<br>                onPress={() =&gt; props.navigation.replace(&quot;BottomTabs&quot;)}<br>                style={{<br>                    backgroundColor: &#39;teal&#39;,<br>                    borderRadius: 10,<br>                    marginTop: 20,<br>                    paddingHorizontal: 20,<br>                    paddingVertical: 10<br>                }}<br>            &gt;<br>                &lt;Text<br>                    style={{<br>                        color: &#39;white&#39;,<br>                        fontWeight: &#39;bold&#39;,<br>                        fontSize: 20<br>                    }}<br>                &gt;<br>                    Go To Bottom Tabs<br>                &lt;/Text&gt;<br>            &lt;/TouchableOpacity&gt;<br>        &lt;/View&gt;<br>    )<br>}<br><br>export default Login;</pre><p>It can be seen that there are command code <strong>props.navigation.replace(</strong>‘BottomTabs’). The command is used to navigate to the <strong>BottomTabs</strong> page by replacing and not stacking on it because it is known that after the Login page, <strong>we will prevent the user from returning to the </strong>Login page <strong>when the back button is pressed.</strong></p><p>The Login page has been created but not registered in our Stack Navigator. Open the App.tsx file. We edited it again to register <strong>the Login page on the Stack Navigator, don’t forget to add the initialRouteName property with the value “ </strong>Login” <strong>because we want to make </strong>the <strong>Login</strong> page the main page and first accessed when the application is run.</p><pre>import React from &#39;react&#39;;<br><br>import {NavigationContainer} from &#39;@react-navigation/native&#39;;<br>import {createStackNavigator} from &#39;@react-navigation/stack&#39;;<br><br>const Stack = createStackNavigator();<br><br>import Login from &#39;./screens/Login&#39;;<br>import BottomTabs from &#39;./screens/BottomTabs&#39;;<br><br>const App = () =&gt; {<br>    return (<br>        &lt;NavigationContainer&gt;<br>            &lt;Stack.Navigator&gt;<br>                &lt;Stack.Screen name=&quot;BottomTabs&quot; component={BottomTabs} /&gt;<br>                &lt;Stack.Screen name=&quot;Login&quot; component={Login} /&gt;<br>            &lt;/Stack.Navigator&gt;<br>        &lt;/NavigationContainer&gt;<br>    )<br>}<br><br>export default App;</pre><p>When run, we can try the application navigating from the <strong>Login</strong> page to the <strong>BottomTabs page</strong>. <br> <br>Finally, we create the remaining pages we will register that have yet to be created, namely <strong>DestinationDetail.js</strong>, <strong>OrderSuccess.js</strong> and <strong>PersonalInformation.js</strong>, while creating them in the screens folder and filling the file with the following code.</p><pre>import React from &#39;react&#39;;<br>import {Text, View} from &#39;react-native&#39;;<br><br>const DestinationDetail = () =&gt; {<br>    return (<br>        &lt;View<br>            style={{<br>                alignItems: &#39;center&#39;,<br>                flex: 1,<br>                justifyContent: &#39;center&#39;<br>            }}<br>        &gt;<br>            &lt;Text<br>                style={{<br>                    fontSize: 28,<br>                    fontWeight: &#39;bold&#39;<br>                }}<br>            &gt;<br>                Destination Detail<br>            &lt;/Text&gt;<br>        &lt;/View&gt;<br>    )<br>}<br><br>export default DestinationDetail;</pre><pre>import React from &#39;react&#39;;<br>import {Text, View} from &#39;react-native&#39;;<br><br>const OrderSuccess = () =&gt; {<br>    return (<br>        &lt;View<br>            style={{<br>                alignItems: &#39;center&#39;,<br>                flex: 1,<br>                justifyContent: &#39;center&#39;<br>            }}<br>        &gt;<br>            &lt;Text<br>                style={{<br>                    fontSize: 28,<br>                    fontWeight: &#39;bold&#39;<br>                }}<br>            &gt;<br>                Order Success<br>            &lt;/Text&gt;<br>        &lt;/View&gt;<br>    )<br>}<br><br>export default OrderSuccess;</pre><pre>import React from &#39;react&#39;;<br>import {Text, View} from &#39;react-native&#39;;<br><br>const PersonalInformation = () =&gt; {<br>    return (<br>        &lt;View<br>            style={{<br>                alignItems: &#39;center&#39;,<br>                flex: 1,<br>                justifyContent: &#39;center&#39;<br>            }}<br>        &gt;<br>            &lt;Text<br>                style={{<br>                    fontSize: 28,<br>                    fontWeight: &#39;bold&#39;<br>                }}<br>            &gt;<br>                Personal Information<br>            &lt;/Text&gt;<br>        &lt;/View&gt;<br>    )<br>}<br><br>export default PersonalInformation;</pre><p>And in App.tsx, we list all three pages.</p><pre>import React from &#39;react&#39;;<br><br>import {NavigationContainer} from &#39;@react-navigation/native&#39;;<br>import {createStackNavigator} from &#39;@react-navigation/stack&#39;;<br><br>const Stack = createStackNavigator();<br><br>import Login from &#39;./screens/Login&#39;;<br>import BottomTabs from &#39;./screens/BottomTabs&#39;;<br>import DestinationDetail from &#39;./screens/DestinationDetail&#39;;<br>import OrderSuccess from &#39;./screens/OrderSuccess&#39;;<br>import PersonalInformation from &#39;./screens/PersonalInformation&#39;;<br><br>const App = () =&gt; {<br>    return (<br>        &lt;NavigationContainer&gt;<br>            &lt;Stack.Navigator initialRouteName=&quot;Login&quot;&gt;<br>                &lt;Stack.Screen name=&quot;BottomTabs&quot; component={BottomTabs} /&gt;<br>                &lt;Stack.Screen name=&quot;Login&quot; component={Login} /&gt;<br>                &lt;Stack.Screen name=&quot;DestinationDetail&quot; component={DestinationDetail} /&gt;<br>                &lt;Stack.Screen name=&quot;OrderSuccess&quot; component={OrderSuccess} /&gt;<br>                &lt;Stack.Screen name=&quot;PersonalInformation&quot; component={PersonalInformation} /&gt;<br>            &lt;/Stack.Navigator&gt;<br>        &lt;/NavigationContainer&gt;<br>    )<br>}<br><br>export default App;</pre><p>We now have all the needed pages, which can be pushed to git first. We will continue to create the UI based on the design in the following article.</p><p>Interested in realising your dream app to help your business and your target market? Contact <a href="https://upscalix.com.au/contact"><strong><em>Upscalix</em></strong></a> now.</p><p><em>This article is written by </em><a href="http://upscalix.com.au/"><em>Upscalix</em></a><em> Senior Frontend and Mobile Developer, </em><a href="https://www.linkedin.com/in/reynald-prabha-nova/"><em>Nova</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c8b6fc051cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Booking App UIs Using React-Native — Project Initiation (Part 1)]]></title>
            <link>https://upscalix.medium.com/create-a-booking-app-uis-using-react-native-project-initiation-part-1-97d86876dd7e?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/97d86876dd7e</guid>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 04:56:31 GMT</pubDate>
            <atom:updated>2023-10-13T01:47:41.210Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Create a Booking App UIs Using React-Native — Project Initiation (Part 1)</strong></h3><p>In this comprehensive guide, we will take you step by step through the process of crafting captivating UIs for a tour booking app using the power of React Native. This dynamic mobile application will encompass a range of essential features, including:</p><p>1. Tour Type Selection</p><p>2. Tour Details Page</p><p>3. Order Form</p><p>4. Order List Management</p><p>The design we will be implementing is as follows. Hopefully, it will facilitate your learning experience when tackling the UIs code challenge in React Native.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rggUzyUo-LwmZAME2P70Dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6i3mtLsXoNL0Gm0j3WWZNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*269pywsb9EImg1kHmhv-4A.png" /><figcaption>from left: login, home, search</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ib591DeuTGllb5je0zJzCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BW_UEr0zctUA6AeVS8xCxg.png" /><figcaption>from left: detail, order form</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Sy12Su1UwUHh3RXRpFjsSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OWyZUtbDepSlhVG4WNH0A.png" /><figcaption>from left: order completion, order list</figcaption></figure><p>From that design to the final part of the article series, we will learn the implementation of:</p><ul><li>React Navigation Stack</li><li>React Navigation Bottom Tabs</li><li>React Native Vector Icons</li><li>React Native Maps</li><li>React Hook Forms</li><li>React Native Swiper</li><li>List Rendering</li></ul><p>For the first part, we will focus on project initiation first.</p><h3><strong>1. Project Initiation</strong></h3><p>We start the work by initializing a React-Native project using version 0.71.13. Assuming that Node.js is installed, run the following command in the terminal/command prompt.</p><pre>npx react-native init TourApp --version=&quot;0.71.13“ </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*nNv7CVqL18xtbRUndbi1mQ.png" /></figure><h3><strong>2. Library Installation</strong></h3><p>Here are the libraries that we will use in this project:</p><ul><li>React Navigation Stack</li><li>React Navigation Bottom Tabs</li><li>React Native Vector Icons</li><li>React Native Maps</li><li>React Hook Forms</li><li>React Native Swiper</li></ul><p>Run the following long command to install all of those libraries.</p><pre>yarn add @react-navigation/native react-native-screens react-native-safe-area-context @react-navigation/stack react-native-gesture-handler @react-navigation/bottom-tabs @react-native-masked-view/masked-view react-native-maps react-hook-form react-native-swiper react-native-vector-icons; bundle install; cd ios; pod install; cd ..; </pre><p>To complete the installation of React Navigation in the index.js file, add the code below:</p><pre>import ‘react-native-gesture-handler’; </pre><p>And under the MainActivity.java file, add the following function:</p><pre>@Override protected <br>void onCreate(Bundle savedInstanceState) { <br>  super.onCreate(null); <br>} </pre><p>Still in the MainActivity.java file, don’t forget to add the imports at the top of the code:</p><pre>import android.os.Bundle; </pre><p>To complete the React Native Maps installation, open the ios folder where there will be a file with the extension .xcworkspace. Open the file using XCode. <br> <br>In the hierarchy section, refer to the “Info” file. Then, add the property Fonts provided by the application and one value containing FontAwesome.ttf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*o8IuFzq-HVe8pV9YoW9ppw.png" /></figure><h3><strong>3. Git Initiation and Push to Repository</strong></h3><p>The configuration of the libraries to be used has been successfully installed in the project. Now, let’s store the project in a repository using Git. <br> <br>First, create a new repository on GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*BXtlbr_Ve3ig4lAZ5bkChw.png" /></figure><p>Follow the commands provided by GitHub. Run these commands via the terminal/command prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*uUs5AqQfpglg7shaGb8E4w.png" /></figure><p>Now, the project has been successfully pushed to the repository. We will start implementing the user interface in the second part of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*BV4AhFnAo-BSJXyHGGrJVQ.png" /></figure><p><em>to be continued to </em><a href="https://upscalix.medium.com/create-a-booking-app-uis-using-react-native-stack-navigator-bottom-tab-navigator-part-2-1c8b6fc051cb"><em>part 2</em></a></p><p><em>This article is written by </em><a href="http://upscalix.com.au/"><em>Upscalix</em></a><em> Senior Frontend and Mobile Developer, </em><a href="https://www.linkedin.com/in/reynald-prabha-nova/"><em>Nova</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97d86876dd7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Code]]></title>
            <link>https://upscalix.medium.com/the-art-of-code-1281540093ec?source=rss-91e68ea8f31f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1281540093ec</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Upscalix]]></dc:creator>
            <pubDate>Mon, 18 Sep 2023 04:57:10 GMT</pubDate>
            <atom:updated>2023-11-17T05:05:09.438Z</atom:updated>
            <content:encoded><![CDATA[<p>Every task has its unique style, and every appearance has its beauty. Typically, anything beautiful appears tidy and well-structured, but it all depends on the observer’s perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9IOo-L9eHGhOVw5vgVaSuA.jpeg" /><figcaption><a href="https://grassrootsmotorsports.com/new-cars/2009-mitsubishi-lancer-evolution-x-mr/">Source</a></figcaption></figure><p>The same goes for machines. Machines are created to assist human work, making it easier for humans to complete tasks. The device maker tries to develop it neatly, structured, and cleanly. This way, when one part of the machine encounters an issue, it can quickly identify the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_6aZ_-BmrH4k1gbK55kNQ.png" /></figure><p>Code is also a machine, but it takes the form of written text. Every developer has their code structure and their coding art. However, not all developers have a code structure or coding style that can help other developers easily understand the code they create. Therefore, in software development, we have something called Clean Code.</p><h3>What is Clean Code?</h3><p>Clean code, as defined by Robert C. Martin in his book “Clean Code: A Handbook of Agile Software Craftsmanship,” is code that is easy to read, understand, and modify.</p><h4>Why is clean code necessary?</h4><ol><li><strong>Readability</strong>: Code is not only read by machines but also by humans. Code that is easy to read allows developers to quickly understand the logic of the code, reducing the time spent on debugging or relearning the code after a long time.</li><li><strong>Maintainability</strong>: Like machines, code requires maintenance, bug fixes, feature additions, and more. Clean and well-structured code is easier to modify, reducing the likelihood of new bugs emerging during updates.</li><li><strong>Collaboration</strong>: Most software projects involve multiple developers working together. If the code is clean and well-organised, it can help teams work more effectively together.</li><li><strong>Debugging</strong>: Code that is easy to read and maintain can make it easier and faster to identify errors in the code, reducing the headaches developers face when trying to diagnose code issues.</li></ol><p>Well, those are some benefits of the Clean Code.</p><h4>What are the best practices for Clean Code?</h4><p>1️⃣<strong> Meaningful Names</strong>: Utilise easily comprehensible, clear, and not overly lengthy names.</p><p>DON’T</p><pre>class Air {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br>}</pre><p>DO</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br>}</pre><p>2️⃣ <strong>Functions Should Do One Thing</strong>: Each function should focus on having only one purpose, making it easier for us to understand the task of each function.</p><p>DON’T</p><pre>class AirConditioner {<br>  constructor() {<br>    this.temperature = 22;<br>    this.fanSpeed = “Low”;<br>  }<br><br>  setFanSpeed(newFanSpeed, newTemperature) {<br>    if ( [&quot;Low&quot;, &quot;Medium&quot;, &quot;High&quot;].includes(newFanSpeed)) {<br>      this.fanSpeed = newFanSpeed;<br>        this.temperature = newTemperature;<br><br>        console.log(`Fan speed set to ${this.fanSpeed} and temperature set to ${this.temperature}`);<br>    } else {<br>      console.log(&quot;Invalid fan speed setting. Choose from Low, Medium, or High Or Invalid Temperature setting&quot;);<br>    }<br>  }<br>}</pre><p>DO</p><pre>class AirConditioner {<br>  constructor() {<br>    this.temperature = 22<br>    this.fanSpeed = “Low”;<br>  }<br><br>  setTemperature(newTemperature) {<br>    if (this.isValidTemperature(newTemperature)) {<br>      this.temperature = newTemperature;<br><br>      console.log(`Temperature set to ${this.temperature}`);<br>    } else {<br>      console.log(&quot;Invalid temperature setting, Temperature must be between 16 to 30 Celcius&quot;);<br>    }<br>  }<br><br>  isValidTemperature(newTemperature) {<br>    return newTemperature &gt;= 16 &amp;&amp; newTemperature &lt;= 30<br>  }<br><br>  setFanSpeed(newFanSpeed) {<br>    if (this.isValidFanSpeed(newFanSpeed)) {<br>      this.fanSpeed = newFanSpeed;<br><br>      console.log(`Fan speed set to ${this.fanSpeed}`);<br>    } else {<br>      console.log(&quot;Invalid fan speed setting. Choose from Low, Medium, or High&quot;);<br>    }<br>  }<br><br>  isValidFanSpeed(newFanSpeed) {<br>    const validFanSpeeds = [&quot;Low&quot;, &quot;Medium&quot;, &quot;High&quot;];<br><br>    return validFanSpeeds.includes(newFanSpeed);<br>  }<br>}</pre><p>3️⃣ <strong>Comments</strong>: It’s better to use words for every piece of code that is hard to understand or for overly complex algorithms. However, provide comments that are clear and not excessive.</p><p>DON’T</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br><br>  // To set the fan speed,<br>  // make sure don’t too cold, it’s winter you know! brrrrrr<br>  setFanSpeed(newFanSpeed) {<br>    <br>        ...<br>  }<br><br>  // To check you set it is valid or not, we only have low, medium and high<br>  isValidFanSpeed(newFanSpeed) {<br>        ...<br>  }<br>}</pre><p>DO</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br><br>  // To set the fan speed<br>  setFanSpeed(newFanSpeed) {         <br>    ...<br>  }<br><br>  // To check the fan speed is valid or not<br>  isValidFanSpeed(newFanSpeed) {<br>    ...<br>  }<br>}</pre><p>4️⃣ <strong>Make Your Code Consistent</strong>: Ensure your code’s format is consistent. Use consistent indentation, spacing, and well-spaced line breaks.</p><p>DON’T</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br><br>  // To set the fan speed<br>  setFanSpeed(newFanSpeed) {<br>    ...<br>  }<br><br>  // To check the fan speed is valid or not<br>  isValidFanSpeed(newFanSpeed) {<br>    ...<br>  }<br>}</pre><p>DO</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br><br>  // To set the fan speed<br>  setFanSpeed(newFanSpeed) {<br>    ...<br>  }<br><br>  // To check the fan speed is valid or not<br>  isValidFanSpeed(newFanSpeed) {<br>    ...<br>  }<br>}</pre><p>5️⃣ <strong>Keep It Short</strong>: Fewer functions and classes in code make it easier to read and maintain. However, they still need to be clear in naming and their responsibilities.</p><p>DON’T</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br><br>  // To set the fan speed to Low<br>  setFanSpeedLow() {         <br>     ...<br>  }<br><br>  // To set the fan speed to Medium<br>  setFanSpeedMedium() {         <br>     ...<br>  }<br><br>  // To set the fan speed to High<br>  setFanSpeedHigh() {         <br>     ...<br>  }<br>}</pre><p>DO</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>  }<br><br>  // To set the fan speed<br>  setFanSpeed(newFanSpeed) {         <br>    ...<br>  }<br><br>  // To check the fan speed is valid or not<br>  isValidFanSpeed(newFanSpeed) {<br>    ...<br>  }<br>}</pre><p>6️⃣ Modularisation: It’s better if code can be made reusable. This helps reduce duplication of writing the same code.</p><p>DON’T</p><pre>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>    this.engineStarted = false;<br>  }<br><br>  // To set the fan speed<br>  setFanSpeed(newFanSpeed) {<br>    if (this.engineStarted) {<br>      ...<br>    }<br>  }<br><br>  // To check the fan speed is valid or not<br>  isValidFanSpeed(newFanSpeed) {<br>    ...<br>  }<br><br>  startEngine() {<br>    if (!this.engineStarted) {<br>      console.log(&quot;Engine is starting...&quot;);<br><br>      this.engineStarted = true;<br>    } else {<br>      console.log(&quot;Engine is already running.&quot;);<br>    }<br>  }<br>}</pre><p>DO</p><pre>class Engine {<br>  constructor() {<br>    this.engineStarted = false;<br>  }<br><br>  start() {<br>    if (!this.engineStarted) {<br>      console.log(&quot;Engine is starting...&quot;);<br><br>      this.engineStarted = true;<br>    } else {<br>      console.log(&quot;Engine is already running.&quot;);<br>    }<br>  }<br><br>  isStarted() {<br>     return this.engineStarted;<br>  }<br>}<br><br>class AirConditioner {<br>  constructor() {<br>    this.fanSpeed = “Low”;<br>    this.engine = new Engine();<br>  }<br><br>  // To set the fan speed<br>  setFanSpeed(newFanSpeed) {<br>    if (this.engine.isStarted()) {<br>      ...<br>    }<br>  }<br><br>  // To check the fan speed is valid or not<br>  isValidFanSpeed(newFanSpeed) {<br>     ...<br>  }<br>}</pre><p>Those are some expected benefits and best practices in creating a Clean Code. It’s even better if you have testing code for every primary function so that it will simplify the maintenance in case of bugs in those functions. As Robert C. Martin once said, “Would you rather Test-First, or Debug-Later?”</p><p>Regularly perform Refactoring to improve your skills in Clean Code and keep it clean. Refactoring is the process of improving your code without changing its intended purpose.</p><p>Also, learn about the SOLID Principles discovered by Robert C. Martin to create a more mature Clean Code.</p><h3>Conclusion</h3><p>Every code and machine requires maintenance, even up to five years after they were created. Creating code that is easy to read, straightforward, and maintain will greatly assist every developer in carrying on their work.</p><p>Indeed, creating a Clean Code might not be accessible when you’re working on a Real Project. But the art of neat and clean code is easier to understand than messy code.</p><p>“Clean Code always looks like written by someone who cares.” — Robert C. Martin.</p><p>At Upscalix, our developer always make sure to use clean code for our projects. Want to talk on what product that our developers can build?</p><p>Contact us <a href="https://upscalix.com.au/contact">NOW</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1281540093ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>