forked from shadowfacts/Tusker
Rename StatusState to CollapseState
This commit is contained in:
parent
fcf95ba8c1
commit
cde3109203
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// StatusState.swift
|
// CollapseState.swift
|
||||||
// Pachyderm
|
// Pachyderm
|
||||||
//
|
//
|
||||||
// Created by Shadowfacts on 11/24/19.
|
// Created by Shadowfacts on 11/24/19.
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public class StatusState: Equatable {
|
public class CollapseState: Equatable {
|
||||||
public var collapsible: Bool?
|
public var collapsible: Bool?
|
||||||
public var collapsed: Bool?
|
public var collapsed: Bool?
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ public class StatusState: Equatable {
|
||||||
self.collapsed = collapsed
|
self.collapsed = collapsed
|
||||||
}
|
}
|
||||||
|
|
||||||
public func copy() -> StatusState {
|
public func copy() -> CollapseState {
|
||||||
return StatusState(collapsible: self.collapsible, collapsed: self.collapsed)
|
return CollapseState(collapsible: self.collapsible, collapsed: self.collapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func hash(into hasher: inout Hasher) {
|
public func hash(into hasher: inout Hasher) {
|
||||||
|
@ -30,11 +30,11 @@ public class StatusState: Equatable {
|
||||||
hasher.combine(collapsed)
|
hasher.combine(collapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static var unknown: StatusState {
|
public static var unknown: CollapseState {
|
||||||
StatusState(collapsible: nil, collapsed: nil)
|
CollapseState(collapsible: nil, collapsed: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func == (lhs: StatusState, rhs: StatusState) -> Bool {
|
public static func == (lhs: CollapseState, rhs: CollapseState) -> Bool {
|
||||||
lhs.collapsible == rhs.collapsible && lhs.collapsed == rhs.collapsed
|
lhs.collapsible == rhs.collapsible && lhs.collapsed == rhs.collapsed
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ public struct NotificationGroup: Identifiable, Hashable {
|
||||||
public private(set) var notifications: [Notification]
|
public private(set) var notifications: [Notification]
|
||||||
public let id: String
|
public let id: String
|
||||||
public let kind: Notification.Kind
|
public let kind: Notification.Kind
|
||||||
public let statusState: StatusState?
|
public let statusState: CollapseState?
|
||||||
|
|
||||||
init?(notifications: [Notification]) {
|
init?(notifications: [Notification]) {
|
||||||
guard !notifications.isEmpty else { return nil }
|
guard !notifications.isEmpty else { return nil }
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
|
||||||
extension StatusState {
|
extension CollapseState {
|
||||||
|
|
||||||
func resolveFor(status: StatusMO, height: CGFloat, textLength: Int? = nil) {
|
func resolveFor(status: StatusMO, height: CGFloat, textLength: Int? = nil) {
|
||||||
let longEnoughToCollapse: Bool
|
let longEnoughToCollapse: Bool
|
||||||
|
|
|
@ -17,7 +17,7 @@ class BookmarksTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
private var loaded = false
|
private var loaded = false
|
||||||
|
|
||||||
var statuses: [(id: String, state: StatusState)] = []
|
var statuses: [(id: String, state: CollapseState)] = []
|
||||||
|
|
||||||
var newer: RequestRange?
|
var newer: RequestRange?
|
||||||
var older: RequestRange?
|
var older: RequestRange?
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
weak var mastodonController: MastodonController!
|
weak var mastodonController: MastodonController!
|
||||||
|
|
||||||
let mainStatusID: String
|
let mainStatusID: String
|
||||||
let mainStatusState: StatusState
|
let mainStatusState: CollapseState
|
||||||
var statusIDToScrollToOnLoad: String
|
var statusIDToScrollToOnLoad: String
|
||||||
private(set) var dataSource: UITableViewDiffableDataSource<Section, Item>!
|
private(set) var dataSource: UITableViewDiffableDataSource<Section, Item>!
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
private var loadingState = LoadingState.unloaded
|
private var loadingState = LoadingState.unloaded
|
||||||
|
|
||||||
init(for mainStatusID: String, state: StatusState = .unknown, mastodonController: MastodonController) {
|
init(for mainStatusID: String, state: CollapseState = .unknown, mastodonController: MastodonController) {
|
||||||
self.mainStatusID = mainStatusID
|
self.mainStatusID = mainStatusID
|
||||||
self.mainStatusState = state
|
self.mainStatusState = state
|
||||||
self.statusIDToScrollToOnLoad = mainStatusID
|
self.statusIDToScrollToOnLoad = mainStatusID
|
||||||
|
@ -336,7 +336,7 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func item(for indexPath: IndexPath) -> (id: String, state: StatusState)? {
|
func item(for indexPath: IndexPath) -> (id: String, state: CollapseState)? {
|
||||||
return self.dataSource.itemIdentifier(for: indexPath).flatMap { (item) in
|
return self.dataSource.itemIdentifier(for: indexPath).flatMap { (item) in
|
||||||
switch item {
|
switch item {
|
||||||
case let .status(id: id, state: state):
|
case let .status(id: id, state: state):
|
||||||
|
@ -402,7 +402,7 @@ extension ConversationTableViewController {
|
||||||
case childThread(firstStatusID: String)
|
case childThread(firstStatusID: String)
|
||||||
}
|
}
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case status(id: String, state: StatusState)
|
case status(id: String, state: CollapseState)
|
||||||
case expandThread(childThreads: [ConversationNode], inline: Bool)
|
case expandThread(childThreads: [ConversationNode], inline: Bool)
|
||||||
|
|
||||||
static func == (lhs: Item, rhs: Item) -> Bool {
|
static func == (lhs: Item, rhs: Item) -> Bool {
|
||||||
|
@ -443,7 +443,7 @@ extension ConversationTableViewController {
|
||||||
extension ConversationTableViewController: TuskerNavigationDelegate {
|
extension ConversationTableViewController: TuskerNavigationDelegate {
|
||||||
var apiController: MastodonController! { mastodonController }
|
var apiController: MastodonController! { mastodonController }
|
||||||
|
|
||||||
func conversation(mainStatusID: String, state: StatusState) -> ConversationTableViewController {
|
func conversation(mainStatusID: String, state: CollapseState) -> ConversationTableViewController {
|
||||||
let vc = ConversationTableViewController(for: mainStatusID, state: state, mastodonController: mastodonController)
|
let vc = ConversationTableViewController(for: mainStatusID, state: state, mastodonController: mastodonController)
|
||||||
// transfer show statuses automatically state when showing new conversation
|
// transfer show statuses automatically state when showing new conversation
|
||||||
vc.showStatusesAutomatically = self.showStatusesAutomatically
|
vc.showStatusesAutomatically = self.showStatusesAutomatically
|
||||||
|
|
|
@ -62,7 +62,7 @@ class TrendingStatusesViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||||
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, StatusState)> { [unowned self] cell, indexPath, item in
|
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, item in
|
||||||
cell.delegate = self
|
cell.delegate = self
|
||||||
cell.updateUI(statusID: item.0, state: item.1)
|
cell.updateUI(statusID: item.0, state: item.1)
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ extension TrendingStatusesViewController {
|
||||||
case statuses
|
case statuses
|
||||||
}
|
}
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case status(id: String, state: StatusState)
|
case status(id: String, state: CollapseState)
|
||||||
case loadingIndicator
|
case loadingIndicator
|
||||||
|
|
||||||
static func ==(lhs: Item, rhs: Item) -> Bool {
|
static func ==(lhs: Item, rhs: Item) -> Bool {
|
||||||
|
|
|
@ -110,7 +110,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
|
|
||||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||||
collectionView.register(ProfileHeaderCollectionViewCell.self, forCellWithReuseIdentifier: "headerCell")
|
collectionView.register(ProfileHeaderCollectionViewCell.self, forCellWithReuseIdentifier: "headerCell")
|
||||||
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, StatusState, Bool)> { [unowned self] cell, indexPath, item in
|
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState, Bool)> { [unowned self] cell, indexPath, item in
|
||||||
cell.delegate = self
|
cell.delegate = self
|
||||||
cell.showPinned = item.2
|
cell.showPinned = item.2
|
||||||
cell.updateUI(statusID: item.0, state: item.1)
|
cell.updateUI(statusID: item.0, state: item.1)
|
||||||
|
@ -288,7 +288,7 @@ extension ProfileStatusesViewController {
|
||||||
typealias TimelineItem = String
|
typealias TimelineItem = String
|
||||||
|
|
||||||
case header(String)
|
case header(String)
|
||||||
case status(id: String, state: StatusState, pinned: Bool)
|
case status(id: String, state: CollapseState, pinned: Bool)
|
||||||
case loadingIndicator
|
case loadingIndicator
|
||||||
case confirmLoadMore
|
case confirmLoadMore
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ extension SearchResultsViewController {
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case account(String)
|
case account(String)
|
||||||
case hashtag(Hashtag)
|
case hashtag(Hashtag)
|
||||||
case status(String, StatusState)
|
case status(String, CollapseState)
|
||||||
|
|
||||||
func hash(into hasher: inout Hasher) {
|
func hash(into hasher: inout Hasher) {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
|
@ -14,7 +14,7 @@ class StatusActionAccountListViewController: UIViewController {
|
||||||
private let mastodonController: MastodonController
|
private let mastodonController: MastodonController
|
||||||
private let actionType: ActionType
|
private let actionType: ActionType
|
||||||
private let statusID: String
|
private let statusID: String
|
||||||
private let statusState: StatusState
|
private let statusState: CollapseState
|
||||||
private var accountIDs: [String]?
|
private var accountIDs: [String]?
|
||||||
|
|
||||||
/// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate.
|
/// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate.
|
||||||
|
@ -33,7 +33,7 @@ class StatusActionAccountListViewController: UIViewController {
|
||||||
- Parameter accountIDs The accounts that will be shown. If `nil` is passed, a request will be performed to load the accounts.
|
- Parameter accountIDs The accounts that will be shown. If `nil` is passed, a request will be performed to load the accounts.
|
||||||
- Parameter mastodonController The `MastodonController` instance this view controller uses.
|
- Parameter mastodonController The `MastodonController` instance this view controller uses.
|
||||||
*/
|
*/
|
||||||
init(actionType: ActionType, statusID: String, statusState: StatusState, accountIDs: [String]?, mastodonController: MastodonController) {
|
init(actionType: ActionType, statusID: String, statusState: CollapseState, accountIDs: [String]?, mastodonController: MastodonController) {
|
||||||
self.mastodonController = mastodonController
|
self.mastodonController = mastodonController
|
||||||
self.actionType = actionType
|
self.actionType = actionType
|
||||||
self.statusID = statusID
|
self.statusID = statusID
|
||||||
|
|
|
@ -69,7 +69,7 @@ class InstanceTimelineViewController: TimelineViewController {
|
||||||
toggleSaveButton.title = toggleSaveButtonTitle
|
toggleSaveButton.title = toggleSaveButtonTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
override func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: StatusState) {
|
override func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: CollapseState) {
|
||||||
cell.delegate = browsingEnabled ? self : nil
|
cell.delegate = browsingEnabled ? self : nil
|
||||||
cell.overrideMastodonController = mastodonController
|
cell.overrideMastodonController = mastodonController
|
||||||
cell.updateUI(statusID: id, state: state)
|
cell.updateUI(statusID: id, state: state)
|
||||||
|
|
|
@ -99,7 +99,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
}
|
}
|
||||||
|
|
||||||
// separate method because InstanceTimelineViewController needs to be able to customize it
|
// separate method because InstanceTimelineViewController needs to be able to customize it
|
||||||
func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: StatusState) {
|
func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: CollapseState) {
|
||||||
cell.delegate = self
|
cell.delegate = self
|
||||||
if case .home = timeline {
|
if case .home = timeline {
|
||||||
cell.showFollowedHashtags = true
|
cell.showFollowedHashtags = true
|
||||||
|
@ -110,7 +110,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||||
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, StatusState)> { [unowned self] cell, indexPath, item in
|
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, item in
|
||||||
self.configureStatusCell(cell, id: item.0, state: item.1)
|
self.configureStatusCell(cell, id: item.0, state: item.1)
|
||||||
}
|
}
|
||||||
let gapCell = UICollectionView.CellRegistration<TimelineGapCollectionViewCell, Void> { cell, indexPath, _ in
|
let gapCell = UICollectionView.CellRegistration<TimelineGapCollectionViewCell, Void> { cell, indexPath, _ in
|
||||||
|
@ -463,7 +463,7 @@ extension TimelineViewController {
|
||||||
enum Item: TimelineLikeCollectionViewItem {
|
enum Item: TimelineLikeCollectionViewItem {
|
||||||
typealias TimelineItem = String // status ID
|
typealias TimelineItem = String // status ID
|
||||||
|
|
||||||
case status(id: String, state: StatusState)
|
case status(id: String, state: CollapseState)
|
||||||
case gap
|
case gap
|
||||||
case loadingIndicator
|
case loadingIndicator
|
||||||
case confirmLoadMore
|
case confirmLoadMore
|
||||||
|
|
|
@ -13,7 +13,7 @@ import Pachyderm
|
||||||
protocol TuskerNavigationDelegate: UIViewController, ToastableViewController {
|
protocol TuskerNavigationDelegate: UIViewController, ToastableViewController {
|
||||||
var apiController: MastodonController! { get }
|
var apiController: MastodonController! { get }
|
||||||
|
|
||||||
func conversation(mainStatusID: String, state: StatusState) -> ConversationTableViewController
|
func conversation(mainStatusID: String, state: CollapseState) -> ConversationTableViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TuskerNavigationDelegate {
|
extension TuskerNavigationDelegate {
|
||||||
|
@ -76,7 +76,7 @@ extension TuskerNavigationDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func conversation(mainStatusID: String, state: StatusState) -> ConversationTableViewController {
|
func conversation(mainStatusID: String, state: CollapseState) -> ConversationTableViewController {
|
||||||
return ConversationTableViewController(for: mainStatusID, state: state, mastodonController: apiController)
|
return ConversationTableViewController(for: mainStatusID, state: state, mastodonController: apiController)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ extension TuskerNavigationDelegate {
|
||||||
self.selected(status: statusID, state: .unknown)
|
self.selected(status: statusID, state: .unknown)
|
||||||
}
|
}
|
||||||
|
|
||||||
func selected(status statusID: String, state: StatusState) {
|
func selected(status statusID: String, state: CollapseState) {
|
||||||
show(conversation(mainStatusID: statusID, state: state), sender: self)
|
show(conversation(mainStatusID: statusID, state: state), sender: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ extension TuskerNavigationDelegate {
|
||||||
show(vc, sender: self)
|
show(vc, sender: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: StatusState, accountIDs: [String]?) -> StatusActionAccountListViewController {
|
func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: CollapseState, accountIDs: [String]?) -> StatusActionAccountListViewController {
|
||||||
return StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: state, accountIDs: accountIDs, mastodonController: apiController)
|
return StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: state, accountIDs: accountIDs, mastodonController: apiController)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private(set) var statusState: StatusState!
|
private(set) var statusState: CollapseState!
|
||||||
var collapsible = false {
|
var collapsible = false {
|
||||||
didSet {
|
didSet {
|
||||||
collapseButton.isHidden = !collapsible
|
collapseButton.isHidden = !collapsible
|
||||||
|
@ -130,7 +130,7 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final func updateUI(statusID: String, state: StatusState) {
|
final func updateUI(statusID: String, state: CollapseState) {
|
||||||
createObserversIfNecessary()
|
createObserversIfNecessary()
|
||||||
|
|
||||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||||
|
@ -142,7 +142,7 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
doUpdateUI(status: status, state: state)
|
doUpdateUI(status: status, state: state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doUpdateUI(status: StatusMO, state: StatusState) {
|
func doUpdateUI(status: StatusMO, state: CollapseState) {
|
||||||
self.statusState = state
|
self.statusState = state
|
||||||
|
|
||||||
let account = status.account
|
let account = status.account
|
||||||
|
|
|
@ -80,7 +80,7 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
timestampAndClientLabel.adjustsFontForContentSizeCategory = true
|
timestampAndClientLabel.adjustsFontForContentSizeCategory = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override func doUpdateUI(status: StatusMO, state: StatusState) {
|
override func doUpdateUI(status: StatusMO, state: CollapseState) {
|
||||||
super.doUpdateUI(status: status, state: state)
|
super.doUpdateUI(status: status, state: state)
|
||||||
|
|
||||||
var timestampAndClientText = ConversationMainStatusTableViewCell.dateFormatter.string(from: status.createdAt)
|
var timestampAndClientText = ConversationMainStatusTableViewCell.dateFormatter.string(from: status.createdAt)
|
||||||
|
|
|
@ -36,7 +36,7 @@ protocol StatusCollectionViewCell: UICollectionViewCell, AttachmentViewDelegate
|
||||||
var showReplyIndicator: Bool { get }
|
var showReplyIndicator: Bool { get }
|
||||||
|
|
||||||
var statusID: String! { get set }
|
var statusID: String! { get set }
|
||||||
var statusState: StatusState! { get set }
|
var statusState: CollapseState! { get set }
|
||||||
var accountID: String! { get set }
|
var accountID: String! { get set }
|
||||||
|
|
||||||
var isGrayscale: Bool { get set }
|
var isGrayscale: Bool { get set }
|
||||||
|
|
|
@ -265,7 +265,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
|
|
||||||
// alas these need to be internal so they're accessible from the protocol extensions
|
// alas these need to be internal so they're accessible from the protocol extensions
|
||||||
var statusID: String!
|
var statusID: String!
|
||||||
var statusState: StatusState!
|
var statusState: CollapseState!
|
||||||
var accountID: String!
|
var accountID: String!
|
||||||
private var reblogStatusID: String?
|
private var reblogStatusID: String?
|
||||||
private var rebloggerID: String?
|
private var rebloggerID: String?
|
||||||
|
@ -422,7 +422,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
|
|
||||||
// MARK: Configure UI
|
// MARK: Configure UI
|
||||||
|
|
||||||
func updateUI(statusID: String, state: StatusState) {
|
func updateUI(statusID: String, state: CollapseState) {
|
||||||
guard var status = mastodonController.persistentContainer.status(for: statusID) else {
|
guard var status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||||
fatalError()
|
fatalError()
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func doUpdateUI(status: StatusMO, state: StatusState) {
|
override func doUpdateUI(status: StatusMO, state: CollapseState) {
|
||||||
var status = status
|
var status = status
|
||||||
|
|
||||||
if let rebloggedStatus = status.reblog {
|
if let rebloggedStatus = status.reblog {
|
||||||
|
|
Loading…
Reference in New Issue