mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00

- Laboriously updated the icons (finding the names in the web inspector, updating the code, inspecting the colors, setting those separately, dealing with scaling issues, etc etc). - Let me know if you spot any icons that I missed, or unscaled icons (they have to be explicitly sized, otherwise appear huge). - More space between story title and story content. - More space when reading a folder. - Added Compact/Comfortable to feed detail menu. - Changing Compact/Comfortable also adjusts the feed detail list. - Adjusted the color of the story content etc in the feed detail list. - Removed top and bottom borders from feed title gradient in story detail. - More space in story detail header. - The feed detail is offset when selected. - Updated the feeds social, search, and saved background colors. - Unread counts no longer have a shadow, and have more space. - Folders and feeds remain selected in the feeds list when returning from a story or refreshing. - Folders in the feeds list no longer have a different background color. - The folders and feeds highlight is now rounded and unbordered like on web.
148 lines
5.3 KiB
Swift
148 lines
5.3 KiB
Swift
//
|
|
// ShareViewDelegate.swift
|
|
// Share Extension
|
|
//
|
|
// Created by David Sinclair on 2021-07-18.
|
|
// Copyright © 2021 NewsBlur. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class ShareViewDelegate: NSObject {
|
|
@IBOutlet weak var viewController: ShareViewController!
|
|
}
|
|
|
|
extension ShareViewDelegate: UITableViewDelegate {
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
if viewController.mode == .add, indexPath.section == 0 {
|
|
viewController.selectedFolderIndexPath = indexPath
|
|
tableView.reloadData()
|
|
}
|
|
|
|
viewController.updateSaveButtonState()
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
|
|
viewController.updateSaveButtonState()
|
|
}
|
|
}
|
|
|
|
extension ShareViewDelegate: UITableViewDataSource {
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
if viewController.mode == .add {
|
|
return 2
|
|
} else {
|
|
return 1
|
|
}
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
|
if viewController.mode == .add, section == 1 {
|
|
return "Add new sub-folder:"
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
switch viewController.mode {
|
|
case .save:
|
|
return viewController.tags.count + 1
|
|
case .share:
|
|
return 1
|
|
case .add:
|
|
if section == 0 {
|
|
return viewController.folders.count
|
|
} else {
|
|
return 1
|
|
}
|
|
}
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
if viewController.mode == .save {
|
|
if indexPath.item < viewController.tags.count {
|
|
return makeSaveTagCell(for: tableView, indexPath: indexPath)
|
|
} else {
|
|
return makeSaveNewCell(for: tableView, indexPath: indexPath, name: "", placeholder: "new tag")
|
|
}
|
|
} else if viewController.mode == .add {
|
|
if indexPath.section == 0 {
|
|
return makeAddSiteCell(for: tableView, indexPath: indexPath)
|
|
} else {
|
|
return makeSaveNewCell(for: tableView, indexPath: indexPath, name: viewController.newFolder, placeholder: "new tag")
|
|
}
|
|
} else {
|
|
return makeShareCommentCell(for: tableView, indexPath: indexPath)
|
|
}
|
|
}
|
|
}
|
|
|
|
private extension ShareViewDelegate {
|
|
func makeSaveTagCell(for tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
|
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: ShareSaveTagCell.reuseIdentifier, for: indexPath) as? ShareSaveTagCell else {
|
|
preconditionFailure("Expected to dequeue a ShareSaveTagCell")
|
|
}
|
|
|
|
let tag = viewController.tags[indexPath.item]
|
|
|
|
cell.tagLabel.text = tag.name
|
|
cell.countLabel.text = "\(tag.count)"
|
|
|
|
return cell
|
|
}
|
|
|
|
func makeSaveNewCell(for tableView: UITableView, indexPath: IndexPath, name: String, placeholder: String) -> UITableViewCell {
|
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: ShareSaveNewCell.reuseIdentifier, for: indexPath) as? ShareSaveNewCell else {
|
|
preconditionFailure("Expected to dequeue a ShareSaveNewCell")
|
|
}
|
|
|
|
cell.tagField.text = name
|
|
cell.tagField.placeholder = placeholder
|
|
|
|
return cell
|
|
}
|
|
|
|
func makeAddSiteCell(for tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
|
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: ShareAddSiteCell.reuseIdentifier, for: indexPath) as? ShareAddSiteCell else {
|
|
preconditionFailure("Expected to dequeue a ShareAddSiteCell")
|
|
}
|
|
|
|
let components = viewController.folders[indexPath.item].components(separatedBy: " ▸ ")
|
|
|
|
if components.first == "everything" {
|
|
cell.folderImageView.image = UIImage(named: "all-stories")
|
|
cell.folderLabel.text = "Top Level"
|
|
cell.folderImageLeadingConstraint.constant = 20
|
|
} else {
|
|
cell.folderImageView.image = UIImage(named: "g_icn_folder.png")
|
|
cell.folderLabel.text = components.last ?? "?"
|
|
cell.folderImageLeadingConstraint.constant = 20 + CGFloat(components.count * 35)
|
|
}
|
|
|
|
cell.accessoryType = indexPath == viewController.selectedFolderIndexPath ? .checkmark : .none
|
|
|
|
return cell
|
|
}
|
|
|
|
func makeShareCommentCell(for tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
|
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: ShareCommentCell.reuseIdentifier, for: indexPath) as? ShareCommentCell else {
|
|
preconditionFailure("Expected to dequeue a ShareCommentCell")
|
|
}
|
|
|
|
cell.commentTextView.text = ""
|
|
cell.commentTextView.delegate = self
|
|
|
|
DispatchQueue.main.async {
|
|
cell.commentTextView.becomeFirstResponder()
|
|
}
|
|
|
|
return cell
|
|
}
|
|
}
|
|
|
|
extension ShareViewDelegate: UITextViewDelegate {
|
|
func textViewDidChange(_ textView: UITextView) {
|
|
viewController.comments = textView.text
|
|
}
|
|
}
|