Thursday, October 25, 2018

Hacktober III

This is my third blog post in my Hacktober Series. Throughout these 5 blog posts I hope to explain my introductory work into contributing to Open Source Software.

What I Worked On

This time around I decided to try out another open source Swift project. After some digging around Github, I found the repository for the Brave iOS browser. This felt like the perfect second project to work on since my first two contributions for Hacktoberfest were for the focus iOS browser. This would allow me to transfer my knowledge between the two iOS browser projects.

After looking through some of the posted issues I ended up finding one that I wanted to work on. It was a layout issue where a popup would clip off the phone's screen if it was in landscape mode. Instead of rushing into the problem, I decided to take my time and read through the relevant codebase - as I learned to do after my first Hacktoberfest contribution - to figure out an approach on how to tackle this problem.


The Fix

I had to work out a simple algorithm to layout the subviews to change their sizes proportionally to shrink the container to fit in the bounds of the screen. Initially, the code would set the heights of the views based on the available width and font size.



To fix the issue, I had to figure out the amount that every element had to be resized by to allow for the entire popup to fit on a compact screen. To do this, I had to take the external heights of the popup into consideration, including the buttons and the padding between the views. The following is the formula used to determine the resize percentage to fit:



The code was then changed to take the resize percentage into consideration.



Code Review

This was my first commit during Hacktoberfest to recieve a code review. The comments were mostly about best practics to follow and code cleanup. For example, one of the comments was about potential recursion within my code. After reading the comment I began to work on a method to avoid having to use recursion and reduced the risk of a potential bug arrising in the future. Having my code reviewed with suggestions on how to alter it makes me feel like part of a community. It's more than just a collection of people pushing code to a project - it's a community that works together to create the best codebase possible. Being able to have a back-and-forth discussion with my reviewers makes me feel like an equal even though I'm new to the project.

My Pull Requests

No comments:

Post a Comment