Skip to content

Commit

Permalink
feat: Symlink files - Drastically improved maintainability
Browse files Browse the repository at this point in the history
- Added code based UI templates and Endpoint template
  • Loading branch information
andrej.jasso@goodrequest.com committed Sep 13, 2021
1 parent eaeacdd commit 57137f3
Show file tree
Hide file tree
Showing 107 changed files with 484 additions and 2,021 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,25 @@ import GRProvider

// MARK: - Class

final class ___VARIABLE_ID___ViewController: UIViewController {
final class ___VARIABLE_ID___ViewController: BaseViewController<___VARIABLE_ID___ViewModel> {

// MARK: - TypeAliases

typealias Section = ___VARIABLE_ID___Factory.Section

// MARK: - Outlets

@IBOutlet weak var collectionView: UICollectionView!
// MARK: - Constaints

// MARK: - Constants

private let layoutComposer = ___VARIABLE_ID___LayoutComposer()
private let provider = GRCollectionViewProvider<Section>()

private enum C {

private let collectionView = UICollectionView().then {
$0.translatesAutoresizingMaskIntoConstraints = false
}

// MARK: - Variables

private var viewModel: ___VARIABLE_ID___ViewModel!
private var cancellables = Set<AnyCancellable>()

// MARK: - Initialization
private enum C {

static func create(viewModel: ___VARIABLE_ID___ViewModel) -> Self {
let instance = gr.makeInstance()
instance.viewModel = viewModel
return instance
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,31 @@ import GRProvider

// MARK: - Class

final class ___VARIABLE_ID___ViewController: UIViewController {
final class ___VARIABLE_ID___ViewController: BaseViewController<___VARIABLE_ID___ViewModel> {

// MARK: - TypeAliases

typealias Section = ___VARIABLE_ID___Factory.Section

// MARK: - Outlets

@IBOutlet weak var collectionView: UICollectionView!
// MARK: - Constaints

// MARK: - Constants

private let layoutComposer = ___VARIABLE_ID___LayoutComposer()
private let provider = GRDiffableCollectionViewProvider<Section>(collectionView: collectionView)

private let collectionView = UICollectionView().then {
$0.translatesAutoresizingMaskIntoConstraints = false
}

private enum C {

}

// MARK: - Variables

lazy var provider = GRDiffableCollectionViewProvider<Section>(collectionView: collectionView)

private var viewModel: ___VARIABLE_ID___ViewModel!
private var cancellables = Set<AnyCancellable>()

// MARK: - Initialization

static func create(viewModel: ___VARIABLE_ID___ViewModel) -> Self {
let instance = gr.makeInstance()
instance.viewModel = viewModel
return instance
}

}

// MARK: - Lifecycle
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// ___FILEHEADER___

import UIKit
import Combine
import GRProvider

// MARK: - Class

final class ___VARIABLE_ID___ViewController: BaseViewController<___VARIABLE_ID___ViewModel> {

// MARK: - TypeAliases

typealias Section = ___VARIABLE_ID___Factory.Section

// MARK: - Constaints

// MARK: - Constants

private let provider = GRTableViewProvider<Section>()

private let tableView = UITableView().then {
$0.translatesAutoresizingMaskIntoConstraints = false
}

private enum C {

}

}

// MARK: - Lifecycle

extension ___VARIABLE_ID___ViewController {

override func viewDidLoad() {
super.viewDidLoad()

setupTableView()
setupTableProvider()
setupNavigation()

bindState(reactor: viewModel)
bindActions(reactor: viewModel)
}

}

// MARK: - Setup

private extension ___VARIABLE_ID___ViewController {

// MARK: - Setup Navigation

func setupNavigation() {

}

// MARK: - Setup Table View

func setupTableView() {
registerCells()
setupRefreshControl()
}

func registerCells() {

}

func setupRefreshControl() {
// Setup refresh controll action bound to view model action
//
// provider.configureRefreshGesture = { [weak self] _ in
// self?.viewModel.send(event: .refreshData)
// }
}

// MARK: - Setup Table View Provider

func setupTableProvider() {
setupCell()
}

func setupCell() {

}

}

// MARK: - Combine

extension ___VARIABLE_ID___ViewController {

func bindState(reactor: ___VARIABLE_ID___ViewModel) {
reactor.state
.map { $0.dataFetchingState }
.removeDuplicates()
.sink { [weak self] state in
// Switch over data fetching states to handle
//
// switch state {
// case .idle:
// self?.showIdleState()
//
// case .loading:
// self?.showLoadingState()
//
// case .failure(let error):
// self?.showErrorState(error: error)
//
// case .empty:
// self?.showEmptyState()
// }
}
.store(in: &cancellables)

reactor.state
.map { $0.sections }
.removeDuplicates()
.sink { [weak self] sections in
guard let self = self else { return }
self.provider.bind(to: self.tableView, sections: sections)
}
.store(in: &cancellables)
}

func bindActions(reactor: ___VARIABLE_ID___ViewModel) {

}

}

// MARK: - Private

extension ___VARIABLE_ID___ViewController {

// Sample state handling functions
//
// func showIdleState() {
// tableView.refreshControl?.endCurrentRefreshing()
// }
//
// func showLoadingState() {
//
// }
//
// func showErrorState(error: AppError) {
// tableView.refreshControl?.endCurrentRefreshing()
// if viewModel.currentState.sections.isEmpty {
//
// } else {
//
// }
// }
//
// func showEmptyState() {
// tableView.refreshControl?.endCurrentRefreshing()
// }

}
Loading

0 comments on commit 57137f3

Please sign in to comment.