Tusker/Tusker/Screens/Lists/ListTimelineViewController....

66 lines
1.8 KiB
Swift

//
// ListTimelineViewController.swift
// Tusker
//
// Created by Shadowfacts on 12/17/19.
// Copyright © 2019 Shadowfacts. All rights reserved.
//
import UIKit
import Pachyderm
class ListTimelineViewController: TimelineTableViewController {
let list: List
var presentEditOnAppear = false
init(for list: List, mastodonController: MastodonController) {
self.list = list
super.init(for: .list(id: list.id), mastodonController: mastodonController)
title = list.title
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(editButtonPressed))
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if presentEditOnAppear {
presentEdit(animated: animated)
}
}
func presentEdit(animated: Bool) {
let editListAccountsController = EditListAccountsViewController(list: list, mastodonController: mastodonController)
editListAccountsController.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(doneButtonPressed))
let navController = UINavigationController(rootViewController: editListAccountsController)
present(navController, animated: animated)
}
// MARK: - Interaction
@objc func editButtonPressed() {
presentEdit(animated: true)
}
@objc func doneButtonPressed() {
dismiss(animated: true)
// todo: show loading indicator
timelineSegments = []
loadInitialStatuses()
}
}