Skip to content

Commit

Permalink
Merge pull request #9 from emadhegab/develop
Browse files Browse the repository at this point in the history
v1.1
  • Loading branch information
emadhegab committed Oct 2, 2019
2 parents 4692bb1 + 909713e commit e675601
Show file tree
Hide file tree
Showing 260 changed files with 2,553 additions and 20,641 deletions.
Binary file added .DS_Store
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
language: objective-c
osx_image: xcode9
osx_image: xcode10.2
env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
- WORKSPACE=MHNetwork.xcworkspace
- LANG=en_US.UTF-8
- IOS_FRAMEWORK_SCHEME="MHNetwork"
- SCHEME="MHNetwork"
- TEST_SCHEME="MHNetworkTests"
- IOS_SDK=iphonesimulator11.0
- EXAMPLE_SCHEME="QuoteAppExample"
- TEST_SCHEME="MHNetwork"
- IOS_SDK=iphonesimulator12.2
- EXAMPLE_SCHEME="ExampleApp"
matrix:
- DESTINATION="OS=11.0,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="YES" COVERAGE="YES"
- DESTINATION="OS=10.0,name=iPhone 6s Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" COVERAGE="NO"
- DESTINATION="OS=11.0,name=iPhone 7" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" COVERAGE="NO"
- DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" COVERAGE="NO"
- DESTINATION="OS=12.2,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="YES" COVERAGE="YES"
script:
- set -o pipefail
- xcodebuild -version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// AppDelegate.swift
// QuoteApp
// ExampleApp
//
// Created by Mohamed Emad Abdalla Hegab on 17.07.18.
// Copyright © 2018 Mohamed Hegab. All rights reserved.
// Created by Mohamed Emad Abdalla Hegab on 7/19/19.
// Copyright © 2019 Mohamed Hegab. All rights reserved.
//

import UIKit
Expand All @@ -13,9 +13,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

let router = Container.shared.createBaseRouter()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.tintColor = UIColor.mainColor
router.route()
return true
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<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">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
Expand Down
14 changes: 14 additions & 0 deletions ExampleApp/Classes/Features/Bases/BaseDatasources.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// BaseDatasources.swift
// TypiCodeUsers
//
// Created by Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

import UIKit

protocol BaseTableDataSource: class, UITableViewDelegate, UITableViewDataSource {
associatedtype ItemType
var items: [ItemType] { get set }
}
30 changes: 30 additions & 0 deletions ExampleApp/Classes/Features/Bases/BaseRouter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// BaseRouter.swift
// TypiCodeUsers
//
// Created by Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

import UIKit


protocol BaseRouter {
func route()
}
class DefaultBaseRouter: BaseRouter {

func route() {

guard let rootVC = UIApplication.shared.delegate?.window??.rootViewController else {

UIApplication.shared.delegate?.window??.makeKeyAndVisible()
UIApplication.shared.delegate?.window??.rootViewController =
UINavigationController(rootViewController: UserRouter.createModule())

return
}

UserRouter.route(from: rootVC, animated: false)
}
}
17 changes: 17 additions & 0 deletions ExampleApp/Classes/Features/Posts/Datasources/Cells/PostCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// PostCell.swift
// TypiCodeUsers
//
// Created by Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

import UIKit

class PostCell: UITableViewCell {

@IBOutlet weak var titleLabel: UILabel!

@IBOutlet weak var bodyLabel: UILabel!

}
52 changes: 52 additions & 0 deletions ExampleApp/Classes/Features/Posts/Datasources/Cells/PostCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="166" id="KGk-i7-Jjw" customClass="PostCell" customModule="TypiCodeUsers" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="558" height="166"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="558" height="165.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tSf-Yx-IC3">
<rect key="frame" x="20" y="25" width="518" height="33.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="28"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y2K-9X-CpZ">
<rect key="frame" x="20" y="68.5" width="518" height="86.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="Y2K-9X-CpZ" firstAttribute="trailing" secondItem="H2p-sc-9uM" secondAttribute="trailingMargin" id="5sn-CA-Ked"/>
<constraint firstItem="tSf-Yx-IC3" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="M32-R4-HPv"/>
<constraint firstItem="Y2K-9X-CpZ" firstAttribute="bottom" secondItem="H2p-sc-9uM" secondAttribute="bottomMargin" id="Qcr-zr-XjI"/>
<constraint firstItem="tSf-Yx-IC3" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="14" id="eg2-el-qFZ"/>
<constraint firstAttribute="trailingMargin" secondItem="tSf-Yx-IC3" secondAttribute="trailing" id="hih-VI-6pk"/>
<constraint firstItem="Y2K-9X-CpZ" firstAttribute="top" secondItem="tSf-Yx-IC3" secondAttribute="bottom" constant="10" id="jAX-OP-JSc"/>
<constraint firstItem="Y2K-9X-CpZ" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="oyS-gU-XJt"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="bodyLabel" destination="Y2K-9X-CpZ" id="H8z-QX-8Mn"/>
<outlet property="titleLabel" destination="tSf-Yx-IC3" id="Hub-q3-9HE"/>
</connections>
<point key="canvasLocation" x="238.40000000000001" y="148.42578710644679"/>
</tableViewCell>
</objects>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// PostsDatasources.swift
// TypiCodeUsers
//
// Created by Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

import UIKit

class PostDatasources: NSObject, BaseTableDataSource {

var items: [Post] = []

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: PostCell.reuseId) as? PostCell else { return UITableViewCell(frame: CGRect.zero) }
let post = self[indexPath]
cell.titleLabel.text = post.title
cell.bodyLabel.text = post.body
return cell
}
}


extension PostDatasources {
subscript(indexPath: IndexPath) -> Post {
return items[indexPath.row]
}
}
14 changes: 14 additions & 0 deletions ExampleApp/Classes/Features/Posts/Entities/Post.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Post.swift
// TypiCodeUsers
//
// Created by Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

import Foundation

struct Post: Codable {
let title: String
let body: String
}
25 changes: 25 additions & 0 deletions ExampleApp/Classes/Features/Posts/PostInteractor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// PostInteractor.swift
// TypiCodeUsers
//
// Created Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

class PostInteractor: PostInteractorProtocol {

weak var presenter: PostPresenterProtocol?
func getPosts(userId: String, onCompletion: @escaping ([Post]) -> Void, onError: @escaping (NetworkError) -> Void) {
let dispatcher = Container.shared.createNetworkDispatcher()
let getPostsTask = GetPostsTasks<[Post]>(userId: userId)

getPostsTask.execute(in: dispatcher) { (result) in
switch result {
case .success(let posts):
onCompletion(posts)
case .failure(let error):
onError(error)
}
}
}
}
32 changes: 32 additions & 0 deletions ExampleApp/Classes/Features/Posts/PostPresenter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// PostPresenter.swift
// TypiCodeUsers
//
// Created Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//


import UIKit

class PostPresenter: PostPresenterProtocol {

weak private var view: PostViewProtocol?
var interactor: PostInteractorProtocol?

init(interface: PostViewProtocol, interactor: PostInteractorProtocol?) {
self.view = interface
self.interactor = interactor
}

func getPosts(userId: String) {
interactor?.getPosts(userId: userId, onCompletion: { (posts) in
DispatchQueue.main.async { [weak self] in
self?.view?.reloadData(posts: posts)
}
}, onError: { (error) in
print(error)
})
}

}
26 changes: 26 additions & 0 deletions ExampleApp/Classes/Features/Posts/PostProtocols.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// PostProtocols.swift
// TypiCodeUsers
//
// Created Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//

//MARK: Presenter -
protocol PostPresenterProtocol: class {
func getPosts(userId: String)
}

//MARK: Interactor -
protocol PostInteractorProtocol: class {

var presenter: PostPresenterProtocol? { get set }
func getPosts(userId: String, onCompletion: @escaping ([Post]) -> Void, onError: @escaping (NetworkError) -> Void)
}

//MARK: View -
protocol PostViewProtocol: class {

var presenter: PostPresenterProtocol? { get set }
func reloadData(posts: [Post])
}
32 changes: 32 additions & 0 deletions ExampleApp/Classes/Features/Posts/PostRouter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// PostRouter.swift
// TypiCodeUsers
//
// Created Mohamed Hegab on 10/29/18.
// Copyright © 2019 MHNetwork All rights reserved.
//


import UIKit

class PostRouter {

weak var viewController: UIViewController?

static func createModule(userId: String) -> UIViewController {
let view = PostViewController(userId: userId)
let interactor = PostInteractor()
let router = PostRouter()
let presenter = PostPresenter(interface: view, interactor: interactor)

view.presenter = presenter
interactor.presenter = presenter
router.viewController = view

return view
}

static func route(userId: String, from: UIViewController, animated: Bool) {
from.navigationController?.pushViewController(createModule(userId: userId), animated: animated)
}
}

0 comments on commit e675601

Please sign in to comment.