<?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 Frank Jia on Medium]]></title>
        <description><![CDATA[Stories by Frank Jia on Medium]]></description>
        <link>https://medium.com/@frankjia?source=rss-a777d7e94e27------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q8VHNfqwavIi-b5wMM8Otw.jpeg</url>
            <title>Stories by Frank Jia on Medium</title>
            <link>https://medium.com/@frankjia?source=rss-a777d7e94e27------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:44:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@frankjia/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[Building Solutions with PayID — The Future of Cryptocurrency Payments]]></title>
            <link>https://medium.com/swlh/building-solutions-with-payid-the-future-of-cryptocurrency-payments-f56cc0d548ae?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/f56cc0d548ae</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[payid]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Wed, 02 Sep 2020 02:30:42 GMT</pubDate>
            <atom:updated>2020-09-02T02:30:42.815Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Solutions with PayID — The Future of Cryptocurrency Payments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7qb2gWlXQ31ayBfF1PWiA.png" /></figure><p>One of the biggest hurdles to the adoption of cryptocurrency is the difficulty in transacting. The complex terminology, high overhead in setting up wallets, and myriad of different currencies that exist present huge challenges to mainstream crypto payments. The PayID protocol attempts to solve some of these pain-points to decrease friction in the entire process. In this blog post, I’m going to share my experience working with PayID while creating <a href="https://devpost.com/software/xpayments-me">xPayments</a>, my submission to the <a href="https://payid.devpost.com/">PayID hackathon</a>.</p><h3>What is PayID?</h3><p>Want to send some USD to a friend? Open Venmo or Cash app and do it in a click.</p><p>Want to buy stuff online? Use your PayPal or credit card and pay in a few clicks.</p><p>Want to send cryptocurrency? Make sure you have a compatible currency wallet, login with your 10+ character password, then manually copy and paste a long and complex address before triple checking and sending off the payment.</p><p>The folks at <a href="https://payid.org/">PayID</a> envisioned a payment protocol that was currency agnostic and easy to interface with. A simple, easy-to-read payment address, such as frank$jiafrank.com, contains all the payment methods and addresses that I accept - be it Bitcoin, XRP, Ethereum, or even USD.</p><p>In an ideal world, all cryptocurrency wallets would be able to take in a PayID address as input, and automatically resolve the payment addresses associated with that payment address.</p><p>You would input a simple, email-like identifier into your mobile wallet, then enter in the amount to send before pressing confirm. Or even simpler — scan a QR code — which would already encode the value of crypto to send, then simply confirm the requested amount before sending off the transaction.</p><p>As you can see, the PayID protocol enables <strong>anyone</strong> to easily send cryptocurrency (or even fiat) payments.</p><h3>Great — How Does it Work?</h3><p>PayID is built to support decentralization. Anyone can host their own PayID, and as long as they adhere to the protocol, any client can resolve the addresses associated with the PayID. The basic protocol is simple. A given payment address, for example frank$jiafrank.com, maps to a URL from which the address details can be retrieved.</p><p>By default, an address frank$jiafrank.com maps to the url jiafrank.com/frank.json. I can simply serve this json file, and any client would be able to retrieve it and parse it for payment details. Here&#39;s an example JSON:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26a9bc935581b166641d1840cb83ede7/href">https://medium.com/media/26a9bc935581b166641d1840cb83ede7/href</a></iframe><p>The workflow for a client would be:</p><ul><li>Take in the PayID, then retrieve the json file that maps to the URL associated with the PayID</li><li>Read the json file for a list of the payment methods</li></ul><p>Pretty simple, but there’s lots in the works, such as setting up “verified” PayID’s and adding in the ability for invoicing. Interested? Check out the PayID <a href="https://payid.org/whitepaper.pdf">whitepaper</a>.</p><h3>Creating a PayID</h3><p>For now, PayID is in its infancy. As far as I know (and at the time of writing), only the <a href="https://xumm.app/">Xumm</a> mobile wallet supports PayID resolution. When first starting to develop with the protocol, it was difficult to figure out how to even create a PayID.</p><p>There isn’t a great resource to quickly generate a PayID with an external service’s domain name (I really think there should be!). So for now, your options are the following:</p><p>After setting up a PayID, you can use <a href="https://payidvalidator.com/">PayID Validator</a> to make sure that your PayID is valid.</p><h3>xPayments.me — Easy Crypto Payment Pages</h3><p>Now for the cool new stuff! PayID is a protocol, meaning that it’s the basis on which additional functionality can be built. I wanted to address the following pain points:</p><ul><li>It’s difficult to share cryptocurrency payment information — this is easily solvable using the PayID protocol</li><li>Most of us suffer from “registration fatigue” — getting setup should take less than a minute</li><li>It’s difficult to create and maintain a PayID — we never got around to enabling PayID creation, but this is easily doable with a simple backend + database</li></ul><p><a href="https://devpost.com/software/xpayments-me">xPayments.me</a> was designed to address these shortcomings. By building on top of the PayID protocol, users can create their own “payment page” with their crypto address information in just a few seconds:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9GZuTjnFFBkySvYqSPrwA.png" /></figure><p>Further, they can specify a requested amount — this is especially useful for invoicing. Let’s say that I’m a freelance web developer, with a single PayID, I can create multiple payment pages for my different clients, share them through social media or email, and collect payments without needing to triple-check my payment addresses and manually coordinate payments.</p><p>When people receive the payment page link, they see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIQD7rIYBf4kCxvCWnEO-Q.png" /></figure><p>The page would show all the payment options associated with the PayID, and the requested amount (if any). The payee can then pick and choose their payment method and send the requested amount (which is automatically converted to the currency using the latest exchange rates). Here’s a complete demo:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FoFfFI-1ywHU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DoFfFI-1ywHU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoFfFI-1ywHU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/07c55fb501daa383ac6af4b6c3c44d60/href">https://medium.com/media/07c55fb501daa383ac6af4b6c3c44d60/href</a></iframe><p>Building the initial prototype was quite pain-free. The tech stack is as follows:</p><ul><li>Vue.js front-end (<a href="https://github.com/frankfka/PayIDHackathon-Frontend">Repo</a>)</li><li>Node.js back-end (<a href="https://github.com/frankfka/PayIDHackathon-Backend">Repo</a>) + MongoDB Atlas as a database</li></ul><p>We used the <a href="https://github.com/xpring-eng/Xpring-JS">Xpring-JS</a> library to interface with PayID — this helped to abstract away the nitty gritty details of working with the PayID protocol directly. This POC turned out pretty well, but is not meant at all for production use.</p><p>That being said — I haven’t seen something like this being offered as a production service just yet. So if anyone is interested in collaborating to polish up the project and offer it as a service, feel free to reach out!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f56cc0d548ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/building-solutions-with-payid-the-future-of-cryptocurrency-payments-f56cc0d548ae">Building Solutions with PayID — The Future of Cryptocurrency Payments</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Multi-Segment Picker in SwiftUI]]></title>
            <link>https://medium.com/better-programming/how-to-multi-segment-picker-in-swiftui-9c5b909971f5?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c5b909971f5</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Sat, 08 Aug 2020 04:49:58 GMT</pubDate>
            <atom:updated>2020-08-18T14:51:45.788Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to pick multiple things in your UI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PAkiRkrU7ul86Ost" /><figcaption>Photo by <a href="https://unsplash.com/@mlarosa97?utm_source=medium&amp;utm_medium=referral">Michael LaRosa</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>After a few weeks off from SwiftUI content, I’m back! In this article, we’ll go over how to create a multi-segment picker. This might be useful for selecting a time duration (ex. one day, four weeks, etc.), which was my use case. This is the final product:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*b3zXd-ozwSUJSCYt6C2kAA.png" /><figcaption>Photo by the author.</figcaption></figure><p>Let’s first define a simple, single segment picker in SwiftUI:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4c56be2e4f4d99e8de3992d9b245b4c/href">https://medium.com/media/f4c56be2e4f4d99e8de3992d9b245b4c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*0cnHvdJHHVgMMDD3Za5VBg.png" /><figcaption>Photo by the author.</figcaption></figure><p>Let’s go over this really quickly:</p><ol><li>A SwiftUI picker needs some sort of data (i.e. what the picker values are). It also needs a state or a binding that informs the currently selected value.</li><li>SwiftUI makes declaring a picker <a href="https://developer.apple.com/documentation/swiftui/picker">relatively easy</a>. The first argument is the picker’s label and the second (selection) is a binding to the current selection. The last argument is a closure that creates a series of views. Each view is a selectable value.</li><li>Inside the picker, we create a series of views with ForEach. Notice that instead of iterating over data itself, we iterate over the indices. This is fine as long as the number of items in ForEach doesn&#39;t change. If it does, consider conforming the items in data to Identifiable.</li><li>We display the value using Text and give it a tag value of the index. This means that each Text instance is associated with the index within the array. This works with the selection argument for SwiftUI to determine which item to show as the current selection.</li></ol><h3>Creating Multiple Segments</h3><p>That was pretty standard, but how can we start defining multiple segments for the picker? In my opinion, it’s always good to start with the view model first. This way, we can cleanly describe what our incoming data looks like and create our view accordingly:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a8233f73b6020ca9218bbdbfc36ad19/href">https://medium.com/media/6a8233f73b6020ca9218bbdbfc36ad19/href</a></iframe><p>Our view model has a single property, segments, which is an array of tuples. Each tuple represents one segment within the picker. Each tuple is composed of:</p><ol><li>A String label.</li><li>A binding to a selection. In this case, we are using the selection index as an integer, but you can use any binding you see fit by changing the type alias.</li><li>An array of values for the particular segment. We have defined these to be of type String, but again, the type alias can be used for your use case.</li></ol><p>Now we can define the view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4f2dbe4e9b5dc9c888b2cb90a4cd42c/href">https://medium.com/media/e4f2dbe4e9b5dc9c888b2cb90a4cd42c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*b3zXd-ozwSUJSCYt6C2kAA.png" /><figcaption>Photo by the author.</figcaption></figure><p>Nice! This is exactly what we want. Let’s go over the view. Notice that we are declaring a collection of pickers arranged horizontally using HStack:</p><ol><li>For us to be able to define multiple segments, we must size each picker accordingly. GeometryReader gives us the sizing of the parent view. We can then use this to frame each Picker accordingly.</li><li>As mentioned, for us to lay out the pickers in a horizontal fashion, we use HStack.</li><li>We iterate over the different picker segments and define a picker for each segment using ForEach. Notice that the definition for each individual picker is the same as our initial example of the single-segment picker.</li><li>We use .frame(...) to size each picker to the appropriate width, which is the parent width divided by the number of pickers.</li><li>Using .clipped() is key here. If we don&#39;t use the modifier, you&#39;ll see that the lines of the picker will overlap. clipped() will make sure that each picker does not extend beyond the bounds of each view.</li></ol><p>And there you go: multi-segment pickers in SwiftUI. Visit the <a href="https://gist.github.com/frankfka/704645201f384d93afefc9385b2eed81">GitHub playground</a> with all the code for the multi-segment picker.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c5b909971f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-multi-segment-picker-in-swiftui-9c5b909971f5">Create a Multi-Segment Picker in SwiftUI</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cancelled Internships — Where to Go Next? Learning from My Experience.]]></title>
            <link>https://levelup.gitconnected.com/cancelled-internships-where-to-go-next-learning-from-my-experience-3819ddb2eb1e?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/3819ddb2eb1e</guid>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[personal-development]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 17:09:51 GMT</pubDate>
            <atom:updated>2020-07-17T12:37:26.561Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cancelled Internships — Where to Go Next? Learning from My Experience.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QDTB2iTWNMaHhMgx" /><figcaption>Photo by <a href="https://unsplash.com/@clarktibbs?utm_source=medium&amp;utm_medium=referral">Clark Tibbs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As the COVID-19 pandemic ravages the world, students and new grads lie hopeless in its wake of destruction. Although nothing is more important than the health and wellbeing of our fellow global citizens, the effect of the pandemic on the future careers of our rising STEM generation is not trivial.</p><p>I too, like many of you reading this, have had my internship cancelled as a result of the travel restrictions and border closures. From the conscious decision to actively cancel pending offers (ex. Airbnb &amp; Uber) to the forced cancellation of foreign hires (ex. the cancellation of H1-B visas), companies around the globe are cutting ties with the rising generation.</p><p>Whether you’ve had your summer internship cancelled, or your new grad offer revoked — I want to share my own experience with the roadblocks introduced by COVID-19, and offer opportunities to continue your career development, no matter where you are.</p><p>But let me preface this by saying:</p><p><strong>I am not some CS major from Stanford.</strong> I attend a mid-rank Canadian University with a major in Engineering Physics — which involves basically no computer science coursework.</p><p><strong>I don’t have past internships from Facebook, Jane Street, and Google.</strong> But I am grateful to have gained valuable experience at a small startup and more recently, SAP Concur.</p><p><strong>I am not conveniently located in the Bay Area.</strong> I am a first generation immigrant. My family relocated to Canada when I was eight, abandoning any existing degrees &amp; certifications to start form scratch in a land of opportunity.</p><h3>So — What’s My Story?</h3><p>I’m usually not the type to share personal stories, but I feel that my journey might be useful for those in a similar position. If you’d just like a tl;dr of what I learned, feel free to skip to the next section.</p><p>As an aspiring software engineer, the allure of silicon valley was undeniable. I had completed two amazing internships in Vancouver, Canada, and was ready to explore new places of work.</p><p>I had an upcoming internship term in the summer of 2020. I applied to numerous positions across the United States and Canada. After endless applications and interviews, I was both relieved and excited to have received an internship offer from Robinhood.</p><p>For those who don’t know, Robinhood is a stock (and cryptocurrency) trading service that enables commission-free trading of equities. I was extremely excited to be relocating to a major tech hub, and to be contributing to a service that I understand and appreciate. I had my J1 visa ready to go, health insurance figured out (duh!), and even my flights booked.</p><p>Then, the pandemic hit.</p><p>At first, I thought nothing of it. My internship wouldn’t be for another few months, so surely this entire situation will blow over. But as the days dragged on, I began hearing about the cancelled internships and layoffs. These served as the canary in the coal mine for what was about to happen to me.</p><p>And on one fateful day in April, an incoming notification informed me of the inevitable. Robinhood was unable to support an incoming intern cohort for the summer of 2020. Its U.S. interns would be able to work remotely, but legal regulations prevent them from having employees from Canada. They would have to delay my internship until the fall.</p><p>Grudgingly, I accepted.</p><p>But my confidence was shaken. With no resolution to the COVID-19 pandemic in sight, I became doubtful that an internship in the fall would ever occur. As a precautionary measure, I began applying for other internship positions — both the last-minute postings for the summer, as well as positions for the fall. With a last ditch effort to secure some sort of work for the summer, I began cold-emailing local tech companies and reached out to my network.</p><p>It was no after no. Companies saying that they are no longer accepting interns, or that they would love to help, but are not in a position to due so as a result of the pandemic. Things were looking bleak for some sort of software work during the summer term. After weeks of searching, I had no options in sight. But just a few weeks before the end of my school term, I was offered a contract position at my past internship — SAP Concur. My manager had jumped through hoops to get a last minute hire approved — a feat for which I am extremely grateful for. Relieved, yet exhausted from the job search, I could rest easy knowing that my summer position was secured.</p><p>So, what about the fall? It was supposed to be a school term, but with my school moving classes online for the fall term and the possibility of resuscitating my Robinhood internship, I decided to forego my academic plans for an additional internship term.</p><p>That being said, I was shaken by the uncertainty of my upcoming position. In an effort to mitigate the risk of another cancelled internship, I decided to apply to other positions. The job market was bleak — after all, many have lost their full-time and upcoming internships from revered companies such as Uber, Lyft, and Airbnb. I gave special attention to the companies that were thriving during the epidemic, including those who have quickly rolled out <a href="https://www.cnn.com/2020/03/10/tech/google-work-from-home-coronavirus/index.html">work-from-home strategies</a> and companies that recognize the <a href="https://ottawa.ctvnews.ca/shopify-says-most-employees-will-permanently-work-remotely-following-covid-19-1.4948371">potential of remote work</a> in the future of software development.</p><p>Amazingly, I was offered an interview at Shopify. After two rounds of remote interviews, I was offered a fall (remote) internship position. I was ecstatic, and happily accepted the offer.</p><p>What about Robinhood? Sure, it might have offered an opportunity to work in the bay area. It also paid a <em>lot</em> more. But I had to look past my dream of working in Silicon Valley and rationally approach the risks and rewards of the two possible positions. The pandemic was still raging in many parts of the world, and the US — Canada border remained closed until further notice. And although I loved the culture of Robinhood, Shopify’s engineering culture and drive to innovate were well known within the industry. Shopify was the clear winner — as much as it hurts, the Bay Area dream can wait.</p><h3>What Did I Learn?</h3><p>The past few months have been tumultuous, but have offered a great opportunity for learning and reflection. I’m happy to have weathered the economic consequences of the pandemic. Sure, my plans have changed, but I’m happy with how I adapted to the many obstacles in the past few months. Most importantly, I’m happy that my friends and family are healthy and safe. With all that being said, here are a few things that I’ve learned along the way.</p><p><strong>1. Accept, Adapt, Repeat.</strong></p><p>The world has changed immensely in the span of just a few months. The harsh new reality has created unprecedented challenges and obstacles, but humans are resistant to change. We see this resistance in many nations’ reactions to the spreading pandemic. The United States, in an attempt to maintain the status quo, has been criticized as being too slow to react to the raging virus. I, too, initially acted in denial about the true nature of the situation. I doubted the ability of a virus to bring the world economy (and public health) to its knees. I hadn’t taken actions to mitigate the risk of a cancelled summer internship. I could have, for example, began applying for alternative roles (or explored other summer plans) much earlier in the year.</p><p>I learned from my mistakes when I was navigating my plan for the upcoming fall. Although I had a loose promise of an internship position at Robinhood, I accepted and adapted to the uncertain nature of the U.S. pandemic mitigation effort and planned accordingly.</p><p>And although the shock of a lost career prospect can be debilitating, I urge that you put aside the initial disappointment. Adapt to the current situation — jump into action as soon as you can.</p><p><strong>2. The Importance of a Support Network</strong></p><p>Simply put, I would be lost without the network that I’ve built throughout my past internships.</p><p>When I was first informed of my cancelled internship, I reached out to the supervisors and recruitment managers within my professional circles. The HR manager from my first internship connected me with a bunch of local hiring managers and startups that may have interest in a last-minute summer intern. My current summer role at SAP Concur would not have been possible had I not reached out to my past manager.</p><p>Many often say that the formed connections and extensive career network developed from internships are perhaps more important than the hands-on learning itself. I couldn’t agree more. Professional opportunities often come not from a job posting on a public careers website, but rather from interaction with connections embedded within the industry.</p><p>I’m grateful to have a support network within Vancouver, and will definitely emphasize professional network development in my future roles.</p><p><strong>3. Plan for the Unexpected</strong></p><p>Plan for the unexpected — a classic cliché phrase that sounds like a great idea until it gets ignored for the sake of efficiency. When times are good, contingency plans are rarely prioritized. But if this pandemic has taught me anything about future planning, it’s that a healthy amount of skepticism often goes a long way.</p><p>I’m not necessarily suggesting that you should have a detailed contingency plan for everything. In fact, it would be somewhat irresponsible for me to do so. The chances of a black swan event are so low that it would be a waste of resources to <em>always</em> plan for a possible disaster. But every time a significant career/life event is scheduled — ask yourself the following:</p><ul><li>What steps would/could you take if this opportunity was pulled out from under you?</li><li>Is there anything you can do — that requires relatively little effort — that could act as a backup?</li><li>How necessary is this opportunity to your long-term goals/life plans?</li></ul><p>If the answer to the last question is <em>extremely necessary,</em> I would put some effort into risk mitigation.</p><h3>Your Next Steps</h3><p>Key takeaways are nice and enlightening, but they’re forward-looking. Reflecting upon what <em>could</em> have helped you is useful for the next black swan, but what can you do <em>now</em> to rescue your career trajectory?</p><p>Well, if you haven’t already:</p><ul><li>Reach out to your network — you never know what opportunities may surface — even if it seems too late to do so</li><li>Browse job boards — lots of companies are still hiring, especially in the tech sector</li><li>Make a tentative plan for the future — and make sure to plan for the unexpected</li></ul><p>When my internship was initially cancelled, I had to face the daunting question: if I had a summer with nothing to do, what would I do to make the best of the time available? I compiled a list of things that I would potentially pursue, had I not found an alternate internship. These are, of course, focused in the realm of software development.</p><ol><li><strong>Start a new side-project:</strong> Not only does this bolster your resume, but it also allows you to develop your software development skills in a relatively low-risk environment. It’s important to pick a project that’s <em>non-trivial</em>. The goal should be to push the boundaries of your knowledge. Perhaps take advantage of the <a href="https://www.forbes.com/sites/martingiles/2020/03/19/free-software-for-businesses-and-schools-covid19/#4c7a544f752d">free/discounted resources</a> that some companies are offering during the COVID pandemic.</li><li><strong>Increase the breadth of your expertise:</strong> Are you a proficient mobile engineer? Perhaps look at learning how to create backend software. Already experienced across full-stack development? Why not try out dev-ops or machine learning?</li><li><strong>Participate in competitions:</strong> Put your skills to use — participate in <a href="https://www.kaggle.com/competitions">Kaggle</a> competitions (for ML) or in <a href="https://www.agorize.com/en/challenges">Agorize</a> challenges (for general software/ideation).</li><li><strong>Learn a tangential skill:</strong> Skills such as UI/UX design and digital illustration may not be directly relevant to software engineering, but can differentiate you from the masses. It’s rare to find someone who is both proficient at writing code and designing intuitive user interfaces. This is still one of my long-term goals: to be able to both design <em>and</em> create immersive user experiences.</li><li><strong>Or — try something totally new:</strong> Sometimes, we just need a break. Many of us have been immersed in academic/professional development that we have forgotten the joys of other activities. Perhaps take up a physical activity (I’ve been enjoying weekend hikes), baking, or painting. It is as important to work on your personal wellbeing as it is on career development — so some time off may not be the worst thing in the world.</li></ol><p>I hope that my stories and insight shave been helpful, and that some of my insights will help you tread confidently in this new world. I’d like to know — how has COVID-19 affected you, and what have you learned from this entire experience?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3819ddb2eb1e" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/cancelled-internships-where-to-go-next-learning-from-my-experience-3819ddb2eb1e">Cancelled Internships — Where to Go Next? Learning from My Experience.</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Better RESTful Image Transfer: Multipart Uploads with Python Flask & Swift]]></title>
            <link>https://levelup.gitconnected.com/better-restful-image-transfer-multipart-uploads-with-python-flask-swift-38a34d4e6e1f?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/38a34d4e6e1f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Mon, 29 Jun 2020 02:40:10 GMT</pubDate>
            <atom:updated>2020-06-29T14:17:35.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l17UJRKrgq6j8lDY" /><figcaption>Photo by <a href="https://unsplash.com/@photoholgic?utm_source=medium&amp;utm_medium=referral">Holger Link</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my last <a href="https://medium.com/swlh/restful-image-transfer-with-base64-encoding-cd9fb4453598">blog post</a>, I discussed how to create a backend that supports image transfers using Base64 encoding, as well as the front-end code for the iOS client. In this article, I’ll be documenting an alternative (and arguably, better) approach to handling RESTful image transfer.</p><p>Base64 encoding images was traditionally used in websites as an alternative to static file loading, helping to save an additional HTTP call to retrieve an image. In REST-land, sending base64 through API requests is useful if you want to adopt a purely JSON-driven API. That being said, encoding images in base64 format increases the size by ~33%, making it an inefficient method to transmit images between client and server.</p><p>So, what’s the better alternative?</p><h3>1 Multipart Form Data</h3><p>Multipart form data as part of a <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST">POST request</a> is exactly what it sounds like — it is the standard method by which clients transmit form-based data to the server. It’s suitable for our purpose as this method of data transmission supports file uploads.</p><p>Sending images through a multipart form is sufficient if we’re uploading <strong>one image at a time (or at most, a few images).</strong> For videos and batched image uploads, it would be more feasible to use some sort of streaming upload.</p><h3>2 Basic Python REST Server</h3><p>As in my last blog post, a basic backend server can be created in Python with <a href="https://github.com/pallets/flask/">flask</a> together with <a href="https://github.com/flask-restful/flask-restful">flask-restful</a>. With flask-restful, endpoints are defined as Python classes. Again, we create a post function to indicate that this endpoint supports HTTP POST operations.</p><p>In our RequestParser, we used to define the following expected argument: parser.add_argument(&quot;image&quot;, type=str, location=&#39;json&#39;). Now, we&#39;re sending data over a form upload, so we change the expected argument to: parser.add_argument(&quot;image&quot;, type=werkzeug.datastructures.FileStorage, location=&#39;files&#39;)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c059111a281bc3468cf39563ab6c753/href">https://medium.com/media/5c059111a281bc3468cf39563ab6c753/href</a></iframe><p>This is not too different at all from the base64 case. By implementing image transfer this way, we save a lot of bandwidth in the long run. We also reduce the time spent in transit — translating to shorter wait times for the end user.</p><h3>3 Sending Images with Swift (iOS)</h3><p>As in the last blog post, recall that when you take an image using the Swift AVFoundation library, you get an output of type AVCapturePhoto. We can easily retrieve a data representation of the photo using .fileDataRepresentation().</p><p>Again, we leverage the Alamofire framework, which easily facilitates multipart form POST requests. We can then create a service with a makeRequest function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e6e5db7504d8a1ae271e0b27a8c9be6/href">https://medium.com/media/6e6e5db7504d8a1ae271e0b27a8c9be6/href</a></iframe><p>If you have other arguments you would like to send, you can either attach them to the request as headers, add it to the URL as a parameter, or just add an additional entry to formData.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38a34d4e6e1f" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/better-restful-image-transfer-multipart-uploads-with-python-flask-swift-38a34d4e6e1f">Better RESTful Image Transfer: Multipart Uploads with Python Flask &amp; Swift</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RESTful Image Transfer with Base64 Encoding]]></title>
            <link>https://medium.com/swlh/restful-image-transfer-with-base64-encoding-cd9fb4453598?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9fb4453598</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Sat, 13 Jun 2020 20:21:20 GMT</pubDate>
            <atom:updated>2020-06-19T14:44:00.894Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To: Base64 Image Transfer with Swift &amp; Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q1Fl4oehnW0COUK0" /><figcaption>Photo by <a href="https://unsplash.com/@charbutch?utm_source=medium&amp;utm_medium=referral">Charlotte Butcher</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’m currently building an iOS app that requires some image processing functionality — the user would scan a food label, and I would need to parse the nutritional information and return some content back to the user.</p><p>In this blog post, I’m going to explore how we can enable image transfers through a REST API — which I built with Python. I’m also going to briefly discuss how I interact with this API with Swift code within the iOS app.</p><p>This is going to be part one of a two-part series. In this blog post, I go over my initial implementation of the client and API. In the next post, I’m going to explore another method for sending images through to the API. Let’s get started!</p><h3>1 Base64 Encoding</h3><p>Before we dive into a rough overview of the code, we need to think about how exactly we can transfer image data over the internet. You may be familiar with HTTP requests with JSON data — but this data is completely textual. How do we transfer visual content through textual data?</p><p>In my first implementation, I POST JSON request data to my server endpoint. The JSON would have an image property - which represents some textual representation of the image that we want to send.</p><p>To convert an image into a JSON-friendly format, we can use <a href="https://www.lifewire.com/base64-encoding-overview-1166412">Base64 encoding</a>. In short, Base64 converts a binary representation (an image file) into an ASCII string that is safe for plain text systems. The downside is that the resulting representation is ~1.3x larger in size than the original file. Keep this in mind when building the system — image file sizes can quickly add up, and that extra 33% of space might add up to be quite a lot over the long run!</p><h3>2 Basic Python REST Server</h3><p>To implement a basic server, I used <a href="https://github.com/pallets/flask/">flask</a> together with <a href="https://github.com/flask-restful/flask-restful">flask-restful</a>. The docs are pretty self explanatory, so I will focus more on the specific implementation for image transfer.</p><p>With flask-restful, endpoints are defined as Python classes. In this example, we parse the image argument from the POST JSON request body.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3bd77f65b35735063d22b6186cc0f28/href">https://medium.com/media/e3bd77f65b35735063d22b6186cc0f28/href</a></iframe><p>Simple enough! Now let’s take a look at the client side.</p><h3>3 Sending Images with Swift (iOS)</h3><p>Let’s say that we want the user to take an image, then send it to our backend. In iOS, the output from the camera is of type AVCapturePhoto. We can extract a Base64 encoded string like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0d08f66585965f639a372310d4a3732/href">https://medium.com/media/d0d08f66585965f639a372310d4a3732/href</a></iframe><p>To make requests to our backend server, we can use a library such as Alamofire. We can then create a service with a makeRequest function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37f61e1c71123bfcd2d214ade174e10b/href">https://medium.com/media/37f61e1c71123bfcd2d214ade174e10b/href</a></iframe><p>Of course, in an actual app, we would have a callback that executes some action when the response comes back. This is a pretty simple system. I hope that it helps you make your own image transfer app :).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9fb4453598" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/restful-image-transfer-with-base64-encoding-cd9fb4453598">RESTful Image Transfer with Base64 Encoding</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Conditionally Apply View Modifiers in SwiftUI]]></title>
            <link>https://medium.com/better-programming/conditionally-applying-view-modifiers-in-swiftui-c5541711eb41?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5541711eb41</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Sun, 31 May 2020 17:16:09 GMT</pubDate>
            <atom:updated>2020-06-09T14:16:55.177Z</atom:updated>
            <content:encoded><![CDATA[<h4>Apply view modifiers depending on some property or variable</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NiVnQN4LcIO0FLII.png" /><figcaption>Photo from <a href="https://developer.apple.com/documentation/swiftui">Apple Developer</a>.</figcaption></figure><p>When developing in SwiftUI, sometimes we’re tempted to conditionally apply a view modifier. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd9b37c471267188aefcf379c191bfb7/href">https://medium.com/media/bd9b37c471267188aefcf379c191bfb7/href</a></iframe><p>Unfortunately, we can’t do this directly. After a bit of searching and toying around, I arrived at a good solution thanks to this <a href="https://stackoverflow.com/questions/59029560/how-to-apply-modifier-or-view-by-condition">Stack Overflow post</a>. Let’s see the implementation first:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d704644e3a56a0c3be67d35b61e4f19b/href">https://medium.com/media/d704644e3a56a0c3be67d35b61e4f19b/href</a></iframe><p>First, we create an extension function on the type View. This allows us to call conditionalModifier on any type of view. We use a <a href="https://docs.swift.org/swift-book/LanguageGuide/Generics.html">generic function</a>, as this function can be applied to any type that conforms to View.</p><p>The function takes two parameters, a condition that determines whether transform (i.e. a view modifier such as .foregroundColor(...) ) should be applied or not.</p><p>The @ViewBuilder part might confuse some people. Majid has a good <a href="https://swiftwithmajid.com/2019/12/18/the-power-of-viewbuilder-in-swiftui/">blog post</a> about ViewBuilders in SwiftUI. In short, this allows us to conditionally return two different types of content ( transform(self) and self) without erasing their types to AnyView.</p><p>The function body is quite straightforward: Apply the transform if the condition is true. And there you have it! You can use this extension like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1af73363c9ed180a159890e7faf4421f/href">https://medium.com/media/1af73363c9ed180a159890e7faf4421f/href</a></iframe><p>We can go one step further. Let’s say we want to apply a different modifier if the condition is false. With our current setup, we would have to do:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/148fdf55e22dd8467cc4b015333de7f9/href">https://medium.com/media/148fdf55e22dd8467cc4b015333de7f9/href</a></iframe><p>That isn’t very elegant. To improve this, we can have one more parameter in our conditionalModifier function — another modifier closure that is applied when the condition is false:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f8428b062da5ad49fa7b344fc26fab8/href">https://medium.com/media/6f8428b062da5ad49fa7b344fc26fab8/href</a></iframe><p>Not too bad!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5541711eb41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/conditionally-applying-view-modifiers-in-swiftui-c5541711eb41">How to Conditionally Apply View Modifiers in SwiftUI</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Custom iOS Segmented Control With SwiftUI]]></title>
            <link>https://medium.com/better-programming/custom-ios-segmented-control-with-swiftui-473b386d0b51?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/473b386d0b51</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Mon, 18 May 2020 01:31:00 GMT</pubDate>
            <atom:updated>2020-05-25T13:51:15.052Z</atom:updated>
            <content:encoded><![CDATA[<h4>Let’s go further than Apple’s default segmented control</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_wp-KGLnkl1qfPgVpTALA.png" /><figcaption>This is what we’ll be building in this tutorial (photo by the author).</figcaption></figure><p>In this article, I’ll be sharing my implementation of a custom SegmentedPicker in SwiftUI. You may ask, “Why go through the pain of implementing this yourself?”</p><p>Well, using a SwiftUI picker with .pickerStyle(SegmentedPickerStyle()) is a native way to get segmented control functionality without too much overhead:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed452d92da55eabd7843d5745f0c2d8b/href">https://medium.com/media/ed452d92da55eabd7843d5745f0c2d8b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*Tty7PxueoNtS0sxzdCnYPw.png" /></figure><p>But there’s a huge downside: The animations that come with the native picker mean that it’s hard to encapsulate the selection variable without some funny behavior. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/257bc3000865d35d0993d614c526a959/href">https://medium.com/media/257bc3000865d35d0993d614c526a959/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*EVvBoaFDeb8j3RnCU0U_RA.gif" /></figure><p>See that annoying flickering?</p><p>It’s also nearly impossible to customize the appearance of the picker, so to move beyond these constraints, I’ve decided to implement my own segmented control in SwiftUI.</p><h3>1. Overview</h3><p>So, here’s what we’re going to build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SgIvGftgChVg2ary-662MA.png" /></figure><p>We might be tempted to just do something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de7734211aae8af9e25a96f281cc690b/href">https://medium.com/media/de7734211aae8af9e25a96f281cc690b/href</a></iframe><p>This is essentially just adding a white RoundedRectangle background to the currently selected index. This works well for simple use cases but doesn&#39;t support nice sliding animations between selection transitions.</p><p>To make this more elegant, we have three basic elements of the segmented control:</p><ol><li>The rounded rectangle background view</li><li>The text for each item</li><li>The rounded rectangle that denotes the current selection</li></ol><h3>2. Creating the Container and Items</h3><p>Let’s define a simple view that just enumerates the items for the segmented control:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25178c73980d4663f3c254db3154cd8b/href">https://medium.com/media/25178c73980d4663f3c254db3154cd8b/href</a></iframe><p>This is quite a bit of code. Let’s go over it:</p><ol><li>I always strive to keep view constants like padding, font, and text color nice and organized. This allows me to adjust views without re-diving into the implementation of the view itself. These static constants allow me to easily see and edit minor view details.</li><li>Much like the inputs to the native SwiftUI Picker, we need some items to display and a @Binding selection property so that we can propagate state changes to the parent view.</li><li>The view itself is simple. It is an HStack that places equal-width items horizontally. For each item in items, we call a function to retrieve a Text view element.</li><li>The function getSegmentView returns a Text element with the item name for the specified index. We apply some view modifiers here and make sure to check that the index used is actually within the bounds of our array. Some notable points: We compute whether the current index is selected and use slightly darker text to denote the selection. We use .frame(minWidth: 0, maxWidth: .infinity) so that the tappable frame takes up all of the available space instead of wrapping the Text element.</li><li>We define an onItemTap method. This allows us to change the current selection when we tap on a text element.</li></ol><p>Here’s what we get. Not bad! We’re just missing the active element indicator, which is a simple white RoundedRectangle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*5czA1z9iGGc1yeIXuFHSPw.png" /></figure><h3>3. Active Selection Indicator</h3><p>The background for the selected element is a RoundedRectangle. To show this rectangle behind our available selections, we wrap our HStack in a ZStack as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f61cd5eeafed4af7867ea5b7f0859e9/href">https://medium.com/media/2f61cd5eeafed4af7867ea5b7f0859e9/href</a></iframe><p>We now see a rounded rectangle in the background, but we need to define the size of the rectangle and its relative position depending on the currently active selection.</p><p>To define the sizes and offset, we need to somehow get the size of each item. To do this in SwiftUI, we take advantage of PreferenceKey.</p><h4>3.1 PreferenceKey to get item width</h4><p><a href="https://swiftwithmajid.com/2020/01/15/the-magic-of-view-preferences-in-swiftui/">This blog post</a> goes over SwiftUI PreferenceKeys. In short, we can define a PreferenceKey to pass an attribute from a subview to its superview. In our case, we need to pass the size of each text item. Our HStack divides up each item into equal width, so we essentially just need the width of one segment view created in the ForEach loop.</p><p>Let’s define a PreferenceKey to retrieve the size. We can then use a neat little trick to get a view&#39;s intrinsic size by defining a GeometryReader on the background of the view. We then use a custom ViewModifier to encapsulate all of the operations needed to retrieve the view size and update a binding:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c859e47d50529875739d8499d747821/href">https://medium.com/media/6c859e47d50529875739d8499d747821/href</a></iframe><p>Going through the items:</p><ol><li>This is the PreferenceKey to retrieve the size. We define the type of the retrieved value as a CGSize, which contains width and height information.</li><li>We define a helper View (BackgroundGeometryReader) that will serve as the background of our text items. This uses the trick I mentioned earlier — defining a GeometryReader on the background gives us the intrinsic size of the view. Note that we attach the SizePreferenceKey and pass to it the view size.</li><li>We define SizeAwareViewModifier to encapsulate all of this logic. It takes as input a Binding for viewSize. This is so that updates in the size can be propagated up the view hierarchy. Note that we attach the background BackgroundGeometryReader, which attaches the SizePreferenceKey to the view. We then watch for changes in the values of the PreferenceKey by calling onPreferenceChange. The callback watches for updates in SizePreferenceKey values, then updates the binding accordingly.</li></ol><p>Great! Now we just attach the new ViewModifier:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01804435e80f81a1b1c2c87719f4b7e6/href">https://medium.com/media/01804435e80f81a1b1c2c87719f4b7e6/href</a></iframe><p>Now that we have access to the intrinsic size of one of the segments, we can build the active selection indicator properly.</p><h4>3.2 Using view size to create an active selection indicator</h4><p>As a recap, this is what our final product should look like. The active selection indicator is the white background that slides with the current selection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SgIvGftgChVg2ary-662MA.png" /></figure><p>We have two main challenges:</p><ol><li>Defining an appropriate size for the active selection indicator.</li><li>Determining the correct position for the indicator depending on the current selection.</li></ol><p>Before, we defined a simple RoundedRectangle in a ZStack as our active segment view. Let&#39;s do the following:</p><ol><li>Extract the view as a variable to keep things nice and clean.</li><li>Change the ZStack alignment to .leading. This means that all the views in the ZStack will be lined up to the leading edge of the frame (rather than the center). This makes calculating the active segment location a lot easier!</li><li>Define a method called computeActiveSegmentHorizontalOffset. This gives us the location of the active segment indicator.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8f442a1a3ddba73a1d8bbaa11b4e57b/href">https://medium.com/media/f8f442a1a3ddba73a1d8bbaa11b4e57b/href</a></iframe><p>The code should be relatively straightforward, with the exception of computeActiveSegmentHorizontalOffset(). In this method, we use the assumption that our ZStack is aligned to the leading edge (the left edge for most locales). We know the effective horizontal width of each item within our picker to be (self.segmentSize.width + SegmentedPicker.SegmentXPadding / 2). Thus, the value of the offset from the leading edge is just the index selection multiplied by this width.</p><p>And that’s it! We now see this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bHJLS85ySeR6zRg7aw-Mxg.gif" /></figure><p>To get the complete code, see this <a href="https://gist.github.com/frankfka/2784adff55be72a4f044d8c2bcc9fd3f">gist</a>. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=473b386d0b51" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/custom-ios-segmented-control-with-swiftui-473b386d0b51">Build a Custom iOS Segmented Control With SwiftUI</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To: Programmatically Change iOS Status Bar Color with SwiftUI]]></title>
            <link>https://medium.com/@frankjia/how-to-programmatically-change-ios-status-bar-color-with-swiftui-baf7d836aa79?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/baf7d836aa79</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Fri, 08 May 2020 16:41:15 GMT</pubDate>
            <atom:updated>2020-05-08T16:41:15.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C0FyDucabH6VJTB_.jpg" /><figcaption><a href="https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iOS/ios13-iphone-xs-setup-hello-select-country-region.jpg">Source</a>: Apple</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*TQNbybEdfnMAE36y.png" /><figcaption><a href="https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iOS/ios12-iphone7-status-bar-crop.png">Source</a>: Apple | We want to change the color of this status bar content</figcaption></figure><p>With UIKit, changing the color of the status bar content is as simple as:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9498edca49ec807e2b2587c152358704/href">https://medium.com/media/9498edca49ec807e2b2587c152358704/href</a></iframe><p>Unfortunately, it took quite a bit of searching (and some help from <a href="https://stackoverflow.com/questions/57063142/swiftui-status-bar-color">this StackOverflow question</a>) to find a suitable solution for SwiftUI. Let’s get started!</p><p>First, let’s understand how SwiftUI views are attached in SceneDelegate.swift:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fff6fc14dee31612eddb9c1e2fcba7a/href">https://medium.com/media/7fff6fc14dee31612eddb9c1e2fcba7a/href</a></iframe><p>We see that the root SwiftUI view, ContentView is attached to a single UIHostingController, which is the root view controller of the key window.</p><p>The key to programmatically changing the status bar color is to create our own implementation of UIHostingController:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77390a25745437b9a0fee57a5a8710d8/href">https://medium.com/media/77390a25745437b9a0fee57a5a8710d8/href</a></iframe><p>Now in SceneDelegate.swift, we can simply use ContentHostingController instead of UIHostingController. But how do we retrieve the ContentHostingController in a SwiftUI view, so that we can call changeStatusBarStyle?</p><p>In SceneDelegate, recall that we made ContentHostingController the rootViewController of our key window. We can then declare an extension on UIApplication to access these properties:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ade1d7250b41e396204a2ae39ceae6d/href">https://medium.com/media/2ade1d7250b41e396204a2ae39ceae6d/href</a></iframe><p>Nice! Now all we need to do in a view is something like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffc1e53dd55fc24d54b0675a43fa361f/href">https://medium.com/media/ffc1e53dd55fc24d54b0675a43fa361f/href</a></iframe><p>And that’s it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baf7d836aa79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Activity Rings in SwiftUI]]></title>
            <link>https://medium.com/@frankjia/creating-activity-rings-in-swiftui-11ef7d336676?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/11ef7d336676</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Thu, 30 Apr 2020 02:44:35 GMT</pubDate>
            <atom:updated>2020-04-30T02:44:35.033Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksqI6DkkOJVTqIg7h08_UQ.png" /><figcaption>Source: <a href="https://www.apple.com/">https://www.apple.com</a></figcaption></figure><p><strong>TLDR: All the code shown here is available in this </strong><a href="https://gist.github.com/frankfka/2517d69da68ef041e3257d5cfd27fe5d"><strong>Playground gist</strong></a></p><p>For one of my latest iOS projects, I decided to go with the new SwiftUI framework for building declarative views. I’ve found that prototyping views are so much faster with the live editor and intuitive structure of the framework. That being said, support for SwiftUI is still nascent. I had to build something resembling the activity rings on Apple Watch, but couldn’t find a suitable solution. I managed to piece together a few tutorials to make a suitable solution.</p><p>I needed an activity ring that showed a certain percentage value. For example, if the percent value was 80%, then 80% of the ring would be filled. I needed a solution that:</p><ul><li>Supported percentages over 100%</li><li>Supported a gradient of colors</li><li>Supported different ring widths, colors, and backgrounds</li></ul><p>This is available with UIKit using <a href="https://github.com/maxkonovalov/MKRingProgressView">MKRingProgressView</a>, but nothing was built purely in SwiftUI. Let’s get started!</p><h3>1 Creating a Custom Shape</h3><p>A few tutorials use overlapped circles, but I think a more elegant solution is to define a custom Shape in SwiftUI. I adapted code from <a href="https://liquidcoder.com/swiftui-ring-animation/">this tutorial</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd48ffaff6f43427c4cd84e65bc2e674/href">https://medium.com/media/fd48ffaff6f43427c4cd84e65bc2e674/href</a></iframe><p>A few things to note here:</p><ol><li>I declared a helper function, percentToAngle which converts percentage values to angles in degrees. This supports percentages over 100 as we will just have degrees larger than 360</li><li>animatableData is what SwiftUI uses to ensure smooth animation transitions between different values. This essentially tells SwiftUI that percent determines changes in the shape</li><li>The path function tells SwiftUI how to draw the shape. In our case, it is a simple arc from the startAngle to the endAngle. The radius of the arc is the minimum dimension of the bounding box</li></ol><p>We can now get a nice little preview of our new shape:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/896f81e51129c1cd977c4cc1459b2951/href">https://medium.com/media/896f81e51129c1cd977c4cc1459b2951/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*URb36JbqehxSphbpEhCFXQ.png" /></figure><h3>2 Building a Simple Activity Ring</h3><p>We can use our shape with a ZStack to create a simple activity ring. In the body property, we can declare:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e97c0db8dc1e05ba2dd8c93a1e06910d/href">https://medium.com/media/e97c0db8dc1e05ba2dd8c93a1e06910d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*svpr4nq-TSvVySb_tnrf4Q.png" /></figure><p>Let’s go through this view:</p><ol><li>We use a GeometryReader because we need to access the size of the parent view — we’ll need the size very soon!</li><li>We have 2 RingShape shapes in a ZStack. The first is the background, which in our case is a lighter green color that covers the entire arc.</li><li>The next is the foreground ring, which signifies the percentage value, we use .stroke(style: StrokeStyle(lineWidth: self.ringWidth, lineCap: .round)) to give the arc rounded ends, similar to the iOS activty rings</li><li>As we are stroking the shapes with a certain radius, the view will “overflow” the bounding box by half the stroke width. To make sure that the entire ring fits within the view size allocated, we give it padding of half the ring width</li></ol><p>This looks good! If you have simpler needs, this is probably a good enough solution. But we see an immediate problem when we have percent values over 100%:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*rD_LQXRvRM-UTXEafZge8w.png" /></figure><p>We can’t see where the arc ends!</p><h3>3 Adding a Shadow</h3><p>To signify the current progress for percentages over 100%, we can add a drop shadow:</p><p>We put this shadow at the very top of our ZStack, so that it shows above the ring shapes. To create this effect, we do something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c4faa0e2840afc89c4663c8a2e22d21/href">https://medium.com/media/4c4faa0e2840afc89c4663c8a2e22d21/href</a></iframe><p>We are essentially creating a filled-in circle at the end of the arc.</p><ol><li>The size of the circle should be the same as the arc, so that it blends in with the stroked foreground</li><li>offset positions the view in the proper location</li><li>shadow gives the circle a drop shadow - creating the effect that we want. We specify x and y values to offset the drop shadow for the desired effect as shown above</li></ol><p>To help with our calculations, we’ll declare the following extension on Double:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28a3def1aa0825e2f217931a83d72ec3/href">https://medium.com/media/28a3def1aa0825e2f217931a83d72ec3/href</a></iframe><p><strong>3.1 Calculating Circle Location</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21b01c0b2c1637a8ec4c65d2b4c4f1ce/href">https://medium.com/media/21b01c0b2c1637a8ec4c65d2b4c4f1ce/href</a></iframe><p>The offset is calculated from the middle of the view. We need the size of the parent bounding box. We then use the ending angle with the radius of the arc to calculate the x and y location of the end of the arc.</p><p><strong>3.2 Calculating Shadow Position</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccb0206eccbd828d7a9c29977da7b91f/href">https://medium.com/media/ccb0206eccbd828d7a9c29977da7b91f/href</a></iframe><p>This one took a bit of mathematical derivation which is outside the scope of the article. I’d be happy to go over this with anyone interested though (feel free to contact me through my <a href="http://jiafrank.com/">website</a>). A quick gist of what’s going on:</p><ul><li>We get a standardized angle to calculate the relative position of the shadow with regards to the end of the arc</li><li>We get the X and Y offsets, then multiply it by a constant multiplier. We do this because sinusoidal functions are rangebound between -1 and 1, which doesn’t give us the magnitude of offset that we need</li></ul><p>So finally, this is our circle view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7537173f4a8dedd96a427f04b62b914c/href">https://medium.com/media/7537173f4a8dedd96a427f04b62b914c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*1-EBmTBte26ShKyLfpTAbA.png" /></figure><h3>4 Adding a Gradient</h3><p>Let’s first declare some helper variables:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12c3cf2d346365c4904567dee2ddc7b2/href">https://medium.com/media/12c3cf2d346365c4904567dee2ddc7b2/href</a></iframe><p>We can then use ringGradient in our foreground view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9df51a864880b692c5e28723459ac858/href">https://medium.com/media/9df51a864880b692c5e28723459ac858/href</a></iframe><p>Now, instead of using a single foregroundColor, we pass an array of colors that signify the range of colors for the computed gradient. We use an angular gradient to vary colors over different degrees. Heres a <a href="https://sarunw.com/posts/gradient-in-swiftui/">great read</a> on gradient in SwiftUI</p><ol><li>To support percentages over 100%, we start the gradient at the startAngle if our activity ring is <strong>not filled (i.e. percentage is less than 100%)</strong>. If the activity ring <strong>is filled</strong>, then we space out the gradient over the last 360 degrees.</li><li>As mentioned, we use AngularGradient, centered at the center of the ring</li></ol><p>I also decided to hide the shadow for percentages where the ring does not overlap with itself, using the following function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d3b6aed18fafe28312abb6d05a1c955/href">https://medium.com/media/2d3b6aed18fafe28312abb6d05a1c955/href</a></iframe><p>The above code calculates the unfilled arc length, and compares it to the width of the arc to determine whether the ring has overlapped with itself. Percentage values over 100 obviously lead to overlapped arcs, so we return true immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*NLLawAGBZdN0cOebaSPL-g.png" /></figure><p>This looks great! One limitation is that gradients look a bit weird for small percentages. To fix this, we might opt to instead show the gradient over the entire 360 degrees, instead of over the active arc length. However, as I’m going with a color scheme similar to that of the iOS activity rings (slight gradient from dark to light, of the same color), this doesn’t really bother me.</p><p>And that’s it! Again, the code in this tutorial is available in a Playground file <a href="https://gist.github.com/frankfka/2517d69da68ef041e3257d5cfd27fe5d">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11ef7d336676" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Mobile App Development: From Clueless to a Profession]]></title>
            <link>https://medium.com/@frankjia/learning-mobile-app-development-from-clueless-to-a-profession-880083810a5f?source=rss-a777d7e94e27------2</link>
            <guid isPermaLink="false">https://medium.com/p/880083810a5f</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Frank Jia]]></dc:creator>
            <pubDate>Mon, 08 Jul 2019 20:36:21 GMT</pubDate>
            <atom:updated>2019-07-08T20:36:21.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Uktsjyw9atE0Tobi" /><figcaption>Photo by <a href="https://unsplash.com/@maxcodes?utm_source=medium&amp;utm_medium=referral">Max Nelson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I had no idea how to develop mobile apps, but I was intent on learning. Six months later, I was tasked to help build a mobile client for one of <a href="https://www.concur.ca/">SAP Concur</a>’s core services.</p><p>As an Engineering Physics major at the University of British Columbia, I have the opportunity to indulge in a diversity of courses across multiple disciplines. But diversity comes at the risk of foregoing specialization — I have had few opportunities to learn software development in an academic setting.</p><p>But nevertheless, I had a strong interest in the field of software development. Having developed knowledge in backend technologies during a previous internship, I wanted to focus more on front-end development, especially for mobile. Although I wasn’t completely new to coding, the challenge of learning new workflows and development languages was still extremely intimidating.</p><p><strong>I began my education with an online development bootcamp.</strong></p><p>When learning anything new, I believe it’s best to be guided by a professional. This not only saves time during the learning process but also helps to reduce the anxiety of learning an entirely new framework. Following this methodology, I enrolled in an iOS Development Bootcamp on Udemy. Specifically, <a href="https://www.udemy.com/ios-12-app-development-bootcamp/">this course</a> taught by Angela Yu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LENSxOGwFsaoYgpUIpSbxw.png" /><figcaption>Be sure to look for the latest release!</figcaption></figure><p>I found the step-by-step guidance to be extremely helpful as a complete novice to iOS app development. Through this course, I was able to learn and practice the fundamentals of Swift as well as the numerous iOS app development conventions and workflows. It’s <strong>extremely </strong>important and helpful to be constantly curious! The course provided a framework for learning app development, but conducting little experiments while you follow along is a great way to learn the intricacies of the language.</p><p><strong>Knowing the basics of iOS development, I found it much easier to self-learn Android dev.</strong></p><p>I didn’t have a huge desire to pay for an Android bootcamp. Many principles translate over to Kotlin/Java for Android. There are also numerous free resources that helped guide me along in the learning process, such as Stack Overflow and the Android developer’s website. The inverse is probably also true — learning iOS development shouldn’t be too hard if you understand how to write software for Android. I’d recommend picking the platform that you already use. I have an iPhone, so it was natural for me to learn iOS development first.</p><p><strong>When you’re comfortable with the basics, start experimenting and create apps that you would use yourself.</strong></p><p>Building towards a vision is a great way to be motivated to try new things and explore new frameworks. I found that by building apps that I would want to use myself, I was extremely motivated to continue experimenting with mobile development, even after long days at school.</p><p>For example, I’m a stickler for healthy eating, so I built <a href="https://apps.apple.com/us/app/betterplate-healthy-eating/id1447765100">Betterplate</a>, which allowed me to find and choose the healthiest dining options when eating out. I also needed an easy way to track my spending and digitize my receipts, so I built <a href="https://apps.apple.com/us/app/keepreceipt-receipt-tracker/id1449402433">KeepReceipt</a>. Having pet projects was a great way for me to explore not only native mobile development frameworks, but also to understand cloud technologies such as Google Firebase. I’ve continued to learn and cement my software development knowledge with projects that are both educational and useful within my daily life.</p><p><strong>And remember, learning continues when you’re on the job!</strong></p><p>I’m excited to have joined SAP iXP (internship experience program) as a software developer. I was initially assigned mobile work, which I found to be painless to onboard onto because of my self-taught knowledge in mobile development.</p><p>That being said, there were numerous new concepts and frameworks that came as part of the job, such as interacting with <a href="https://graphql.org/">GraphQL</a> to retrieve data, using <a href="https://github.com/ReSwift/ReSwift">Redux</a> for application state management, and <a href="http://reactivex.io/">ReactiveX</a> to implement the observer pattern.</p><p>I took it upon myself to understand and learn to implement these development patterns. The best way to do so is by example — I began incorporating these practices into my own projects.</p><p>If there’s one thing you take away from this, it’s that <strong>learning by doing is the most effective and efficient way to pick up any new skill.</strong></p><p>So if you’re looking to learn mobile development, begin a course, set up your machine, and code away!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=880083810a5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>