Giter Club home page Giter Club logo

swiftuinavigation's Introduction

SwiftUINavigation

  1. Structure
  2. Module components
  3. Navigation

Video presentation record

Structure

  • Application - contains app's entry point files(AppDelegate, SceneDelegate), app configurations(dev, stg, prod) and
    • App entry points (AppDelegate, SceneDelegate)
  • BusinessLogic
    • Models - response, database, domain entities
    • Services - Independent services and managers
    • Injection - Registering our services in Resolver
  • Core
    • Base - Base classes for app's modules
    • Extensions - Extensions for Foundation, UIKit, Combine, other classes/structs
    • Helpers - Independent and reusable tools
    • Views - Reusable views(which can be used twice or more times)
  • Presentation - all modules in the app (can be grouped by flow)
  • Resources - assets, colors, fonts, strings resources

Screenshot 2023-01-23 at 23 22 46

Module Components

Each module has 4 main components(can be more if you need to split giant logic in some of them):

  • View
  • Router
  • ViewModel
  • Builder

Which are connected with ViewModel though the bindings. In this case case ViewModel acts as a connector between View and Router.

Screenshot 2023-01-23 at 23 24 46

View

  • View holds strong reference to ViewModel.
  • View listen to ViewModels's publishers.
  • View has @State var presentedScreen, every time variable not nil view pushes or presents other View(via ViewModifiers, ex .push, .present)

Screenshot 2023-01-23 at 23 31 51

ViewModel

  • ViewModel is independent component.
  • Each ViewModel has its own transition publisher where you should notify subscribers(ex. Router) when you should go forward or backward in your flow.
  • If ViewModel need some services or parameters, the should be injected with Resolver.
  • ViewModel holds strong reference to Router
  • ViewModel listens to Routers publishers.

Screenshot 2023-01-23 at 23 57 22

Router

  • Router has enum ...Route where all possible transitions are listed.
  • Router has didFinish publisher where you shoud notify subsriber(ex. ViewModel) when you should update.
  • Each router confirms to protocol Routing
  • Returning next View via func view(for route:)

Screenshot 2023-01-23 at 23 43 59

Builder

  • Builder constructs a Module
  • It creates needed components with injecting parameters and wrap it into "Module" type - which is just container with 2 generic types(view and transition, image below)

Screenshot 2023-01-23 at 23 53 43

Screenshot 2023-01-23 at 23 55 14

Navigation

Screenshot 2023-01-23 at 23 58 16

  • When app starts it opens RootView. RootView has variable presentedScreen, which decides what flow is presented now.
  • Router creates next module(via Builder) and passes it to View.

Screenshot 2023-01-24 at 00 21 07

  • Each flow has entry view, which is NavigationView, and can push or present child views.

Screenshot 2023-01-24 at 00 22 10

Screenshot 2023-01-24 at 00 22 59

  • In current implementation RootView changes flow when user is created in UserService. Also you can subscribe to a RootRouter didFinishPublisher in RootViewModel for custom logic.

swiftuinavigation's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.