Skip to content

A demonstration of a calculator app written in Swift using The Composable Architecture.

License

Notifications You must be signed in to change notification settings

DandyLyons/TCACalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCACalc

Welcome to TCACalc, an example of a calculator app implemented in TCA (The Composable Architecture), with a calculation engine implemented as a Finite State Machine.

Features

  • Animated Text View
  • Light/dark mode toggle
    • Introducing Night Mode: A black and red UI Appearance for better sleep.

Tech Stack

  • Architecture: TCA
    • I chose TCA because it is extremely easy to prototype, iterate, and test. Each TCA feature is composable because it only observes it's own state, and cannot accidentally mutate someone else's state.
    • The calculation engine is also implemented in TCA, but with an atypical approach, a Finite State Machine. An FSM is a system that can only possibly be in one of a limited number of possible states, and can only transition from one state to another.
  • SwiftUI
  • Modern Swift Concurrency
    • This app uses only modern concurrency tools such as async await.

Inspiration and Acknowledgements

  • Robert M. Vunabandi
    • Part way through implementing the calculation engine, I discovered that the logic of calculators is far more complex than I initially suspected. I began to suspect that it might be modeled as an FSM. This led me to find Vunabandi's fantastic article Designing A Calculator with FSM Logic which is essentially reverse-engineering the calculator logic of Apple's Calculator app as an FSM. This article was absolutely vital to the implementation of TCACalc's calculation engine.
  • This helpful discussion on how to implement an FSM in TCA.
  • David Khourshid - Infinitely Better UIs with Finite Automata

Roadmap

Feedback

Feedback is greatly appreciated. To share suggestions for improvement, please open an issue.

About

A demonstration of a calculator app written in Swift using The Composable Architecture.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages