Skip to content

Instantly share code, notes, and snippets.

@mhijack
Last active April 28, 2021 06:55
Show Gist options
  • Save mhijack/2de0eebf8425223d90b0f66800bb97bc to your computer and use it in GitHub Desktop.
Save mhijack/2de0eebf8425223d90b0f66800bb97bc to your computer and use it in GitHub Desktop.
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment