Commit 6b2e1f41 authored by Ivan Michaylovsky's avatar Ivan Michaylovsky
Browse files

Merge branch 'task/update_templates_shopotam' into 'master'

Task/update templates shopotam

See merge request ios-development/templates!12
No related merge requests found
Showing with 508 additions and 0 deletions
+508 -0
//
// {{ module_info.name }}DIPart.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import DITranquillity
extension DIHelper {
func {{ module_info.name | downcase }}View() -> {{ module_info.name }}View {
return self.container.resolve(
arguments: AnyArguments(
for: {{ module_info.name }}Presenter.self,
args: nil
)
)
}
}
\ No newline at end of file
//
// {{ module_info.name }}DIPart.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import Foundation
import DITranquillity
final class {{ module_info.name }}DIPart: DIPart {
static func load(container: DIContainer) {
container.register({{ module_info.name }}UseCasesImpl.init)
.as({{ module_info.name }}UseCases.self)
.lifetime(.prototype)
container.register({{ module_info.name }}RouterImpl.init)
.as({{ module_info.name }}Router.self)
container.register({{ module_info.name }}PresenterImpl.init)
.injection(cycle: false, \.view)
.injection(cycle: true, \.router)
.injection(cycle: true, \.useCases)
.as({{ module_info.name }}Presenter.self)
.lifetime(.objectGraph)
container.register { {{ module_info.name }}ViewController() }
.injection(cycle: true, \.presenter)
.as({{ module_info.name }}View.self)
.lifetime(.objectGraph)
}
}
extension DIModules {
@objc
func loadModule{{ module_info.name }}DIPart() {
self.parts.append({{ module_info.name }}DIPart.self)
}
}
//
// {{ module_info.name }}Data.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import Foundation
// MARK: - {{ module_info.name }}Data
final class {{ module_info.name }}Data {
}
//
// {{ module_info.name }}Presenter.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import Foundation
import SQExtensions
// MARK: - {{ module_info.name }}Presenter
protocol {{ module_info.name }}Presenter: BasePresenter {
}
// MARK: - {{ module_info.name }}PresenterImpl
final class {{ module_info.name }}PresenterImpl: BasePresenterImpl {
// MARK: - VUPER
weak var view: {{ module_info.name }}View?
var router: {{ module_info.name }}Router?
var useCases: {{ module_info.name }}UseCases?
// MARK: - Data
private var data = {{ module_info.name }}Data()
// MARK: - Life cycle
override func viewDidLoad() {
super.viewDidLoad()
}
}
// MARK: - {{ module_info.name }}Presenter
extension {{ module_info.name }}PresenterImpl: {{ module_info.name }}Presenter {
}
\ No newline at end of file
//
// {{ module_info.name }}UseCases.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import Foundation
// MARK: - {{ module_info.name }}UseCases
protocol {{ module_info.name }}UseCases {
}
// MARK: - {{ module_info.name }}UseCasesImpl
struct {{ module_info.name }}UseCasesImpl: {{ module_info.name }}UseCases {
}
//
// {{ module_info.name }}Router.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import UIKit
// MARK: - {{ module_info.name }}Router
protocol {{ module_info.name }}Router: BaseRouter {
}
// MARK: - {{ module_info.name }}RouterImpl
final class {{ module_info.name }}RouterImpl: BaseRouterImpl {
// MARK: - VUPER
weak var view: {{ module_info.name }}View?
// MARK: - Init
required init(view: {{ module_info.name }}View) {
self.view = view
}
}
// MARK: - {{ module_info.name }}Router
extension {{ module_info.name }}RouterImpl: {{ module_info.name }}Router {
}
\ No newline at end of file
# Template information section
name: "CollectionModule"
summary: "Basic collection module for application"
author: "Sequenia"
version: "1.0.0"
# The declarations for code files
code_files:
# View layer
- {name: View/Controller/ViewController.swift, path: View/Controller/ViewController.swift.liquid}
- {name: View/Controller/ViewController+Delegates.swift, path: View/Controller/ViewController+Delegates.swift.liquid}
- {name: View/Controller/ViewController+Sections.swift, path: View/Controller/ViewController+Sections.swift.liquid}
- {name: View/Layout/Cells}
- {name: View/Layout/Factory.swift, path: View/Layout/Factory.swift.liquid}
- {name: View/Layout/Section.swift, path: View/Layout/Section.swift.liquid}
- {name: View/Layout/LayoutManager.swift, path: View/Layout/LayoutManager.swift.liquid}
# Presenter layer
- {name: Presenter/Presenter.swift, path: Presenter/Presenter.swift.liquid}
- {name: Presenter/Data.swift, path: Presenter/Data.swift.liquid}
- {name: Presenter/UseCases.swift, path: Presenter/UseCases.swift.liquid}
# Router layer
- {name: Router/Router.swift, path: Router/Router.swift.liquid}
# DIPart
- {name: DIPart.swift, path: DIPart.swift.liquid}
# DIHelper
- {name: DIHelper.swift, path: DIHelper.swift.liquid}
\ No newline at end of file
//
// {{ module_info.name }}ViewController+Delegates.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import UIKit
import SQUIKit
import SQEntities
// MARK: - {{ module_info.name }}LayoutManagerDelegate
extension {{ module_info.name }}ViewController: {{ module_info.name }}LayoutManagerDelegate {
func sectionType(forSection section: Int) -> {{ module_info.name }}Section? {
self.sections[safe: section]?.content as? {{ module_info.name }}Section
}
}
// MARK: - CustomizableLayoutDelegate
extension {{ module_info.name }}ViewController: CustomizableLayoutDelegate {
func uiSettings(for indexPath: IndexPath) -> UISettings? {
.init(backgroundColor: .clear)
}
}
\ No newline at end of file
//
// {{ module_info.name }}ViewController+Sections.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import SQCompositionLists
// MARK: - Create Sections Methods
extension {{ module_info.name }}ViewController {
}
\ No newline at end of file
//
// {{ module_info.name }}View.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import UIKit
import SQCompositionLists
import SQExtensions
import SQUIKit
import SnapKit
protocol {{ module_info.name }}View: BaseView {
@MainActor
func show(data: {{ module_info.name }}Data)
@MainActor
func show(data: {{ module_info.name }}Data, animated: Bool)
}
final class {{ module_info.name }}ViewController: BaseListViewController {
// MARK: - VUPER
var presenter: {{ module_info.name }}Presenter?
// MARK: - Layout
private lazy var layoutManager = {{ module_info.name }}LayoutManager(delegate: self)
// MARK: - Life cycle
override func loadView() {
super.loadView()
self.configure()
self.setupLayout()
}
override func viewDidLoad() {
super.viewDidLoad()
self.presenter?.viewDidLoad()
}
// MARK: - Configure collection
override func createCollectionViewLayout() -> UICollectionViewLayout {
self.layoutManager.createLayout(layoutDelegate: self)
}
override func setupCollectionView() {
}
override func setupFabric() {
self.factory = {{ module_info.name }}Factory(collectionView: self.collectionView, parent: self)
}
}
// MARK: - SQConfigurableView
extension {{ module_info.name }}ViewController: SQConfigurableView {
func configure() {
}
func setupLayout() {
self.view.addSubview(self.collectionView)
self.collectionView.snp.makeConstraints {
$0.top.equalToSuperview()
$0.bottom.equalToSuperview()
$0.left.equalToSuperview()
$0.right.equalToSuperview()
}
}
}
// MARK: - {{ module_info.name }}View
extension {{ module_info.name }}ViewController: {{ module_info.name }}View {
func show(data: {{ module_info.name }}Data) {
self.show(data: data, animated: true)
}
func show(data: {{ module_info.name }}Data, animated: Bool) {
let sectionsContent: [SQSectionContent] = [
]
self.reloadData(
withSectionsContent: sectionsContent,
animated: animated
)
}
}
//
// {{ module_info.name }}Factory.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import UIKit
import SQExtensions
import SQCompositionLists
final class {{ module_info.name }}Factory {
weak var collectionView: UICollectionView?
weak var parent: AnyObject?
convenience init() {
fatalError("Unable to implement")
}
required init(collectionView: UICollectionView, parent: AnyObject?) {
self.collectionView = collectionView
self.parent = parent
self.registerElements()
}
}
// MARK: - SQListFactory
extension {{ module_info.name }}Factory: SQListFactory {
func registerElements() {
}
func cell(
forItemModel itemModel: AnyHashable,
inSection section: SQSectionContent?,
atIndexPath indexPath: IndexPath
) -> UICollectionViewCell? {
guard let collectionView else { return nil }
switch itemModel {
default:
return nil
}
}
}
\ No newline at end of file
//
// {{ module_info.name }}LayoutManager.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import UIKit
import SQExtensions
import SQCompositionLists
import SQUIKit
protocol {{ module_info.name }}LayoutManagerDelegate: AnyObject {
func sectionType(forSection section: Int) -> {{ module_info.name }}Section?
}
final class {{ module_info.name }}LayoutManager {
private weak var delegate: {{ module_info.name }}LayoutManagerDelegate!
init(delegate: {{ module_info.name }}LayoutManagerDelegate) {
self.delegate = delegate
}
func createLayout(
layoutDelegate: CustomizableLayoutDelegate?
) -> CustomizableLayout {
let layoutConfig = UICollectionViewCompositionalLayoutConfiguration()
let collectionViewLayout = CustomizableLayout(
sectionProvider: { index, _ in
let section = self.delegate.sectionType(forSection: index)
let sectionLayout = self.layoutGroup(forSection: section)
let backgroundDecoration = NSCollectionLayoutDecorationItem.background(
elementKind: .backgroundElementKind
)
backgroundDecoration.zIndex = -1
sectionLayout.decorationItems = [
backgroundDecoration
]
if section?.header != nil {
let header = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: .init(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(44)
),
elementKind: .collectionSectionHeader,
alignment: .top
)
header.pinToVisibleBounds = true
sectionLayout.boundarySupplementaryItems.append(header)
}
if section?.footer != nil {
let footer = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: .init(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(44)
),
elementKind: .collectionSectionFooter,
alignment: .bottom
)
sectionLayout.boundarySupplementaryItems.append(footer)
}
return sectionLayout
},
configuration: layoutConfig
)
collectionViewLayout.delegate = layoutDelegate
return collectionViewLayout
}
private func layoutGroup(forSection section: {{ module_info.name }}Section?) -> NSCollectionLayoutSection {
return .createPlainLayoutSection()
}
}
//
// {{ module_info.name }}Section.swift
// {{ module_info.project_name }}
//
// Created by {{ developer.name }} on {{ date }}.
// Copyright {{ year }} {{ developer.company }}. All rights reserved.
//
import Foundation
import SQCompositionLists
enum {{ module_info.name }}SectionType: String {
case section
}
struct {{ module_info.name }}Section: SQSectionContent {
let type: {{ module_info.name }}SectionType
var id: String {
self.type.rawValue
}
var items: [AnyHashable]
var header: AnyHashable?
var footer: AnyHashable?
init(
type: {{ module_info.name }}SectionType,
items: [AnyHashable],
header: AnyHashable? = nil,
footer: AnyHashable? = nil
) {
self.type = type
self.items = items
self.header = header
self.footer = footer
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment