Create a library to see all of your app’s buttons in their various states

Photo by Siddharth Singh on Unsplash

Buttons are some of the most frequently used components in our apps.

It’s important to make them look appropriate to the action they trigger. They should be consistent and accessible across the app and give visual feedback to users.

In my previous article, I talked about view modifiers and how they can be used to create a stylish UI for our SwiftUI apps.

Here, I’ll present how to apply them to create reusable styles for buttons. It’s going to be a long and enjoyable ride.

SwiftUI Buttons

Creating a button in SwiftUI is pretty simple. …

Create custom SwiftUI elements that house other elements

Photo by Joshua Sortino on Unsplash

Maintaining UI consistency while keeping your codebase clean is a must-have. But how can we achieve that in SwiftUI?

Developing a pet/serious project is the perfect way to learn a new framework or paradigm. SwiftUI is no exception to this truth.

While doing that, I stumbled upon having to use the same components on several screens: titles, subtitles, and buttons. Having mini UI libraries inside the project for different UI building blocks helps a lot.

What Are View Modifiers?

In SwiftUI we can use the existing UI components (e.g., Text, TextField, and Button) with our own shared styles through view modifiers.

A view modifier

We don’t have didSet anymore. Now what?

Photo by the author.

This is how I learned to implement an equivalent of onChange in SwiftUI controls to update other @State variables.

Almost a year after SwiftUI was released, I decided to give it a go. I started to get my hands dirty by implementing basic UI controls (like Slider or TextField) and learning how to manipulate view states.

I quickly faced the challenge of updating an @State variable based on another @State variable’s changes.

And, yes, the property observers that we know (like didSet or willSet) don't work in @State variables.

After some research (which took longer than I expected), I learned…

Better analytics on every platform

You’re building two mobile apps (iOS and Android) using React Native. The apps get approved in their stores. How do you know if your customers are enjoying your creation and find it useful? You don’t unless you find a way to get insights and understand how your apps are used.

First, one has to decide what library should be used. Fortunately, there are some great choices that make it easy to integrate, like:

Calin-Cristian Ciubotariu

I’m a developer passionate about mobile technologies. iOS/React Native | | Follow me on Twitter:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store