[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

//
// ComposeAccessoryView.swift
// elpha-ios
//
// Created by Dwayne Harris on 11/14/18.
// Copyright © 2018 Elpha. All rights reserved.
//
import UIKit
protocol ComposeAccessoryViewDelegate: class {
func attachmentTapped(_ sender: Any)
func visibilityTapped(_ sender: Any)
func tootTapped(_ sender: Any)
}
class ComposeAccessoryView: UIView {
@IBOutlet var contentView: UIView!
@IBOutlet var attachmentButton: UIButton!
@IBOutlet var visibilityButton: UIButton!
@IBOutlet var tootButton: UIButton!
weak var delegate: ComposeAccessoryViewDelegate?
var selectedVisibility: StatusVisibility = .public {
didSet {
visibilityButton.setTitle(" \(selectedVisibility.rawValue.capitalized)", for: .normal)
}
}
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
private func setup() {
Bundle.main.loadNibNamed("ComposeAccessoryView", owner: self, options: nil)
addSubview(contentView)
contentView.frame = self.bounds
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
attachmentButton.addTarget(self, action: #selector(attachmentTapped), for: .touchUpInside)
visibilityButton.addTarget(self, action: #selector(visibilityTapped), for: .touchUpInside)
tootButton.addTarget(self, action: #selector(tootTapped), for: .touchUpInside)
}
@objc func attachmentTapped() {
delegate?.attachmentTapped(self)
}
@objc func visibilityTapped() {
delegate?.visibilityTapped(self)
}
@objc func tootTapped() {
delegate?.tootTapped(self)
}
}