// // DocumentControlViewController.swift // App // // Created by James Magahern on 9/22/20. // import UIKit class DocumentControlViewController: UIViewController { let documentControlsView = DocumentControlsView() let fontSizeAdjustView = FontSizeAdjustView() let navigationControlView = NavigationControlsView() let findOnPageControlView = DocumentControlItemView().title("Find On Page") .symbol("magnifyingglass") let settingsView = DocumentControlItemView().title("Settings") .symbol("gear") let readabilityView = DocumentControlItemView().title("Reader Mode") .symbol("doc.richtext") let archiveView = DocumentControlItemView().title("Archive.today") .symbol("shippingbox") let emailView = DocumentControlItemView().title("Email") .symbol("envelope") let sharingView = DocumentControlItemView().title("Share") .symbol("square.and.arrow.up") let historyView = DocumentControlItemView().title("History") .symbol("clock.arrow.circlepath") let darkModeView = DocumentControlItemView().title("Dark Mode") var observations: [NSKeyValueObservation] = [] static public let preferredWidth = CGFloat(230.0) init(darkModeEnabled: Bool) { super.init(nibName: nil, bundle: nil) if darkModeEnabled { darkModeView.label.text = "Disable Dark Mode" } else { darkModeView.label.text = "Enable Dark Mode" } darkModeView.imageView.image = DarkModeControls.buttonImage(forDarkModeState: darkModeEnabled) documentControlsView.stackView.addArrangedSubview(navigationControlView) documentControlsView.stackView.addArrangedSubview(fontSizeAdjustView) documentControlsView.stackView.addArrangedSubview(emailView) documentControlsView.stackView.addArrangedSubview(sharingView) documentControlsView.stackView.addArrangedSubview(findOnPageControlView) documentControlsView.stackView.addArrangedSubview(darkModeView) documentControlsView.stackView.addArrangedSubview(readabilityView) documentControlsView.stackView.addArrangedSubview(archiveView) documentControlsView.stackView.addArrangedSubview(historyView) documentControlsView.stackView.addArrangedSubview(settingsView) for (i, view) in documentControlsView.stackView.arrangedSubviews.enumerated() { view.drawsBottomSeparator = (i < documentControlsView.stackView.arrangedSubviews.count - 1) } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func loadView() { self.view = documentControlsView } override var preferredContentSize: CGSize { get { documentControlsView.stackView.sizeThatFits(CGSize(width: Self.preferredWidth, height: -1)) } set {} } }