Move ImageViewController out of storyboard and into its own xib.

This commit is contained in:
Brent Simmons
2025-01-12 21:55:09 -08:00
parent dadf3ec253
commit 5a43886640
4 changed files with 118 additions and 98 deletions

View File

@@ -8,9 +8,8 @@
import UIKit
class ImageViewController: UIViewController {
final class ImageViewController: UIViewController {
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var shareButton: UIButton!
@IBOutlet weak var imageScrollView: ImageScrollView!
@@ -24,6 +23,14 @@ class ImageViewController: UIViewController {
var zoomedFrame: CGRect {
return imageScrollView.zoomedFrame
}
init() {
super.init(nibName: "ImageViewController", bundle: nil)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func viewDidLoad() {
super.viewDidLoad()

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ImageViewController" customModule="NetNewsWire" customModuleProvider="target">
<connections>
<outlet property="closeButton" destination="bh5-KV-5HI" id="3gh-Y3-Kjf"/>
<outlet property="imageScrollView" destination="t42-v5-7DN" id="TR2-aK-Pz0"/>
<outlet property="shareButton" destination="3Wa-fp-kMe" id="jjN-jQ-BWP"/>
<outlet property="titleBackground" destination="rXU-KY-jBH" id="JGd-Fp-biL"/>
<outlet property="titleLabel" destination="lQ6-x9-Tcu" id="QPn-ac-kYi"/>
<outlet property="titleLeading" destination="bHE-Eq-ddT" id="WKB-C3-z0s"/>
<outlet property="titleTrailing" destination="OFG-cU-iTN" id="VyL-dz-6Ch"/>
<outlet property="view" destination="2qJ-Gw-Tlk" id="S0T-fW-KSq"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="2qJ-Gw-Tlk">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView verifyAmbiguity="off" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="t42-v5-7DN" customClass="ImageScrollView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<viewLayoutGuide key="contentLayoutGuide" id="rDi-IL-3hP"/>
<viewLayoutGuide key="frameLayoutGuide" id="Rk2-H7-hcc"/>
</scrollView>
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rXU-KY-jBH">
<rect key="frame" x="-4" y="806" width="401" height="8"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="Sbe-dT-bwF">
<rect key="frame" x="0.0" y="0.0" width="401" height="8"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
<blurEffect style="systemUltraThinMaterial"/>
</visualEffectView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lQ6-x9-Tcu">
<rect key="frame" x="0.0" y="810" width="393" height="0.0"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3Wa-fp-kMe">
<rect key="frame" x="341" y="59" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="BG7-ht-naS"/>
<constraint firstAttribute="height" constant="44" id="cuX-WF-pUh"/>
</constraints>
<color key="tintColor" name="primaryAccentColor"/>
<state key="normal" image="square.and.arrow.up.fill" catalog="system"/>
<connections>
<action selector="share:" destination="-1" eventType="touchUpInside" id="jti-xh-2Yt"/>
</connections>
</button>
<button opaque="NO" clipsSubviews="YES" contentMode="center" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bh5-KV-5HI">
<rect key="frame" x="8" y="59" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="VXi-hw-q5q"/>
<constraint firstAttribute="height" constant="44" id="yWs-vd-PHK"/>
</constraints>
<color key="tintColor" name="primaryAccentColor"/>
<state key="normal" image="multiply.circle.fill" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="large" weight="regular"/>
</state>
<connections>
<action selector="done:" destination="-1" eventType="touchUpInside" id="OZB-pn-m1N"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="Mwx-oc-6Cf"/>
<color key="backgroundColor" name="fullScreenBackgroundColor"/>
<constraints>
<constraint firstItem="3Wa-fp-kMe" firstAttribute="top" secondItem="Mwx-oc-6Cf" secondAttribute="top" id="3Mg-5D-jao"/>
<constraint firstItem="rXU-KY-jBH" firstAttribute="bottom" secondItem="lQ6-x9-Tcu" secondAttribute="bottom" constant="4" id="5AX-Pq-B03"/>
<constraint firstItem="lQ6-x9-Tcu" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Mwx-oc-6Cf" secondAttribute="trailing" id="OFG-cU-iTN"/>
<constraint firstItem="rXU-KY-jBH" firstAttribute="trailing" secondItem="lQ6-x9-Tcu" secondAttribute="trailing" constant="4" id="P5Y-FS-He4"/>
<constraint firstItem="rXU-KY-jBH" firstAttribute="leading" secondItem="lQ6-x9-Tcu" secondAttribute="leading" constant="-4" id="PeO-2J-lve"/>
<constraint firstItem="rXU-KY-jBH" firstAttribute="top" secondItem="lQ6-x9-Tcu" secondAttribute="top" constant="-4" id="Rgg-Bx-6R4"/>
<constraint firstItem="Mwx-oc-6Cf" firstAttribute="bottom" secondItem="lQ6-x9-Tcu" secondAttribute="bottom" constant="8" id="Thj-eJ-Fvw"/>
<constraint firstItem="bh5-KV-5HI" firstAttribute="top" secondItem="Mwx-oc-6Cf" secondAttribute="top" id="WIh-RA-e0M"/>
<constraint firstItem="lQ6-x9-Tcu" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Mwx-oc-6Cf" secondAttribute="leading" id="bHE-Eq-ddT"/>
<constraint firstItem="lQ6-x9-Tcu" firstAttribute="centerX" secondItem="2qJ-Gw-Tlk" secondAttribute="centerX" id="dhZ-1K-ezQ"/>
<constraint firstItem="t42-v5-7DN" firstAttribute="leading" secondItem="2qJ-Gw-Tlk" secondAttribute="leading" id="eFN-9k-B2Z"/>
<constraint firstItem="Mwx-oc-6Cf" firstAttribute="trailing" secondItem="3Wa-fp-kMe" secondAttribute="trailing" constant="8" id="jLl-sH-LgH"/>
<constraint firstAttribute="bottom" secondItem="t42-v5-7DN" secondAttribute="bottom" id="ovl-eX-nHk"/>
<constraint firstItem="t42-v5-7DN" firstAttribute="top" secondItem="2qJ-Gw-Tlk" secondAttribute="top" id="xAA-lL-BRQ"/>
<constraint firstAttribute="trailing" secondItem="t42-v5-7DN" secondAttribute="trailing" id="xh0-GX-R9G"/>
<constraint firstItem="bh5-KV-5HI" firstAttribute="leading" secondItem="Mwx-oc-6Cf" secondAttribute="leading" constant="8" id="yP2-xR-h9i"/>
</constraints>
<point key="canvasLocation" x="-460" y="-627"/>
</view>
</objects>
<resources>
<image name="multiply.circle.fill" catalog="system" width="128" height="123"/>
<image name="square.and.arrow.up.fill" catalog="system" width="117" height="128"/>
<namedColor name="fullScreenBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
<namedColor name="primaryAccentColor">
<color red="0.031372549019607843" green="0.41568627450980394" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>

View File

@@ -114,7 +114,7 @@
<objects>
<tableViewController storyboardIdentifier="MainTimelineViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" clearsSelectionOnViewWillAppear="NO" id="Kyk-vK-QRX" customClass="TimelineViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="onDrag" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="mtv-Ik-FoJ">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="721"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
@@ -232,95 +232,6 @@
</objects>
<point key="canvasLocation" x="452" y="-1794"/>
</scene>
<!--Image View Controller-->
<scene sceneID="TT4-oA-DBw">
<objects>
<viewController storyboardIdentifier="ImageViewController" id="vO9-a3-Dnu" customClass="ImageViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="w6Q-vH-063">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView verifyAmbiguity="off" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="msG-pz-EKk" customClass="ImageScrollView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<viewLayoutGuide key="contentLayoutGuide" id="phv-DN-krZ"/>
<viewLayoutGuide key="frameLayoutGuide" id="NNU-C8-Fsz"/>
</scrollView>
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bHh-pW-oTS">
<rect key="frame" x="-4" y="850" width="422" height="8"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="StS-kO-TuW">
<rect key="frame" x="0.0" y="0.0" width="422" height="8"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
<blurEffect style="systemUltraThinMaterial"/>
</visualEffectView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eMj-1g-3xm">
<rect key="frame" x="0.0" y="854" width="414" height="0.0"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RmY-a3-hUg">
<rect key="frame" x="362" y="48" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="56o-Zr-T0w"/>
<constraint firstAttribute="height" constant="44" id="lBg-Wy-k9P"/>
</constraints>
<color key="tintColor" name="primaryAccentColor"/>
<state key="normal" image="square.and.arrow.up.fill" catalog="system"/>
<connections>
<action selector="share:" destination="vO9-a3-Dnu" eventType="touchUpInside" id="m8y-Gs-YF1"/>
</connections>
</button>
<button opaque="NO" clipsSubviews="YES" contentMode="center" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cXR-ll-xBx">
<rect key="frame" x="8" y="48" width="44" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="6kc-Gw-KbZ"/>
<constraint firstAttribute="width" constant="44" id="cBq-gs-WzN"/>
</constraints>
<color key="tintColor" name="primaryAccentColor"/>
<state key="normal" image="multiply.circle.fill" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="large" weight="regular"/>
</state>
<connections>
<action selector="done:" destination="vO9-a3-Dnu" eventType="touchUpInside" id="tgd-ov-4Ft"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="mbY-02-GFL"/>
<color key="backgroundColor" name="fullScreenBackgroundColor"/>
<constraints>
<constraint firstItem="RmY-a3-hUg" firstAttribute="top" secondItem="mbY-02-GFL" secondAttribute="top" id="A0i-Hs-1Ac"/>
<constraint firstAttribute="bottom" secondItem="msG-pz-EKk" secondAttribute="bottom" id="AtA-bA-jDr"/>
<constraint firstItem="eMj-1g-3xm" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="mbY-02-GFL" secondAttribute="trailing" id="E7e-Lv-6ZA"/>
<constraint firstItem="eMj-1g-3xm" firstAttribute="centerX" secondItem="w6Q-vH-063" secondAttribute="centerX" id="H2b-IA-6hz"/>
<constraint firstItem="bHh-pW-oTS" firstAttribute="bottom" secondItem="eMj-1g-3xm" secondAttribute="bottom" constant="4" id="P3m-i2-3pJ"/>
<constraint firstAttribute="trailing" secondItem="msG-pz-EKk" secondAttribute="trailing" id="R49-qV-8nm"/>
<constraint firstItem="msG-pz-EKk" firstAttribute="leading" secondItem="w6Q-vH-063" secondAttribute="leading" id="XN1-xN-hYS"/>
<constraint firstItem="eMj-1g-3xm" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="mbY-02-GFL" secondAttribute="leading" id="Xni-Dn-I3Z"/>
<constraint firstItem="mbY-02-GFL" firstAttribute="trailing" secondItem="RmY-a3-hUg" secondAttribute="trailing" constant="8" id="Zlz-lM-LV8"/>
<constraint firstItem="mbY-02-GFL" firstAttribute="bottom" secondItem="eMj-1g-3xm" secondAttribute="bottom" constant="8" id="eaS-iG-yMv"/>
<constraint firstItem="bHh-pW-oTS" firstAttribute="leading" secondItem="eMj-1g-3xm" secondAttribute="leading" constant="-4" id="f8r-dq-Irr"/>
<constraint firstItem="bHh-pW-oTS" firstAttribute="top" secondItem="eMj-1g-3xm" secondAttribute="top" constant="-4" id="gTP-i5-FYQ"/>
<constraint firstItem="msG-pz-EKk" firstAttribute="top" secondItem="w6Q-vH-063" secondAttribute="top" id="p1a-s0-wdK"/>
<constraint firstItem="bHh-pW-oTS" firstAttribute="trailing" secondItem="eMj-1g-3xm" secondAttribute="trailing" constant="4" id="qB9-zk-5JN"/>
<constraint firstItem="cXR-ll-xBx" firstAttribute="leading" secondItem="mbY-02-GFL" secondAttribute="leading" constant="8" id="vJs-LN-Ydd"/>
<constraint firstItem="cXR-ll-xBx" firstAttribute="top" secondItem="mbY-02-GFL" secondAttribute="top" id="xVN-Qt-WYA"/>
</constraints>
</view>
<connections>
<outlet property="closeButton" destination="cXR-ll-xBx" id="sDG-49-joi"/>
<outlet property="imageScrollView" destination="msG-pz-EKk" id="dGi-M6-dcO"/>
<outlet property="shareButton" destination="RmY-a3-hUg" id="Z54-ah-WAI"/>
<outlet property="titleBackground" destination="bHh-pW-oTS" id="o2K-cY-90c"/>
<outlet property="titleLabel" destination="eMj-1g-3xm" id="6wF-IZ-fNw"/>
<outlet property="titleLeading" destination="Xni-Dn-I3Z" id="8Ik-la-Qkw"/>
<outlet property="titleTrailing" destination="E7e-Lv-6ZA" id="lGu-iv-C9W"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ZPN-tH-JAG" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3056.521739130435" y="-759.375"/>
</scene>
<!--Context Menu Preview View Controller-->
<scene sceneID="Tc4-Ma-XSa">
<objects>
@@ -417,16 +328,11 @@
<image name="gear" catalog="system" width="128" height="122"/>
<image name="line.3.horizontal.decrease.circle" catalog="system" width="128" height="123"/>
<image name="markAllAsRead" width="13" height="20"/>
<image name="multiply.circle.fill" catalog="system" width="128" height="123"/>
<image name="square.and.arrow.up" catalog="system" width="110" height="128"/>
<image name="square.and.arrow.up.fill" catalog="system" width="117" height="128"/>
<image name="star" catalog="system" width="128" height="116"/>
<namedColor name="barBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
<namedColor name="fullScreenBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</namedColor>
<namedColor name="primaryAccentColor">
<color red="0.031372549019607843" green="0.41568627450980394" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>

View File

@@ -1180,7 +1180,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
}
func showFullScreenImage(image: UIImage, imageTitle: String?, transitioningDelegate: UIViewControllerTransitioningDelegate) {
let imageVC = UIStoryboard.main.instantiateController(ofType: ImageViewController.self)
let imageVC = ImageViewController()
imageVC.image = image
imageVC.imageTitle = imageTitle
imageVC.modalPresentationStyle = .currentContext