Swiftmas – Day 01 – Wishlist

Posted by

·

Happy Swiftmas Start Day!

For the first prompt, we have Wishlist. What will you create?

Are you ready to spread holiday cheer with a simple, fun, and functional app? In this tutorial, we’ll build a Wishlist Tracker using SwiftUI. This app will allow users to add items to a wishlist, mark them as purchased, and enjoy festive styling along the way.

By the end, you’ll have a fully functional app with:

  1. A sleek interface to add wishlist items.
  2. A dynamically updating list with purchase tracking.
  3. Festive touches like color-coded rows and a background image.

Let’s dive in!

Getting Started


1. Set Up Your Project

You can find the sample project in the GitHub repository here

Create a new SwiftUI project in Xcode:

  1. Open Xcode and select Create a new project.
  2. Choose the App template, click Next.
  3. Enter your project name (e.g., “WishlistApp”), set the interface to SwiftUI, and click Create.

Step 1: Define the Data Model

To manage wishlist items, we’ll create a simple data model:

This struct conforms to the Identifiable protocol, making it easy to use in SwiftUI’s lists.


Step 2: Build the User Interface

Adding the Wishlist Input

Now let’s build the main screen. Start by adding the following components:

  • TextField to enter new item names.
  • A stylish “Add” button to add the item to the list.

Here’s how we’ll do it:


Displaying the Wishlist

We’ll use SwiftUI’s List to display all the wishlist items. Each row will have:

  1. The item’s name.
  2. A button to toggle its purchase status.
  3. A color-coded background to indicate whether it’s been purchased.

Here’s the code:


Adding Some Festive Flair

Let’s add a background image for some holiday spirit. Modify the VStack to include a background like this:

Replace "paper-bg" with the name of an image asset you’ve added to your project. You can find this exact asset on pixabay or in the sample project.


Step 3: Assembling the Full View

Here’s the complete code for the main view:


Step 4: Run Your App

  1. Add a background image to your project assets.
  2. Run your app in the simulator or on a device.
  3. Start adding items to your wishlist and watch as they update in real time!

What’s Next?

You can expand this app with features like:

  • Categories: Group wishlist items (e.g., “For Me,” “For Family”).
  • Database: Save the wishlist using SwiftData or Core Data.
  • Sharing: Allow users to share their wishlist via email or text.

This project is a fantastic way to learn SwiftUI while creating something useful and festive. Happy coding! See you tomorrow.🎄


Discover more from

Subscribe to get the latest posts sent to your email.

thecodingsprite avatar

About the author

Hi! My name is Billie, my friends call me Billie Boo. I am a self taught iOS developer with a background in computer science, animation, graphic design & web design. I love sharing my knowledge & projects with the world & that is my mission for this blog. It’s never too late or too hard to follow your dreams.