Inspiration

The sunset app is a safety app to help students get home before dark.

What it does

Imagine you’re a student working late into the night, for example maybe you are a developer at a hackathon inside Pauley Pavilion and haven’t seen the sun in 10 hours, and don’t know whether it’s light or dark outside. You want to know what time you should leave in order to make it home before sundown. With the sunset app, we’ve integrated a weather API that updates what time the sun will be setting based on the date and your real time location.

How we built it

This app was built in XCode using Swift. This was both of our first times using Swift. We initially planned on using a Github repository that had already implemented the weather API as a reference, and changing the code to fit our app idea. However, changing the code line by line led to the app breaking because we didn't fully understand Swift syntax or the changes we were making. Therefore, we decided to pivot to building up the API class ourselves from scratch.

We wrote a reusable APIService Singleton Class to fetch, retrieve and decode the data from the OpenWeather API. This function is generic so it can be used for this app, but also any API call in any app and also has error handling functionality. We chose to use a singleton (rather than a Utility class) to create a one time initialization for an instance, in this case that is the API call. This is an example of a JSON file returned by OpenWeather, and here is the decoded data after our model. You can see the information we need (sunset time) is easily accessible.

While we initially planned our app to show only sunset time, it was easy to use the data for sunrise time as well, so after the sun sets it will show the next morning’s sunrise time, and after sunrise it will show sunset time.

We also included a scroll wheel to set a timer. For example, if a student wants to leave 30 minutes before sundown in order to make it home before dark you can set the scroll wheel to set a timer. We’re still working on implementing the timer notification feature but the time you choose saves as a variable so it should be easy to implement a time based alert in the future.

If you are indoors and want to know at a quick glance whether the sun is still up or not, the background color of our app changes depending on the time of day, for example in the morning it is yellow, and later in the afternoon it will be a darker shade of orange, and after sundown it will be a dark blue. You can see here in the code we implemented this functionality by setting the color to a certain hex code based on the time in-app user’s current location, so every minute that passes the color will get darker until it has graduated to the end color.

You can also change the location and see the app color and sunset time changes.

Challenges we ran into

Figuring out how to get setup in the Swift Xcode environment and spotting deprecated code snippets meant that we spent a lot of time fixing things before we could actually start building. Swift was a new programming language for the whole team so we troubleshooted a lot of syntax errors and adjusting to the new codebase by reviewing documentation.

Accomplishments that we're proud of

We are proud of designing a minimalistic and sleek UI/UX that takes out the clutter of overcomplexity in an app built for efficiency. We were also happy to successfully integrate the OpenWeatherMap API and enable real-time location tracking features for greater precision in sunset predictions. We also really like that the app can show you exactly what the sky looks like outside, via sunset-date calculations, saving busy college students like us the trip to the nearest window.

What we learned

That every idea, no matter how straight forward it sounds, can require to a substantial amount of heavy lifting. There were definitely moments where we questioned our faith both in terms of our abilities to complete this project, but also our career goals.

This was a humbling experience. ._.

What's next for Sunset App

We've got lots more features planned for the app and these include:

  • Starred location saving (Tells you when you should head back)
  • Golden Hour Time (BeReal but it hits just when you want it)
  • Widget and Notification functionalities (in case reaching to open the app was too much work)

Built With

Share this project:

Updates