Skip to content

Commit 9865d6a

Browse files
committed
MVC, MVVM, Clean Swift
Add Files
1 parent 1570bc4 commit 9865d6a

File tree

62 files changed

+3666
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3666
-0
lines changed

CleanSwift/AppDelegate.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// AppDelegate.swift
3+
// CleanSwift
4+
//
5+
// Created by Mohammad Tahir on 11/07/19.
6+
// Copyright © 2019 iOSMaster. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
16+
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18+
// Override point for customization after application launch.
19+
return true
20+
}
21+
}
22+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "3x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "40x40",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "3x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "60x60",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "60x60",
41+
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"size" : "29x29",
56+
"scale" : "1x"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"size" : "29x29",
61+
"scale" : "2x"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"size" : "40x40",
66+
"scale" : "1x"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"size" : "40x40",
71+
"scale" : "2x"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"size" : "76x76",
76+
"scale" : "1x"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"size" : "76x76",
81+
"scale" : "2x"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"size" : "83.5x83.5",
86+
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
92+
}
93+
],
94+
"info" : {
95+
"version" : 1,
96+
"author" : "xcode"
97+
}
98+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Zry-1w-0Ab">
3+
<device id="retina6_1" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
9+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11+
</dependencies>
12+
<scenes>
13+
<!--Home View Controller-->
14+
<scene sceneID="k6k-Cf-pJ3">
15+
<objects>
16+
<viewController id="DCQ-Zf-mJy" customClass="HomeViewController" customModule="CleanSwift" customModuleProvider="target" sceneMemberID="viewController">
17+
<view key="view" contentMode="scaleToFill" id="zaN-dq-OfV">
18+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
19+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20+
<subviews>
21+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GHN-xg-tdc">
22+
<rect key="frame" x="168" y="433" width="78" height="30"/>
23+
<state key="normal" title="Clean Swift"/>
24+
<connections>
25+
<action selector="pushToUserList:" destination="DCQ-Zf-mJy" eventType="touchUpInside" id="dV8-B7-mkI"/>
26+
</connections>
27+
</button>
28+
</subviews>
29+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
30+
<constraints>
31+
<constraint firstItem="GHN-xg-tdc" firstAttribute="centerY" secondItem="zaN-dq-OfV" secondAttribute="centerY" id="G8L-Dd-sNE"/>
32+
<constraint firstItem="GHN-xg-tdc" firstAttribute="centerX" secondItem="zaN-dq-OfV" secondAttribute="centerX" id="NMp-eO-DGr"/>
33+
</constraints>
34+
<viewLayoutGuide key="safeArea" id="JJZ-oc-lX7"/>
35+
</view>
36+
<navigationItem key="navigationItem" id="Xtp-gh-vBe"/>
37+
</viewController>
38+
<placeholder placeholderIdentifier="IBFirstResponder" id="hg3-xC-7tZ" sceneMemberID="firstResponder"/>
39+
</objects>
40+
<point key="canvasLocation" x="783" y="280"/>
41+
</scene>
42+
<!--User List View Controller-->
43+
<scene sceneID="uMZ-zI-5rL">
44+
<objects>
45+
<viewController storyboardIdentifier="UserListViewController" id="wlA-BJ-Wu0" customClass="UserListViewController" customModule="CleanSwift" customModuleProvider="target" sceneMemberID="viewController">
46+
<view key="view" contentMode="scaleToFill" id="gT9-sb-yn0">
47+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
48+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
49+
<subviews>
50+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="DSE-rr-Ffj">
51+
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
52+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
53+
<inset key="separatorInset" minX="15" minY="0.0" maxX="15" maxY="0.0"/>
54+
<prototypes>
55+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CellUserList" rowHeight="68" id="Rd0-zu-Qca" customClass="CellUserList" customModule="CleanSwift" customModuleProvider="target">
56+
<rect key="frame" x="0.0" y="28" width="414" height="68"/>
57+
<autoresizingMask key="autoresizingMask"/>
58+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Rd0-zu-Qca" id="wG1-1d-z5w">
59+
<rect key="frame" x="0.0" y="0.0" width="414" height="67.5"/>
60+
<autoresizingMask key="autoresizingMask"/>
61+
<subviews>
62+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rDD-Ej-lmU">
63+
<rect key="frame" x="16" y="5" width="382" height="57.5"/>
64+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
65+
<nil key="textColor"/>
66+
<nil key="highlightedColor"/>
67+
</label>
68+
</subviews>
69+
<constraints>
70+
<constraint firstAttribute="trailing" secondItem="rDD-Ej-lmU" secondAttribute="trailing" constant="16" id="4Bu-iE-pJM"/>
71+
<constraint firstAttribute="bottom" secondItem="rDD-Ej-lmU" secondAttribute="bottom" constant="5" id="9OM-gQ-e5M"/>
72+
<constraint firstItem="rDD-Ej-lmU" firstAttribute="top" secondItem="wG1-1d-z5w" secondAttribute="top" constant="5" id="aJD-fw-XqQ"/>
73+
<constraint firstItem="rDD-Ej-lmU" firstAttribute="leading" secondItem="wG1-1d-z5w" secondAttribute="leading" constant="16" id="gZf-nm-uhm"/>
74+
</constraints>
75+
</tableViewCellContentView>
76+
<connections>
77+
<outlet property="titleLabel" destination="rDD-Ej-lmU" id="nAM-rn-upz"/>
78+
</connections>
79+
</tableViewCell>
80+
</prototypes>
81+
</tableView>
82+
</subviews>
83+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
84+
<constraints>
85+
<constraint firstItem="DSE-rr-Ffj" firstAttribute="bottom" secondItem="BvV-G6-p2z" secondAttribute="bottom" id="Q8S-pe-kCA"/>
86+
<constraint firstItem="DSE-rr-Ffj" firstAttribute="top" secondItem="BvV-G6-p2z" secondAttribute="top" id="SOV-wp-Y5u"/>
87+
<constraint firstItem="DSE-rr-Ffj" firstAttribute="trailing" secondItem="BvV-G6-p2z" secondAttribute="trailing" id="akC-IR-kq5"/>
88+
<constraint firstItem="DSE-rr-Ffj" firstAttribute="leading" secondItem="BvV-G6-p2z" secondAttribute="leading" id="hzG-WP-O1E"/>
89+
</constraints>
90+
<viewLayoutGuide key="safeArea" id="BvV-G6-p2z"/>
91+
</view>
92+
<connections>
93+
<outlet property="userListTableView" destination="DSE-rr-Ffj" id="zVm-S7-N8c"/>
94+
</connections>
95+
</viewController>
96+
<placeholder placeholderIdentifier="IBFirstResponder" id="FwT-35-FyS" userLabel="First Responder" sceneMemberID="firstResponder"/>
97+
</objects>
98+
<point key="canvasLocation" x="1408.8" y="279.31034482758622"/>
99+
</scene>
100+
<!--Navigation Controller-->
101+
<scene sceneID="lAF-zK-kWe">
102+
<objects>
103+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Zry-1w-0Ab" sceneMemberID="viewController">
104+
<toolbarItems/>
105+
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="v1g-qP-Cc9">
106+
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
107+
<autoresizingMask key="autoresizingMask"/>
108+
</navigationBar>
109+
<nil name="viewControllers"/>
110+
<connections>
111+
<segue destination="DCQ-Zf-mJy" kind="relationship" relationship="rootViewController" id="8dG-Uh-gXB"/>
112+
</connections>
113+
</navigationController>
114+
<placeholder placeholderIdentifier="IBFirstResponder" id="xqR-oT-Lye" userLabel="First Responder" sceneMemberID="firstResponder"/>
115+
</objects>
116+
<point key="canvasLocation" x="166" y="281"/>
117+
</scene>
118+
</scenes>
119+
</document>

CleanSwift/CellUserList.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CellUserList.swift
3+
// MVC
4+
//
5+
// Created by Mohammad Tahir on 11/07/19.
6+
// Copyright © 2019 iOSMaster. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class CellUserList: UITableViewCell {
12+
13+
@IBOutlet weak private var titleLabel: UILabel!
14+
15+
var user: UserListModels.UserList? {
16+
didSet {
17+
if let user = user {
18+
self.titleLabel.text = user.name
19+
}
20+
}
21+
}
22+
23+
override func awakeFromNib() {
24+
super.awakeFromNib()
25+
// Initialization code
26+
}
27+
28+
override func setSelected(_ selected: Bool, animated: Bool) {
29+
super.setSelected(selected, animated: animated)
30+
31+
// Configure the view for the selected state
32+
}
33+
34+
}

CleanSwift/HomeRouter.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// HomeRouter.swift
3+
// CleanSwift
4+
//
5+
// Created by Mohammad Tahir on 12/07/19.
6+
// Copyright © 2019 iOSMaster. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
struct HomeRouter {
12+
13+
private var viewController: UIViewController!
14+
15+
init(viewController: UIViewController) {
16+
17+
self.viewController = viewController
18+
}
19+
}
20+
21+
// MARK: - HomeRoutable -
22+
23+
extension HomeRouter: HomeRoutable {
24+
25+
func pushToUserListViewController() {
26+
let userListViewController = UIStoryboard.init(name: "User", bundle: .main).instantiateViewController(withIdentifier: "UserListViewController")
27+
self.viewController.navigationController?.pushViewController(userListViewController, animated: true)
28+
}
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// HomeStoreInterface.swift
3+
// CleanSwift
4+
//
5+
// Created by Mohammad Tahir on 12/07/19.
6+
// Copyright © 2019 iOSMaster. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
protocol HomeRoutable { // Router
12+
func pushToUserListViewController()
13+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// ViewController.swift
3+
// CleanSwift
4+
//
5+
// Created by Mohammad Tahir on 11/07/19.
6+
// Copyright © 2019 iOSMaster. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class HomeViewController: UIViewController {
12+
13+
// MARK: Router
14+
15+
lazy var router: HomeRoutable = HomeRouter(
16+
viewController: self
17+
)
18+
19+
// MARK: - ViewLife Cycle
20+
override func viewDidLoad() {
21+
super.viewDidLoad()
22+
// Do any additional setup after loading the view.
23+
}
24+
25+
26+
@IBAction func pushToUserList(_ sender: UIButton) {
27+
28+
self.router.pushToUserListViewController()
29+
}
30+
}
31+

0 commit comments

Comments
 (0)