This app presents few examples for common patterns using purer SwiftUI code

Overview

VIPERtoSwiftUI

GOAL

This app presents few examples for common patterns using purer (from authors experience) SwiftUI code.

LITERATURE

  1. https://www.appypie.com/pass-data-between-views-swiftui-how-to
  2. https://www.hackingwithswift.com/articles/216/complete-guide-to-navigationview-in-swiftui
  3. https://www.raywenderlich.com/8440907-getting-started-with-the-viper-architecture-pattern#toc-anchor-004

(last visited 12/2021)

MVVM vs VIPER

  • Viper is used for additional separation of concerns, in most of the most cases not needed in modern mobile app development!
  • Mvvm separation should suffice in most of nowadays mobile app screens/features - which are lightweight, modular, recyclable.

Happy to hear arguments against these thoughts/statements - will argue back and change my opinion if yours arguments are stronger/better :)

VIPER

  • Router is implementation of principle - inversion of control, knows how to create each View with everything needed for that View to live happily.

  • Entity is object containing/wrapping/uniting all variables. Multiple entities enable syntacticall / logic separation of concerns.

  • Interactor is point of interaction for various presenters to handle user interaction with app/feature. Multiple interactors enable syntacticall / logical separation of concerns (preceeded by multiple Entity instances).

  • Presenter is instance, wrapped in @ObservableObject that triggers UI changes. Multiple presenters enable syntactically / logical separation of concerns (for each View where View is lowest hierarchical UI unit we want to control dinamically in feature).

  • View is lowest hierarchical UI unit (e.g. SwiftUI View subview) we want to control dinamically in feature. Multiple views, well, you get that part by now hopefully. Multiple views, all passive UI elements, are grouped in (theirs) parent View which is controlled by respective Presenter instance.

EXAMPLES

  1. Navigation flow with passing data forw-backw in setup StartView-MediatorView-FinalView.
    In which data is presented on StartView and changed in FinalView.
    MediatorView and FinalView are dismissed withouth transitions between.
  2. Data presented on View is always re-rendered (core paradigm of and goal of usage of SwiftUI) but data is consistent because it comes from @Environment instance.
You might also like...
UIView category which makes it easy to create layout constraints in code

FLKAutoLayout FLKAutoLayout is a collection of categories on UIView which makes it easy to setup layout constraints in code. FLKAutoLayout creates sim

Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.
Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.

QuickLayout QuickLayout offers an additional way, to easily manage the Auto Layout using only code. You can harness the power of QuickLayout to align

🎄 Advent of Code ’21 solutions in Swift

Advent of Code '21 My solutions to this years Advent of Code challenge written in Swift. Content Day 1: Sonar Sweep solution Day 2: Dive! solution Day

A Swift playgrounds with solutions of the Advent of Code 2021 challenge.

🎄 Advent of Code 2021 🎅 A Swift playgrounds with solutions of the Advent of Code 2021. How to run Clone the repo and open the Playground in Xcode. S

A Code challenge I solved leveraging a lot on Composite collection view layout written in swift

AsthmApp Mobile app designed as a support aid for people with Asthma Accounts Google and Firebase [email protected] dICerytiMPSI Facebook asthmp.ap

A Code challenge I solved leveraging a lot on Composite collection view layout...written in swift

Space44 Code Challenge Space44 Code Challenge iOS application for Space 44 hiring process, it leverages on Image download and composite collection vie

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors

SwiftColorGen A tool that generate code for Swift projects, designed to improve the maintainability of UIColors. Please notice, this tool still under

QR code generator in Swift, with no external dependencies.
QR code generator in Swift, with no external dependencies.

QRDispenser is a lightweight library to generate a QR code as image (UIImage) in your app. It uses only native components, with no dependency from oth

Owner
Tomislav Gelešić
Tomislav Gelešić
A Custom ImagePicker Code with SwiftUI.

YYImagePicker A Custom ImagePicker Code with SwiftUI. Author Thanks for Kavsoft!!! ?? ScreenShot Usage VStack { } .popupImagePickerView(show: $showIm

Chuanqing 6 Nov 24, 2022
CodeEdit App for macOS – Elevate your code editing experience. Open source, free forever.

CodeEdit for macOS CodeEdit is a code editor built by the community, for the community, written entirely and unapologetically for macOS. Features incl

CodeEdit 15.8k Dec 31, 2022
Arrange views in your app’s interface using layout tools that SwiftUI provides.

Composing custom layouts with SwiftUI Arrange views in your app's interface using layout tools that SwiftUI provides. Overview This sample app demonst

Apple Sample Code 0 Jun 9, 2022
Write less UI code

Layoutless Layoutless enables you to spend less time writing UI code. It provides a way to declaratively style and layout views. Here is an example of

Declarative Hub 428 Oct 9, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

layoutBox 2.1k Dec 22, 2022
Write concise Autolayout code

Winner of Hacking with Swift Recommended award You + Stevia = ?? ?? Write concise, readable layouts ?? Reduce your maintenance time ?? Compose your st

Fresh 3.3k Jan 6, 2023
An easier and faster way to code Autolayout

EZAnchor 中文介绍 An easier way to code Autolayout Are you annoyed of coding .active = true while using Autolayout Anchors over and over again? Are you an

Alex.Liu 25 Feb 20, 2022
The fast path to autolayout views in code

NorthLayout The fast path to autolayout views in code Talks https://speakerdeck.com/banjun/auto-layout-with-an-extended-visual-format-language at AltC

banjun 36 Jul 15, 2022
CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.

CompositionalLayoutDSL CompositionalLayoutDSL is a Swift library. It makes easier to create compositional layout for collection view. Requirements Doc

FABERNOVEL 44 Dec 27, 2022
A collection of operators and utilities that simplify iOS layout code.

Anchorage A lightweight collection of intuitive operators and utilities that simplify Auto Layout code. Anchorage is built directly on top of the NSLa

Rightpoint 620 Jan 3, 2023