<?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 Alvin Matthew Pratama on Medium]]></title>
        <description><![CDATA[Stories by Alvin Matthew Pratama on Medium]]></description>
        <link>https://medium.com/@alvinmatthew?source=rss-dc031e8b3903------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_lCAsQw9zxDsoq-dmW97bA.jpeg</url>
            <title>Stories by Alvin Matthew Pratama on Medium</title>
            <link>https://medium.com/@alvinmatthew?source=rss-dc031e8b3903------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 12:55:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alvinmatthew/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[Back to Basics: UIKit Constraint and Auto Layout]]></title>
            <link>https://alvinmatthew.medium.com/back-to-basics-uikit-constraint-and-auto-layout-2141efb89f43?source=rss-dc031e8b3903------2</link>
            <guid isPermaLink="false">https://medium.com/p/2141efb89f43</guid>
            <category><![CDATA[auto-layout-techniques]]></category>
            <category><![CDATA[intrinsic-content-size]]></category>
            <category><![CDATA[uiscrollview-layouts]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[uikit-constraints]]></category>
            <dc:creator><![CDATA[Alvin Matthew Pratama]]></dc:creator>
            <pubDate>Fri, 17 May 2024 16:27:23 GMT</pubDate>
            <atom:updated>2024-05-17T16:27:23.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NW7VveVO7e4pNsTs" /><figcaption>Photo by <a href="https://unsplash.com/@alterego_swiss?utm_source=medium&amp;utm_medium=referral">AbsolutVision</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hi everyone, today we will revisit and deepen our understanding of UIKit constraints and auto layout. This article will be divided into three parts: first, we’ll explore intrinsic content size; next, we’ll discuss constraints and auto layout; and finally, we’ll examine how constraints and Auto Layout function within UIScrollView and UICollectionView.</p><p>In this article, we will use the creation of a ticker view as our practical use case. A ticker view is a common UI component that displays a continuous stream of information, such as news headlines or stock prices. By building this component, we will explore how to effectively apply UIKit constraints and auto layout principles. This hands-on example will help us understand intrinsic content size, configure constraints, and ensure our layout adapts correctly within UIScrollView or UICollectionView. Through this process, you’ll gain a deeper understanding of how to implement and troubleshoot auto layout in your own projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UerXgB7eA7SdTtGk4idhbg.png" /><figcaption>Ticker View Anatomy</figcaption></figure><h3><strong>Understanding Intrinsic Content Size</strong></h3><p>The ticker view anatomy is outlined above. Components of UIKit utilized in its construction include <strong>UILabel, UITextView, UIImageView, UIStackView, UIScrollView, and UIView.</strong></p><p>In the context of creating a ticker with dynamic height and constrained width, it’s important to consider the <strong>intrinsic content size</strong> of the components. Here’s a breakdown:</p><blockquote>Intrinsic content size refers to the inherent dimensions or natural size of a UI element based on its content or internal properties. This intrinsic size allows these elements to adapt their dimensions based on the amount of content they contain.</blockquote><p><strong>Views with Intrinsic Content Size</strong></p><ul><li><strong>UILabel</strong>, Provides intrinsic size determined by their text, making it well-suited for dynamic height adjustments.</li><li><strong>UITextView</strong> Also has an intrinsic size determined by the text, allowing for dynamic height based on content. Make sure to disable the scrolling, this ensures that the components adapt to their content without unnecessary scrolling.</li></ul><p><strong>Views without Intrinsic Content Size</strong></p><ul><li><strong>UIImageView</strong>, Typically doesn’t have intrinsic size. Its dimensions are often determined by content or constraints.</li><li><strong>UIStackView,</strong> Doesn’t have intrinsic size; its size adapts dynamically based on arranged subviews.</li><li><strong>UIScrollView,</strong> Lacks intrinsic size; its size is determined by content and constraints.</li><li><strong>UIView,</strong> Similar to UIImageView, a UIView typically doesn’t have intrinsic size. Its dimensions are influenced by content and constraints.</li></ul><h3>Constraint and Auto Layout</h3><p>Before delving into details, it’s essential to understand the concepts of content hugging, compression, and the fundamentals of constraints.</p><p><strong>Content Hugging</strong></p><p>Content hugging priority is a measure of how much a UI element resists growing larger than its intrinsic content size.</p><ul><li><strong>Higher Priority:</strong> A higher content hugging priority means the element prefers to stay at or near its intrinsic content size, resisting expansion.</li><li><strong>Use Case:</strong> Useful when you want a view to maintain a compact size unless there’s a compelling reason for it to expand.</li></ul><p><strong>Content Compression Resistance</strong></p><p>Content compression resistance priority is a measure of how much a UI element resists shrinking smaller than its intrinsic content size.</p><ul><li><strong>Higher Priority:</strong> A higher content compression resistance priority means the element prefers to avoid reducing its size below its intrinsic size.</li><li><strong>Use Case:</strong> Useful when you want to prevent a view from becoming too small, especially when there’s limited space.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8ze4qPzfX84LzDCFO4IC7g.png" /></figure><p><strong>Basics of Constraints</strong></p><p>Constraints are rules that define the layout and behavior of UI elements within a view.</p><ul><li><strong>Types of Constraints:</strong> Constraints can specify attributes like width, height, spacing, and relationships between different elements.</li><li><strong>Auto Layout:</strong> In UIKit, Auto Layout is the system used to define and manage constraints.</li><li><strong>Adaptive Layout:</strong> Constraints enable adaptive layouts that adjust to different screen sizes and orientations.</li></ul><p>In summary, content hugging and content compression resistance priorities are key factors in guiding Auto Layout on how to handle the size of UI elements based on their intrinsic content size. Constraints, on the other hand, are the rules and relationships that define the layout of these elements within a view.</p><p>Based on the breakdown provided earlier, prioritizing components with intrinsic size is essential to determine the content size of the ticker. To achieve this, let’s delve into some effective constraint and auto layout tricks.</p><ol><li>Setup the <strong>UILabel</strong></li></ol><ul><li>Set the number of lines to 0 for multiline text, allowing it to dynamically adjust its height based on content.</li><li>Ensure that the content hugging and compression resistance priorities are set to required</li></ul><pre>titleLabel.numberOfLines = 0<br>// below code just to make sure the priority is right, by default it already set to required<br>titleLabel.setContentHuggingPriority(.required, for: .vertical)<br>titleLabel.setContentCompressionResistancePriority(.required, for: .vertical)</pre><p>2. Setup the <strong>UITextView</strong></p><ul><li>Set <strong>isScrollEnabled</strong> to <strong>false</strong>, to prevent the UITextView to allows the UITextView to adjust its size according to its content, effectively utilizing its intrinsic size.</li></ul><pre>contentTextView.isScrollEnabled = false</pre><p>3. Setup the <strong>UIImageView</strong></p><ul><li>As UIImageView lacks intrinsic content size based on its content, it is necessary to explicitly set width and height constraints to define its dimensions.</li></ul><pre>NSLayoutConstraint.activate([<br> iconImageView.widthAnchor.constraint(equalToConstant: 24),<br> iconImageView.heightAnchor.constraint(equalToConstant: 24)<br>])</pre><p>4. Setup the <strong>UIStackView</strong></p><ul><li>If we revisit the anatomy of the ticker, we observe that it comprises two stack views encapsulating the ticker components. The inner vertical stack envelops the <strong>titleLabel</strong> and <strong>contentTextView</strong>, and this, in turn, is enclosed within a horizontal stack alongside the <strong>iconImageView</strong>.</li><li>The <strong>UIStackView</strong> inherently adapts its dimensions based on the intrinsic content size of its arranged subviews, such as the <strong>titleLabel</strong> and <strong>contentTextView</strong>. This dynamic adjustment is influenced by both the intrinsic sizes of the components and the specified settings for alignment and distribution within the stack view.</li></ul><pre>let labelStackView = UIStackView()<br>labelStackView.addArrangedSubview(titleLabel)<br>labelStackView.addArrangedSubview(contentTextView)<br>labelStackView.axis = .vertical<br>labelStackView.spacing = 4</pre><ul><li>Similarly, the horizontal stack view functions by dynamically creating dimensions based on its content. With the UIImageView constraints set and distribution configured to fill by default, the horizontal stack view prioritizes the first child, compress it, and expands the second child — labelStackView — in the process.</li></ul><pre>let mainStackView = UIStackView(arrangedSubviews: [<br> iconImageView,<br> labelStackView<br>])<br>mainStackView.axis = .horizontal<br>mainStackView.alignment = .center<br>mainStackView.spacing = 8</pre><p>5. Set <strong>mainStackView</strong> constraint</p><ul><li>Next, establish constraints for the <strong>mainStackView</strong> by aligning its top, leading, and trailing edges to its UIView container.</li><li>While these constraints ensure the stack view spans the full width, it’s important to include the <strong>bottom</strong> constraint. This additional constraint, even with intrinsic height from the content, precisely defines the vertical positioning of the <strong>mainStackView</strong> within its UIView container.</li></ul><blockquote>While the intrinsic height of the content inside the mainStackView is considered for its vertical dimension, setting the bottom constraint is crucial to define the content’s position relative to the bottom edge of the enclosing UIView. Without the bottom constraint, the vertical positioning of the mainStackView would be ambiguous, and Auto Layout wouldn’t have enough information to determine the exact vertical placement.</blockquote><ul><li>By setting the bottom constraint, you explicitly instruct Auto Layout to position the mainStackView in a specific way, ensuring it has a well-defined position within its containing UIView. This becomes especially important when dealing with dynamic layouts or in scenarios where the intrinsic content size might not fully determine the overall vertical position.</li></ul><pre>mainStackView.translatesAutoresizingMaskIntoConstraints = false<br>addSubview(mainStackView)<br><br>let inset = 8.0<br>NSLayoutConstraint.activate([<br> mainStackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: inset),<br> mainStackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -inset),<br> mainStackView.topAnchor.constraint(equalTo: topAnchor, constant: inset),<br> mainStackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -inset)<br>])</pre><p>With the completion of these five steps, we have successfully created a ticker content layout with dynamic height, allowing for adaptability based on the intrinsic sizes of its components.</p><h3>UIScrollView vs UICollectionView</h3><p>In the case of managing multiple contents for a paginated carousel, two viable options are UIScrollView and UICollectionView. This section will evaluate and determine which one is more suitable for achieving our goals.</p><p>In terms of adapting to intrinsic size, UICollectionView generally outperforms UIScrollView. However, when our objective is to ensure that either UICollectionView or UIScrollView accommodates the tallest content height for its overall height, there are distinct considerations.</p><p>In the case of UICollectionView, the optimal approach involves calculating content size dynamically due to its lazy loading behavior. This is essential as we can&#39;t load all content simultaneously, making it challenging to identify the maximum height.</p><p>Conversely, UIScrollView preloads all contents within its content view, facilitating the determination of contentSize based on the cumulative height of its contents. This capability enables us to identify the content with the greatest height and apply it as the UIScrollView&#39;s overall height.</p><p>Despite UIScrollView lacking cell reusability and custom layout features, it efficiently meets our requirement with minimal code. Considering the expected usage scenario where a ticker may not contain an extensive amount of content, the absence of these advanced features becomes an acceptable trade-off for simplicity and ease of implementation.</p><p>Here’s a comparison table summarizing the considerations between <strong>UICollectionView</strong> and <strong>UIScrollView</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9nkgk3fkv-JPzPd0hqEOLQ.png" /></figure><p>Considering the outlined considerations, UIScrollView proves to be the suitable choice meeting all the requirements. Therefore, we opt for UIScrollView. Now, let’s delve into the implementation details.</p><p>Setting Up UIScrollView</p><ol><li>Setup Properties</li></ol><pre>public final class TickerView: UIView {<br>  private let scrollView: UIScrollView = {<br>        let scrollView = UIScrollView()<br>        scrollView.isPagingEnabled = true<br>        scrollView.showsVerticalScrollIndicator = false<br>        scrollView.showsHorizontalScrollIndicator = false<br>        return scrollView<br>    }()<br><br>  private let contents: [TickerContent]<br>  ...<br>}</pre><p>2. Create Horizontal UIStackView</p><pre>let contentStackView = UIStackView(arrangedSubviews: contentViews)<br>contentStackView.axis = .horizontal<br>contentStackView.translatesAutoresizingMaskIntoConstraints = false<br>scrollView.addSubview(contentStackView)</pre><p>3. Configure each contentView to match the width of the parent view, enabling seamless pagination.</p><pre>for contentView in contentViews {<br>  contentView.translatesAutoresizingMaskIntoConstraints = false<br>  contentView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true<br>}</pre><p>4. Set UIScrollView the constraints</p><pre>NSLayoutConstraint.activate([<br>  contentStackView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),<br>  contentStackView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),<br>  contentStackView.topAnchor.constraint(equalTo: scrollView.topAnchor),<br>  contentStackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),<br>  scrollView.heightAnchor.constraint(equalTo: contentStackView.heightAnchor)<br>])</pre><ul><li><strong>contentStackView</strong> is pinned to the leading, trailing, top, and bottom edges of the <strong>scrollView</strong>.</li><li>The height of the <strong>scrollView</strong> is constrained to be equal to the height of the <strong>contentStackView</strong>. This ensures that the height of the <strong>scrollView</strong> is determined by the height of the content within the stack view.</li></ul><p>More explanation of scrollView.heightAnchor.constraint(equalTo: contentStackView.heightAnchor)</p><p>In this line of code, a constraint is set for the height of the <strong>scrollView</strong> to be equal to the height of the <strong>contentStackView</strong>. This constraint has a significant impact on how the <strong>scrollView</strong> behaves and adapts to the content within the <strong>contentStackView</strong>.</p><p>Here’s the breakdown:</p><ol><li><strong>Height Constraint: </strong>This constraint establishes a relationship between the height of the <strong>scrollView</strong> and the height of the <strong>contentStackView</strong>. It essentially states that the height of the <strong>scrollView</strong> should dynamically adjust to match the height of its content, which is the <strong>contentStackView</strong>.</li><li><strong>Dynamic Adaptation: </strong>By setting the <strong>scrollView</strong> height equal to the <strong>contentStackView</strong> height, the <strong>scrollView</strong> dynamically adjusts its own height based on the combined height of its content views within the horizontal stack. This ensures that the <strong>scrollView</strong> can properly display and scroll through all the content within the stack view.</li><li><strong>Automatic Sizing: </strong>As the content within the <strong>contentStackView</strong> changes or if different content views have varying heights, the <strong>scrollView</strong> automatically adapts its height to accommodate the maximum height among the content views. This behavior is crucial for handling multiple contents of different sizes within the scrollable view.</li><li><strong>Responsive Layout: </strong>The constraint ensures a responsive layout, allowing the <strong>scrollView</strong> to efficiently manage and display various content scenarios without having a fixed or predetermined height. It&#39;s particularly useful when dealing with dynamic content where the height is not known in advance.</li></ol><p>In summary, by establishing this height constraint, the <strong>scrollView</strong> becomes a flexible container that adjusts its height based on the varying heights of its content views within the <strong>contentStackView</strong>.</p><p>With the aforementioned setup, we have successfully implemented a structure accommodating multiple contents within a UIScrollView, utilizing a horizontal stack view. Each content view dynamically adjusts its width to match that of the parent view, providing an effective and adaptable solution for handling diverse content scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2141efb89f43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Validating Social Media URLs in Swift]]></title>
            <link>https://medium.com/tokopedia-engineering/validating-social-media-urls-in-swift-5df900b7bcad?source=rss-dc031e8b3903------2</link>
            <guid isPermaLink="false">https://medium.com/p/5df900b7bcad</guid>
            <category><![CDATA[swift-validator]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[url]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[url-validator]]></category>
            <dc:creator><![CDATA[Alvin Matthew Pratama]]></dc:creator>
            <pubDate>Mon, 30 May 2022 06:05:22 GMT</pubDate>
            <atom:updated>2022-05-30T06:05:22.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j86rEwrJmyC5up3YWBNwAA.jpeg" /></figure><h3>Background</h3><p>In February 2022, Tokopedia introduced an <a href="https://affiliate.tokopedia.com/">affiliate program</a> to all Tokopedia users and the public. To become an affiliate, users need to register their social media accounts by providing the social media URLs. As each social media URL has a different domain and URL path, the application needs to validate the URL according to the social media.</p><p>We agree that <a href="https://en.wikipedia.org/wiki/Regular_expression">regex</a> is one of the easiest ways to solve many parsing problems However, this case is complex due to several rules for each social media and will be challenging to customize in the future. Some social media have more than one URL path for the user page. For example, Youtube has several paths as follows:</p><pre><a href="https://www.youtube.com/user/example">https://www.youtube.com/user/example</a><br>https://www.youtube.com/c/coldplay<br>https://www.youtube.com/channel/UC9zY...</pre><p>One way to solve this is by creating a reusable validator that allows validating specific social media URLs in the simplest way. This article will use and introduce <a href="https://github.com/tokopedia/ios-supervalidator">SuperValidator</a> as our swift validator library to solve this problem.</p><h3>SuperValidator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CB_eS34xTnFFJ798MWKRDQ.png" /></figure><p><a href="https://github.com/tokopedia/ios-supervalidator">SuperValidator</a> is an option-based validator and an open-source library managed by Tokopedia iOS Engineers. The validator provides options to customize the validation according to your needs. Let’s go through this article to know more about this!</p><h3>URL Validator</h3><p>If we look at the URL anatomy, we can create separate validation for each of the URL’s components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nHylTd9wjy7-lE9uTi0XlQ.png" /></figure><p>SuperValidator has split up the components as parameters such as the following:</p><pre>protocols: [String] = [&quot;https&quot;, &quot;http&quot;, &quot;ftp&quot;],<br>requireProtocol: Bool = false,<br>requireValidProtocol: Bool = true,<br>paths: [String] = [],<br>allowQueryComponents: Bool = true,<br>domainWhitelist: [String] = [],<br>domainBlacklist: [String] = [],<br>fqdn: FQDN = .init() // Fully Qualified Domain Name</pre><h4>protocols</h4><p>An array of strings for valid protocols, such as http or https. If we store https only then it will only allow https.</p><h4>requireProtocol</h4><p>If set to true, then the URL must have a protocol.</p><h4>requireValidProtocol</h4><p>If set to true, then the URL protocol must be the same as one of the valid protocols listed in the protocols options.</p><h4>paths</h4><p>An array of strings for URL paths /shop/{shopID}. <br>There are two types, which include fixed and value.</p><pre>/shop/{shopID}</pre><p>The path will be separated by /, <br>shop is a fixed type, which means the URL path inputted must be exactly the same. <br>{shopID} is a value type, curly braces {} indicate the content inside is the value type.</p><h4>allowQueryComponents</h4><p>If set to false, the query component and anchor are not allowed.</p><h4>domainWhitelist</h4><p>An array of strings for the whitelist domain. It can also use regex.</p><h4>domainBlacklist</h4><p>An array of strings for the blacklist domain. It can also use regex.</p><h4>FQDN</h4><p>FQDN stands for Fully Qualified Domain Name. It will check if the domain is good to go.</p><h3>Basic Usage</h3><p>We can just call isURL function to return a boolean that indicates a valid URL.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9d4e15de60b16441cab8df88c9b8a9e/href">https://medium.com/media/a9d4e15de60b16441cab8df88c9b8a9e/href</a></iframe><p>If you want to customize the validator, you can set the options parameters covered in the previous section.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34a33ff494951f862b11082ffe451494/href">https://medium.com/media/34a33ff494951f862b11082ffe451494/href</a></iframe><p>You can also use validateURL function to return success or error result. You can use the error type provided by SuperValidator to generate an error message.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c3d3d1f489a3d7a8b1e32b9c1d075ab/href">https://medium.com/media/2c3d3d1f489a3d7a8b1e32b9c1d075ab/href</a></iframe><h3>Use Cases</h3><p>Let’s break down the users’ social media URLs. They have different domains and paths, and some of them have multiple valid paths. Cases like this can also happen in other URLs. We can create an enum to store options for every social media.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/953e3c79da979dc2ca6eebbad5f704e9/href">https://medium.com/media/953e3c79da979dc2ca6eebbad5f704e9/href</a></iframe><p>Then you can use isURL or validateURL function from SuperValidator.</p><pre><strong>SuperValidator.shared</strong>.isURL(<br>   &quot;https://instagram.com/myuser&quot;, <br>   options: SocialMediaURL.instagram.options<br>)</pre><p><strong>Fortunately</strong>, you don’t need to create a new function for social media URL validation, because SuperValidator already covers this. You can call isURL or validateURL with socialMedia parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4eb48ff4e87fda3b3f62a3fe00bc19eb/href">https://medium.com/media/4eb48ff4e87fda3b3f62a3fe00bc19eb/href</a></iframe><p>You can use validateURL to get the error reasons and give it to the user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0aaa3a07fd90ec2e3b469194064c1e2/href">https://medium.com/media/c0aaa3a07fd90ec2e3b469194064c1e2/href</a></iframe><p>For more test cases you can see this <a href="https://github.com/tokopedia/ios-supervalidator/blob/main/Tests/SuperValidatorTests/SocialMediaURLValidatorTests.swift">link</a>.</p><h3>Other Validators</h3><p>Besides URL, there are several validators that SuperValidator already covers:</p><h4>FQDN</h4><p>Help validate fully qualified domain names. (<a href="https://en.wikipedia.org/wiki/Fully_qualified_domain_name">Wikipedia</a>)</p><h4>Email</h4><p>Help validate email with options such as length limit of the <a href="https://en.wikipedia.org/wiki/Email_address#:~:text=The%20general%20format%20of%20an,of%20the%20recipient&#39;s%20mail%20system.">local part</a>, whitelist, and blacklist domain.</p><h4>Phone number</h4><p>Help validate phone numbers with International, North American, and Extensible Provisioning Protocol formats, validate country code or the <a href="https://www.iban.com/dialing-codes">national prefix</a>.</p><h3>Future Plans</h3><ul><li>More validators</li><li>Bind with <a href="https://developer.apple.com/documentation/uikit/uitextfield">UITextField</a></li><li>Bind with <a href="https://github.com/ReactiveX/RxSwift">RxSwift</a></li></ul><h3>Contribute🚨</h3><p>Calling contributors!! SuperValidator is open-source, and we’re excited to hear and learn from you. Your experiences will benefit others who use SuperValidator. Let’s make it even better!</p><blockquote><a href="https://github.com/tokopedia/ios-supervalidator">https://github.com/tokopedia/ios-supervalidator</a></blockquote><h3>Credits</h3><p>Thanks to <a href="https://www.linkedin.com/in/christophermienarto/">Christopher Teddy</a> for helping with the development. Kudos to Superman squad and all developers who helped make this happen.</p><p>As always, we have an opening at Tokopedia.<br>We are an Indonesian technology company with a mission to democratize commerce through technology, and our vision is to build an ecosystem where everyone can start and discover anything.<br>Find your Dream Job with us in Tokopedia!<br><a href="https://www.tokopedia.com/careers/">https://www.tokopedia.com/careers/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5df900b7bcad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tokopedia-engineering/validating-social-media-urls-in-swift-5df900b7bcad">Validating Social Media URLs in Swift</a> was originally published in <a href="https://medium.com/tokopedia-engineering">Tokopedia Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SuperPlayer: A way to incorporate AVPlayer with The Composable Architecture]]></title>
            <link>https://medium.com/tokopedia-engineering/superplayer-a-way-to-incorporate-avplayer-with-the-composable-architecture-f165133b5a9a?source=rss-dc031e8b3903------2</link>
            <guid isPermaLink="false">https://medium.com/p/f165133b5a9a</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[composable-architecture]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Alvin Matthew Pratama]]></dc:creator>
            <pubDate>Tue, 19 Oct 2021 01:27:28 GMT</pubDate>
            <atom:updated>2022-01-26T03:57:25.211Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnyruaFArt_DevtzDvEipQ.jpeg" /></figure><p>Tokopedia Play has become a demonstrative visual tour that showcases the looks and the benefits of the product listed on Tokopedia. Users can watch live or VOD content on Tokopedia Play. Other than Play, Tokopedia’s Feed and Product Detail Page also use videos to humanize the product experience.</p><p>In this article, we’re going to spill out a pinch of Tokopedia iOS’ secret recipe on how to built all video content and integrate it with many features in the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DXz3JO8NqVitGDah3aRQg.png" /></figure><h3>The Problem</h3><p>In Tokopedia Play, <a href="https://developer.apple.com/documentation/avfoundation/avplayer">AVPlayer</a> and <a href="https://developer.apple.com/documentation/avfoundation/avplayeritem">AVPlayerItem</a> are used as a playback engine for streaming live and VOD content. However, since AVPlayer and AVPlayerItem use the <a href="https://developer.apple.com/documentation/swift/cocoa_design_patterns/using_key-value_observing_in_swift">Key-Value Observing (KVO)</a> pattern to publish their playback states that force developers to write some tedious code to observe some properties such as timeControlStatus<strong>, </strong>reasonForWaitingToPlay<strong>,</strong> loadedTimeRanges<strong>, </strong>etc<strong>. </strong>Writing a pool of KVO patterns would even result in a messier code base.</p><p>Tokopedia iOS app is built on top of <a href="https://github.com/pointfreeco/swift-composable-architecture">The Composable Architecture</a> or TCA for short. Using plain AVPlayer to play a huge number of media displayed will lead to a messy codebase because it is not designed for effective integration with TCA. Every feature that plays videos needs to observe AVPlayer properties with inconsistent design patterns. This will take more development time and make the code hard to read and maintain. It’s also hard to collaborate when all developers built the features using different design patterns.</p><h3>The Solution</h3><blockquote><a href="https://priorart.ip.com/IPCOM/000266742">SuperPlayer</a> was created by <a href="https://www.tokopedia.com/about/?lang=en">Tokopedia</a>’s iOS media team to wrap AVPlayer with composable business logic so it can be reused across any features built with TCA.</blockquote><p>SuperPlayer includes,</p><ul><li>Subscribing to all common playback states from <a href="https://developer.apple.com/av-foundation/">AVFoundation</a> in the intermediate object</li><li>Declaration of all the composable states, actions, and reducers for each playback state</li><li>Send the playback states to the store using defined actions and write any shared playback logic in the reducer</li></ul><p>With SuperPlayer, developers don’t need to write any code inside the intermediate object and can directly plug it into their TCA environment. Moreover, any playback logic can be written fully in Reducer and can be tested later with all unit test tools provided by TCA.</p><p>Consistent design patterns used among features can increase the readability and maintainability of the code. Building features with less code leads to saving more development time.</p><blockquote>Refer to this <a href="https://medium.com/@alvinmatthew/build-ios-video-player-on-top-of-tca-superplayer-db2de75ed2fd"><strong>link</strong></a> to see how SuperPlayer works.</blockquote><h3>The Implementation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aR3W-XcQEg9eMqFyKmaxDA.png" /></figure><p>If the ParentViewController has another TCA Store, SuperPlayerState and SuperPlayerAction can be directly associated with the parent TCA State and Action, then <em>pullback</em> the SuperPlayerReducer to the parent Reducer. Only this time the SuperPlayer-scoped Store is the one that is going to be passed to the SuperPlayerViewController.</p><p>Based on the picture, developers do not have to worry about writing AVPlayer repetitive code like declaring playback state subscription that happens on the <em>green column</em> or writing the TCA representation of AVPlayer that is covered on the <em>blue column</em>. They just need to worry about their feature on the <em>yellow column</em> and how it integrates with the player.</p><h3>Basic Architecture</h3><p>The purpose of the architecture is to compose a player to any TCA component. Developers don’t need to worry about handling the property’s subscription code because components like AVPlayer and AVPlayerItem will be represented in state, action, and reducer.</p><h4><strong>ComposablePlayer</strong></h4><p><strong>ComposablePlayerState<br></strong>A struct that consists of AVPlayer subscribed properties. It also has an optional enum property named method of type ComposablePlayerMethod that is going to be subscribed in the intermediate object to call the actual AVPlayer methods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09def68c47d6329c8333a20e8adf1be9/href">https://medium.com/media/09def68c47d6329c8333a20e8adf1be9/href</a></iframe><p><strong>ComposablePlayerMethod<br></strong>An enum that consists of AVPlayer methods representation such as replaceCurrentItem(with: URL?), play, etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd8fbb9014a7c70a8b414ce1a4480ef0/href">https://medium.com/media/cd8fbb9014a7c70a8b414ce1a4480ef0/href</a></iframe><p><strong>ComposablePlayerAction<br></strong>An enum that consists of actions to be sent from the actual AVPlayer object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb52503634dcf822bcef9d22520fab02/href">https://medium.com/media/fb52503634dcf822bcef9d22520fab02/href</a></iframe><p><strong>ComposablePlayerReducer<br></strong>A logic to assign values from the intermediate object sent as ComposablePlayerAction to ComposablePlayerState.</p><h4>ComposablePlayerItem</h4><p>The implementation of ComposablePlayerItem is very much similar to ComposablePlayer. The only difference is that ComposablePlayerItem represents the AVPlayerItem object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51efbd193e255ef42c818163838a6ca4/href">https://medium.com/media/51efbd193e255ef42c818163838a6ca4/href</a></iframe><h4>SuperPlayer</h4><p><strong>SuperPlayerState<br></strong>A struct that acts as a parent state that holds ComposablePlayerState and ComposablePlayerItemState. This is also the right place to extend other functionalities to the player.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4381c0fbacd78739afcf08010f1a61e2/href">https://medium.com/media/4381c0fbacd78739afcf08010f1a61e2/href</a></iframe><p><strong>SuperPlayerControlState<br></strong>A struct that contains states for populating the playback control UI.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71adac78a786d60570b0fed336116169/href">https://medium.com/media/71adac78a786d60570b0fed336116169/href</a></iframe><p><strong>SuperPlayerAction<br></strong>An enum that is used to modify SuperPlayerControlState and other extended states. It wraps ComposablePlayerAction and ComposablePlayerItemAction, and contains extended actions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cf766800f645a17ddb398f494b587fa/href">https://medium.com/media/7cf766800f645a17ddb398f494b587fa/href</a></iframe><p><strong>SuperPlayerReducer</strong><br>This is where the pullback declared for both ComposablePlayerReducer and ComposablePlayerItemReducer. The logic inside can be executed when an intermediate object sent an action.</p><h3>Basic API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*63q5BLtn9DCl6fQcjfpMrw.png" /></figure><p>In addition to declaring the TCA components above, an <strong>intermediate object</strong> needs to be created to accepts Store&lt;SuperPlayerState, SuperPlayerAction&gt;. SuperPlayerViewController will act as the intermediate object that performs the actual subscription to both store and the AVFoundation playback states. <br>SuperPlayerViewController is a UIViewController type that has AVPlayerLayer as its sublayer to display the video from AVPlayer.</p><h3>How to use</h3><p>You can refer to <a href="https://medium.com/@alvinmatthew/build-ios-video-player-in-tca-superplayer-db2de75ed2fd">this article</a> to set up SuperPlayer. Let’s start over there!</p><p><a href="https://medium.com/@alvinmatthew/build-ios-video-player-in-tca-superplayer-db2de75ed2fd">Medium</a></p><h3>Summary</h3><p>Most pages and features in Tokopedia are built with TCA as their architecture. TCA provides a way to break down business logic that feels like composing <em>Lego</em> blocks. <br>SuperPlayer helps create a new video player block, so developers can directly plug it into their TCA environment. Any playback logic can be written in the reducer and can be tested with tools provided by TCA. With this consistent design patterns used among features can increase the readability and maintainability of the code that leads to saving more development time.</p><h3>Contribute🚨</h3><p>Want to make a suggestion or feedback? SuperPlayer is open source and we’re excited to hear and learn from you. Your experiences will benefit others who use SuperPlayer. Let’s make it even better!</p><blockquote><a href="https://github.com/tokopedia/ios-superplayer">https://github.com/tokopedia/ios-superplayer</a></blockquote><h3>Credits</h3><p>Thanks to <a href="https://www.linkedin.com/in/rancaka/"><strong>Adityo Rancaka</strong></a> to make <strong>SuperPlayer</strong> happen. Also kudos to all developers who helped make this happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*6MZi8t86fXsGpbXrUBSLTg.jpeg" /></figure><h3>References</h3><ul><li><a href="https://priorart.ip.com/IPCOM/000266742">Prior Art Database - IP.com</a></li><li><a href="https://github.com/tokopedia/ios-superplayer">GitHub - tokopedia/ios-superplayer: Repository to publish our library (SuperPlayer) for open source</a></li></ul><p>As always, we have an opening at Tokopedia.<br>We are an Indonesian technology company with a mission to democratize commerce through technology and help everyone achieve more.<br>Find your Dream Job with us in Tokopedia!<br><a href="https://www.tokopedia.com/careers/">https://www.tokopedia.com/careers/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f165133b5a9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tokopedia-engineering/superplayer-a-way-to-incorporate-avplayer-with-the-composable-architecture-f165133b5a9a">SuperPlayer: A way to incorporate AVPlayer with The Composable Architecture</a> was originally published in <a href="https://medium.com/tokopedia-engineering">Tokopedia Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build iOS Video Player on Top of TCA — SuperPlayer]]></title>
            <link>https://alvinmatthew.medium.com/build-ios-video-player-on-top-of-tca-superplayer-db2de75ed2fd?source=rss-dc031e8b3903------2</link>
            <guid isPermaLink="false">https://medium.com/p/db2de75ed2fd</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[composable-architecture]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Alvin Matthew Pratama]]></dc:creator>
            <pubDate>Mon, 18 Oct 2021 10:05:40 GMT</pubDate>
            <atom:updated>2021-10-18T10:05:40.343Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build iOS Video Player on Top of TCA — SuperPlayer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mesICu7Nead43Ih9oXo6uw.jpeg" /></figure><p>Before we start, I recommend you to read <a href="https://medium.com/@alvinmatthew/superplayer-a-way-to-plug-avplayer-to-the-composable-architecture-f165133b5a9a"><strong>this article</strong></a> so you can get a glimpse of SuperPlayer.</p><p><a href="https://medium.com/@alvinmatthew/superplayer-a-way-to-plug-avplayer-to-the-composable-architecture-f165133b5a9a">Medium</a></p><p>In this article, you will see how to set up SuperPlayer on top of <br><a href="https://github.com/pointfreeco/swift-composable-architecture">The Composable Architecture</a> or TCA for short. Let’s get started!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*KkT7AuV2crk_hrPsUPagcw.gif" /></figure><p>We will create a video like <em>IGTV</em> or <em>Twitter Video</em>, but much simpler. It can play, pause and resume, show and seek time. We will build this using TCA, UIKit, and SuperPlayer.</p><p>Clone this <a href="https://github.com/alvinmatthewp/spTV">Github repository</a>. This repository includes packages and helpers that we will use. You will see this file structure after cloning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*yeMXR7ClBhh40wt-ce5BeQ.png" /></figure><p>Try to build the project and you will see this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*UCgnC82DMxqkyhfq8VHAbw.png" /></figure><p>Let’s add SuperPlayer package using SwiftPackageManager. <a href="https://github.com/tokopedia/ios-superplayer">https://github.com/tokopedia/ios-superplayer</a></p><blockquote>File &gt; Swift Packages &gt; Add Package Dependency…</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*m8yKAdAzQGaOe4f7ZoDwaA.png" /></figure><p>Let’s play the video from the link below. <a href="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4">http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp</a>4</p><p>Open ViewController.swift, Import ComposableArchitecture and SuperPlayer</p><pre>import ComposableArchitecture<br>import SuperPlayer</pre><p>Create a function call handleVideo() , we will handle video setup in this function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7887caed6f4fab763d181f6efffb759c/href">https://medium.com/media/7887caed6f4fab763d181f6efffb759c/href</a></iframe><ol><li>SuperPlayerViewController will act as the intermediate object that performs the actual subscription to both store and the AVFoundation playback states. SuperPlayerViewController has AVPlayerLayer as its sublayer to display the video from AVPlayer.</li><li>Constructing view for SuperPlayerViewController</li><li>Send the action to load the video.</li></ol><p>Call the function inside viewDidLoad before setupView() . Build the project and you’ll see the video.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d51301f6cab706ce0e53e8d0304a3fda/href">https://medium.com/media/d51301f6cab706ce0e53e8d0304a3fda/href</a></iframe><p>SuperPlayer is supposed to working with TCA, so why not create our TCA state management to play the video. Open AppReducer.swift file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d890db4a820b7925c00724e3ac676651/href">https://medium.com/media/d890db4a820b7925c00724e3ac676651/href</a></iframe><ol><li>Import SuperPlayer</li><li>Add SuperPlayerState and SuperPlayerAction to pullback SuperPlayerReducer.1<br>loadVideo action will act as a trigger to load the video when we call it from ViewController later.</li><li>Usually, the environment is used for producing Effects such as API clients, analytics clients, etc. For this case let’s directly return the video URL we want to play.</li><li>Combine appReducer and superPlayerReducer to merge all the effects. We create a pullback to transforms superPlayerReducer into state management that works on global state management.</li></ol><p>Get back toViewController.swift and set up the store.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71567746463f5150bae307b8e79a9f9f/href">https://medium.com/media/71567746463f5150bae307b8e79a9f9f/href</a></iframe><ol><li>Setup store and viewStore to pass states as objects to interact with view.</li><li>Scope to transform a store into SuperPlayer’s store that deals with local state and actions.</li><li>Send loadVideo action load the video.</li><li>Update SuperPlayerViewController parameter to use the store that was scoped before.</li></ol><p>Build the project, and it will show the same result. Now we can play video without setting up many AVPlayer states.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*A7n7rFL_BItPh6tXKohkXg.jpeg" /></figure><p>Video player is not a video player without pause play and other control. We have custom video control. You can create your own video control too, but for now, let’s use this one, I will show you how to incorporate the control with SuperPlayer.</p><p>First, the pause and play function. Open PlayerControlView.swift file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e2e0cd244296cbe82db6d445a7a1c49/href">https://medium.com/media/1e2e0cd244296cbe82db6d445a7a1c49/href</a></iframe><blockquote>Don’t remove the other code</blockquote><ol><li>Import ComposableArchitecture, Combine and SuperPlayer.</li><li>Create an emitter to tell the parent that playButton is tapped, later we will use this to trigger pause and play.</li><li>SuperPlayer provided some states, such as currentTimeLabel, playIcon, etc. to help with the video control call SuperPlayerControlState. Create store and viewStore for SuperPlayerControlState and SuperPlayerAction.</li><li>If you are familiar with <a href="https://github.com/ReactiveX/RxSwift">RxSwift</a> or reactive programming, after subscribing to an observer, we need to dispose of it, in order to prevent wasted memory. Let’s call it disposeBag and use AnyCancellable type to cancel Combine publishers.</li><li>Add store parameter on init for scope store in the parent.</li><li>Use SuperPlayerControlState‘s playIcon to change the button image.</li></ol><p>Okay! all set, let’s move to AppReducer.swift to handle SuperPlayer pause and play effects.</p><p>Add the functionality for handlePausePlayVideo action we created before. SuperPlayerState provides us what method is active now. The method is an enum that contains pause, play, and the other. Get the state value and make a condition for pause and play like below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6852dda7985bf4a48c8b11a5ae718fe3/href">https://medium.com/media/6852dda7985bf4a48c8b11a5ae718fe3/href</a></iframe><p>Let’s finish the pause and play in ViewController.swift</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7eac336b54ed6e6bc3af7a00d5e3f2d/href">https://medium.com/media/d7eac336b54ed6e6bc3af7a00d5e3f2d/href</a></iframe><ol><li>Import Combine</li><li>Scope store to satisfy PlayerControlView to exposes local state and actions.</li><li>Create disposeBag to cancel Combine publishers.</li><li>Listen to the emitter from PlayerControlView to send action to the reducer.</li></ol><p>Now you can pause and play your video, give it a try! Well done, you deserve a flower.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*Deqvalj0EbbAe4AieBGekw.gif" /></figure><p>Now we are about to update the time indicator that hangs in the right of the screen. This one below ⤵️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*_E5Pn7nnYQ8MhKVx0eA7pA.png" /></figure><p>Open PlayerControlView.swift, SuperPlayer provided all states that we need to update the time indicator.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f550d2857d22faec82daa75a163e4c7/href">https://medium.com/media/9f550d2857d22faec82daa75a163e4c7/href</a></iframe><ol><li>Since we can have 00:00:00 or 00:00, we better update the timeIndicator constraint. We need to listen to actualDuration state and make a condition like the code above.</li><li>We need the current time and the actual duration. We use CombineLatest, so when either state emits a new value, the code block will execute and update the time indicator label.</li></ol><p>Build the app again and the time indicator should be working.</p><p>Last but not least, let’s do the video slider. Let’s call it SeekBar View. Open PlayerSeekBarView.swift file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f24200e564a6cdb851fe246ff500f66/href">https://medium.com/media/1f24200e564a6cdb851fe246ff500f66/href</a></iframe><blockquote>Don’t remove the other code</blockquote><ol><li>Import Combine, ComposableArchitecture, and SuperPlayer</li><li>Create store, viewStore and disposeBag.</li><li>barNodeDidLayout will help to prevent repeated seek bar width update in layoutSubview().</li><li>Add store parameter in init for scope store in the parent.</li><li>Listen to loadedTimes to show the video has sufficient buffer to play.</li><li>SuperPlayer helps to calculate seeker (slider thumb) position from the current time. The calculation is stored in seekerPosition state.</li><li>Before we start seeking time, we need to pause the player first. It’s common UX used in almost streaming platforms (Youtube, Netflix, Hotstar, etc.)</li><li>After finish seeking time, or cancel seeking, we need to play the video again.</li><li>We need to tell SuperPlayer the bar width (slider width) we construct in the view, so SuperPlayer can recalculate the seeker position for us.</li><li>When start sliding, we need to send seekingSeeker(to: CGFloat), store the x coordinate of the pan location to the parameter. This is for SuperPlayer to help us calculate the new current time.</li><li>When pan gesture end, we need to send doneSeeking action for SuperPlayer to play the video at the desired time.</li></ol><p>Now back to PlayerControlView.swift to satisfy PlayerSeekBarView.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5cafcde5f861de19349f9ca3eef29f42/href">https://medium.com/media/5cafcde5f861de19349f9ca3eef29f42/href</a></iframe><p>Now let’s see the <strong>Final</strong> result!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*klD4PmVRVr0rKhwntkojIg.gif" /></figure><blockquote>Final result in this <a href="https://github.com/alvinmatthewp/spTV"><strong>Github repository</strong></a></blockquote><p>Cool right! You can create your own video player with and use SuperPlayer design patterns to reused them among features. With SuperPlayer we can increase the readability and maintainability of the code that leads to saving more development time.</p><h3>Contribute🚨</h3><p>Want to make a suggestion or feedback? SuperPlayer is open source and we’re excited to hear and learn from you. Your experiences will benefit others who use SuperPlayer. Let’s make it even better!</p><blockquote><a href="https://github.com/tokopedia/ios-superplayer">https://github.com/tokopedia/ios-superplayer</a></blockquote><h3>Credits</h3><p>Thanks to <a href="https://www.linkedin.com/in/rancaka/"><strong>Adityo Rancaka</strong></a> to make <strong>SuperPlayer</strong> happen. Also kudos to all developers who helped make this happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*6MZi8t86fXsGpbXrUBSLTg.jpeg" /></figure><h3>References</h3><ul><li><a href="https://priorart.ip.com/IPCOM/000266742">Prior Art Database - IP.com</a></li><li><a href="https://github.com/tokopedia/ios-superplayer">GitHub - tokopedia/ios-superplayer: Repository to publish our library (SuperPlayer) for open source</a></li><li><a href="https://medium.com/@alvinmatthew/superplayer-a-way-to-incorporate-avplayer-to-the-composable-architecture-f165133b5a9a">Medium</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db2de75ed2fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dogged — UX Design Portfolio]]></title>
            <link>https://alvinmatthew.medium.com/dogged-ux-design-portfolio-ecd773ab2be9?source=rss-dc031e8b3903------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecd773ab2be9</guid>
            <category><![CDATA[high-fidelity]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[user-flow]]></category>
            <category><![CDATA[user-experience-design]]></category>
            <dc:creator><![CDATA[Alvin Matthew Pratama]]></dc:creator>
            <pubDate>Thu, 03 Sep 2020 18:26:06 GMT</pubDate>
            <atom:updated>2020-11-06T03:55:12.527Z</atom:updated>
            <content:encoded><![CDATA[<h3>UX Design — Redesigning iOS App (Dogged) Hi-Fid User Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-trDubhlgzUyKeNVePBYQ.png" /><figcaption>Dog vectors designed by macrovector / Freepik</figcaption></figure><h3>About Dogged</h3><p>Dogged is a budgeting app for dog owners to plan and save for their dogs. The app provides the estimation costs of having a dog and aims to help dog owners fulfill their dogs’ needs.</p><h4>Version 1.0.0-beta</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q16ZsZjUPmO7myi_4WY0Fg.png" /><figcaption>some screens in version 1.0.0-beta</figcaption></figure><h4><strong>The Problems</strong></h4><p>After being released in testflight, there was a lot of feedback given by testers. There are many problems were found, especially in the UX Design. The application does not provide the user with a good journey and flow, thus resulting confusion for first time users and new dog owners.</p><p>When the application opens for the first time, there is no onboarding screen and the user arrives to the overview screen. This case make the user confused about what to do in this application. Not only that, the steps that must be taken are quite long so that users can add saving for their dog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q15HwiWALY1p0Rc0KPq9FQ.png" /><figcaption>the steps that must be taken to add saving for dog</figcaption></figure><p>When adding a dog, the user must fill in the dog breed and bio, for experienced dog owners it may not be difficult to fill in the form, but for new dog owners it will be very confused. Not only add dog form, add plan also confusing for new dog owners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzR1RD7dZsPjqSbiOlUnpw.png" /><figcaption>add dog and add plan form</figcaption></figure><h3>The Redesign — For First Time Users</h3><p>The objective of this article is to improve previous version hi-fidelity user flow especially for first time users.</p><h4>Opening the application for the first time</h4><p>Flow 1 — Goal : Add a dog</p><ol><li>User tap the Dogged icon.</li><li>User arrive at onboarding screen as first time user.</li><li>User surf the onboarding screen by tap NEXT or slide the screen.</li><li>User tap START to add a dog.</li><li>User arrive at page 1 of add new dog screen and start filling dog biodata form.</li><li>User tap NEXT when finished filling out the dog biodata form.</li><li>User arrive at page 2 of add new dog screen to select dog breed.</li><li>User explore dog breeds by sliding the collection view.</li><li>User tap on the selected dog’s breed cell.</li><li>User arrive at dog breed detail screen.</li><li>User explore the screen by scrolling.</li><li>User tap SELECT button on the bottom of the screen.</li><li>User arrive at page 3 of add new dog and start filling dog size form.</li><li>User tap NEXT when finished filling out the dog size form.</li><li>User arrive at the last page of add new dog and make sure the dog’s information is correct.</li><li>User tap FINISH button.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LxPP3vp9660xbcsE0xUUrg.png" /><figcaption>Flow 1 — Goal : Add a dog | Dog vectors designed by macrovector / Freepik | Dog images by Unsplash</figcaption></figure><p>Flow 2 · Scenario A — Goal: Add saving plan with suggestions</p><ol><li>Refer to flow 1.</li><li>User arrive at add plan onboarding screen.</li><li>User tap START to add plan.</li><li>User arrive at page 1 of add new plan screen and start searching to select dog.</li><li>User tap on selected dog cell.</li><li>User arrive at page 2 of add new plan screen and start browsing suggested categories by scrolling.</li><li>User tap on selected suggested category cell.</li><li>User arrive at category detail screen.</li><li>User tap SELECT button on the bottom of the screen.</li><li>User arrive at page 3 of add new plan screen and start exploring the places and costs of the selected plan category suggestions.</li><li>User tap on selected suggestion cell.</li><li>User arrive at page 4 of add new plan screen and start filling saving plan target time or amount of savings per certain period.</li><li>User tap Set Amount to switch to amount of savings per certain period and vice versa.</li><li>User tap SET button on the bottom of the screen.</li><li>User arrive at the last page of add new plan and make sure the saving plan is correct.</li><li>User tap ADD PLAN button on the bottom of the screen.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70j2T1bjtpUUWE1VcB7H3w.png" /><figcaption>Flow 2 · Scenario A — Goal: Add saving plan with suggestions | Dog vectors designed by macrovector / Freepik</figcaption></figure><p>Flow 2 · Scenario B — Goal: Add saving plan without suggestions</p><ol><li>Refer to flow 1.</li><li>User arrive at add plan onboarding screen.</li><li>User tap START to add plan.</li><li>User arrive at page 1 of add new plan screen and start searching to select dog.</li><li>User tap on selected dog cell.</li><li>User arrive at page 2 of add new plan screen.</li><li>User tap Skip on top right of the screen.</li><li>User arrive at page 3 of add new plan screen and start filling plan information form.</li><li>User tap DONE button on the bottom of the screen.</li><li>User arrive at page 4 of add new plan screen and start filling saving plan target time or amount of savings per certain period.</li><li>User tap Set Amount to switch to amount of savings per certain period and vice versa.</li><li>User tap SET button on the bottom of the screen.</li><li>User arrive at the last page of add new plan and make sure the saving plan is correct.</li><li>User tap ADD PLAN button on the bottom of the screen.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4SH0sDXaZ8kRF9C9QHgFg.png" /><figcaption>Flow 2 · Scenario B — Goal: Add saving plan without suggestions | Dog vectors designed by macrovector / Freepik</figcaption></figure><p>Flow 2 · Scenario C — Goal: Add saving plan from overview screen</p><ol><li>Refer to flow 1.</li><li>User arrive at add plan onboarding screen.</li><li>User tap SKIP at bottom left of the screen.</li><li>User arrive at overview screen.</li><li>User tap on Add Plan button on the middle of the screen.</li><li>User arrive at add new plan screen.</li><li>Refer to Flow 2 Scenario A, step 4 –16.</li><li>Or refer to Flow 2 Scenario B, step 4 –14.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2cRssniy0w5xNtbLrLcpw.png" /><figcaption>Flow 2 · Scenario C — Goal: Add saving plan from overview screen | Dog vectors designed by macrovector / Freepik</figcaption></figure><p>Flow 3 — Goal: Add saving</p><ol><li>User tap the Dogged icon.</li><li>User arrive at overview screen.</li><li>User tap Add Savings.</li><li>User arrive at page 1 of add savings screen and start searching to select plan.</li><li>User tap on selected plan cell.</li><li>User arrive at last page of add savings and start filling the add savings form.</li><li>User tap ADD SAVINGS button on the bottom of the screen.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-G-Wfrm9HL42ii2V-uzQ-g.png" /><figcaption>Flow 3 — Goal: Add saving | Dog vectors designed by macrovector / Freepik</figcaption></figure><h3>Summary</h3><p>From above redesign process I gained new skills in thinking about the better user flow and better undestanding on user flow. Through this process I learn that user flow can help visualize how users will move through the application ensures everyone is on the same page which allows for a more productive and rewarding work environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzxfDlQ5K9uuG0LxUdEXzg.png" /><figcaption>Dog vectors designed by macrovector / Freepik | Dog images by Unsplash</figcaption></figure><ul><li>Vectors: <a href="https://www.freepik.com/">https://www.freepik.com/</a></li><li>Images: <a href="https://unsplash.com/">https://unsplash.com/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecd773ab2be9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>