Put document controls view in a scroll view
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class DocumentControlView: UIControl
|
||||
class DocumentControlItemView: UIControl
|
||||
{
|
||||
static public let controlHeight = CGFloat(48.0)
|
||||
|
||||
@@ -9,14 +9,14 @@ import UIKit
|
||||
|
||||
class DocumentControlViewController: UIViewController
|
||||
{
|
||||
let documentControlView = StackView<DocumentControlView>(dimension: .vertical)
|
||||
let documentControlsView = DocumentControlsView()
|
||||
let fontSizeAdjustView = FontSizeAdjustView()
|
||||
let findOnPageControlView = DocumentControlView()
|
||||
let findOnPageControlView = DocumentControlItemView()
|
||||
let navigationControlView = NavigationControlsView()
|
||||
let settingsView = DocumentControlView()
|
||||
let readabilityView = DocumentControlView()
|
||||
let darkModeView = DocumentControlView()
|
||||
let archiveView = DocumentControlView()
|
||||
let settingsView = DocumentControlItemView()
|
||||
let readabilityView = DocumentControlItemView()
|
||||
let darkModeView = DocumentControlItemView()
|
||||
let archiveView = DocumentControlItemView()
|
||||
|
||||
var observations: [NSKeyValueObservation] = []
|
||||
|
||||
@@ -45,17 +45,17 @@ class DocumentControlViewController: UIViewController
|
||||
|
||||
darkModeView.imageView.image = DarkModeControls.buttonImage(forDarkModeState: darkModeEnabled)
|
||||
|
||||
documentControlView.addArrangedSubview(navigationControlView)
|
||||
documentControlView.addArrangedSubview(fontSizeAdjustView)
|
||||
documentControlView.addArrangedSubview(findOnPageControlView)
|
||||
documentControlView.addArrangedSubview(darkModeView)
|
||||
documentControlView.addArrangedSubview(readabilityView)
|
||||
documentControlView.addArrangedSubview(archiveView)
|
||||
documentControlsView.stackView.addArrangedSubview(navigationControlView)
|
||||
documentControlsView.stackView.addArrangedSubview(fontSizeAdjustView)
|
||||
documentControlsView.stackView.addArrangedSubview(findOnPageControlView)
|
||||
documentControlsView.stackView.addArrangedSubview(darkModeView)
|
||||
documentControlsView.stackView.addArrangedSubview(readabilityView)
|
||||
documentControlsView.stackView.addArrangedSubview(archiveView)
|
||||
|
||||
documentControlView.addArrangedSubview(settingsView)
|
||||
documentControlsView.stackView.addArrangedSubview(settingsView)
|
||||
|
||||
for (i, view) in documentControlView.arrangedSubviews.enumerated() {
|
||||
view.drawsBottomSeparator = (i < documentControlView.arrangedSubviews.count - 1)
|
||||
for (i, view) in documentControlsView.stackView.arrangedSubviews.enumerated() {
|
||||
view.drawsBottomSeparator = (i < documentControlsView.stackView.arrangedSubviews.count - 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ class DocumentControlViewController: UIViewController
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
self.view = documentControlView
|
||||
self.view = documentControlsView
|
||||
}
|
||||
|
||||
override var preferredContentSize: CGSize {
|
||||
get { documentControlView.sizeThatFits(CGSize(width: Self.preferredWidth, height: -1)) }
|
||||
get { documentControlsView.stackView.sizeThatFits(CGSize(width: Self.preferredWidth, height: -1)) }
|
||||
set {}
|
||||
}
|
||||
}
|
||||
|
||||
29
App/Document Controls UI/DocumentControlsView.swift
Normal file
29
App/Document Controls UI/DocumentControlsView.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// DocumentControlsView.swift
|
||||
// App
|
||||
//
|
||||
// Created by James Magahern on 4/28/21.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class DocumentControlsView : UIScrollView
|
||||
{
|
||||
public let stackView = StackView<DocumentControlItemView>(dimension: .vertical)
|
||||
|
||||
convenience init() {
|
||||
self.init(frame: .zero)
|
||||
addSubview(stackView)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
let stackViewSize = stackView.sizeThatFits(CGSize(width: bounds.width, height: -1))
|
||||
stackView.frame = CGRect(
|
||||
origin: .zero, size: stackViewSize
|
||||
)
|
||||
|
||||
contentSize = stackViewSize
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class FontSizeAdjustView: DocumentControlView
|
||||
class FontSizeAdjustView: DocumentControlItemView
|
||||
{
|
||||
let decreaseSizeButton = UIButton(frame: .zero)
|
||||
let increaseSizeButton = UIButton(frame: .zero)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class NavigationControlsView: DocumentControlView
|
||||
class NavigationControlsView: DocumentControlItemView
|
||||
{
|
||||
let backButton = UIButton(frame: .zero)
|
||||
let forwardButton = UIButton(frame: .zero)
|
||||
|
||||
Reference in New Issue
Block a user