Add Reddit Feed adding functionality

This commit is contained in:
Maurice Parker
2020-08-11 16:27:42 -05:00
parent 0ec250ec24
commit e7f42905dc
12 changed files with 96 additions and 46 deletions

View File

@@ -11,7 +11,7 @@
<!--Add Web Feed-->
<scene sceneID="2Tc-JN-edX">
<objects>
<tableViewController id="7aE-6a-iP7" customClass="AddWebFeedViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableViewController storyboardIdentifier="AddWebFeedViewController" id="7aE-6a-iP7" customClass="AddWebFeedViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" dataMode="static" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="D0S-TM-mtm">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

View File

@@ -12,6 +12,12 @@ import RSCore
import RSTree
import RSParser
enum AddFeedType {
case web
case reddit
case twitter
}
class AddWebFeedViewController: UITableViewController {
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@@ -25,6 +31,7 @@ class AddWebFeedViewController: UITableViewController {
private var folderLabel = ""
private var userCancelled = false
var addFeedType = AddFeedType.web
var initialFeed: String?
var initialFeedName: String?
@@ -33,6 +40,17 @@ class AddWebFeedViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
switch addFeedType {
case .reddit:
navigationItem.title = NSLocalizedString("Add Reddit Feed", comment: "Add Reddit Feed")
navigationItem.leftBarButtonItem = nil
case .twitter:
navigationItem.title = NSLocalizedString("Add Twitter Feed", comment: "Add Twitter Feed")
navigationItem.leftBarButtonItem = nil
default:
break
}
activityIndicator.isHidden = true
activityIndicator.color = .label

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17147" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="q78-0w-suH">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17147" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="fak-6k-FqE">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
@@ -123,6 +123,13 @@
<outlet property="delegate" destination="q78-0w-suH" id="j69-O6-ths"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Select Reddit Type" id="sDs-V8-FbQ">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="PvO-Kb-jDe">
<connections>
<action selector="cancel:" destination="q78-0w-suH" id="G70-O2-P1M"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yI5-IG-7Sl" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
@@ -215,10 +222,10 @@
</objects>
<point key="canvasLocation" x="836" y="173"/>
</scene>
<!--Select Type-->
<!--Select Sort Order-->
<scene sceneID="fgY-Vy-10A">
<objects>
<tableViewController storyboardIdentifier="RedditSelectSortTableViewController" title="Select Type" id="IlC-3Q-oEI" customClass="RedditSelectSortTableViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableViewController storyboardIdentifier="RedditSelectSortTableViewController" title="Select Sort Order" id="IlC-3Q-oEI" customClass="RedditSelectSortTableViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="fZZ-h8-KOR">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -226,11 +233,11 @@
<sections>
<tableViewSection id="ExH-4T-drs">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="Two-PX-Viz" detailTextLabel="0ye-pS-sK4" style="IBUITableViewCellStyleSubtitle" id="55H-tz-eaT" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="Two-PX-Viz" detailTextLabel="0ye-pS-sK4" style="IBUITableViewCellStyleSubtitle" id="55H-tz-eaT" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="18" width="374" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="55H-tz-eaT" id="hMA-SY-f5j">
<rect key="frame" x="0.0" y="0.0" width="374" height="59"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Best" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="Two-PX-Viz">
@@ -250,11 +257,11 @@
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="zH0-LJ-jQI" detailTextLabel="l2u-CB-A9e" style="IBUITableViewCellStyleSubtitle" id="HA0-YT-b8c" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="zH0-LJ-jQI" detailTextLabel="l2u-CB-A9e" style="IBUITableViewCellStyleSubtitle" id="HA0-YT-b8c" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="77" width="374" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="HA0-YT-b8c" id="OcV-IL-7kf">
<rect key="frame" x="0.0" y="0.0" width="374" height="59"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Hot" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="zH0-LJ-jQI">
@@ -274,11 +281,11 @@
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="NkD-IS-qVP" detailTextLabel="Qra-AN-CyW" style="IBUITableViewCellStyleSubtitle" id="UhD-9i-fap" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="NkD-IS-qVP" detailTextLabel="Qra-AN-CyW" style="IBUITableViewCellStyleSubtitle" id="UhD-9i-fap" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="136" width="374" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="UhD-9i-fap" id="8bk-pA-IdP">
<rect key="frame" x="0.0" y="0.0" width="374" height="59"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="New" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="NkD-IS-qVP">
@@ -298,11 +305,11 @@
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="cQv-hE-hhj" detailTextLabel="6XP-xO-a2Z" style="IBUITableViewCellStyleSubtitle" id="hT6-IN-s9D" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="cQv-hE-hhj" detailTextLabel="6XP-xO-a2Z" style="IBUITableViewCellStyleSubtitle" id="hT6-IN-s9D" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="195" width="374" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="hT6-IN-s9D" id="KR1-8i-PxS">
<rect key="frame" x="0.0" y="0.0" width="374" height="59"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Top" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="cQv-hE-hhj">
@@ -322,11 +329,11 @@
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="xqK-wP-umX" detailTextLabel="6AI-Dt-0ix" style="IBUITableViewCellStyleSubtitle" id="Iz4-re-FWT" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="xqK-wP-umX" detailTextLabel="6AI-Dt-0ix" style="IBUITableViewCellStyleSubtitle" id="Iz4-re-FWT" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="254" width="374" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Iz4-re-FWT" id="1k3-3E-F1T">
<rect key="frame" x="0.0" y="0.0" width="374" height="59"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="59"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Rising" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="xqK-wP-umX">
@@ -360,6 +367,22 @@
</objects>
<point key="canvasLocation" x="1529" y="173"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="J2T-Ji-NG0">
<objects>
<navigationController id="fak-6k-FqE" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="eDp-09-xHT">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="q78-0w-suH" kind="relationship" relationship="rootViewController" id="QJq-wm-92D"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3Vk-Oj-BST" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1257" y="173"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">

View File

@@ -11,13 +11,12 @@ import Foundation
import UIKit
import Account
class RedditEnterDetailTableViewController: UITableViewController, SelectURLBuilder {
class RedditEnterDetailTableViewController: UITableViewController {
@IBOutlet weak var detailTextField: UITextField!
var nextBarButtonItem = UIBarButtonItem()
var redditFeedType: RedditFeedType?
weak var delegate: SelectURLBuilderDelegate?
override func viewDidLoad() {
super.viewDidLoad()
@@ -38,7 +37,6 @@ class RedditEnterDetailTableViewController: UITableViewController, SelectURLBuil
let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self)
selectSort.redditFeedType = redditFeedType
selectSort.subreddit = detailTextField.text?.collapsingWhitespace
selectSort.delegate = delegate
navigationController?.pushViewController(selectSort, animated: true)
}

View File

@@ -11,12 +11,11 @@ import Foundation
import UIKit
import Account
class RedditSelectAccountTableViewController: UITableViewController, SelectURLBuilder {
class RedditSelectAccountTableViewController: UITableViewController {
private var redditFeedProviders = [RedditFeedProvider]()
var redditFeedType: RedditFeedType?
weak var delegate: SelectURLBuilderDelegate?
override func viewDidLoad() {
super.viewDidLoad()
@@ -37,7 +36,6 @@ class RedditSelectAccountTableViewController: UITableViewController, SelectURLBu
let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self)
selectSort.redditFeedType = redditFeedType
selectSort.username = redditFeedProviders[indexPath.row].username
selectSort.delegate = delegate
navigationController?.pushViewController(selectSort, animated: true)
}

View File

@@ -9,16 +9,11 @@
import UIKit
import Account
class RedditSelectSortTableViewController: UITableViewController, SelectURLBuilder {
class RedditSelectSortTableViewController: UITableViewController {
weak var delegate: SelectURLBuilderDelegate?
var redditFeedType: RedditFeedType?
var username: String?
var subreddit: String?
override func viewDidLoad() {
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -39,11 +34,13 @@ class RedditSelectSortTableViewController: UITableViewController, SelectURLBuild
}
guard let redditFeedType = redditFeedType else { return }
let url = RedditFeedProvider.buildURL(redditFeedType, username: username, subreddit: subreddit, sort: sort)?.absoluteString
if let url = RedditFeedProvider.buildURL(redditFeedType, username: username, subreddit: subreddit, sort: sort) {
delegate?.selectURLBuilderDidBuildURL(url)
}
dismiss(animated: true)
let addViewController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddWebFeedViewController") as! AddWebFeedViewController
addViewController.addFeedType = .reddit
addViewController.initialFeed = url
navigationController?.pushViewController(addViewController, animated: true)
}
}

View File

@@ -9,14 +9,12 @@
import UIKit
import Account
class RedditSelectTypeTableViewController: UITableViewController, SelectURLBuilder {
class RedditSelectTypeTableViewController: UITableViewController {
weak var delegate: SelectURLBuilderDelegate?
@IBAction func cancel(_ sender: Any) {
dismiss(animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0:
@@ -25,28 +23,23 @@ class RedditSelectTypeTableViewController: UITableViewController, SelectURLBuild
let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self)
selectSort.redditFeedType = .home
selectSort.username = redditFeedProviders.first!.username
selectSort.delegate = delegate
navigationController?.pushViewController(selectSort, animated: true)
} else {
let selectAccount = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectAccountTableViewController.self)
selectAccount.redditFeedType = .home
selectAccount.delegate = delegate
navigationController?.pushViewController(selectAccount, animated: true)
}
case 1:
let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self)
selectSort.redditFeedType = .popular
selectSort.delegate = delegate
navigationController?.pushViewController(selectSort, animated: true)
case 2:
let selectSort = UIStoryboard.redditAdd.instantiateController(ofType: RedditSelectSortTableViewController.self)
selectSort.redditFeedType = .all
selectSort.delegate = delegate
navigationController?.pushViewController(selectSort, animated: true)
case 3:
let enterDetail = UIStoryboard.redditAdd.instantiateController(ofType: RedditEnterDetailTableViewController.self)
enterDetail.redditFeedType = .subreddit
enterDetail.delegate = delegate
navigationController?.pushViewController(enterDetail, animated: true)
default:
fatalError()