Skip to content

VladimirBorodko/Conventional

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conventional

platforms

Conventional is a library that helps you to:
  • unify storyboard segues and custom transitions
  • separate storyboard related code from view controllers
  • export transition logic without exposing view controllers
  • reduce boilerplate by using reflection in the way that is conventional for your project
  • have opportunity to deviate from convention where you need to
  • keep reuseable cell factories code expressive
  • combine cell registration and dequeueing code
  • detect internal inconsistency earlier in debug time
  • have debug information on what's wrong
  • catch objc / cpp exceptions in swift

Usage

Configure UITableView or UICollectionView:
override func viewDidLoad() {
  super.viewDidLoad()
  tableConfiguration = tableView.conventional.configuration
    .cell(StringCellV.self).byClass().configure(with: StringCellV.configure(stringVM:))
    .cell(IntCellV.self).inStoryboard().configure(with: IntCellV.configure(intVM:))
    .cellFromNib(ConventionalCell1V.self)
    .cellFromNib(ConventionalCell2V.self)
    .build()
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  return tableConfiguration.cell(from: tableView, at: indexPath, for: cellModels[indexPath.row])
}
Configure UIWindow:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  let window = UIWindow(frame: UIScreen.main.bounds)
  self.window = window

  windowConfiguration = window.conventional.configuration
    .register(WelcomeC.self).instantiateInitial().changeRoot().noContext()
    .build()

  windowConfiguration.transit(WelcomeC.self)
  return true
}
Configure UIViewController:
override func viewDidLoad() {
  super.viewDidLoad()
  configuration = conventional.configuration
    .embedd(SubController.self, \.subController)
    .showInitial(SeguedC.self)
    .build()
  viewModel = ViewModel(converter: configuration.converter, transit: {[weak self] in self?.configuration.perform($0)})
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  configuration.prepare(for: segue, sender: sender)
}

Requirements

  • Xcode 9.0
  • Swift 4.1

Dependencies

Conventional depends only on UIKit

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published