Skip to content

Commit 8334913

Browse files
author
Oleh
committed
Updated MVVMs templates
1 parent 724a315 commit 8334913

8 files changed

+208
-38
lines changed

MVVM Templates/MVVM/MVVM.xctemplate/TemplateInfo.plist

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<key>DefaultCompletionName</key>
66
<string>Scene</string>
77
<key>Description</key>
8-
<string>This generates a new scene using The MVVM-R architecture. It consists of the view controller, view model, router and storyboard.</string>
8+
<string>This generates a new scene using The MVVM architecture. It consists of the view controller, view model, router and storyboard.</string>
99
<key>Kind</key>
1010
<string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string>
1111
<key>Options</key>
@@ -60,20 +60,6 @@
6060
<key>Type</key>
6161
<string>static</string>
6262
</dict>
63-
<dict>
64-
<key>Default</key>
65-
<string>___VARIABLE_sceneIdentifier___Router</string>
66-
<key>Description</key>
67-
<string>The router name</string>
68-
<key>Identifier</key>
69-
<string>routerName</string>
70-
<key>Name</key>
71-
<string>Router Name:</string>
72-
<key>Required</key>
73-
<true/>
74-
<key>Type</key>
75-
<string>static</string>
76-
</dict>
7763
<dict>
7864
<key>Default</key>
7965
<string>___VARIABLE_sceneIdentifier___ViewController</string>
@@ -96,6 +82,6 @@
9682
<key>SortOrder</key>
9783
<string>9</string>
9884
<key>Summary</key>
99-
<string>This generates a new scene using MVVM-R architecture.</string>
85+
<string>This generates a new scene using MVVM architecture.</string>
10086
</dict>
10187
</plist>

MVVM Templates/MVVM/MVVM.xctemplate/___VARIABLE_sceneIdentifier___Router.swift

Lines changed: 0 additions & 17 deletions
This file was deleted.

MVVM Templates/MVVM/MVVM.xctemplate/___VARIABLE_sceneIdentifier___ViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class ___VARIABLE_sceneIdentifier___ViewController: UIViewController, Storyboard
1414

1515
class func create(with viewModel: ___VARIABLE_sceneIdentifier___ViewModel) -> ___VARIABLE_sceneIdentifier___ViewController {
1616
let view = ___VARIABLE_sceneIdentifier___ViewController.instantiateViewController()
17-
view.viewModel.router = Default___VARIABLE_sceneIdentifier___Router(view: view)
1817
return view
1918
}
2019

MVVM Templates/MVVM/MVVM.xctemplate/___VARIABLE_sceneIdentifier___ViewModel.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88

99
import Foundation
1010

11-
protocol ___VARIABLE_sceneIdentifier___Router {
12-
11+
protocol ___VARIABLE_sceneIdentifier___ViewModelInput {
12+
func viewDidLoad()
1313
}
1414

15-
class ___VARIABLE_sceneIdentifier___ViewModel {
15+
protocol ___VARIABLE_sceneIdentifier___ViewModelOutput {
1616

17-
var router: ___VARIABLE_sceneIdentifier___Router?
17+
}
18+
19+
protocol ___VARIABLE_sceneIdentifier___ViewModel: ___VARIABLE_sceneIdentifier___ViewModelInput, ___VARIABLE_sceneIdentifier___ViewModelOutput { }
20+
21+
class Default___VARIABLE_sceneIdentifier___ViewModel: ___VARIABLE_sceneIdentifier___ViewModel {
1822

1923
// MARK: - OUTPUT
24+
2025
}
2126

2227
// MARK: - INPUT. View event methods
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>DefaultCompletionName</key>
6+
<string>Scene</string>
7+
<key>Description</key>
8+
<string>This generates a new scene using The MVVMR architecture. It consists of the view controller, view model, router enum and storyboard.</string>
9+
<key>Kind</key>
10+
<string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string>
11+
<key>Options</key>
12+
<array>
13+
<dict>
14+
<key>Description</key>
15+
<string>The name of the scene to create</string>
16+
<key>Identifier</key>
17+
<string>sceneName</string>
18+
<key>Name</key>
19+
<string>New Scene Name:</string>
20+
<key>NotPersisted</key>
21+
<true/>
22+
<key>Required</key>
23+
<true/>
24+
<key>Type</key>
25+
<string>text</string>
26+
</dict>
27+
<dict>
28+
<key>Default</key>
29+
<string>___VARIABLE_sceneName:identifier___</string>
30+
<key>Identifier</key>
31+
<string>sceneIdentifier</string>
32+
<key>Type</key>
33+
<string>static</string>
34+
</dict>
35+
<dict>
36+
<key>Default</key>
37+
<string>___VARIABLE_sceneIdentifier___ViewController</string>
38+
<key>Description</key>
39+
<string>The view controller name</string>
40+
<key>Identifier</key>
41+
<string>viewControllerName</string>
42+
<key>Name</key>
43+
<string>View Controller Name:</string>
44+
<key>Required</key>
45+
<true/>
46+
<key>Type</key>
47+
<string>static</string>
48+
</dict>
49+
<dict>
50+
<key>Default</key>
51+
<string>___VARIABLE_sceneIdentifier___ViewModel</string>
52+
<key>Description</key>
53+
<string>The view model name</string>
54+
<key>Identifier</key>
55+
<string>viewModelName</string>
56+
<key>Name</key>
57+
<string>ViewModel Name:</string>
58+
<key>Required</key>
59+
<true/>
60+
<key>Type</key>
61+
<string>static</string>
62+
</dict>
63+
<dict>
64+
<key>Default</key>
65+
<string>___VARIABLE_sceneIdentifier___ViewController</string>
66+
<key>Description</key>
67+
<string>The storyboard name</string>
68+
<key>Identifier</key>
69+
<string>storyboardName</string>
70+
<key>Name</key>
71+
<string>Storyboard Name:</string>
72+
<key>Required</key>
73+
<true/>
74+
<key>Type</key>
75+
<string>static</string>
76+
</dict>
77+
</array>
78+
<key>Platforms</key>
79+
<array>
80+
<string>com.apple.platform.iphoneos</string>
81+
</array>
82+
<key>SortOrder</key>
83+
<string>9</string>
84+
<key>Summary</key>
85+
<string>This generates a new scene using MVVMR architecture.</string>
86+
</dict>
87+
</plist>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="mrg-aK-cPW">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<scenes>
11+
<!--scene Identifier View Controller-->
12+
<scene sceneID="wNu-vz-AgM">
13+
<objects>
14+
<viewController storyboardIdentifier="___VARIABLE_sceneIdentifier___ViewControllerID" useStoryboardIdentifierAsRestorationIdentifier="YES" id="mrg-aK-cPW" customClass="___VARIABLE_sceneIdentifier___ViewController" customModuleProvider="target" sceneMemberID="viewController">
15+
<layoutGuides>
16+
<viewControllerLayoutGuide type="top" id="lNf-Tp-JWb"/>
17+
<viewControllerLayoutGuide type="bottom" id="PXa-7e-hdt"/>
18+
</layoutGuides>
19+
<view key="view" contentMode="scaleToFill" id="xRA-Nz-89m">
20+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
21+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
22+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
23+
</view>
24+
<navigationItem key="navigationItem" id="fO7-ju-87H"/>
25+
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
26+
</viewController>
27+
<placeholder placeholderIdentifier="IBFirstResponder" id="SPs-1e-mb8" userLabel="First Responder" sceneMemberID="firstResponder"/>
28+
</objects>
29+
<point key="canvasLocation" x="905" y="152"/>
30+
</scene>
31+
</scenes>
32+
</document>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// ___FILENAME___
3+
// ___PROJECTNAME___
4+
//
5+
// Created by ___FULLUSERNAME___ on ___DATE___.
6+
// Copyright (c) ___YEAR___ sp. z o.o. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ___VARIABLE_sceneIdentifier___ViewController: UIViewController, StoryboardInstantiable {
12+
13+
var viewModel: ___VARIABLE_sceneIdentifier___ViewModel!
14+
15+
class func create(with viewModel: ___VARIABLE_sceneIdentifier___ViewModel) -> ___VARIABLE_sceneIdentifier___ViewController {
16+
let view = ___VARIABLE_sceneIdentifier___ViewController.instantiateViewController()
17+
return view
18+
}
19+
20+
override func viewDidLoad() {
21+
super.viewDidLoad()
22+
23+
bind(to: viewModel)
24+
viewModel.viewDidLoad()
25+
}
26+
27+
func bind(to viewModel: ___VARIABLE_sceneIdentifier___ViewModel) {
28+
29+
}
30+
}
31+
32+
// MARK: - Perform Routing
33+
34+
extension ___VARIABLE_sceneIdentifier___ViewController {
35+
func perform(_ route: ___VARIABLE_sceneIdentifier___ViewModelRoute?) {
36+
guard let route = route else { return }
37+
switch route {
38+
case .showDetails(let itemId):
39+
// present view
40+
break
41+
}
42+
}
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// ___FILENAME___
3+
// ___PROJECTNAME___
4+
//
5+
// Created by ___FULLUSERNAME___ on ___DATE___.
6+
// Copyright (c) ___YEAR___ All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
enum ___VARIABLE_sceneIdentifier___ViewModelRoute {
12+
case showDetails(itemId: String)
13+
}
14+
15+
protocol ___VARIABLE_sceneIdentifier___ViewModelInput {
16+
func viewDidLoad()
17+
}
18+
19+
protocol ___VARIABLE_sceneIdentifier___ViewModelOutput {
20+
21+
}
22+
23+
protocol ___VARIABLE_sceneIdentifier___ViewModel: ___VARIABLE_sceneIdentifier___ViewModelInput, ___VARIABLE_sceneIdentifier___ViewModelOutput { }
24+
25+
class Default___VARIABLE_sceneIdentifier___ViewModel: ___VARIABLE_sceneIdentifier___ViewModel {
26+
27+
// MARK: - OUTPUT
28+
private(set) var route: Observable<___VARIABLE_sceneIdentifier___ViewModelRoute?> = Observable(nil)
29+
}
30+
31+
// MARK: - INPUT. View event methods
32+
extension ___VARIABLE_sceneIdentifier___ViewModel {
33+
func viewDidLoad() {
34+
}
35+
}

0 commit comments

Comments
 (0)