Skip to content

Patterns

Egor Badmaev edited this page Jan 9, 2023 · 3 revisions

Coordinator

An object responsible for setting the project up:

  • Tab bar
  • Onboarding

func start()

This method setup tab bar controller with 3 modules and set root view controller for the UIWindow

In addition to it, it opens Onboarding module, if user has not onboarded yet.

func openOnboarding()

Assembles "Onboarding" module, if it was called from start method, described above

It also conforms to OnboardingModuleOutput protocol to dismiss "Onboarding" module when it will be the time

extension AppCoordinator: OnboardingModuleOutput {
    
    func onboardingModuleDidFinish() {
        tabBarController.presentedViewController?.dismiss(animated: true)
    }
}

Private Methods

Creating UINavigationController

func createNavController(viewController: UIViewController, itemName: String, itemImage: UIImage?) -> UINavigationController

Creates UINavigationController instance with provided data.

itemName and itemImage properties will be set up as UITabBarItem

DI Containter

Class responsible setting up dependencies of the application.

Init

It has private init with 2 types of services and static methods, initializing itself.

Declaration

private init(networkManager: NetworkManagerProtocol, coreDataManager: CoreDataManagerProtocol)

Methods

makeDefault()

Method that creates default application DI container.

Declaration

static func makeDefault() -> AppDIContainer

Returns: App DI containter with default services' settings

Properties

coreDataManager

Core Data Manager. It is responsible for all operations connected with persistance.

Declaration

let coreDataManager: CoreDataManagerProtocol

networkManager

Network Manager. It is responsible for all network requests of this app.

Declaration

let networkManager: NetworkManagerProtocol