-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,034 additions
and
11 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+5.5 KB
(100%)
RM Client.xcworkspace/xcuserdata/yazantarifi.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// RmPropsUseCase.swift | ||
// RM Client | ||
// | ||
// Created by Yazan Tarifi on 05/09/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
public class RmPropsUseCase<Props, Result>: RmUseCase<Result> { | ||
public func onExecute(props: Props) { | ||
// Child Class will Fill This | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 56 additions & 6 deletions
62
RM Client/Features/Character/CharacterScreenViewController.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,72 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> | ||
<device id="retina6_12" orientation="portrait" appearance="light"/> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="System colors in document resources" minToolsVersion="11.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CharacterScreenViewController" customModuleProvider="target"> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CharacterScreenViewController" customModule="RM_Client" customModuleProvider="target"> | ||
<connections> | ||
<outlet property="loadingView" destination="aAH-7T-1qP" id="LNJ-Rp-BQa"/> | ||
<outlet property="otherNavigationCollectionView" destination="7ue-JW-yFO" id="daz-qn-Le3"/> | ||
<outlet property="screenContentCollectionView" destination="elx-8c-3DB" id="xkC-bW-Mke"/> | ||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> | ||
</connections> | ||
</placeholder> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
<subviews> | ||
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="elx-8c-3DB"> | ||
<rect key="frame" x="10" y="69" width="373" height="712"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="SIi-KU-B3e"> | ||
<size key="itemSize" width="128" height="128"/> | ||
<size key="headerReferenceSize" width="0.0" height="0.0"/> | ||
<size key="footerReferenceSize" width="0.0" height="0.0"/> | ||
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> | ||
</collectionViewFlowLayout> | ||
</collectionView> | ||
<collectionView hidden="YES" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="7ue-JW-yFO"> | ||
<rect key="frame" x="10" y="781" width="373" height="47"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
<constraints> | ||
<constraint firstAttribute="height" constant="47" id="N0u-hM-oCK"/> | ||
</constraints> | ||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="xtv-ts-fGi"> | ||
<size key="itemSize" width="128" height="128"/> | ||
<size key="headerReferenceSize" width="0.0" height="0.0"/> | ||
<size key="footerReferenceSize" width="0.0" height="0.0"/> | ||
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> | ||
</collectionViewFlowLayout> | ||
</collectionView> | ||
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="aAH-7T-1qP"> | ||
<rect key="frame" x="186.66666666666666" y="416" width="20" height="20"/> | ||
</activityIndicatorView> | ||
</subviews> | ||
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
<constraints> | ||
<constraint firstItem="7ue-JW-yFO" firstAttribute="bottom" secondItem="fnl-2z-Ty3" secondAttribute="bottom" constant="10" id="241-M6-cQU"/> | ||
<constraint firstItem="7ue-JW-yFO" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="10" id="5W7-gl-LYp"/> | ||
<constraint firstItem="elx-8c-3DB" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" constant="10" id="Nz6-3S-CTI"/> | ||
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="7ue-JW-yFO" secondAttribute="trailing" constant="10" id="Ukx-ce-w7z"/> | ||
<constraint firstItem="aAH-7T-1qP" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="VVm-Si-xXU"/> | ||
<constraint firstItem="7ue-JW-yFO" firstAttribute="top" secondItem="elx-8c-3DB" secondAttribute="bottom" id="ZhK-hD-gqD"/> | ||
<constraint firstItem="aAH-7T-1qP" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="gNy-4h-1u0"/> | ||
<constraint firstItem="elx-8c-3DB" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="10" id="hxi-3e-6jE"/> | ||
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="elx-8c-3DB" secondAttribute="trailing" constant="10" id="oh1-88-vzo"/> | ||
</constraints> | ||
<point key="canvasLocation" x="110.68702290076335" y="-11.267605633802818"/> | ||
</view> | ||
</objects> | ||
<resources> | ||
<systemColor name="systemBackgroundColor"> | ||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
</systemColor> | ||
</resources> | ||
</document> |
24 changes: 24 additions & 0 deletions
24
RM Client/Features/Character/ViewModel/CharacterAction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// CharacterAction.swift | ||
// RM Client | ||
// | ||
// Created by Yazan Tarifi on 05/09/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
public class CharacterAction: RmAction { | ||
public final class GetCharacterInfoAction: CharacterAction { | ||
let id: Int64 | ||
init(id: Int64) { | ||
self.id = id | ||
} | ||
} | ||
|
||
public final class GetCharacterInfoByOtherCharacters: CharacterAction { | ||
let id: Int64 | ||
init(id: Int64) { | ||
self.id = id | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
RM Client/Features/Character/ViewModel/CharacterViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// CharacterViewModel.swift | ||
// RM Client | ||
// | ||
// Created by Yazan Tarifi on 05/09/2023. | ||
// | ||
|
||
import Foundation | ||
import RealmSwift | ||
|
||
public final class CharacterViewModel: RmBaseViewModel<CharacterAction> { | ||
|
||
private var useCaseInstance: GetCharacterInfoUseCase? = nil | ||
let screenState: RmViewModelState<[CharacterItem]> = RmViewModelState() | ||
let loadingState: RmViewModelState<Bool> = RmViewModelState() | ||
let otherNavigationState: RmViewModelState<[CharacterOtherInfoItem]> = RmViewModelState() | ||
|
||
public override func onPerformAction(action: CharacterAction) { | ||
if action is CharacterAction.GetCharacterInfoAction { | ||
self.getScreenContent( | ||
id: (action as! CharacterAction.GetCharacterInfoAction).id, | ||
action: action | ||
) | ||
} else if action is CharacterAction.GetCharacterInfoByOtherCharacters { | ||
let id = (action as! CharacterAction.GetCharacterInfoByOtherCharacters).id | ||
self.getScreenContent( | ||
id: id, | ||
action: action | ||
) | ||
|
||
self.getOtherNavigationItems(id: id) | ||
} | ||
} | ||
|
||
private func getOtherNavigationItems(id: Int64) { | ||
getDispatchQueue().async { [weak self] in | ||
self?.otherNavigationState.onPostValue(value: self?.getUseCase().getOtherCharactersList(id: id) ?? []) | ||
} | ||
} | ||
|
||
private func getScreenContent(id: Int64, action: CharacterAction) { | ||
let screenContent = screenState.getValue() ?? [] | ||
if screenContent.isEmpty { | ||
getUseCase().onExecute(props: self.getUseCaseProp( | ||
id: id, | ||
action: action) | ||
) | ||
} | ||
} | ||
|
||
private func getUseCaseProp(id: Int64, action: CharacterAction) -> GetCharacterInfoUseCaseProps { | ||
return GetCharacterInfoUseCaseProps( | ||
id: id, | ||
isInfoAction: action is CharacterAction.GetCharacterInfoAction | ||
) | ||
} | ||
|
||
private func getUseCase() -> GetCharacterInfoUseCase { | ||
if useCaseInstance == nil { | ||
useCaseInstance = GetCharacterInfoUseCase( | ||
dispatchQueue: getDispatchQueue(), | ||
listener: GetCharacterInfoUseCaseListener(viewModel: self) | ||
) | ||
} | ||
|
||
return useCaseInstance! | ||
} | ||
|
||
public override func getViewModelTitle() -> String { | ||
return "CharacterViewModel" | ||
} | ||
|
||
deinit { | ||
getUseCase().onDestroyUseCase() | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
RM Client/Features/Character/Views/CharacterHeaderCollectionViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// CharacterHeaderCollectionViewCell.swift | ||
// RM Client | ||
// | ||
// Created by Yazan Tarifi on 05/09/2023. | ||
// | ||
|
||
import UIKit | ||
|
||
class CharacterHeaderCollectionViewCell: UICollectionViewCell { | ||
|
||
@IBOutlet weak var imageView: UIImageView! | ||
@IBOutlet weak var deacriptionView: UILabel! | ||
@IBOutlet weak var nameView: UILabel! | ||
|
||
public func configure(item: CharacterHeaderItem) { | ||
DispatchQueue.main.async { [weak self] in | ||
self?.imageView?.layer.cornerRadius = 5 | ||
self?.imageView?.clipsToBounds = true | ||
} | ||
|
||
self.nameView.text = item.name | ||
self.deacriptionView.text = "This is the Long Text Desctiption Providing a Multi Lines in each Character Page info as you can see the Multiple Lines in Labels \(item.description)" | ||
|
||
guard let imageUrl = URL(string: item.image) else { return } | ||
imageView?.load(url: imageUrl) | ||
} | ||
} |
Oops, something went wrong.