Tusker/Tusker/Screens/Timeline/TimelineGapCollectionViewCe...

59 lines
1.8 KiB
Swift

//
// TimelineGapCollectionViewCell.swift
// Tusker
//
// Created by Shadowfacts on 11/16/22.
// Copyright © 2022 Shadowfacts. All rights reserved.
//
import UIKit
class TimelineGapCollectionViewCell: UICollectionViewCell {
var fillGap: ((TimelineGapDirection) -> Void)?
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .red
var belowConfig = UIButton.Configuration.borderless()
belowConfig.title = "Below"
let below = UIButton(configuration: belowConfig)
below.addTarget(self, action: #selector(loadBelowPressed), for: .touchUpInside)
var aboveConfig = UIButton.Configuration.borderless()
aboveConfig.title = "Above"
let above = UIButton(configuration: aboveConfig)
above.addTarget(self, action: #selector(loadAbovePressed), for: .touchUpInside)
let stack = UIStackView(arrangedSubviews: [
above,
below,
])
stack.axis = .vertical
stack.spacing = 4
stack.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(stack)
NSLayoutConstraint.activate([
stack.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
stack.topAnchor.constraint(equalTo: contentView.topAnchor),
stack.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
])
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc private func loadBelowPressed() {
fillGap?(.below)
}
@objc private func loadAbovePressed() {
fillGap?(.above)
}
}