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.7 KiB
63 lines
1.7 KiB
//
|
|
// ComposeAccessoryView.swift
|
|
// elpha-ios
|
|
//
|
|
// Created by Dwayne Harris on 11/14/18.
|
|
// Copyright © 2018 Elpha. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
protocol ComposeAccessoryViewDelegate {
|
|
func attachmentTapped()
|
|
func visibilityTapped()
|
|
func tootTapped()
|
|
}
|
|
|
|
class ComposeAccessoryView: UIView {
|
|
@IBOutlet var contentView: UIView!
|
|
@IBOutlet var attachmentButton: UIButton!
|
|
@IBOutlet var visibilityButton: UIButton!
|
|
@IBOutlet var tootButton: UIButton!
|
|
|
|
var delegate: ComposeAccessoryViewDelegate? = nil
|
|
|
|
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()
|
|
}
|
|
|
|
@objc func visibilityTapped() {
|
|
delegate?.visibilityTapped()
|
|
}
|
|
|
|
@objc func tootTapped() {
|
|
delegate?.tootTapped()
|
|
}
|
|
}
|