All Projects → yokurin → Swift-VIPER-iOS

yokurin / Swift-VIPER-iOS

Licence: MIT license
SwiftVIPER is an sample iOS App written in Swift using the VIPER architecture. Also SwiftVIPER is not a strict VIPER architecture.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swift-VIPER-iOS

RxSwift-VIPER-iOS
RxSwiftVIPER is an sample iOS App written in RxSwift using the VIPER architecture. Also RxSwiftVIPER is not a strict VIPER architecture.
Stars: ✭ 47 (+88%)
Mutual labels:  github-api, viper, viper-architecture
VIPERArchitectureGenerator
Generates files for your VIPER Architecture files.
Stars: ✭ 15 (-40%)
Mutual labels:  viper, viper-architecture
Swift-Viper-Weather-App
iOS app with Clean Architecture
Stars: ✭ 20 (-20%)
Mutual labels:  viper, viper-architecture
AndroidVIP
Android project to experiment the VIPER approach using mosby, RxJava and dagger2
Stars: ✭ 21 (-16%)
Mutual labels:  viper, viper-architecture
git-down-repo
Download git-repo for any url
Stars: ✭ 50 (+100%)
Mutual labels:  github-api
larry
Larry 🐦 is a really simple Twitter bot generator that tweets random repositories from Github built in Go
Stars: ✭ 64 (+156%)
Mutual labels:  github-api
myPortfolio
This is a portfolio application built by using Next.js, ChakraUi, Typescript and Dev.to api.
Stars: ✭ 127 (+408%)
Mutual labels:  github-api
github-markdown-render
Display Markdown formatted documents on your local web server using GitHub's Markdown rendering API and CSS to mimic the visuals of GitHub itself.
Stars: ✭ 18 (-28%)
Mutual labels:  github-api
go-github
Go library for accessing the GitHub v3 API
Stars: ✭ 8,539 (+34056%)
Mutual labels:  github-api
top-github-scraper
Scape top GitHub repositories and users based on keywords
Stars: ✭ 40 (+60%)
Mutual labels:  github-api
github-app
node module to handle authentication for the GitHub Apps API
Stars: ✭ 51 (+104%)
Mutual labels:  github-api
journalist
App to write journal digitally. Simple as that.
Stars: ✭ 23 (-8%)
Mutual labels:  github-api
GitHubReadmeWebTrends
An automated tool created using Azure Functions that double checks each Readme to ensure every repository is leveraging Web Trends
Stars: ✭ 13 (-48%)
Mutual labels:  github-api
github-admin
vue和element-ui搭建一個後台管理系統,使用github提供的api搞事情。輸入您的github賬號名自動幫你生成基本的github信息哦😯
Stars: ✭ 15 (-40%)
Mutual labels:  github-api
github-api-plugin
This plugin packages stock github-api library
Stars: ✭ 20 (-20%)
Mutual labels:  github-api
awesome-generator
Generate awesome list over Github API
Stars: ✭ 46 (+84%)
Mutual labels:  github-api
go-contrib
Helper for Log configuration, Mixin for properties with fangs
Stars: ✭ 20 (-20%)
Mutual labels:  viper
github-classroom-utils
Python tools for instructors working with GitHub Classroom
Stars: ✭ 66 (+164%)
Mutual labels:  github-api
github-status-updater
Command line utility for updating GitHub commit statuses and enabling required status checks for pull requests
Stars: ✭ 83 (+232%)
Mutual labels:  github-api
2017-year-in-review
Year in Review with R Rmd Template
Stars: ✭ 34 (+36%)
Mutual labels:  github-api

SwiftVIPER (View, Interactor, Presenter, Entity, Router)

SwiftVIPER is an sample iOS App written in Swift using the VIPER architecture.
Also SwiftVIPER is not a strict VIPER architecture.
Part of the project is a unique way.

Language

Sample App

Architecture

Run Sample

  1. Clone this repository.

    git clone [email protected]:yokurin/Swift-VIPER-iOS.git
    
  2. Open SwiftVIPER.xcodeproj in Xcode.

  3. Run

Description

SwiftVIPER is not a strict VIPER architecture.
Part of the project is a unique way. This is just a suggestion.

View (including UIViewController)

View must implement Viewable. Viewable has Default Extension.
※ View is not just View like UIView etc in this case.

protocol Viewable: AnyObject {
    func push(_ vc: UIViewController, animated: Bool)
    func present(_ vc: UIViewController, animated: Bool)
    func pop(animated: Bool)
    func dismiss(animated: Bool)
    func dismiss(animated: Bool, completion: @escaping (() -> Void))
}

extension Viewable where Self: UIViewController {

    func push(_ vc: UIViewController, animated: Bool) {
        self.navigationController?.pushViewController(vc, animated: animated)
    }

    func present(_ vc: UIViewController, animated: Bool) {
        self.present(vc, animated: animated, completion: nil)
    }

    func pop(animated: Bool) {
        self.navigationController?.popViewController(animated: animated)
    }

    func dismiss(animated: Bool) {
        self.dismiss(animated: animated, completion: nil)
    }

    func dismiss(animated: Bool, completion: @escaping (() -> Void)) {
        self.dismiss(animated: animated, completion: completion)
    }
}

Example

protocol ViewInputs: AnyObject {
    
}

protocol ViewOutputs: AnyObject {
    func viewDidLoad()
}

final class ListViewController: UIViewController {

    internal var presenter: ViewOutputs?

    override func viewDidLoad() {
        super.viewDidLoad()
        presenter?.viewDidLoad()
    }
    
    ...

}

extension ListViewController: ListViewInputs {}

extension ListViewController: Viewable {}

Interactor

Interactor must implement Interactorable. But Interactorable has no properties.

protocol Interactorable {
    // nop
}

Example

protocol InteractorOutputs: AnyObject {

}

final class Interactor: Interactorable {

    weak var presenter: InteractorOutputs?
    
}

Presenter

Presenter must implement Presenterable.

protocol Presenterable {
    associatedtype I: Interactorable
    associatedtype R: Routerable
    var dependencies: (interactor: I, router: R) { get }
}

Example

/// Must not import UIKit

typealias PresenterDependencies = (
    interactor: Interactor,
    router: RouterOutput
)

final class Presenter: Presenterable {
    
    ...
    
    internal var entities: Entities
    private weak var view: ViewInputs!
    let dependencies: PresenterDependencies

    init(entities: Entities,
         view: ViewInputs,
         dependencies: PresenterDependencies)
    {
        self.view = view
        self.entities = entities
        self.dependencies = dependencies
    }
    
    ...
}

Entity

Entity has no protocol.

Example

struct EntryEntity {}

final class Entities {
    let entryEntity: EntryEntity
    
    var entities: [SomeEntity] = []

    init(entryEntity: EntryEntity) {
        self.entryEntity = entryEntity
    }
}

Router

Router must implement Routerable.

protocol Routerable {
    var view: Viewable! { get }

    func dismiss(animated: Bool)
    func dismiss(animated: Bool, completion: @escaping (() -> Void))
    func pop(animated: Bool)
}

extension Routerable {
    func dismiss(animated: Bool) {
        view.dismiss(animated: animated)
    }

    func dismiss(animated: Bool, completion: @escaping (() -> Void)) {
        view.dismiss(animated: animated, _completion: completion)
    }

    func pop(animated: Bool) {
        view.pop(animated: animated)
    }
}

Example

struct RouterInput {

    private func view(entryEntity: EntryEntity) -> ViewController {
        let view = ViewController()
        let interactor = Interactor()
        let dependencies = PresenterDependencies(interactor: interactor, router: RouterOutput(view))
        let presenter = Presenter(entities: Entities(entryEntity: entryEntity), view: view, dependencies: dependencies)
        view.presenter = presenter
        interactor.presenter = presenter
        return view
    }

    func push(from: Viewable, entryEntity: EntryEntity) {
        let view = self.view(entryEntity: entryEntity)
        from.push(view, animated: true)
    }

    func present(from: Viewable, entryEntity: EntryEntity) {
        let nav = UINavigationController(rootViewController: view(entryEntity: entryEntity))
        from.present(nav, animated: true)
    }
}

final class RouterOutput: Routerable {

    private(set) weak var view: Viewable!

    init(_ view: Viewable) {
        self.view = view
    }

    func transitionToOther() {
        OtherRouterInput().push(from: view, entryEntity: OtherEntryEntity())
    }
}

Unit Test

WIP ...

Xcode Template ( xctemplate )

WIP ...

Requirements

  • Xcode 10.0+
  • Swift 4.2+

Installation

git clone [email protected]:yokurin/Swift-VIPER-iOS.git

Author

Tsubasa Hayashi, [email protected]

License

SwiftVIPER is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].