From 042f3a38ba976d8bf41abd604910dc2fa50a9ab7 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Sat, 6 Sep 2025 14:47:59 -0400 Subject: [PATCH 01/11] Add iPad as target for app. --- Spellbook.xcodeproj/project.pbxproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Spellbook.xcodeproj/project.pbxproj b/Spellbook.xcodeproj/project.pbxproj index d4df155..d3f194f 100644 --- a/Spellbook.xcodeproj/project.pbxproj +++ b/Spellbook.xcodeproj/project.pbxproj @@ -1071,10 +1071,12 @@ PRODUCT_BUNDLE_IDENTIFIER = dnd.jon.Spellbook; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_OBJC_BRIDGING_HEADER = "SWRevealViewController/Spellbook-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -1100,9 +1102,11 @@ PRODUCT_BUNDLE_IDENTIFIER = dnd.jon.Spellbook; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_OBJC_BRIDGING_HEADER = "SWRevealViewController/Spellbook-Bridging-Header.h"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; From 8e92549aa7336671ee92ff0e4735bf50beaf4e41 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Sat, 6 Sep 2025 14:53:46 -0400 Subject: [PATCH 02/11] Check whether we're on an iPad. --- Spellbook/iOSUtils.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Spellbook/iOSUtils.swift b/Spellbook/iOSUtils.swift index dda0c46..082de8d 100644 --- a/Spellbook/iOSUtils.swift +++ b/Spellbook/iOSUtils.swift @@ -12,11 +12,14 @@ import Foundation let iOSNSFoundationVersion = NSFoundationVersionNumber let iOSVersion = Version.fromString(UIDevice.current.systemVersion) ?? Version(major: 0, minor: 0, patch: 0) -// The iPhone version -let iPhoneVersion = UIDevice.current.model +// The device version +let deviceVersion = UIDevice.current.model // The current version number of the app let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "0" // The current build number of the app let appBuild = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? "0" + +// Are we on an iPad? +let oniPad = UIDevice.current.userInterfaceIdiom == .pad From b3f4df5ba9811f3f6db86d8a81a510b5faf24820 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 11 Sep 2025 01:34:44 -0400 Subject: [PATCH 03/11] Do some device-based width sizing. --- Spellbook/Base.lproj/Main.storyboard | 64 ++++++++++----------------- Spellbook/SpellWindowController.swift | 45 ++++++++++++++++--- Spellbook/ViewController.swift | 2 +- 3 files changed, 65 insertions(+), 46 deletions(-) diff --git a/Spellbook/Base.lproj/Main.storyboard b/Spellbook/Base.lproj/Main.storyboard index df4436a..7203d16 100644 --- a/Spellbook/Base.lproj/Main.storyboard +++ b/Spellbook/Base.lproj/Main.storyboard @@ -579,7 +579,7 @@ - + @@ -665,7 +665,7 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -1775,7 +1797,7 @@ - + diff --git a/Spellbook/SideMenuController.swift b/Spellbook/SideMenuController.swift index 11f5478..c15ce64 100644 --- a/Spellbook/SideMenuController.swift +++ b/Spellbook/SideMenuController.swift @@ -20,6 +20,8 @@ class SideMenuController: UIViewController, UIPopoverPresentationControllerDeleg @IBOutlet weak var updateInfoLabel: UILabel! @IBOutlet weak var whatsNewButton: UIButton! @IBOutlet weak var spellSlotsButton: UIButton! + @IBOutlet weak var scrollView: UIScrollView! + @IBOutlet weak var contentView: UIView! var statusController: StatusFilterController? @@ -62,6 +64,11 @@ class SideMenuController: UIViewController, UIPopoverPresentationControllerDeleg viewWidth = viewRect.size.width characterLabel.textColor = defaultFontColor + + selectionButton.addTarget(self, action: #selector(selectionButtonPressed), for: UIControl.Event.touchUpInside) + exportSpellListButton.addTarget(self, action: #selector(exportSpellListButtonPressed), for: UIControl.Event.touchUpInside) + whatsNewButton.addTarget(self, action: #selector(updateInfoButtonPressed), for: UIControl.Event.touchUpInside) + spellSlotsButton.addTarget(self, action: #selector(spellSlotsButtonPressed), for: UIControl.Event.touchUpInside) } override func viewWillAppear(_ animated: Bool) { @@ -70,7 +77,7 @@ class SideMenuController: UIViewController, UIPopoverPresentationControllerDeleg $0.select { $0.profile?.name } } } - + override func viewDidAppear(_ animated: Bool) { // Set the character label @@ -79,7 +86,24 @@ class SideMenuController: UIViewController, UIPopoverPresentationControllerDeleg characterLabel.text = "Character: " + name! } } - + + func setScrollViewSize() { + if let content = contentView, let scroll = scrollView { + // The content size of the scroll view is equal to the content view's size + scroll.contentSize = content.frame.size + + } + } + + override func viewWillTransition(to size: CGSize, + with coordinator: UIViewControllerTransitionCoordinator) { + setScrollViewSize() + } + + override func viewDidLayoutSubviews() { + setScrollViewSize() + } + // Connecting to the child controllers override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "statusSegue" { @@ -96,11 +120,11 @@ class SideMenuController: UIViewController, UIPopoverPresentationControllerDeleg // // } } - + func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle { return UIModalPresentationStyle.none } - + @objc func selectionButtonPressed() { let storyboard = UIStoryboard(name: "Main", bundle: nil) let controller = storyboard.instantiateViewController(withIdentifier: "characterSelection") as! CharacterSelectionController diff --git a/Spellbook/ViewController.swift b/Spellbook/ViewController.swift index 4e8bc04..22afeeb 100644 --- a/Spellbook/ViewController.swift +++ b/Spellbook/ViewController.swift @@ -130,10 +130,6 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - // Set the sizes of the container views (there are no other top level elements) - let screenRect = UIScreen.main.bounds - setContainerDimensions(screenWidth: screenRect.size.width, screenHeight: screenRect.size.height) - store.subscribe(self) { $0.select { ($0.profile, $0.profile?.sortFilterStatus, $0.profile?.spellFilterStatus, $0.currentSpellList, $0.dirtySpellIDs) @@ -259,11 +255,14 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega // The view has appeared, so we can set firstAppearance to false firstAppearance = false - } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() + + // Set the sizes of the container views (there are no other top level elements) + let screenRect = UIScreen.main.bounds + setContainerDimensions(screenWidth: screenRect.size.width, screenHeight: screenRect.size.height) } // This function sets the sizes of the top-level container views @@ -283,7 +282,9 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega // The button images // It's too costly to do the re-rendering every time, so we just do it once - self.imageWidth = max(self.buttonFraction * self.usableWidth, CGFloat(30)) + // self.imageWidth = max(self.buttonFraction * self.usableWidth, CGFloat(30)) + + self.imageWidth = oniPad ? CGFloat(40.5) : CGFloat(30.5) self.imageHeight = self.imageWidth self.starEmpty = UIImage(named: "star_empty.png")?.withRenderingMode(.alwaysOriginal).resized(width: self.imageWidth, height: self.imageHeight) self.starFilled = UIImage(named: "star_filled.png")?.withRenderingMode(.alwaysOriginal).resized(width: self.imageWidth, height: self.imageHeight) @@ -312,8 +313,8 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega // But for the moment, the SpellDataCell change doesn't work correctly, and so rotation is disabled override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { - setContainerDimensions(screenWidth: size.width, screenHeight: size.height) super.viewWillTransition(to: size, with: coordinator) + setContainerDimensions(screenWidth: size.width, screenHeight: size.height) } // Until the issue with the SpellDataCell sizing is fixed, let's disable rotation @@ -626,6 +627,10 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega button in return button?.widthAnchor.constraint(equalToConstant: self.imageWidth) })) + NSLayoutConstraint.activate(buttons.compactMap({ + button in + return button?.heightAnchor.constraint(equalToConstant: self.imageHeight) + })) } private func makeTargetedPreview(for configuration: UIContextMenuConfiguration, backgroundColor: UIColor? = nil) -> UITargetedPreview? { From faa5f1587831b0665d8bb6610dfe3da6ae4a24dd Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Sat, 4 Oct 2025 18:46:32 -0400 Subject: [PATCH 10/11] Split out spell table functionality into its own view controller. --- Spellbook/Base.lproj/Main.storyboard | 163 ++++-------- Spellbook/SpellTableViewController.swift | 254 ++++++++++++++---- Spellbook/ViewController.swift | 326 +---------------------- 3 files changed, 257 insertions(+), 486 deletions(-) diff --git a/Spellbook/Base.lproj/Main.storyboard b/Spellbook/Base.lproj/Main.storyboard index e536466..b620ce3 100644 --- a/Spellbook/Base.lproj/Main.storyboard +++ b/Spellbook/Base.lproj/Main.storyboard @@ -406,98 +406,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + @@ -553,7 +469,7 @@ - + @@ -1451,39 +1367,39 @@ - + - + - + -