Skip to content

Commit

Permalink
Merge pull request #21 from infinum/feature/v3
Browse files Browse the repository at this point in the history
Version 3 - generator of templates
  • Loading branch information
fgulan authored Apr 25, 2019
2 parents e8ef869 + 4114846 commit 4a0eb98
Show file tree
Hide file tree
Showing 141 changed files with 3,615 additions and 369 deletions.
46 changes: 0 additions & 46 deletions Base VIPER Interfaces V1/BaseWireframe.swift

This file was deleted.

31 changes: 0 additions & 31 deletions Base VIPER Interfaces V1/PresenterInterface.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Base VIPER Interfaces V2/InteractorInterface.swift

This file was deleted.

31 changes: 0 additions & 31 deletions Base VIPER Interfaces V2/PresenterInterface.swift

This file was deleted.

10 changes: 0 additions & 10 deletions Base VIPER Interfaces V2/UIStoryboardExtension.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Base VIPER Interfaces V2/ViewInterface.swift

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions Base VIPER Interfaces/FormatterInterface.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
protocol FormatterInterface: class {
}

extension FormatterInterface {
}
File renamed without changes.
5 changes: 5 additions & 0 deletions Base VIPER Interfaces/PresenterInterface.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
protocol PresenterInterface: class {
}

extension PresenterInterface {
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
XCODE_USER_TEMPLATES_DIR=~/Library/Developer/Xcode/Templates/File\ Templates
VIPER_TEMPLATES_DIR=VIPER\ Templates
VIPER_TEMPLATES_DIR=Templates/VIPER\ Templates

install_templates:
rm -R -f $(XCODE_USER_TEMPLATES_DIR)/$(VIPER_TEMPLATES_DIR)
mkdir -p $(XCODE_USER_TEMPLATES_DIR)
cp -R -f $(VIPER_TEMPLATES_DIR) $(XCODE_USER_TEMPLATES_DIR)

uninstall_templates:
rm -R $(XCODE_USER_TEMPLATES_DIR)/$(VIPER_TEMPLATES_DIR)
rm -R $(XCODE_USER_TEMPLATES_DIR)/$(VIPER_TEMPLATES_DIR)
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
![iOS VIPER](/Images/ios_viper_logo.png "iOS VIPER")

# Versions
Latest version is v2. You can still use initial v1 of the VIPER templates generator. v2 has breaking changes in base VIPER methods related to wireframe setup and navigation and is recommended to use it if starting a new project. It's not backwards compatible with v1.
Latest version is v3.
You can find older versions in [version/2.0 branch](https://github.com/infinum/iOS-VIPER-Xcode-Templates/tree/version/2.0).

# Installation instructions

Expand Down Expand Up @@ -31,8 +32,9 @@ Let's go over the basics quickly - the main components of VIPER are as follows:

* **View**: contains UI logic and knows how to layout and animate itself. It displays what it's _told_ by the Presenter and it _delegates_ user interaction actions to the Presenter. Ideally it contains no business logic, only view logic.
* **Interactor**: used for fetching data when requested by the Presenter, regardless of where the data is coming from. Contains only business logic.
* **Presenter**: prepares the content which it receives from the Interactor to be presented by the View. Contains business and view logic - basically it connects the two.
* **Presenter**: also known as the event handler. Handles all the communication with view, interactor and wireframe. Contains presentation logic - basically it controllers the module.
* **Entity**: models which are handled by the Interactor. Contains only business logic, but primarily data, not rules.
* **Formatter**(new): handles formatting logic. Sits between presenter and the view. It formats the data from the business world into something that can be consumed by the view.
* **Router**: handles navigation logic. In our case we use components called Wireframes for this responsibility.

## Components
Expand All @@ -43,6 +45,7 @@ Module components:
* **View**
* **Presenter**
* **Interactor** (not mandatory)
* **Formatter** (not mandatory)
* **Wireframe**

In some simpler cases you won't need an Interactor for a certain module, which is why this component is not mandatory. These are cases where you don't need to fetch any data, which is usually not common.
Expand Down
81 changes: 81 additions & 0 deletions Templates/Resources/TemplateInfo.plist.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DefaultCompletionName</key>
<string>VIPERModule</string>
<key>Description</key>
<string>This generates a new Module using 🐍VIPER generator.</string>
<key>Kind</key>
<string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string>
<key>Options</key>
<array>
<dict>
<key>Description</key>
<string>The name of the module to create</string>
<key>Default</key>
<string></string>
<key>Identifier</key>
<string>moduleName</string>
<key>Name</key>
<string>New <%= @template.name %> Name:</string>
<key>Required</key>
<string>YES</string>
<key>Type</key>
<string>text</string>
</dict>
<dict>
<key>Default</key>
<string>___VARIABLE_moduleName___</string>
<key>Identifier</key>
<string>productName</string>
<key>Type</key>
<string>static</string>
</dict>
<dict>
<key>Identifier</key>
<string>interface</string>
<key>Name</key>
<string>Generate Interface Builder:</string>
<key>Description</key>
<string>Which interface builder to generate</string>
<key>Type</key>
<string>popup</string>
<key>Default</key>
<string><%= @interface.default.name%></string>
<key>Values</key>
<array>
<%- @interface.types.each do |type| -%>
<string><%= type.name %></string>
<%- end -%>
</array>
</dict>
<dict>
<key>Identifier</key>
<string>complex</string>
<key>Name</key>
<string>Module Complexity:</string>
<key>Description</key>
<string>Type of a module to generate - simple, with interactor, or with interactor and formatter</string>
<key>Type</key>
<string>popup</string>
<key>Default</key>
<string><%= @complexity.default.name%></string>
<key>Values</key>
<array>
<%- @complexity.types.each do |type| -%>
<string><%= type.name %></string>
<%- end -%>
</array>
</dict>
</array>
<key>Platforms</key>
<array>
<string>com.apple.platform.iphoneos</string>
</array>
<key>SortOrder</key>
<string>1</string>
<key>Summary</key>
<string>This generates a new 🐍 VIPER module.</string>
</dict>
</plist>
29 changes: 29 additions & 0 deletions Templates/Resources/Templates/___FILEBASENAME___.storyboard.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--___VARIABLE_moduleName___ View Controller-->
<scene sceneID="XJ1-QA-Nrj">
<objects>
<viewController storyboardIdentifier="___VARIABLE_moduleName___ViewController" id="zIc-eW-6fX" customClass="___VARIABLE_moduleName___ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Z2g-4m-atm">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="3pi-N7-nbV"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rle-ol-2Ax" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="306" y="303"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
//
// This file was generated by the 🐍 VIPER generator
//

import UIKit
<% if @template.generate_io -%>
import RxSwift
import RxCocoa
<% end -%>

final class ___VARIABLE_moduleName___Formatter {
}

// MARK: - Extensions -

extension ___VARIABLE_moduleName___Formatter: ___VARIABLE_moduleName___FormatterInterface {
<%- if @template.generate_io -%>

func format(for input: ___VARIABLE_moduleName___.FormatterInput) -> ___VARIABLE_moduleName___.FormatterOutput {
return ___VARIABLE_moduleName___.FormatterOutput()
}

<%- end -%>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
//
// This file was generated by the 🐍 VIPER generator
//

import Foundation
<% if @template.generate_io -%>
import RxSwift
<% end -%>

final class ___VARIABLE_moduleName___Interactor {
}

// MARK: - Extensions -

extension ___VARIABLE_moduleName___Interactor: ___VARIABLE_moduleName___InteractorInterface {
}
Loading

0 comments on commit 4a0eb98

Please sign in to comment.