From 557efa40e9d2d42b08b082e5ab5d0d6a0408d8b3 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Wed, 28 Apr 2021 17:03:27 -0700 Subject: [PATCH] Put document controls view in a scroll view --- ...ew.swift => DocumentControlItemView.swift} | 2 +- .../DocumentControlViewController.swift | 34 +++++++++---------- .../DocumentControlsView.swift | 29 ++++++++++++++++ .../FontSizeAdjustView.swift | 2 +- .../NavigationControlsView.swift | 2 +- SBrowser.xcodeproj/project.pbxproj | 12 ++++--- 6 files changed, 57 insertions(+), 24 deletions(-) rename App/Document Controls UI/{DocumentControlView.swift => DocumentControlItemView.swift} (98%) create mode 100644 App/Document Controls UI/DocumentControlsView.swift diff --git a/App/Document Controls UI/DocumentControlView.swift b/App/Document Controls UI/DocumentControlItemView.swift similarity index 98% rename from App/Document Controls UI/DocumentControlView.swift rename to App/Document Controls UI/DocumentControlItemView.swift index cd868af..6c11340 100644 --- a/App/Document Controls UI/DocumentControlView.swift +++ b/App/Document Controls UI/DocumentControlItemView.swift @@ -7,7 +7,7 @@ import UIKit -class DocumentControlView: UIControl +class DocumentControlItemView: UIControl { static public let controlHeight = CGFloat(48.0) diff --git a/App/Document Controls UI/DocumentControlViewController.swift b/App/Document Controls UI/DocumentControlViewController.swift index 29a44b2..68a626f 100644 --- a/App/Document Controls UI/DocumentControlViewController.swift +++ b/App/Document Controls UI/DocumentControlViewController.swift @@ -9,14 +9,14 @@ import UIKit class DocumentControlViewController: UIViewController { - let documentControlView = StackView(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 {} } } diff --git a/App/Document Controls UI/DocumentControlsView.swift b/App/Document Controls UI/DocumentControlsView.swift new file mode 100644 index 0000000..e49677d --- /dev/null +++ b/App/Document Controls UI/DocumentControlsView.swift @@ -0,0 +1,29 @@ +// +// DocumentControlsView.swift +// App +// +// Created by James Magahern on 4/28/21. +// + +import UIKit + +class DocumentControlsView : UIScrollView +{ + public let stackView = StackView(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 + } +} diff --git a/App/Document Controls UI/FontSizeAdjustView.swift b/App/Document Controls UI/FontSizeAdjustView.swift index a230e9d..fdac7ed 100644 --- a/App/Document Controls UI/FontSizeAdjustView.swift +++ b/App/Document Controls UI/FontSizeAdjustView.swift @@ -7,7 +7,7 @@ import UIKit -class FontSizeAdjustView: DocumentControlView +class FontSizeAdjustView: DocumentControlItemView { let decreaseSizeButton = UIButton(frame: .zero) let increaseSizeButton = UIButton(frame: .zero) diff --git a/App/Document Controls UI/NavigationControlsView.swift b/App/Document Controls UI/NavigationControlsView.swift index 45fbae6..60c8757 100644 --- a/App/Document Controls UI/NavigationControlsView.swift +++ b/App/Document Controls UI/NavigationControlsView.swift @@ -7,7 +7,7 @@ import UIKit -class NavigationControlsView: DocumentControlView +class NavigationControlsView: DocumentControlItemView { let backButton = UIButton(frame: .zero) let forwardButton = UIButton(frame: .zero) diff --git a/SBrowser.xcodeproj/project.pbxproj b/SBrowser.xcodeproj/project.pbxproj index d60b7f8..f5fcf83 100644 --- a/SBrowser.xcodeproj/project.pbxproj +++ b/SBrowser.xcodeproj/project.pbxproj @@ -21,7 +21,7 @@ 1AD3103D252541E600A4A952 /* PersonalRedirectRules.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AD3103C252541E600A4A952 /* PersonalRedirectRules.swift */; }; 1AD31040252545BF00A4A952 /* FindOnPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AD3103F252545BF00A4A952 /* FindOnPageView.swift */; }; 1AD3104325254FB900A4A952 /* FindOnPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AD3104225254FB900A4A952 /* FindOnPageViewController.swift */; }; - 1AD310452525586B00A4A952 /* DocumentControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AD310442525586B00A4A952 /* DocumentControlView.swift */; }; + 1AD310452525586B00A4A952 /* DocumentControlItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AD310442525586B00A4A952 /* DocumentControlItemView.swift */; }; 1ADFF46024C7DE53006DC7AE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF45F24C7DE53006DC7AE /* AppDelegate.swift */; }; 1ADFF46224C7DE53006DC7AE /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF46124C7DE53006DC7AE /* SceneDelegate.swift */; }; 1ADFF46924C7DE54006DC7AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1ADFF46824C7DE54006DC7AE /* Assets.xcassets */; }; @@ -51,6 +51,7 @@ CD853BD124E778B800D2BDCC /* History.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = CD853BCF24E778B800D2BDCC /* History.xcdatamodeld */; }; CD853BD424E77BF900D2BDCC /* HistoryItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD853BD324E77BF900D2BDCC /* HistoryItem.swift */; }; CD97CF9225D5BE6F00288FEE /* NavigationControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD97CF9125D5BE6F00288FEE /* NavigationControlsView.swift */; }; + CDAD9CE8263A2DF200FF7199 /* DocumentControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDAD9CE7263A2DF200FF7199 /* DocumentControlsView.swift */; }; CDC4A1CF25E9D8F7007D33C6 /* Tagger.js in Resources */ = {isa = PBXBuildFile; fileRef = CDC4A1CE25E9D8F7007D33C6 /* Tagger.js */; }; CDC5DA3A25DB774D00BA8D99 /* Readability.js in Resources */ = {isa = PBXBuildFile; fileRef = CDC5DA3925DB774D00BA8D99 /* Readability.js */; }; CDC5DA3E25DB7C2C00BA8D99 /* ReaderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC5DA3D25DB7C2C00BA8D99 /* ReaderViewController.swift */; }; @@ -104,7 +105,7 @@ 1AD3103C252541E600A4A952 /* PersonalRedirectRules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonalRedirectRules.swift; sourceTree = ""; }; 1AD3103F252545BF00A4A952 /* FindOnPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindOnPageView.swift; sourceTree = ""; }; 1AD3104225254FB900A4A952 /* FindOnPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindOnPageViewController.swift; sourceTree = ""; }; - 1AD310442525586B00A4A952 /* DocumentControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentControlView.swift; sourceTree = ""; }; + 1AD310442525586B00A4A952 /* DocumentControlItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentControlItemView.swift; sourceTree = ""; }; 1ADFF45C24C7DE53006DC7AE /* rossler\\attix.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "rossler\\\\attix.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1ADFF45F24C7DE53006DC7AE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 1ADFF46124C7DE53006DC7AE /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -143,6 +144,7 @@ CD853BD024E778B800D2BDCC /* History.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = History.xcdatamodel; sourceTree = ""; }; CD853BD324E77BF900D2BDCC /* HistoryItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryItem.swift; sourceTree = ""; }; CD97CF9125D5BE6F00288FEE /* NavigationControlsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationControlsView.swift; sourceTree = ""; }; + CDAD9CE7263A2DF200FF7199 /* DocumentControlsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentControlsView.swift; sourceTree = ""; }; CDC4A1CE25E9D8F7007D33C6 /* Tagger.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Tagger.js; sourceTree = ""; }; CDC5DA3925DB774D00BA8D99 /* Readability.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = Readability.js; sourceTree = ""; }; CDC5DA3D25DB7C2C00BA8D99 /* ReaderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReaderViewController.swift; sourceTree = ""; }; @@ -390,7 +392,8 @@ isa = PBXGroup; children = ( CDCE2663251AA80F007FE92A /* DocumentControlViewController.swift */, - 1AD310442525586B00A4A952 /* DocumentControlView.swift */, + CDAD9CE7263A2DF200FF7199 /* DocumentControlsView.swift */, + 1AD310442525586B00A4A952 /* DocumentControlItemView.swift */, CDCE2667251AAA9A007FE92A /* FontSizeAdjustView.swift */, CD97CF9125D5BE6F00288FEE /* NavigationControlsView.swift */, ); @@ -554,6 +557,7 @@ CDE6A30625F023EA00E912A4 /* SettingsView.swift in Sources */, 1AB88EFD24D3BA560006F850 /* TabController.swift in Sources */, 1ADFF4C324CA6AF6006DC7AE /* Geometry.swift in Sources */, + CDAD9CE8263A2DF200FF7199 /* DocumentControlsView.swift in Sources */, 1ADFF4C924CA793E006DC7AE /* ToolbarViewController.swift in Sources */, CD7A89172519872D0075991E /* KeyboardShortcuts.swift in Sources */, 1ADFF4CD24CBB0C8006DC7AE /* ScriptPolicyViewController.swift in Sources */, @@ -564,7 +568,7 @@ CDCE2664251AA80F007FE92A /* DocumentControlViewController.swift in Sources */, 1AB88EFF24D3BBA50006F850 /* TabPickerViewController.swift in Sources */, 1A14FC2324D203D9009B3F83 /* TitlebarView.swift in Sources */, - 1AD310452525586B00A4A952 /* DocumentControlView.swift in Sources */, + 1AD310452525586B00A4A952 /* DocumentControlItemView.swift in Sources */, CD97CF9225D5BE6F00288FEE /* NavigationControlsView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0;