Building Freetrade

Journey to Jetpack Compose

Mark Murtagh

June 1, 2023

Mark Murtagh

Freetrade's first Jetpack Compose view.

Why Jetpack Compose? 

Jetpack Compose has taken the Android development world by storm. 

A modern toolkit for building user interfaces (UI), Jetpack Compose makes it easier and faster to develop UIs for Android apps. 

Here at Freetrade, we wanted to start using Jetpack Compose for a number of reasons. 

First, as mobile engineers, we’re always looking to work with the latest and most exciting tech, with state-of-the-art libraries.

Second, Jetpack Compose will help us deliver better, more responsive customer experiences at a faster pace. 

Last but not least, Jetpack Compose uses a declarative approach to development. This means that instead of having to write a lot of code to create and manage UI components, we can simply declare how the UI should look and behave. Our app is reactive, so a declarative UI framework complements this well.

How did we tackle the challenge? 

Like many mobile engineering functions, we strive to find the right balance between working core platform tasks and building new features for our customers. Taking the right approach to the prioritisation of Jetpack Compose is yet another example of just that.

Our main issue was that we still extensively used the Kotlin synthetics library (a deprecated Android UI toolkit) in legacy views. This blocked us from updating our Kotlin version, which in turn prevented us from using the latest Jetpack Compose dependencies.

So the question became: how should we deprecate Kotlin synthetics? (For the non-engineers among us, deprecation means the software or code feature is still useable, but it’s not necessarily recommended).

One option we explored was using an automated Gradle script solution, which replaced synthetic calls with a hardcoded copy, and using findViewById. 

However, we decided against this because we wanted a solution that allowed our legacy views to use ViewBindings, which is a more efficient and type-safe way to access view elements. This ultimately required us to divide and conquer and go with our own solution. 

At Freetrade, we encourage engineers to work across the full stack and we saw this as a great opportunity to educate our engineers on Android view toolkits. We held internal training sessions to help our developers get up to speed on the new ViewBindings library, and we also provided extensive documentation and support. Each mobile engineer (with some backend engineers jumping in to help!) was assigned a set number of view files and got to work. 

This asynchronous approach removed dependencies across the team and enabled each engineer to proceed in the way that worked best for them, balancing their existing priorities. 

How did it go? Well, this approach proved to be highly effective, and we managed to get through all the synthetic files asynchronously in less than 2 months - far less time than we’d anticipated. 

Once we migrated our Synthetic views to use ViewBindings, we needed to deprecate Jetifier from our codebase and finally upgrade to the latest Kotlin version - going through our entire codebase and fixing any errors along the way. 

What was the end result? 

Once we made these changes, we could finally use Jetpack Compose. We were excited by how quickly it let us build complex and responsive UIs. We were particularly impressed with how versatile the animation APIs are. 

We decided to test it out on our upcoming feature, Recurring orders. Here’s a little sneak peek: 

Ooooh!

With just 47 lines of code we were able to create this custom, responsive and animated view component. Before Jetpack Compose, a similar view component on our Insights tab would have required nearly double the lines of code.

Overall, our journey to using Jetpack Compose was a challenging but rewarding experience. 

We’re excited to use it as we build out the future of our app, and to see the type of new experiences we can create. Android customers, stay tuned!

The value of your investments can go down as well as up and you may get back less than you invest. Always do your own research.

The views expressed above are those of community members and do not reflect the views of Freetrade. It is not investment advice and we always encourage you to do your own research.

Simple pricing plans

Choose how you'd like to pay:

Annually

Save 17%

Monthly

Annually

Save 17%

Monthly

£0.00/mo

Accounts

GIA pink
General investment account

Benefits

  • Commission-free trades (other charges may apply. See full pricing table.)
  • Trade USD & EUR stocks at the exchange rate + a 0.99% FX fee
  • Fractional US Shares
  • Access to more than 4,700 stocks, including the most popular shares and ETFs
  • 1% AER on up to £1,000 uninvested cash
£4.99/mo

£59.88 billed annually

£5.99/mo

Billed monthly

Accounts

GIA white
General investment account
ISA
Stocks and shares ISA

Benefits
Everything in Basic, plus:

  • Full range of over 6,000 US, UK and EU stocks and ETFs
  • Trade USD & EUR stocks at the exchange rate + a 0.59% FX fee
  • Automated order types, including recurring orders
  • Advanced stock fundamentals
  • 3% AER on up to £2,000 uninvested cash
£9.99/mo

£119.88 billed annually

£11.99/mo

Billed monthly

Accounts

GIA white
General investment account
ISA
Stocks and shares ISA
SIPP white
Self-invested personal pension (SIPP)

Benefits
Everything in Standard, plus:

  • Trade USD & EUR stocks at the exchange rate + a 0.39% FX fee
  • Priority customer service
  • Freetrade Web beta
  • 5% AER on up to £3,000 uninvested cash

Download the app to start investing now



When you invest your capital is at risk.