You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeOptionsManager: NSObject, OptionsManager {
/// Use private(set) to mark the setter private
private(set) var options: [String]
private let TABLE_CELL_HEIGHT: CGFloat = 44
private var tableViewHeight: CGFloat {
return TABLE_CELL_HEIGHT * CGFloat(options.count) + (UIApplication.shared.windows.first?.safeAreaInsets.bottom ?? 0) /// Taking into account the bottom safe area for full-screen iphones
}
/// Views
private var backgroundView: UIView?
private var optionsView: UITableView?
/// Action handler
public var optionsDidOpen: (() -> ())?
public var optionsDidDismiss: (() -> ())?
public var didSelectOption: ((String) -> ())?
init(options: [String] = []) {
self.options = options
}
/// Configures options view and add to screen
public func showOptions() {
guard backgroundView == nil else { return }
guard let window = UIApplication.shared.windows.first else { return }
/// The background view that covers the entire screen
let backgroundView = UIView(frame: window.bounds)
backgroundView.backgroundColor = .black
backgroundView.alpha = 0
window.subviews(backgroundView)
backgroundView.fillContainer()
/// The actual clickable options table view
let optionsTableView = UITableView(frame: .zero, style: .plain)