Browse Source

Fix Timelines view controller

master
Dwayne Harris 6 years ago
parent
commit
f7501335e5
  1. 8
      elpha-ios.xcodeproj/project.pbxproj
  2. 42
      elpha-ios/AccountTableViewController.swift
  3. 146
      elpha-ios/Base.lproj/Main.storyboard
  4. 50
      elpha-ios/StatusTableViewController.swift
  5. 8
      elpha-ios/StatusView.swift
  6. 49
      elpha-ios/TimelineTableViewController.swift
  7. 66
      elpha-ios/TimelinesViewController.swift

8
elpha-ios.xcodeproj/project.pbxproj

@ -16,6 +16,7 @@
151AD4DD216899E000F07403 /* OAuthSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A79B13215B438C007A326E /* OAuthSwift.framework */; };
151AD4DE216899E000F07403 /* OAuthSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 15A79B13215B438C007A326E /* OAuthSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
151AD4E621689A0F00F07403 /* Alamofire.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 157405C3215890BC00EEAAEB /* Alamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
152734D22186DC74003DB3C8 /* TimelinesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 152734D12186DC74003DB3C8 /* TimelinesViewController.swift */; };
156FF015217289380074D9CA /* AccountTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 156FF014217289380074D9CA /* AccountTableViewCell.swift */; };
156FF0312174797E0074D9CA /* StatusTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 156FF0302174797E0074D9CA /* StatusTableViewController.swift */; };
156FF04F2175CDBC0074D9CA /* MainStatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 156FF04E2175CDBC0074D9CA /* MainStatusTableViewCell.swift */; };
@ -45,7 +46,6 @@
15960E84213774FC00C38CE9 /* InstancesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15960E83213774FC00C38CE9 /* InstancesTableViewController.swift */; };
15A79B2E215C63B6007A326E /* AlamofireImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1517EA842159D72200DE80D6 /* AlamofireImage.framework */; };
15A79B43215EB959007A326E /* CoreDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15A79B42215EB959007A326E /* CoreDataManager.swift */; };
15BB72A92171A6BE002F1FA4 /* TimelinesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15BB72A82171A6BE002F1FA4 /* TimelinesTableViewController.swift */; };
15BB72AB2171A8D4002F1FA4 /* TimelinesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15BB72AA2171A8D4002F1FA4 /* TimelinesTableViewCell.swift */; };
15C91A02216AB2D600D97DC3 /* NewStatusesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15C91A01216AB2D600D97DC3 /* NewStatusesView.xib */; };
15C91A04216AB32500D97DC3 /* NewStatusesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15C91A03216AB32500D97DC3 /* NewStatusesView.swift */; };
@ -254,6 +254,7 @@
15131EF5216DBA820092B252 /* AccountNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountNavigationController.swift; sourceTree = "<group>"; };
1517A6132182B87E00B33735 /* AttachmentView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AttachmentView.xib; sourceTree = "<group>"; };
1517EA6F2159D72200DE80D6 /* AlamofireImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = AlamofireImage.xcodeproj; path = Frameworks/AlamofireImage/AlamofireImage.xcodeproj; sourceTree = "<group>"; };
152734D12186DC74003DB3C8 /* TimelinesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinesViewController.swift; sourceTree = "<group>"; };
156FF014217289380074D9CA /* AccountTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTableViewCell.swift; sourceTree = "<group>"; };
156FF0302174797E0074D9CA /* StatusTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewController.swift; sourceTree = "<group>"; };
156FF04E2175CDBC0074D9CA /* MainStatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainStatusTableViewCell.swift; sourceTree = "<group>"; };
@ -285,7 +286,6 @@
15960E83213774FC00C38CE9 /* InstancesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstancesTableViewController.swift; sourceTree = "<group>"; };
15A79B08215B438C007A326E /* OAuthSwift.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OAuthSwift.xcodeproj; path = Frameworks/OAuthSwift/OAuthSwift.xcodeproj; sourceTree = "<group>"; };
15A79B42215EB959007A326E /* CoreDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataManager.swift; sourceTree = "<group>"; };
15BB72A82171A6BE002F1FA4 /* TimelinesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinesTableViewController.swift; sourceTree = "<group>"; };
15BB72AA2171A8D4002F1FA4 /* TimelinesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelinesTableViewCell.swift; sourceTree = "<group>"; };
15C91A01216AB2D600D97DC3 /* NewStatusesView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NewStatusesView.xib; sourceTree = "<group>"; };
15C91A03216AB32500D97DC3 /* NewStatusesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewStatusesView.swift; sourceTree = "<group>"; };
@ -467,8 +467,8 @@
15960E792132387A00C38CE9 /* MainTabBarController.swift */,
156FF0302174797E0074D9CA /* StatusTableViewController.swift */,
15960E812136668500C38CE9 /* TimelinesNavigationController.swift */,
15BB72A82171A6BE002F1FA4 /* TimelinesTableViewController.swift */,
15F9981621629965009E58DA /* TimelineTableViewController.swift */,
152734D12186DC74003DB3C8 /* TimelinesViewController.swift */,
);
name = "View Controllers";
sourceTree = "<group>";
@ -751,8 +751,8 @@
15960E7E21329FED00C38CE9 /* AuthenticateViewController.swift in Sources */,
15960E5B213145E100C38CE9 /* AppDelegate.swift in Sources */,
15131EF2216D8D570092B252 /* StatusView.swift in Sources */,
152734D22186DC74003DB3C8 /* TimelinesViewController.swift in Sources */,
156FF07221779C650074D9CA /* InstanceRequest.swift in Sources */,
15BB72A92171A6BE002F1FA4 /* TimelinesTableViewController.swift in Sources */,
15960E7721322C6F00C38CE9 /* Configuration.swift in Sources */,
156FF07021779C570074D9CA /* MastodonAPI.swift in Sources */,
15C91A04216AB32500D97DC3 /* NewStatusesView.swift in Sources */,

42
elpha-ios/AccountTableViewController.swift

@ -234,7 +234,7 @@ extension AccountTableViewController: NSFetchedResultsControllerDelegate {
if let account = self.account {
let request = NSFetchRequest<StatusMO>(entityName: "Status")
request.sortDescriptors = [
NSSortDescriptor(key: "pinned", ascending: true),
NSSortDescriptor(key: "pinned", ascending: false),
NSSortDescriptor(key: "createdAt", ascending: false),
]
@ -326,4 +326,44 @@ extension AccountTableViewController: StatusViewDelegate {
self.navigationController?.pushViewController(controller, animated: true)
}
}
func favoriteTapped(status: StatusMO) {
if status.favorited {
MastodonAPI.unfavorite(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
} else {
MastodonAPI.favorite(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
func reblogTapped(status: StatusMO) {
if status.reblogged {
MastodonAPI.unreblog(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
} else {
MastodonAPI.reblog(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
func loadMoreTapped(pagination: PaginationItem) {
fetchStatuses(withPagination: pagination) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}

146
elpha-ios/Base.lproj/Main.storyboard

@ -741,6 +741,7 @@
<rect key="frame" x="0.0" y="44" width="375" height="96"/>
<autoresizingMask key="autoresizingMask"/>
<color key="tintColor" red="0.090196078430000007" green="0.047058823530000002" blue="0.28627450980000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="barTintColor" name="Secondary"/>
<textAttributes key="titleTextAttributes">
<color key="textColor" red="0.090196078430000007" green="0.047058823530000002" blue="0.28627450980000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</textAttributes>
@ -757,62 +758,105 @@
</objects>
<point key="canvasLocation" x="749.60000000000002" y="-320.68965517241384"/>
</scene>
<!--Timelines-->
<scene sceneID="rPf-bh-vX0">
<!--Timelines View Controller-->
<scene sceneID="utN-zB-UGT">
<objects>
<tableViewController title="Timelines" definesPresentationContext="YES" providesPresentationContextTransitionStyle="YES" modalPresentationStyle="overCurrentContext" id="ohq-uu-dqB" customClass="TimelinesTableViewController" customModule="elpha_ios" 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="au7-dg-KQQ">
<viewController id="TVm-XQ-DKr" customClass="TimelinesViewController" customModule="elpha_ios" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ap7-qY-exg">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" showsReorderControl="YES" indentationWidth="10" reuseIdentifier="TimelinesTableViewCell" rowHeight="100" id="HWA-v6-ifS" customClass="TimelinesTableViewCell" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="100"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="HWA-v6-ifS" id="Xod-r8-3b7">
<rect key="frame" x="0.0" y="0.0" width="375" height="99.666666666666671"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="56a-dU-Hpe">
<rect key="frame" x="0.0" y="0.0" width="375" height="729"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="1Oi-SN-Jgn">
<rect key="frame" x="0.0" y="0.0" width="375" height="729"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="pn3-vi-rIP">
<rect key="frame" x="15" y="25" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="NVy-av-IC4"/>
<constraint firstAttribute="height" constant="50" id="w00-gF-A5N"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Timeline" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="65I-lo-p71">
<rect key="frame" x="73" y="39.333333333333336" width="278" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" name="Text"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ZOW-xe-PU2">
<rect key="frame" x="40" y="80" width="295" height="599"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<view key="tableHeaderView" contentMode="scaleToFill" id="l7S-vH-H0D">
<rect key="frame" x="0.0" y="0.0" width="295" height="45"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Timelines" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bXM-kl-c1F">
<rect key="frame" x="15" y="12" width="265" height="21"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" name="Text"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" name="Secondary"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="bXM-kl-c1F" secondAttribute="trailing" constant="15" id="2Bp-NG-HmK"/>
<constraint firstItem="bXM-kl-c1F" firstAttribute="centerY" secondItem="l7S-vH-H0D" secondAttribute="centerY" id="Lua-42-P7W"/>
<constraint firstItem="bXM-kl-c1F" firstAttribute="leading" secondItem="l7S-vH-H0D" secondAttribute="leading" constant="15" id="NtE-lv-L0M"/>
</constraints>
</view>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" showsReorderControl="YES" indentationWidth="0.0" reuseIdentifier="TimelinesTableViewCell" rowHeight="100" id="ac2-yP-Xjn" customClass="TimelinesTableViewCell" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="73" width="295" height="100"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ac2-yP-Xjn" id="FhG-qQ-SYH">
<rect key="frame" x="0.0" y="0.0" width="295" height="99.666666666666671"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="GVK-O1-vGh">
<rect key="frame" x="15" y="25" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="cW7-mc-12y"/>
<constraint firstAttribute="width" constant="50" id="w3g-Dc-RQQ"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Timeline" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oae-Lt-3g2">
<rect key="frame" x="73" y="39.333333333333336" width="207" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" name="Text"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="oae-Lt-3g2" firstAttribute="leading" secondItem="GVK-O1-vGh" secondAttribute="trailing" constant="8" id="1jv-ER-Zfu"/>
<constraint firstAttribute="trailingMargin" secondItem="oae-Lt-3g2" secondAttribute="trailing" id="57p-Ve-Psr"/>
<constraint firstItem="GVK-O1-vGh" firstAttribute="leading" secondItem="FhG-qQ-SYH" secondAttribute="leadingMargin" id="AZj-XB-GmK"/>
<constraint firstItem="GVK-O1-vGh" firstAttribute="centerY" secondItem="FhG-qQ-SYH" secondAttribute="centerY" id="K1C-Sn-UKD"/>
<constraint firstItem="oae-Lt-3g2" firstAttribute="centerY" secondItem="FhG-qQ-SYH" secondAttribute="centerY" id="Qu9-aS-jzH"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="timelineImageView" destination="GVK-O1-vGh" id="FBL-Dm-VVJ"/>
<outlet property="timelineLabel" destination="oae-Lt-3g2" id="Dln-ju-uQr"/>
</connections>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<constraints>
<constraint firstItem="pn3-vi-rIP" firstAttribute="leading" secondItem="Xod-r8-3b7" secondAttribute="leading" constant="15" id="3zj-oF-aEo"/>
<constraint firstItem="65I-lo-p71" firstAttribute="leading" secondItem="pn3-vi-rIP" secondAttribute="trailing" constant="8" id="UDs-ko-mUR"/>
<constraint firstItem="pn3-vi-rIP" firstAttribute="centerY" secondItem="Xod-r8-3b7" secondAttribute="centerY" id="adh-gg-Ujg"/>
<constraint firstItem="65I-lo-p71" firstAttribute="centerY" secondItem="Xod-r8-3b7" secondAttribute="centerY" id="faF-zM-PbW"/>
<constraint firstAttribute="trailingMargin" secondItem="65I-lo-p71" secondAttribute="trailing" constant="8" id="oBY-be-iTb"/>
<constraint firstAttribute="trailing" secondItem="ZOW-xe-PU2" secondAttribute="trailing" constant="40" id="LqP-AN-qDc"/>
<constraint firstItem="ZOW-xe-PU2" firstAttribute="top" secondItem="1Oi-SN-Jgn" secondAttribute="top" constant="80" id="MLp-aO-b9J"/>
<constraint firstItem="ZOW-xe-PU2" firstAttribute="leading" secondItem="1Oi-SN-Jgn" secondAttribute="leading" constant="40" id="QAb-e6-ttN"/>
<constraint firstAttribute="bottom" secondItem="ZOW-xe-PU2" secondAttribute="bottom" constant="50" id="hTu-st-Y8M"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="timelineImageView" destination="pn3-vi-rIP" id="9WN-FV-oBS"/>
<outlet property="timelineLabel" destination="65I-lo-p71" id="AOo-jV-DIO"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="ohq-uu-dqB" id="G6S-L6-k4A"/>
<outlet property="delegate" destination="ohq-uu-dqB" id="rXh-e9-NRO"/>
</connections>
</tableView>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="e9T-Uk-D5X" userLabel="First Responder" sceneMemberID="firstResponder"/>
</view>
<blurEffect style="light"/>
</visualEffectView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="NGp-mN-ka0" firstAttribute="bottom" secondItem="56a-dU-Hpe" secondAttribute="bottom" id="RDn-n7-mm6"/>
<constraint firstItem="56a-dU-Hpe" firstAttribute="leading" secondItem="NGp-mN-ka0" secondAttribute="leading" id="U3o-cx-5sE"/>
<constraint firstItem="56a-dU-Hpe" firstAttribute="top" secondItem="ap7-qY-exg" secondAttribute="top" id="acG-CQ-nb4"/>
<constraint firstItem="NGp-mN-ka0" firstAttribute="trailing" secondItem="56a-dU-Hpe" secondAttribute="trailing" id="ygx-YQ-DKj"/>
</constraints>
<viewLayoutGuide key="safeArea" id="NGp-mN-ka0"/>
</view>
<connections>
<outlet property="tableView" destination="ZOW-xe-PU2" id="DSv-JK-ps7"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Ao-Vi-HOQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2394" y="-1052"/>
<point key="canvasLocation" x="1632.8" y="-1094.3349753694581"/>
</scene>
<!--Timeline-->
<scene sceneID="jGL-v8-K0I">
@ -859,9 +903,7 @@
<attributedString key="attributedTitle"/>
</refreshControl>
<connections>
<segue destination="ohq-uu-dqB" kind="popoverPresentation" identifier="TimelinesSegue" popoverAnchorView="fgT-hp-jpg" id="lfm-EQ-h2m">
<popoverArrowDirection key="popoverArrowDirection" up="YES" down="YES" left="YES" right="YES"/>
</segue>
<segue destination="TVm-XQ-DKr" kind="presentation" identifier="TimelinesSegue" animates="NO" modalPresentationStyle="overCurrentContext" id="Z24-89-f5Z"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="KTy-Tn-EdD" userLabel="First Responder" sceneMemberID="firstResponder"/>
@ -1169,6 +1211,7 @@
<rect key="frame" x="0.0" y="44" width="375" height="96"/>
<autoresizingMask key="autoresizingMask"/>
<color key="tintColor" red="0.090196078430000007" green="0.047058823530000002" blue="0.28627450980000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="barTintColor" name="Secondary"/>
<textAttributes key="titleTextAttributes">
<color key="textColor" red="0.090196078430000007" green="0.047058823530000002" blue="0.28627450980000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</textAttributes>
@ -1195,6 +1238,7 @@
<rect key="frame" x="0.0" y="44" width="375" height="96"/>
<autoresizingMask key="autoresizingMask"/>
<color key="tintColor" red="0.090196078430000007" green="0.047058823530000002" blue="0.28627450980000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="barTintColor" name="Secondary"/>
<textAttributes key="titleTextAttributes">
<color key="textColor" red="0.090196078430000007" green="0.047058823530000002" blue="0.28627450980000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</textAttributes>

50
elpha-ios/StatusTableViewController.swift

@ -259,22 +259,8 @@ extension StatusTableViewController {
cell.statusView.bottomDividerView.isHidden = false
cell.statusView.topLoadMoreView.isHidden = true
cell.statusView.bottomLoadMoreView.isHidden = true
cell.statusView.replyView.isHidden = true
if !loading {
let statusAge = Calendar.current.dateComponents([.minute], from: status.fetchedAt!, to: Date())
let stale = statusAge.minute! > 30
if stale {
fetchStatuses { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
return cell
}
}
@ -298,4 +284,40 @@ extension StatusTableViewController: StatusViewDelegate {
self.navigationController?.pushViewController(controller, animated: true)
}
}
func favoriteTapped(status: StatusMO) {
if status.favorited {
MastodonAPI.unfavorite(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
} else {
MastodonAPI.favorite(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
func reblogTapped(status: StatusMO) {
if status.reblogged {
MastodonAPI.unreblog(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
} else {
MastodonAPI.reblog(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
func loadMoreTapped(pagination: PaginationItem) {
}
}

8
elpha-ios/StatusView.swift

@ -12,9 +12,9 @@ import UIKit
protocol StatusViewDelegate {
func accountTapped(account: AccountMO)
func statusTapped(status: StatusMO)
//func favoriteTapped(status: StatusMO)
//func reblogTapped(status: StatusMO)
//func loadMoreTapped(pagination: PaginationItem)
func favoriteTapped(status: StatusMO)
func reblogTapped(status: StatusMO)
func loadMoreTapped(pagination: PaginationItem)
}
class StatusView: UIView {
@ -94,6 +94,8 @@ class StatusView: UIView {
}
@objc func reveal(sender: UITapGestureRecognizer) {
if let status = status {
status.hidden = false

49
elpha-ios/TimelineTableViewController.swift

@ -10,7 +10,7 @@ import AlamofireImage
import CoreData
import UIKit
class TimelineTableViewController: UITableViewController, TimelinesTableViewControllerDelegate {
class TimelineTableViewController: UITableViewController, TimelinesViewControllerDelegate {
var fetchedResultsController: NSFetchedResultsController<StatusMO>? = nil
let fetchLimit = 20
@ -66,6 +66,7 @@ class TimelineTableViewController: UITableViewController, TimelinesTableViewCont
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
fetchTimeline { error in
if error != nil {
print("\(String(describing: error))")
@ -85,7 +86,7 @@ class TimelineTableViewController: UITableViewController, TimelinesTableViewCont
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "TimelinesSegue" {
if let destination = segue.destination as? TimelinesTableViewController {
if let destination = segue.destination as? TimelinesViewController {
destination.delegate = self
}
}
@ -345,7 +346,7 @@ extension TimelineTableViewController {
if previousStatus.id! != marker.item.statusID && previousMarker != nil {
cell.statusView.topLoadMoreView.isHidden = false
//cell.statusView.topDividerView.isHidden = true
cell.statusView.topDividerView.isHidden = true
}
}
case .next:
@ -355,7 +356,7 @@ extension TimelineTableViewController {
if nextStatus.id! != marker.item.statusID && nextMarker != nil {
cell.statusView.bottomLoadMoreView.isHidden = false
//cell.statusView.bottomDividerView.isHidden = true
cell.statusView.bottomDividerView.isHidden = true
}
}
}
@ -390,6 +391,46 @@ extension TimelineTableViewController: StatusViewDelegate {
self.navigationController?.pushViewController(controller, animated: true)
}
}
func favoriteTapped(status: StatusMO) {
if status.favorited {
MastodonAPI.unfavorite(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
} else {
MastodonAPI.favorite(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
func reblogTapped(status: StatusMO) {
if status.reblogged {
MastodonAPI.unreblog(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
} else {
MastodonAPI.reblog(statusID: status.id!) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
func loadMoreTapped(pagination: PaginationItem) {
fetchTimeline(withPagination: pagination) { error in
if error != nil {
print("\(String(describing: error))")
}
}
}
}
extension TimelineTableViewController {

66
elpha-ios/TimelinesTableViewController.swift → elpha-ios/TimelinesViewController.swift

@ -1,24 +1,32 @@
//
// TimelinesTableViewController.swift
// TimelineViewController.swift
// elpha-ios
//
// Created by Dwayne Harris on 10/12/18.
// Created by Dwayne Harris on 10/28/18.
// Copyright © 2018 Elpha. All rights reserved.
//
import CoreData
import UIKit
protocol TimelinesTableViewControllerDelegate {
protocol TimelinesViewControllerDelegate {
func didSelect(timeline: TimelineMO)
}
class TimelinesTableViewController: UITableViewController {
var delegate: TimelinesTableViewControllerDelegate? = nil
class TimelinesViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet var tableView: UITableView!
var delegate: TimelinesViewControllerDelegate? = nil
var fetchedResultsController: NSFetchedResultsController<TimelineMO>? = nil
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
tableView.layer.cornerRadius = 20
tableView.layer.masksToBounds = true
initializeFetchedResultsController()
}
@ -44,11 +52,11 @@ class TimelinesTableViewController: UITableViewController {
}
}
override func numberOfSections(in tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let count = fetchedResultsController?.fetchedObjects?.count else {
return 0
}
@ -56,7 +64,7 @@ class TimelinesTableViewController: UITableViewController {
return count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "TimelinesTableViewCell", for: indexPath) as? TimelinesTableViewCell else {
fatalError("Unable to find reusable cell")
}
@ -74,22 +82,22 @@ class TimelinesTableViewController: UITableViewController {
}
switch TimelineCategory(rawValue: timeline.category!)! {
case .home:
cell.timelineImageView.image = UIImage(named: "Home")
case .local:
cell.timelineImageView.image = UIImage(named: "Users")
case .federated:
cell.timelineImageView.image = UIImage(named: "Globe")
case .favorites:
cell.timelineImageView.image = UIImage(named: "Star Regular")
case .tag:
cell.timelineImageView.image = UIImage(named: "Tag")
case .home:
cell.timelineImageView.image = UIImage(named: "Home")
case .local:
cell.timelineImageView.image = UIImage(named: "Users")
case .federated:
cell.timelineImageView.image = UIImage(named: "Globe")
case .favorites:
cell.timelineImageView.image = UIImage(named: "Star Regular")
case .tag:
cell.timelineImageView.image = UIImage(named: "Tag")
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let timeline = fetchedResultsController?.object(at: indexPath) else {
fatalError("CoreData error")
}
@ -102,22 +110,22 @@ class TimelinesTableViewController: UITableViewController {
}
}
extension TimelinesTableViewController: NSFetchedResultsControllerDelegate {
extension TimelinesViewController: NSFetchedResultsControllerDelegate {
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
tableView.beginUpdates()
}
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {
case NSFetchedResultsChangeType.insert:
tableView.insertRows(at: [newIndexPath!], with: UITableView.RowAnimation.fade)
case NSFetchedResultsChangeType.delete:
tableView.deleteRows(at: [indexPath!], with: UITableView.RowAnimation.fade)
case NSFetchedResultsChangeType.update:
return
case NSFetchedResultsChangeType.move:
tableView.deleteRows(at: [indexPath!], with: UITableView.RowAnimation.fade)
tableView.insertRows(at: [newIndexPath!], with: UITableView.RowAnimation.fade)
case NSFetchedResultsChangeType.insert:
tableView.insertRows(at: [newIndexPath!], with: UITableView.RowAnimation.fade)
case NSFetchedResultsChangeType.delete:
tableView.deleteRows(at: [indexPath!], with: UITableView.RowAnimation.fade)
case NSFetchedResultsChangeType.update:
return
case NSFetchedResultsChangeType.move:
tableView.deleteRows(at: [indexPath!], with: UITableView.RowAnimation.fade)
tableView.insertRows(at: [newIndexPath!], with: UITableView.RowAnimation.fade)
}
}
Loading…
Cancel
Save