<?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"><channel><title><![CDATA[Saurabh's Blog]]></title><description><![CDATA[Saurabh's Blog]]></description><link>https://saurabhjamadagni.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 20:05:17 GMT</lastBuildDate><atom:link href="https://saurabhjamadagni.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[GSoC '23 Final Work Submission]]></title><description><![CDATA[What an experience!]]></description><link>https://saurabhjamadagni.hashnode.dev/gsoc-23-final-work-submission</link><guid isPermaLink="true">https://saurabhjamadagni.hashnode.dev/gsoc-23-final-work-submission</guid><category><![CDATA[gsoc2023]]></category><category><![CDATA[iOS]]></category><category><![CDATA[wikimedia]]></category><dc:creator><![CDATA[Saurabh Jamadagni]]></dc:creator><pubDate>Sun, 27 Aug 2023 17:45:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1693119316750/ad499679-5b15-4259-afed-d51e1e219079.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-goals-and-deliverables-for-gsoc">Goals and deliverables for GSoC</h2>
<p>My GSoC project was multi-faceted, consisting of two distinct components that aimed to enhance the Scribe iOS app. This two-fold project encompassed:</p>
<p><strong>1. App Menu Revamp:</strong> The first part of the project involved a comprehensive revamp of the Scribe iOS app's menu system. This task required the creation of a new app menu that incorporated several key features and sections. One of the primary objectives was to implement a tab bar that allowed users to seamlessly switch between different screens and sections of the app.</p>
<p>In addition to the tab bar, I had to integrate user-friendly features that allowed users to customize their keyboard experience. This included the ability to save specific preferences and tailor the keyboard to their unique needs and preferences. I also had to add new screens dedicated to essential documentation, such as privacy policy, licenses, and detailed information about how Scribe and Wikidata collaboratively functioned together. This comprehensive revamp aimed to enhance the user experience, making Scribe more accessible and informative for its users.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693059792023/aefef6bd-ee78-4bbd-8156-83c44ee9ceb9.png?height=500" alt class="image--center mx-auto" /></p>
<blockquote>
<p>Img: Menu app before GSoC</p>
</blockquote>
<p><strong>2. Expanding Language Support:</strong> The second part of the project was dedicated to expanding the language support within the Scribe app. Scribe relies on Wikidata to source data for its language offerings. To achieve this expansion, critical tasks include writing scripts to fetch the necessary data using SPARQL queries and Python.</p>
<p>Once the data is retrieved, it requires careful formatting to ensure compatibility with the iOS app. This data is then loaded into SQLite files, optimizing it for efficient use within the app. Beyond data processing, creating the essential layouts and structures was required for the new keyboards to function seamlessly.</p>
<p>The planned languages for this expansion encompassed English and either Danish or Norwegian.</p>
<p>These deliverables collectively aimed to not only improve the Scribe iOS app's functionality but also enhance its user-friendliness and accessibility while expanding its language offerings.</p>
<h2 id="heading-brief-about-my-work-on-the-project">Brief about my work on the project</h2>
<p>My GSoC journey commenced with a deep dive into the enhancement of the Scribe iOS app's user interface (UI), specifically focusing on the menu part. Given my prior experience with iOS development, I hit the ground running, and the initial pace was promising.</p>
<p>One of the most exciting aspects of this project was the opportunity to immerse myself in UIKit, especially since I had been predominantly using SwiftUI. This transition brought forth numerous new insights and findings about UIKit. However, it wasn't all smooth sailing. Scrollviews presented quite a challenge. Implementing auto layout for ScrollViews required some problem-solving, which I tackled by referring to various articles and video tutorials. I published a blog post sharing how I solved this problem. You can find it <a target="_blank" href="https://saurabhjamadagni.hashnode.dev/nested-uitableviews-apples-built-in-viewcontrollers">here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1693129793897/a4561ec3-c2ee-4988-98a2-f83c2bf74d86.png" alt="Storyboard diagram of the Scribe app" class="image--center mx-auto" /></p>
<blockquote>
<p>Img: Storyboard diagram for the Scribe app post work.</p>
</blockquote>
<p>A significant component of this endeavour was creating a user-friendly experience. To achieve this, I established app groups that were common across the different app targets, allowing us to save user preferences for every language seamlessly using <code>UserDefaults</code>. I also was able to put in extensive practice with UITableViews and the art of customizing cells. In fact, this experience led me to explore the concept of <em>nested table views</em>, a useful technique to manage common components across various screens while ensuring reusability.</p>
<p>Recognizing the importance of reusability, especially since many components were shared across screens, I diligently designed and implemented solutions to maximize efficiency. Additionally, I leveraged <a target="_blank" href="https://github.com/marcosgriselli/SwipeableTabBarController">SwipeableTabBarController</a>, an external package to introduce a swiping functionality that enabled users to switch tabs, going beyond the standard behaviour of a <code>UITabBarController</code>. This package significantly improved the overall user experience.</p>
<p>In the process of enhancing the Scribe menu, I faced the challenge of distinguishing Scribe keyboards from system keyboards to be able to list them in the menu to set preferences. This ended up requiring some deep exploration and experimentation. Refreshing the list of installed keyboards also proved tricky, and I had to devise a somewhat hacky solution which is definitely open to improvement. Will be working on it in the coming time. This linked <a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/340">PR</a> directs to the changes for loading the installed keyboards.</p>
<p>My work on the menu app closely followed the designs outlined in the <a target="_blank" href="https://www.figma.com/file/c8945w2iyoPYVhsqW7vRn6/scribe_public_designs?type=design&amp;node-id=405-464&amp;mode=design&amp;t=Mmli4gbrQoj4DODJ-0">Scribe design files</a> available on Figma, providing me with valuable hands-on experience in translating design concepts into functional UI elements. However, I initially faced a challenge in compartmentalizing issues in Git, as it often felt like many tasks overlapped. Nevertheless, I eventually found my stride, allowing me to work efficiently and effectively.</p>
<p>It was exciting to be able to enhance the UI of a vital tool while gaining valuable experience in navigating the intricacies of UIKit. Below is a quick screen capture of my complete work on the Scribe app menu.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtube.com/shorts/wezbUiD3vJQ">https://youtube.com/shorts/wezbUiD3vJQ</a></div>
<p> </p>
<p>In addition to my work on the Scribe iOS app's user interface, a portion of my GSoC journey was dedicated to the <a target="_blank" href="https://github.com/scribe-org/Scribe-Data">Scribe-Data</a> repository. This repository is pivotal in sourcing and managing the data that fuels the app's language support. Here's a closer look at my contributions:</p>
<p><strong>1. Streamlining Data Processing:</strong> The Scribe-data repository is divided into two primary directories: <a target="_blank" href="https://github.com/scribe-org/Scribe-Data/tree/main/src/scribe_data/extract_transform"><code>extract_transform</code></a> and <a target="_blank" href="https://github.com/scribe-org/Scribe-Data/tree/main/src/scribe_data/load"><code>load</code></a>. These directories play a crucial role in the data pipeline. "extract_transform" is responsible for bringing in data through SPARQL queries and then meticulously formatting it to align with Scribe's specific requirements. This step ensures that the data is prepared and structured in a way that the Scribe app can efficiently utilize. The "load" directory, on the other hand, is responsible for loading these formatted data, stored as JSON files, into an SQLite database. This database is the optimal choice for the Scribe app as it provides faster and more efficient data retrieval compared to working directly with JSON files.</p>
<p><strong>2. Refining English Language Data:</strong> My work extended to the English language data, where I focused on formatting files written in Python. At the time, the English data primarily consisted of nouns and verbs. While there were existing SPARQL query files crafted by my mentor, they required updates and refinements. To ensure that the English language data met the evolving needs of Scribe, my mentor and I engaged in detailed discussions during our weekly meetings. These discussions led to valuable refinements in the SPARQL queries which were implemented by my mentor, enhancing the data quality for the app.</p>
<p><strong>3. Open-Sourcing Layout Changes:</strong> As part of the collaborative spirit of open-source projects, the layout changes made during my GSoC tenure were open-sourced. This decision not only encouraged transparency but also extended a warm welcome to new contributors interested in improving Scribe's functionality. I'm particularly grateful for the contributions made by fellow developers who took charge of iPad layouts, ensuring that Scribe's interface was optimized for various devices.</p>
<p>It was a rewarding experience to not only work on the technical aspects but also to see the project grow through the involvement of new contributors. This journey was not only a chance to explore and expand my skills in iOS development but also a testament to the collaborative spirit that drives open-source projects like Scribe.</p>
<p>Following redirects to all my pull requests for:</p>
<ul>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pulls?q=is%3Apr+label%3AGSoC">Scribe-iOS</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-Data/pulls?q=+is%3Apr+label%3AGSoC+">Scribe-Data</a></p>
</li>
</ul>
<p>OR you can find the individual pull requests below categorised by my GSoC task.</p>
<h3 id="heading-pull-requests-for-the-scribe-app-menu"><strong>Pull requests for the Scribe app menu:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/324">#324 Adding a static menu and necessary components</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/328">#328 Adding social links and redirects to About section content</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/331">#331 Privacy policy text in About section</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/335">#335 Adding Licenses and Wikimedia &amp; Scribe screens</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/338">#338 Design fixes discussed in scribe weekly 3/7/23</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/340">#340 Adding a Comma and Period option to the settings menu</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/345">#345 Emoji autosuggest menu</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/347">#347 feat: saving user preference on emoji autosuggest based on menu</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/349">#349 Swiping between tabs using SwipeableTabBarController</a></p>
</li>
</ul>
<h3 id="heading-pull-requests-for-language-data-work"><strong>Pull requests for language data work:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-Data/pull/42">#42 Formatting script for English nouns</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-Data/pull/43">#43 Formatting script for English verbs along with formatted data</a></p>
</li>
</ul>
<h3 id="heading-misc"><strong>misc:</strong></h3>
<ul>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/333">#333 Adding reference to blog post 1 in README</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-iOS/pull/357">#357 Automatically add new issues to Scribe-Board - Scribe-iOS repo</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/scribe-org/Scribe-Data/pull/41">#41 Automatically add new issues to Scribe-Board - Scribe-Data repo</a></p>
</li>
</ul>
<h2 id="heading-addressing-failures">Addressing failures</h2>
<p>One of the primary areas where I fell short during my GSoC journey was the implementation of the Norwegian language into the Scribe app as part of my project. Although I had the task of contributing to the data processes for English, which we accomplished to gain valuable experience with Wikidata, I couldn't deliver the Norwegian language within the GSoC program timeline. It's a regrettable missed opportunity, and I wish I had managed my priorities differently to reach this milestone sooner. However, I remain committed to this task and intend to follow through with it, even if it may no longer count toward my official GSoC work.</p>
<p>Additionally, I also faced challenges with my commitment to bi-weekly blogging. Despite my initial determination and the organization's expectation, I struggled to meet this target as the GSoC journey progressed. The demands of a new internship, combined with the responsibilities of my GSoC project, proved to be more challenging than anticipated. Each time I opened my drafts, it felt like there were more pressing issues requiring my attention. Documenting the process and sharing my insights soon slipped down my list of priorities, and blogging became a seemingly low-priority task that could be deferred. Now, at the end of my GSoC journey, I find myself regretting not having a detailed record of the thoughts and experiences that shaped this remarkable adventure. However, I'm determined to make amends. I plan to document and share what I can recall from memory, in the hope of capturing at least some of the journey's essence.</p>
<p>These lessons in managing time and priorities have been valuable, and I'm determined to learn from these experiences to grow as a developer and contributor.</p>
<h2 id="heading-community-experience">Community experience</h2>
<p>Beyond the technical challenges and personal growth, my GSoC journey was significantly enriched by the vibrant and welcoming Wikimedia community. Wikimedia, with its vast ecosystem of projects, boasts a beautiful community that I am truly grateful to be a part of. While Scribe may be considered a smaller project compared to the grandeur of Wikimedia as a whole, it was a privilege to collaborate with other contributors under the Wikimedia Foundation umbrella.</p>
<p>What began as a project endorsed by Wikidata and Wikimedia evolved into a full-fledged Wikimedia project, enabling me to work alongside Wikimedia contributors and organization administrators. During one of our contributor meet-ups, I discovered that everyone was involved in some truly remarkable initiatives. It was exhilarating to learn about the diverse projects and hear the inspiring stories of fellow contributors.</p>
<p>Moreover, my bond with my mentor and unofficial co-mentor grew stronger over time. I am immensely grateful for the guidance, support, and friendship they offered throughout this journey. This sense of community, where knowledge-sharing and collaboration thrive, has been an invaluable aspect of my GSoC experience.</p>
<h2 id="heading-my-learnings">My learnings</h2>
<p>My journey in Google Summer of Code (GSoC) was a profound learning experience, filled with both technical and personal growth. As I delved into coding, I discovered that there's always something new to learn, even in a tech stack I thought I knew inside out. I honed my skills in UIKit, exploring fresh approaches and techniques with each coding session. Debugging took on a new dimension as I adapted to having to cater to multiple targets in a single application, enriching my knowledge of efficient debugging practices. Implementing features became an exercise in creativity, as I scoured multiple references and resources to brainstorm innovative methods. Git, too, became a trusted ally in managing code versions effectively.</p>
<p>Beyond the technical aspects, GSoC taught me valuable lessons in time management. Juggling a full-time internship alongside GSoC was no small feat. The first month, spent as vacation, was a luxury. However, once the internship began, I found myself working on the project during late nights and weekends. It was a rollercoaster ride; there were days when exhaustion crept in, hindering progress, and a looming sense of burnout threatened to take hold. Thankfully, my mentor provided unwavering support during these challenging times. They helped me navigate the chaos and strike a balance, granting me the time and space to find my way through.</p>
<p>One of the unique aspects of this GSoC project was the opportunity to delve into Wikidata, guided by a mentor who was an employee in the field and had incredible experience working with Wikidata. This opened the door to a whole new world, as I gained insights into working with Wikidata and delved deep into SPARQL. Given the time constraints due to the prolonged UI development phase, learning SPARQL quickly became a necessity. My mentors, both primary and co-mentors, played a pivotal role in helping me transition to a different repository, providing guidance and support every step of the way. The sheer magnitude of data in Wikidata was awe-inspiring, making this journey an enriching experience in working with extensive datasets. In essence, GSoC was not just about code; it was a transformative adventure in knowledge, time management, and mentorship.</p>
<p>Amidst the GSoC adventure, I had the opportunity to witness and contribute to discussions about Continuous Integration and Continuous Deployment (CI/CD) workflows and the world of software testing. While I didn't personally set them up, I was part of the team that oversaw their implementation using GitHub Actions. These workflows brought automation and precision to our development process, making everything run smoother. While formal testing is still on the horizon for Scribe, we've already seen its benefits in Scribe-Data. This journey has been a great learning experience in the world of software engineering, showing me the importance of testing and efficient development practices. It's just one more aspect of my GSoC journey that's broadening my skills and helping me become a better developer.</p>
<h2 id="heading-future-plans">Future plans</h2>
<p>My involvement with Scribe didn't start with GSoC, and it definitely won't end there. I've been part of Scribe's journey even before GSoC, and I'm committed to continuing my contributions.</p>
<p>GSoC has been a real eye-opener. It showed me the vastness of the open-source community and how many exciting projects are out there, each with its own set of challenges and opportunities. This experience has ignited a desire to explore and participate in more open-source communities.</p>
<p>Additionally, GSoC has helped me see where I can improve technically, and I'm eager to dive into this journey of continuous growth. As I look ahead, I'm excited about the new adventures and contributions that lie ahead, whether it's in my ongoing work with Scribe or in my exploration of other open-source projects.</p>
<h2 id="heading-get-in-touch">Get in touch</h2>
<p>Thank you for taking the time to read my post and share in my journey. If you'd like to connect or collaborate on a project, whether it's related to development or just to say hi, feel free to reach out to me:</p>
<ul>
<li><p><strong>LinkedIn:</strong> <a target="_blank" href="https://www.linkedin.com/in/saurabh-jamadagni/">Saurabh Jamadagni</a></p>
</li>
<li><p><strong>Twitter/X:</strong> <a target="_blank" href="https://twitter.com/Saura6hJ">Saura6hJ</a></p>
</li>
<li><p><strong>GitHub:</strong> <a target="_blank" href="https://github.com/SaurabhJamadagni">SaurabhJamadagni</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Nested UITableViews & Apple's built-in ViewControllers]]></title><description><![CDATA[Documenting GSoC '23: Chapter 1]]></description><link>https://saurabhjamadagni.hashnode.dev/nested-uitableviews-apples-built-in-viewcontrollers</link><guid isPermaLink="true">https://saurabhjamadagni.hashnode.dev/nested-uitableviews-apples-built-in-viewcontrollers</guid><category><![CDATA[iOS]]></category><category><![CDATA[gsoc2023]]></category><category><![CDATA[wikimedia]]></category><dc:creator><![CDATA[Saurabh Jamadagni]]></dc:creator><pubDate>Wed, 21 Jun 2023 13:29:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687343086837/eef2fa01-e95a-465d-b9c6-190a8a6da96f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-initial-approach">Initial approach</h3>
<p>The menu is essentially a set of tables with cells that take you to the respective sections. On a particular screen of the menu app, there are sub-sections we must look into. For example, on the About screen, Scribe has sections such as Community, Feedback and Support and Legal. My initial idea was to have a label along with an UITableView for each section. This presented the following problems:</p>
<ul>
<li><p>Too many IBOutlet variables.</p>
</li>
<li><p>ScrollView constraint complexities.</p>
</li>
<li><p>Not a friendly addition process in case new sections or menu options were to be added in the future.</p>
</li>
</ul>
<h3 id="heading-my-struggle-with-scrollview-auto-layout">My struggle with ScrollView auto layout</h3>
<p>Turns out, I am not good at figuring out how to assign constraints to a scroll view without Xcode screaming at me. To break down the constraints we need to first understand the difference between alignment constraints and content constraints.</p>
<p>Consider an image view. We can assume that the content of the image view has a fixed size. There won't be a case where the image is smaller or, worse, larger than its container. In both scenarios, the image will be distorted in some way. This is where we specify 'scale to fit' or 'scale to fill.' The frame of the image view represents the content that we see.</p>
<p>For a ScrollView, that may not be the case. This is the primary reason we use a scroll view in the first place: our content is larger than the screen. Therefore, we need at least one dynamic constraint on the content (usually in the scrolling direction). For example, in a vertical scroll, we need the height to be dynamic.</p>
<p>What we assign to the ScrollView is a constraint on the ScrollView itself, not on the content. I understand that this can be confusing, but please bear with me. The constraints applied to the ScrollView determine the scrollable area of the screen. We then add a container view to hold the ScrollView's frame together. Inside this container, we place our actual content and add constraints with respect to the container, not the scroll view.</p>
<p>With the individual UITableView approach, this implies having individual constraints for each of these table views as well.</p>
<p>Here are a few articles that can help understand this further. If there's anything you can take away from my rant, content should not be constrained with respect to the ScrollView but with the container it sits in.</p>
<p><strong>Article link</strong>: <a target="_blank" href="https://tingyishih.medium.com/ios-scrollview-constraints-8d8140d329a0">https://tingyishih.medium.com/ios-scrollview-constraints-8d8140d329a0</a></p>
<ol>
<li><p><strong>Content View</strong> refers to <em>“the actual full content”</em>, while <strong>Scroll View</strong> refers to <em>“the outer frame”</em>, i.e., the visible part of the content.</p>
</li>
<li><p>Alignment constraints between Scroll View and Content View define “<em>the scrollable range of the content”</em>, which have nothing to do with the actual size of Content View.</p>
</li>
<li><p>Don’t simultaneously assign Content View the constraints to its size and its alignment.</p>
</li>
</ol>
<p>Another article from FreeCodeCamp that helped is <a target="_blank" href="https://www.freecodecamp.org/news/how-to-use-auto-layout-with-uiscrollview-for-ios-b94b8687a4cc/">hyperlinked</a> here.</p>
<h3 id="heading-nested-table-approach">Nested table approach</h3>
<p>If you look at the design files for the menu closely, we can see a repeating structure. It is a heading followed by its section content as table cells. We can identify a nested table structure where the parent table has a clear background. The data can be modeled as an array of sections, where each section has an array of row elements corresponding to it inside.</p>
<pre><code class="lang-swift"><span class="hljs-comment">// Parent Model</span>
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ParentTableCellModel</span> </span>{
  <span class="hljs-keyword">let</span> headingTitle: <span class="hljs-type">String</span>
  <span class="hljs-keyword">let</span> section: [<span class="hljs-type">Section</span>]
}

<span class="hljs-comment">// Model for each top-level section</span>
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Section</span> </span>{
  <span class="hljs-keyword">let</span> sectionTitle: <span class="hljs-type">String</span>
  <span class="hljs-keyword">let</span> imageString: <span class="hljs-type">String</span>
  <span class="hljs-keyword">let</span> hasToggle: <span class="hljs-type">Bool</span>
  <span class="hljs-keyword">let</span> sectionState: <span class="hljs-type">SectionState</span>
}
</code></pre>
<p>We can then prototype the parent cell to have a label inside it that takes the section heading and add a child table inside it. Here's a screenshot of the <code>.xib</code> file:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686915906540/a9de4e4d-f0f5-4b2e-a504-951739c85018.png" alt class="image--center mx-auto" /></p>
<p>Each table row cell can then be prototyped to have its icon and label along with a chevron or toggle based on if the section allows for a toggle.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686915986987/6a033226-009d-4032-9817-90c3ef73e9b6.png" alt class="image--center mx-auto" /></p>
<p>This in a way allows us to run a sort of loop over data that automatically creates the required labels and child tables. We can thus avoid having to create separate <code>IBOutlets</code> for each label and child table. Also, adding new sections becomes easier.</p>
<p>Here's a step-wise breakdown to implement this approach:</p>
<ol>
<li><p>Add a UITableView to your main app screen. Add constraints so it occupies the entire screen.</p>
</li>
<li><p>Consider this the parent table view. The cells of this table view will deque to return a cell with the structure of a parent cell seen above. As separate <code>.xib</code> files are involved you will have to register the nib for the table view first.</p>
</li>
<li><p>Implement <code>UITableViewDataSource</code> delegate methods for the parent table in the main view controller file. The row count is returned using the number of ParentTableCellModel instances in the data.</p>
</li>
<li><p>The dequeued cell should configure the inner table view. Assign the cell data while dequeuing.</p>
</li>
<li><p>The ParentTableViewCell file hosts the IBOutlet variables to the parent cell label and child table.</p>
</li>
<li><p>This class itself becomes the data source and delegate for the inner table.</p>
</li>
<li><p>Implement <code>UITableViewDataSource</code> delegate methods for the child table in the ParentTableViewCell file. The row count is returned using the number of elements in the sections array from the aforementioned ParentTableCellModel.</p>
</li>
<li><p>Each child cell when dequeued is configured to show its corresponding data.</p>
</li>
<li><p>You can add additional views inside the parent cell structure to stylize according to your needs. Refrain from assigning fixed heights to views for vertical scrolling table views as the cells should be able to resize.</p>
</li>
</ol>
<p>Thus for the following data:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">static</span> <span class="hljs-keyword">var</span> aboutTableData = [
    <span class="hljs-type">ParentTableCellModel</span>(
      headingTitle: <span class="hljs-string">"Community"</span>,
      section: [
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"See the code on GitHub"</span>, imageString: <span class="hljs-string">"github"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .github),
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Chat with the team on Matrix"</span>, imageString: <span class="hljs-string">"matrix"</span>, hasToggle: <span class="hljs-literal">false</span>,  sectionState: .matrix),
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Wikimedia and Scribe"</span>, imageString: <span class="hljs-string">"wikimedia"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .wikimedia),
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Share Scribe"</span>, imageString: <span class="hljs-string">"square.and.arrow.up"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .shareScribe)
      ]
    ),
    <span class="hljs-type">ParentTableCellModel</span>(
      headingTitle: <span class="hljs-string">"Feedback and support"</span>,
      section: [
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Rate Scribe"</span>, imageString: <span class="hljs-string">"star"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .rateScribe),
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Report a bug"</span>, imageString: <span class="hljs-string">"ant"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .bugReport),
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Send us an email"</span>, imageString: <span class="hljs-string">"envelope"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .email),
        ]
    ),
    <span class="hljs-type">ParentTableCellModel</span>(
      headingTitle: <span class="hljs-string">"Legal"</span>,
      section: [
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Privacy policy"</span>, imageString: <span class="hljs-string">"lock.shield"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .privacyPolicy),
        <span class="hljs-type">Section</span>(sectionTitle: <span class="hljs-string">"Third-party licenses"</span>, imageString: <span class="hljs-string">"thirdPartyLicenses"</span>, hasToggle: <span class="hljs-literal">false</span>, sectionState: .licenses)
      ]
    ),
  ]
</code></pre>
<p>We get the following view:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686921946027/3fb034df-118b-423d-9855-34de8046271c.png?height=500" alt class="image--center mx-auto" /></p>
<p><strong>The problem faced with dynamic cell resizing</strong></p>
<p>One of the problems I faced was that I needed the parent cell to estimate the size of its content and resize its cell to fit the child tables. This was important as not all sections had the same amount of rows. Here's a <a target="_blank" href="https://quriousclick.com/set-the-dynamic-height-of-a-tableview-which-is-inside-a-tableview/">link to the resource</a> that helped me resolve this problem. You can confirm that you are facing this issue by adding an arbitrarily large row height to parent cells to see if the child table is being clipped.</p>
<h3 id="heading-handling-cell-row-selection">Handling cell row selection</h3>
<p>The handling of cell row selection is done through the <code>UITableViewDelegate</code> protocol. This article on '<a target="_blank" href="https://developer.apple.com/documentation/uikit/uitableviewdelegate/handling_row_selection_in_a_table_view">Handling row selection in a table view</a>' is a good resource available in the Apple docs. The question that arises is: Who should be assigned as the delegate in a nested case? As mentioned earlier, the <code>ParentTableViewCell</code> class acts as the delegate. By conforming the class to the protocol, we can access delegate methods that allow us to perform various interactions, such as selecting and deselecting a row.</p>
<p><a target="_blank" href="https://developer.apple.com/documentation/uikit/uitableviewdelegate">Link to UITableViewDelegate Apple doc</a>.</p>
<h3 id="heading-apple-provided-viewcontrollers-for-cfa-items">Apple provided ViewControllers for CFA items</h3>
<p>Certain actions in the menu are call-for-action items. For example, Rating the app, Share and the Email interface. These often present a new view to the user based on the action. Newer versions of iOS provide us with system components to integrate such elements.</p>
<p>The problem we can face here is that we are handling cell selection inside a class that inherits <code>UITableViewCell</code> instead of <code>UIViewController</code>. So we cannot rely on the <code>present(_:animated:completion:)</code> to present these views. Thus, we need a method to access the parent view controller somehow. This can be achieved by using the following extension on <code>UIView</code> as even a <code>UITableViewCell</code> has a <code>UIView.</code></p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">extension</span> <span class="hljs-title">UIView</span> </span>{
  <span class="hljs-keyword">var</span> parentViewController: <span class="hljs-type">UIViewController?</span> {
    <span class="hljs-keyword">var</span> parentResponder: <span class="hljs-type">UIResponder?</span> = <span class="hljs-keyword">self</span>
    <span class="hljs-keyword">while</span> parentResponder != <span class="hljs-literal">nil</span> {
      parentResponder = parentResponder!.next
      <span class="hljs-keyword">if</span> parentResponder <span class="hljs-keyword">is</span> <span class="hljs-type">UIViewController</span> {
        <span class="hljs-keyword">return</span> parentResponder <span class="hljs-keyword">as</span>? <span class="hljs-type">UIViewController</span>
      }
    }
    <span class="hljs-keyword">return</span> <span class="hljs-literal">nil</span>
  }
}
</code></pre>
<p>We can then access the parent view controller using this computed property for a view.</p>
<h3 id="heading-rating-the-app-using-skstorereviewcontroller">Rating the app using SKStoreReviewController</h3>
<p>SKStoreReviewController is part of StoreKit. This <a target="_blank" href="https://www.avanderlee.com/swift/skstorereviewcontroller-app-ratings/">article by SwiftLee</a> helped me in this area. It allows us to present a view that allows the user to review the app by presenting a pop-up.</p>
<p>The <code>requestReview(in:)</code> takes a UIWindowScene as a parameter. For macOS, we can directly call the function without passing a window. We do need to get a target scene for presenting in iOS. So we fetch the current foreground scene. As you can see in the article, this can be achieved using the following extension on <code>UIApplication:</code></p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">extension</span> <span class="hljs-title">UIApplication</span> </span>{
  <span class="hljs-keyword">var</span> foregroundActiveScene: <span class="hljs-type">UIWindowScene?</span> {
    connectedScenes
      .first(<span class="hljs-keyword">where</span>: { $<span class="hljs-number">0</span>.activationState == .foregroundActive }) <span class="hljs-keyword">as</span>? <span class="hljs-type">UIWindowScene</span>
  }
}
</code></pre>
<p>For iOS, the request review method is supported by versions 14.0 and above. As Scribe supports a deployment target of iOS 13, we need to implement a fallback for rating this app. We can do so by presenting an alert that redirects the user to the app store page for the app. Following is the code for the alert:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> alert = <span class="hljs-type">UIAlertController</span>(title: <span class="hljs-string">"Enjoying Scribe?"</span>, message: <span class="hljs-string">"Rate Scribe on the App Store."</span>, preferredStyle: .alert)
alert.addAction(<span class="hljs-type">UIAlertAction</span>(title: <span class="hljs-string">"Continue"</span>, style: .<span class="hljs-keyword">default</span>, handler: openScribeAppStore(alert:)))
alert.addAction(<span class="hljs-type">UIAlertAction</span>(title: <span class="hljs-string">"Cancel"</span>, style: .cancel, handler: <span class="hljs-literal">nil</span>))
parentViewController?.present(alert, animated: <span class="hljs-literal">true</span>)
</code></pre>
<p>We can add a <code>if #available</code> check to see what can be presented based on the user's OS version.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">if</span> #available(iOS <span class="hljs-number">14.0</span>, *) {
    <span class="hljs-comment">// present SKStoreReviewController</span>
} <span class="hljs-keyword">else</span> {
    <span class="hljs-comment">// present alert</span>
}
</code></pre>
<h3 id="heading-adding-a-share-sheet">Adding a share sheet</h3>
<p>We can present a share sheet using <code>UIActivityViewController</code>.</p>
<p>We will have to make use of the <code>parentViewController</code> variable to present this as well. The view controller takes two parameters -- <code>activityItems</code> and <code>applicationActivities</code>.</p>
<p>We are trying to share the URL to Scribe on the App Store. Thus, this URL will be one of our <code>activityItems</code>. We can have multiple <code>activityItems</code> as they are passed in an array. For example, an app can be capable of sharing a photo as well as an URL to the photo. <code>applicationActivities</code> can be nil.</p>
<blockquote>
<p>Note: Links to an app or links in general, can be encoded. Look for spaces or special characters like #. These imply that a link is encoded. If a link is encoded and we try to create a URL instance from that string, we won't get a valid URL object. We need to add encoding to the string using the <code>addingPercentEncoding</code> method. <a target="_blank" href="https://developer.apple.com/documentation/foundation/nsstring/1411946-addingpercentencoding">Link to Docs</a>. If you are passing a valid URL string and getting nil, try creating an URL with the encoded string.</p>
</blockquote>
<p>Link to <a target="_blank" href="https://developer.apple.com/documentation/uikit/uiactivityviewcontroller">UIActivityViewController docs</a>.</p>
<h3 id="heading-adding-an-email-interface">Adding an Email interface</h3>
<p>We can use the <code>MFMailComposeViewController</code> from Apple to compose an email. This view controller first checks if the device is configured to send email. Thus, if you run this on the simulator, the <code>.canSendMail</code> method will return false as the simulator doesn't have the mail app.</p>
<blockquote>
<p>Apple's directive: You should not attempt to use this interface if the <a target="_blank" href="https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontroller/1616879-cansendmail"><code>canSendMail()</code></a> method returns <code>false</code>.</p>
</blockquote>
<p>Thus to handle the false case, I am using an alert again that shows the user the email they can reach out to.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> alert = <span class="hljs-type">UIAlertController</span>(title: <span class="hljs-string">"Send us an email?"</span>, message: <span class="hljs-string">"Reach out to us at scribe.language@gmail.com"</span>, preferredStyle: .alert)
alert.addAction(<span class="hljs-type">UIAlertAction</span>(title: <span class="hljs-string">"Cancel"</span>, style: .cancel, handler: <span class="hljs-literal">nil</span>))
parentViewController?.present(alert, animated: <span class="hljs-literal">true</span>)
</code></pre>
<p>If the check function returns true, we can then set the email recipients, the subject of the email as well as the email body. This can be useful to provide the user with an email template. It also takes away the friction for the user in case they want to reach out.</p>
<p>The Scribe menu has distinct sections that cater to various reasons why a user might want to reach out, including bug reports and feedback. As a result, the user's reason for writing an email becomes ambiguous. As a solution, I opted not to provide a body for the email and used a general subject line that simply says "Hey Scribe!".</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> mailComposeViewController = <span class="hljs-type">MFMailComposeViewController</span>()
mailComposeViewController.mailComposeDelegate = <span class="hljs-keyword">self</span>
mailComposeViewController.setToRecipients([<span class="hljs-string">"scribe.language@gmail.com"</span>])
mailComposeViewController.setSubject(<span class="hljs-string">"Hey Scribe!"</span>)

parentViewController?.present(mailComposeViewController, animated: <span class="hljs-literal">true</span>, completion: <span class="hljs-literal">nil</span>)
</code></pre>
<p>Link to <a target="_blank" href="https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontroller">MFMailComposeViewController docs.</a></p>
<h3 id="heading-to-summarise">To summarise,</h3>
<p>The past two weeks I learned the intricacies of ScrollView; really learned to battle with auto layout constraints to make stuff work. Learned about built-in view controllers provided by Apple in some of their frameworks. Had regular check-ins with the team. Was able to implement the skeleton of the app menu with continuous improvements. Also, had my first couple of PRs merged into the codebase for my GSoC project! 🚀</p>
<p>Thank you so much for tagging along my journey! Sharing my socials below for anyone interested :)</p>
<p><a target="_blank" href="https://twitter.com/Saura6hJ">Twitter</a> | <a target="_blank" href="https://www.linkedin.com/in/saurabh-jamadagni/">LinkedIn</a></p>
<p>Until the next one...</p>
]]></content:encoded></item><item><title><![CDATA[Documenting GSoC '23 : Preface]]></title><description><![CDATA[Acceptance and Community Bonding]]></description><link>https://saurabhjamadagni.hashnode.dev/documenting-gsoc-23-preface</link><guid isPermaLink="true">https://saurabhjamadagni.hashnode.dev/documenting-gsoc-23-preface</guid><category><![CDATA[gsoc2023]]></category><category><![CDATA[documentation]]></category><category><![CDATA[iOS]]></category><dc:creator><![CDATA[Saurabh Jamadagni]]></dc:creator><pubDate>Fri, 26 May 2023 19:45:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685096201229/20581fc6-2855-48a3-ab4f-4c85897ac3c5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I have been meaning to start blogging and documenting my tech journey for a long time now. Unfortunately, I always found an excuse to delay it. Often it came in the form of 'not a good draft'. GSoC is finally giving me a reason I cannot escape to start blogging and I am extremely grateful for it. Here's the start of my journey!</p>
<h2 id="heading-the-feeling-of-being-accepted-into-gsoc">The feeling of being accepted into GSoC</h2>
<h3 id="heading-starting-to-contribute-to-open-source">Starting to contribute to open-source</h3>
<p>Before I share how it felt for me to be accepted, I would like to talk about how I started contributing to open-source.</p>
<p>It was at the end of my sophomore year that I realized that I had spent a lot of time figuring out what I wanted to learn. Jumping between things without actually doing one thing. It was a scary feeling to think that I had no employable skills post two years of my college. I had to get started somewhere and I had to get started fast.</p>
<p>I picked up an iOS development course and got started. This time, my single objective was to not be swayed by other fascinating technologies until I had the foundations of iOS down and could be tangible and products that can be shipped. The initial projects that were built by following along the course exploited a single concept that they wished to teach at a time. I wanted to get hands-on with production-grade software as soon as possible. I had a couple of minor contributions in the form of bug fixes earlier. I knew open-source was a great path to take as I had engaged with a different community earlier and had a wonderful experience.</p>
<p>I don't know what is it about iOS applications, but I found it very difficult to find an open-source iOS project. I used the <a target="_blank" href="https://goodfirstissues.com/">Good First Issues</a> website to filter down to find issues that were Swift based. That's where I found <a target="_blank" href="https://github.com/scribe-org/Scribe-iOS">Scribe-iOS</a>. It was one of the only well-documented repositories in the filtered list. I forked and cloned the repo, went through the codebase as much as I could and tried to find an issue I could solve. I proceeded to comment on the issue that I would like to help. My current mentor <a target="_blank" href="https://github.com/andrewtavis">Andrew</a>, who is the project owner of Scribe, was the best guide I could ask for! On my first couple of issues, he pointed out where the changes could be made but also left it for me to figure out the rest. The welcoming atmosphere was really what kept me going. I started to see the community aspect that is discussed about open-source as I met new people and felt a similar warm atmosphere. It was different and inspiring!</p>
<h3 id="heading-applying-to-gsoc-23">Applying to GSoC '23</h3>
<p>Andrew and I participated in Wikimania, a hackathon hosted by Wikimedia. During the concluding slides, I saw the mention of GSoC. I decided to take a leap of faith and ask Andrew if Scribe could participate in GSoC as well. Of course, nothing was guaranteed and I had to show proof of work, but I couldn't be more happy about having a chance.</p>
<p>The application was near and the competition was tough. Working on the proposal took several iterations. I uploaded the proposal a few days before the deadline keeping a small margin for correction if required. This was followed by contributing to issues during the application period as well.</p>
<p>I was amidst my final exam when the announcement of the selected candidates went through. That day I stayed up pretty late as I hadn't studied during the evening because of my excitement!</p>
<h2 id="heading-the-community-bonding-period">The Community Bonding Period</h2>
<h3 id="heading-welcome-talk-and-the-contributor-summit">Welcome Talk and the Contributor Summit</h3>
<p>The Welcome talk was conducted by the GSoC coordinators Stephanie Taylor &amp; Perry Burnham. It included welcoming and congratulating the contributors as well as discussing a few statistics related to GSoC applicants. Thank you very much for the warm welcoming note, Stephanie :)</p>
<p>This was followed by a live Q&amp;A. This was especially important as people from different regions had varying doubts related to setting up their payment-accepting account on Payoneer. The questions were varied as different regions had a few specific processes. The Q&amp;A also discussed how to be a better contributor briefly -- the key is <em>communication</em>.</p>
<p>I was traveling during the day of the Contributor Summit. Due to bad reception, I was only able to watch the first few talks of the live stream, unfortunately. During the talks I was able to watch, various aspects of being a contributor were discussed and shared their experience with open-source. This included communication, asking good questions, trying to figure out a problem before asking for help and being realistic about the work you have done and expectations. The limited talks I was able to attend were extremely helpful and I can only wonder about the value I lost out on by missing the rest of the event.</p>
<blockquote>
<p>This process is very intimidating to newcomers, who might be concerned about having their words immortalized on the Internet, and worse, saying something wrong or embarrassing. The only way to get over this fear is to practice and participate publicly.</p>
</blockquote>
<p>This is a quote from the GSoC guide on <a target="_blank" href="https://google.github.io/gsocguides/student/open-source-culture">open-source culture</a> for new contributors. I found it very helpful.</p>
<p>I was also added to the Wikimedia Zulip chat as well as the mailing list for GSoC and Outreachy contributors. The org admins are extremely helpful! Learning about the work they have done for the community is also inspiring. I was going through the projects of the other interns and it is amazing what everybody is working on! I am looking forward to collaborating with them a lot over this summer and beyond.</p>
<h3 id="heading-setting-up">Setting Up</h3>
<p>Some of the stuff that I had to get set up before the coding period:</p>
<ul>
<li><p><strong>Set up the Payoneer account</strong> to avoid hassle later. This ended up being pretty straightforward for me. I did not encounter any problems throughout the process.</p>
</li>
<li><p><strong>Forking the Scribe-Data repo</strong>. In my many contributions to Scribe, I have not contributed any code to the data. My task for GSoC changes that and thus I need to get a stronger grasp on that codebase.</p>
</li>
<li><p><strong>Bringing my local Scribe-iOS repo up to date</strong>. During a small absence in between my exams, the application has seen several changes. So pulling them from upstream is one of the tasks in my setting up list.</p>
</li>
</ul>
<h3 id="heading-meeting-up-with-the-mentors">Meeting up with the mentors</h3>
<p>I have had two meetings with the Scribe team hitherto. The first meeting was my first time meeting <a target="_blank" href="https://github.com/wkyoshida">Will</a>, who is a big contributor to Scribe-Data. It was extremely exciting meeting him! There is so much for me to learn from Andrew and Will and I am very excited for the summer ahead.</p>
<p>During our meeting, we caught up and tried to lay down a basic workflow for the duration of the contribution period. Major points of the workflow:</p>
<ul>
<li><p>Documenting changes related to a particular issue under its designated issue created on GitHub (A separate team is maintained for GSoC on the Scribe project board for easy filtering).</p>
</li>
<li><p>Weekly meetings on Tuesdays to discuss updates and plan the forthcoming weeks.</p>
</li>
<li><p>The basic idea of which issues need to be further broken down into smaller sub-tasks.</p>
</li>
<li><p>Maintaining weekly meeting documentation.</p>
</li>
<li><p>Discussing priority of issues to put in place a rough order for in which to tackle them.</p>
</li>
<li><p>Discussing other aspects of Scribe happening outside GSoC that may be blocked or on hold due to tasks assigned to me.</p>
</li>
</ul>
<p>We also discussed me reviewing other pull requests made to Scribe as well as setting up a framework for writing tests. This should help me gain a stronger understanding of how software engineering works at the production level. I have been going through a few articles and documentation and should be set up soon.</p>
<p>I also have to catch up with some UIKit as I have been using the SwiftUI framework for the past couple of months as my primary framework. Revising how to storyboard, using the delegate pattern and looking at creating multi-page applications using UIKit should wash off the rust that has built up.</p>
<h2 id="heading-plans-for-the-coming-week">Plans for the coming week</h2>
<ul>
<li><p>I need to test the current workflow that has been laid out. If it needs tweaking, the starting weeks should be a good point to make changes. I will be in correspondence with my mentor on this one.</p>
</li>
<li><p>Next is to hit the ground running by tackling a couple of Priority 1 issues along with some Priority 2 or 3s.</p>
</li>
<li><p>I also need to dive deeper into the codebase of Scribe-Data although I do have an understanding of how it works. This should be in preparation for the issues related to adding the English and Norwegian language keyboards.</p>
</li>
</ul>
<p>Thank you so much for tagging along my journey! Sharing my socials below for anyone interested :)</p>
<p><a target="_blank" href="https://twitter.com/Saura6hJ">Twitter</a> | <a target="_blank" href="https://www.linkedin.com/in/saurabh-jamadagni/">LinkedIn</a></p>
<p>Until the next one...</p>
]]></content:encoded></item></channel></rss>