Make ConversationViewController a UITableViewController

This commit is contained in:
Shadowfacts 2018-10-11 21:10:25 -04:00
parent f2a7362618
commit 76beb8ddbe
2 changed files with 21 additions and 36 deletions

View File

@ -1,43 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="3Yl-E3-qsN">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.23.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="twK-ED-gYg">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.16.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Conversation View Controller-->
<scene sceneID="rkM-By-3Qj">
<scene sceneID="3yH-Pl-I9Z">
<objects>
<viewController id="3Yl-E3-qsN" customClass="ConversationViewController" customModule="Tusker" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="yCk-Ig-NdG">
<tableViewController id="twK-ED-gYg" customClass="ConversationViewController" customModule="Tusker" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="MrD-X9-lv9">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<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="k5U-Kb-0kH">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="k5U-Kb-0kH" firstAttribute="leading" secondItem="mo7-1M-ylA" secondAttribute="leading" id="3Xe-vE-WWU"/>
<constraint firstItem="k5U-Kb-0kH" firstAttribute="top" secondItem="mo7-1M-ylA" secondAttribute="top" id="X2A-0c-iZD"/>
<constraint firstItem="mo7-1M-ylA" firstAttribute="bottom" secondItem="k5U-Kb-0kH" secondAttribute="bottom" id="bXb-L7-DfD"/>
<constraint firstItem="k5U-Kb-0kH" firstAttribute="trailing" secondItem="mo7-1M-ylA" secondAttribute="trailing" id="c6s-ef-Dxs"/>
</constraints>
<viewLayoutGuide key="safeArea" id="mo7-1M-ylA"/>
</view>
<connections>
<outlet property="tableView" destination="k5U-Kb-0kH" id="vAY-xd-xkg"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="BtE-Vw-c42" userLabel="First Responder" sceneMemberID="firstResponder"/>
<connections>
<outlet property="dataSource" destination="twK-ED-gYg" id="v7X-IB-dVa"/>
<outlet property="delegate" destination="twK-ED-gYg" id="9NJ-a0-VCf"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="EmL-wm-170" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-358" y="16"/>
<point key="canvasLocation" x="575" y="23"/>
</scene>
</scenes>
</document>

View File

@ -9,7 +9,7 @@
import UIKit
import Pachyderm
class ConversationViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
class ConversationViewController: UITableViewController {
static func create(for mainStatusID: String) -> ConversationViewController {
guard let conversationController = UIStoryboard(name: "Conversation", bundle: nil).instantiateInitialViewController() as? ConversationViewController else { fatalError() }
@ -17,8 +17,6 @@ class ConversationViewController: UIViewController, UITableViewDataSource, UITab
return conversationController
}
@IBOutlet weak var tableView: UITableView!
var mainStatusID: String!
var statusIDs: [String] = [] {
@ -91,15 +89,15 @@ class ConversationViewController: UIViewController, UITableViewDataSource, UITab
// MARK: - Table view data source
func numberOfSections(in tableView: UITableView) -> Int {
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return statusIDs.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let statusID = statusIDs[indexPath.row]
if statusID == mainStatusID {
@ -116,20 +114,20 @@ class ConversationViewController: UIViewController, UITableViewDataSource, UITab
}
}
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
let statusID = statusIDs[indexPath.row]
return statusID == mainStatusID ? nil : indexPath
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider
}
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
}
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
}