Skip to content

Commit

Permalink
#14 Moved ReousableCellViewProtocol to the Adapter/View
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed May 23, 2019
1 parent 99804c3 commit 6d3f845
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 128 deletions.
6 changes: 5 additions & 1 deletion Owl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
641CDA5422789FFF00C88886 /* UITableView+Support.swift in Sources */ = {isa = PBXBuildFile; fileRef = 641CD9D122789E8F00C88886 /* UITableView+Support.swift */; };
6478952D227F5091005F983F /* Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6478952C227F5091005F983F /* Extras.swift */; };
6478952E227F5099005F983F /* Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6478952C227F5091005F983F /* Extras.swift */; };
647DD9862296DF9600288935 /* CatalogItemCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 647DD9852296DF9600288935 /* CatalogItemCell.xib */; };
8933C7901EB5B82D000D00A4 /* OwlTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8933C7891EB5B82A000D00A4 /* OwlTests.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -171,6 +172,7 @@
641CDA3322789FD100C88886 /* UIImageView+Extras.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImageView+Extras.swift"; sourceTree = "<group>"; };
641CDA3422789FD200C88886 /* Commons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Commons.swift; sourceTree = "<group>"; };
6478952C227F5091005F983F /* Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extras.swift; sourceTree = "<group>"; };
647DD9852296DF9600288935 /* CatalogItemCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CatalogItemCell.xib; sourceTree = "<group>"; };
8933C7891EB5B82A000D00A4 /* OwlTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OwlTests.swift; sourceTree = "<group>"; };
AD2FAA261CD0B6D800659CF4 /* Owl.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Owl.plist; sourceTree = "<group>"; };
AD2FAA281CD0B6E100659CF4 /* OwlTests.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = OwlTests.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -350,10 +352,10 @@
isa = PBXGroup;
children = (
641CD9ED22789F0C00C88886 /* AppDelegate.swift */,
641CD9F122789F0C00C88886 /* Main.storyboard */,
641CD9FF22789F3B00C88886 /* Catalog Menu */,
641CDA0922789F5A00C88886 /* Contacts */,
641CDA2922789F9D00C88886 /* Emoji */,
641CD9F122789F0C00C88886 /* Main.storyboard */,
641CD9F422789F0E00C88886 /* Assets.xcassets */,
641CD9F622789F0E00C88886 /* LaunchScreen.storyboard */,
641CDA3822789FD400C88886 /* Support */,
Expand All @@ -376,6 +378,7 @@
children = (
641CDA0022789F4100C88886 /* CatalogItem.swift */,
641CDA0122789F4100C88886 /* CatalogItemCell.swift */,
647DD9852296DF9600288935 /* CatalogItemCell.xib */,
);
path = "Models & UI";
sourceTree = "<group>";
Expand Down Expand Up @@ -638,6 +641,7 @@
641CDA1822789F7400C88886 /* GroupCell.xib in Resources */,
641CDA2222789F8600C88886 /* companies_db.json in Resources */,
641CDA0722789F5700C88886 /* ContactsController.storyboard in Resources */,
647DD9862296DF9600288935 /* CatalogItemCell.xib in Resources */,
641CDA1B22789F7400C88886 /* GroupFooterView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
91 changes: 91 additions & 0 deletions Owl.xcodeproj/xcshareddata/xcschemes/OwlDemo.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641CD9EA22789F0C00C88886"
BuildableName = "OwlDemo.app"
BlueprintName = "OwlDemo"
ReferencedContainer = "container:Owl.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641CD9EA22789F0C00C88886"
BuildableName = "OwlDemo.app"
BlueprintName = "OwlDemo"
ReferencedContainer = "container:Owl.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641CD9EA22789F0C00C88886"
BuildableName = "OwlDemo.app"
BlueprintName = "OwlDemo"
ReferencedContainer = "container:Owl.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "641CD9EA22789F0C00C88886"
BuildableName = "OwlDemo.app"
BlueprintName = "OwlDemo"
ReferencedContainer = "container:Owl.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
54 changes: 1 addition & 53 deletions OwlDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -30,63 +30,14 @@
<!--FlowKit-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController storyboardIdentifier="CatalogViewController" title="FlowKit" automaticallyAdjustsScrollViewInsets="NO" id="BYZ-38-t0r" customClass="CatalogViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="CatalogViewController" title="FlowKit" automaticallyAdjustsScrollViewInsets="NO" id="BYZ-38-t0r" customClass="CatalogViewController" customModule="OwlDemo" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="9mR-Kb-DZH">
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="CatalogItemCell" rowHeight="60" id="sTF-zj-1U6" customClass="CatalogItemCell" customModule="Example" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="60"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="sTF-zj-1U6" id="6OE-5Q-G8E">
<rect key="frame" x="0.0" y="0.0" width="375" height="59.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="stackView" translatesAutoresizingMaskIntoConstraints="NO" id="r1F-hq-CgE">
<rect key="frame" x="15" y="15" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="388-nM-2d8"/>
<constraint firstAttribute="height" constant="30" id="ae1-9b-txi"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Title Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Ph-wc-TjU">
<rect key="frame" x="55" y="11" width="295" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Description Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BpR-OR-gqG">
<rect key="frame" x="55" y="34" width="295" height="14.5"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="BpR-OR-gqG" firstAttribute="top" secondItem="5Ph-wc-TjU" secondAttribute="bottom" constant="2" id="35u-ML-hJy"/>
<constraint firstItem="5Ph-wc-TjU" firstAttribute="top" secondItem="r1F-hq-CgE" secondAttribute="top" constant="-4" id="3X5-oY-rsj"/>
<constraint firstItem="r1F-hq-CgE" firstAttribute="centerY" secondItem="6OE-5Q-G8E" secondAttribute="centerY" id="3b3-5d-U1p"/>
<constraint firstItem="BpR-OR-gqG" firstAttribute="leading" secondItem="r1F-hq-CgE" secondAttribute="trailing" constant="10" id="C2T-TP-6Rd"/>
<constraint firstItem="r1F-hq-CgE" firstAttribute="leading" secondItem="6OE-5Q-G8E" secondAttribute="leadingMargin" id="Nkm-ao-Lju"/>
<constraint firstAttribute="trailingMargin" secondItem="BpR-OR-gqG" secondAttribute="trailing" constant="10" id="QhV-Vc-Kbo"/>
<constraint firstItem="5Ph-wc-TjU" firstAttribute="leading" secondItem="r1F-hq-CgE" secondAttribute="trailing" constant="10" id="agL-ze-EEo"/>
<constraint firstAttribute="trailingMargin" secondItem="5Ph-wc-TjU" secondAttribute="trailing" constant="10" id="yS5-Rc-pVD"/>
</constraints>
</tableViewCellContentView>
<constraints>
<constraint firstAttribute="bottom" secondItem="BpR-OR-gqG" secondAttribute="bottom" constant="11.5" id="C7U-Zs-eA4"/>
</constraints>
<connections>
<outlet property="iconImageView" destination="r1F-hq-CgE" id="v4J-3t-4ee"/>
<outlet property="shortDescLabel" destination="BpR-OR-gqG" id="9L6-eD-QhZ"/>
<outlet property="titleLabel" destination="5Ph-wc-TjU" id="YyU-Bu-mdo"/>
</connections>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -109,7 +60,4 @@
<point key="canvasLocation" x="-398" y="134"/>
</scene>
</scenes>
<resources>
<image name="stackView" width="44" height="44"/>
</resources>
</document>
1 change: 1 addition & 0 deletions OwlDemo/Catalog Menu/CatalogViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CatalogViewController: UIViewController {
tableDirector?.rowHeight = .explicit(60)

let catalogAdapter = TableCellAdapter<CatalogItem, CatalogItemCell>()
catalogAdapter.cellLoadSource = .fromXib(name: nil, bundle: nil)
tableDirector?.registerCellAdapter(catalogAdapter)

catalogAdapter.events.rowHeight = { ctx in
Expand Down
4 changes: 0 additions & 4 deletions OwlDemo/Catalog Menu/Models & UI/CatalogItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@ public class CatalogItemCell: UITableViewCell {
iconImageView.image = item?.icon
}
}

public class var reusableViewSource: ReusableViewSource {
return .fromClass
}

}
Loading

0 comments on commit 6d3f845

Please sign in to comment.