NetNewsWire/iOS/Add/Reddit/RedditSelectSortTableViewCo...

47 lines
1.1 KiB
Swift
Raw Normal View History

2020-05-12 18:17:47 +02:00
//
// RedditSelectSortTableViewController.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 5/12/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import UIKit
import Account
2020-08-11 23:27:42 +02:00
class RedditSelectSortTableViewController: UITableViewController {
2020-05-12 18:17:47 +02:00
var redditFeedType: RedditFeedType?
var username: String?
var subreddit: String?
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let sort: RedditSort
switch indexPath.row {
case 0:
sort = .best
case 1:
sort = .hot
case 2:
sort = .new
case 3:
sort = .top
case 4:
sort = .rising
default:
fatalError()
}
guard let redditFeedType = redditFeedType else { return }
2020-08-11 23:27:42 +02:00
let url = RedditFeedProvider.buildURL(redditFeedType, username: username, subreddit: subreddit, sort: sort)?.absoluteString
2020-05-12 18:17:47 +02:00
let addViewController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddWebFeedViewController") as! AddFeedViewController
2020-08-11 23:27:42 +02:00
addViewController.addFeedType = .reddit
addViewController.initialFeed = url
navigationController?.pushViewController(addViewController, animated: true)
2020-05-12 18:17:47 +02:00
}
}