[ABANDONED] Mastodon iOS client.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB

  1. //
  2. // ComposeAccessoryView.swift
  3. // elpha-ios
  4. //
  5. // Created by Dwayne Harris on 11/14/18.
  6. // Copyright © 2018 Elpha. All rights reserved.
  7. //
  8. import UIKit
  9. protocol ComposeAccessoryViewDelegate: class {
  10. func attachmentTapped(_ sender: Any)
  11. func visibilityTapped(_ sender: Any)
  12. func tootTapped(_ sender: Any)
  13. }
  14. class ComposeAccessoryView: UIView {
  15. @IBOutlet var contentView: UIView!
  16. @IBOutlet var attachmentButton: UIButton!
  17. @IBOutlet var visibilityButton: UIButton!
  18. @IBOutlet var tootButton: UIButton!
  19. weak var delegate: ComposeAccessoryViewDelegate?
  20. var selectedVisibility: StatusVisibility = .public {
  21. didSet {
  22. visibilityButton.setTitle(" \(selectedVisibility.rawValue.capitalized)", for: .normal)
  23. }
  24. }
  25. override init(frame: CGRect) {
  26. super.init(frame: frame)
  27. setup()
  28. }
  29. required init?(coder aDecoder: NSCoder) {
  30. super.init(coder: aDecoder)
  31. setup()
  32. }
  33. private func setup() {
  34. Bundle.main.loadNibNamed("ComposeAccessoryView", owner: self, options: nil)
  35. addSubview(contentView)
  36. contentView.frame = self.bounds
  37. contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  38. attachmentButton.addTarget(self, action: #selector(attachmentTapped), for: .touchUpInside)
  39. visibilityButton.addTarget(self, action: #selector(visibilityTapped), for: .touchUpInside)
  40. tootButton.addTarget(self, action: #selector(tootTapped), for: .touchUpInside)
  41. }
  42. @objc func attachmentTapped() {
  43. delegate?.attachmentTapped(self)
  44. }
  45. @objc func visibilityTapped() {
  46. delegate?.visibilityTapped(self)
  47. }
  48. @objc func tootTapped() {
  49. delegate?.tootTapped(self)
  50. }
  51. }