61 lines
2.0 KiB
Swift
61 lines
2.0 KiB
Swift
//
|
|
// VisibilityTableViewController.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 9/3/18.
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
class VisibilityTableViewController: UITableViewController {
|
|
|
|
// todo: description of visibility types
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
}
|
|
|
|
// MARK: - Table view data source
|
|
|
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
|
return 1
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
return Status.Visibility.allCases.count
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
let visibility = Status.Visibility.allCases[indexPath.row]
|
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "visibilityCell", for: indexPath)
|
|
cell.textLabel!.text = visibility.displayName
|
|
cell.accessoryType = visibility == Preferences.shared.defaultPostVisibility ? .checkmark : .none
|
|
return cell
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
let oldVisibility = Preferences.shared.defaultPostVisibility
|
|
let oldIndexPath = IndexPath(row: Status.Visibility.allCases.firstIndex(of: oldVisibility)!, section: 0)
|
|
|
|
let visibility = Status.Visibility.allCases[indexPath.row]
|
|
Preferences.shared.defaultPostVisibility = visibility
|
|
|
|
tableView.reloadRows(at: [indexPath], with: .automatic)
|
|
tableView.reloadRows(at: [oldIndexPath], with: .none)
|
|
}
|
|
|
|
/*
|
|
// MARK: - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
// Get the new view controller using segue.destination.
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
}
|