NetNewsWire/iOS/Settings/TimelinePreviewTableViewController.swift

100 lines
2.6 KiB
Swift
Raw Normal View History

2019-11-08 17:16:09 -06:00
//
// TimelinePreviewTableViewController.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 11/8/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
import Articles
class TimelinePreviewTableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
2025-01-22 22:18:09 -08:00
2019-11-08 17:16:09 -06:00
override func viewDidLoad() {
super.viewDidLoad()
2025-01-22 22:18:09 -08:00
2019-11-08 17:16:09 -06:00
tableView.delegate = self
tableView.dataSource = self
2025-01-22 22:18:09 -08:00
2019-11-08 17:16:09 -06:00
}
func heightFor(width: CGFloat) -> CGFloat {
if UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory {
let layout = MainTimelineAccessibilityCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData)
2019-11-08 17:16:09 -06:00
return layout.height
} else {
let layout = MainTimelineDefaultCellLayout(width: width, insets: tableView.safeAreaInsets, cellData: prototypeCellData)
2019-11-08 17:16:09 -06:00
return layout.height
}
}
// MARK: - Table view data source
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! MainTimelineTableViewCell
2019-11-08 17:16:09 -06:00
cell.cellData = prototypeCellData
return cell
}
2025-01-22 22:18:09 -08:00
2019-11-08 17:16:09 -06:00
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
}
// MARK: API
func reload() {
tableView.reloadData()
}
}
// MARK: Private
private extension TimelinePreviewTableViewController {
var prototypeCellData: MainTimelineCellData {
2025-01-23 22:52:36 -08:00
let longTitle = Constants.prototypeText
2025-01-22 22:18:09 -08:00
2019-11-08 17:16:09 -06:00
let prototypeID = "prototype"
let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, dateArrived: Date())
2025-01-23 22:52:36 -08:00
let prototypeArticle = Article(
accountID: prototypeID,
articleID: prototypeID,
feedID: prototypeID,
uniqueID: prototypeID,
title: longTitle, contentHTML: nil,
contentText: nil,
url: nil,
externalURL: nil,
summary: nil,
imageURL: nil,
datePublished: nil,
dateModified: nil,
authors: nil,
status: status
)
2025-01-22 22:18:09 -08:00
2019-11-08 17:16:09 -06:00
let iconImage = IconImage(AppAssets.faviconTemplateImage.withTintColor(AppAssets.secondaryAccentColor))
2025-01-22 22:18:09 -08:00
2025-01-23 22:52:36 -08:00
return MainTimelineCellData(
article: prototypeArticle,
showFeedName: .feed,
feedName: "Feed Name",
byline: nil, iconImage: iconImage,
showIcon: true,
numberOfLines: AppDefaults.shared.timelineNumberOfLines,
iconSize: AppDefaults.shared.timelineIconSize
)
2019-11-08 17:16:09 -06:00
}
}