mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-04 03:08:43 +00:00
Merge branch 'feature/slim-icloud-sync'
This commit is contained in:
commit
d9c55f0e22
19 files changed
+363
-261
No files matched your search
@@ -179,7 +179,6 @@ let appName = "NetNewsWire"
|
||||
Self.logger.debug("Is first run.")
|
||||
}
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
|
||||
if isFirstRun && !AccountManager.shared.anyAccountHasAtLeastOneFeed() {
|
||||
// Import default feeds.
|
||||
DefaultFeedsImporter.importDefaultFeeds(account: localAccount)
|
||||
|
||||
@@ -532,7 +532,7 @@
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="Accounts" id="z5c-Js-Up9" customClass="AccountsPreferencesViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" misplaced="YES" id="GrE-GP-fYK">
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="380"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="7UM-iq-OLB" customClass="PreferencesTableViewBackgroundView" customModule="NetNewsWire" customModuleProvider="target">
|
||||
|
||||
@@ -17,7 +17,8 @@ final class NNW3OpenPanelAccessoryViewController: NSViewController {
|
||||
guard let item: NSMenuItem = accountPopUpButton.selectedItem else {
|
||||
return nil
|
||||
}
|
||||
return item.representedObject as? Account
|
||||
let account: Account? = item.representedObject as? Account
|
||||
return account
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
@@ -29,14 +29,18 @@ final class ExportOPMLWindowController: NSWindowController {
|
||||
let savedAccountID: String? = AppDefaults.shared.exportOPMLAccountID
|
||||
|
||||
for oneAccount in accounts {
|
||||
let oneMenuItem = NSMenuItem()
|
||||
oneMenuItem.title = oneAccount.nameForDisplay
|
||||
oneMenuItem.representedObject = oneAccount
|
||||
menu.addItem(oneMenuItem)
|
||||
addMenuItem(to: menu, for: oneAccount, savedAccountID: savedAccountID)
|
||||
}
|
||||
}
|
||||
|
||||
if oneAccount.accountID == savedAccountID {
|
||||
accountPopUpButton.select(oneMenuItem)
|
||||
}
|
||||
private func addMenuItem(to menu: NSMenu, for account: Account, savedAccountID: String?) {
|
||||
let menuItem = NSMenuItem()
|
||||
menuItem.title = account.nameForDisplay
|
||||
menuItem.representedObject = account
|
||||
menu.addItem(menuItem)
|
||||
|
||||
if account.accountID == savedAccountID {
|
||||
accountPopUpButton.select(menuItem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,15 +32,18 @@ final class ImportOPMLWindowController: NSWindowController {
|
||||
if oneAccount.behaviors.contains(.disallowOPMLImports) {
|
||||
continue
|
||||
}
|
||||
addMenuItem(to: menu, for: oneAccount, savedAccountID: savedAccountID)
|
||||
}
|
||||
}
|
||||
|
||||
let oneMenuItem = NSMenuItem()
|
||||
oneMenuItem.title = oneAccount.nameForDisplay
|
||||
oneMenuItem.representedObject = oneAccount
|
||||
menu.addItem(oneMenuItem)
|
||||
private func addMenuItem(to menu: NSMenu, for account: Account, savedAccountID: String?) {
|
||||
let menuItem = NSMenuItem()
|
||||
menuItem.title = account.nameForDisplay
|
||||
menuItem.representedObject = account
|
||||
menu.addItem(menuItem)
|
||||
|
||||
if oneAccount.accountID == savedAccountID {
|
||||
accountPopUpButton.select(oneMenuItem)
|
||||
}
|
||||
if account.accountID == savedAccountID {
|
||||
accountPopUpButton.select(menuItem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -18,29 +17,29 @@
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="453" height="151"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2880" height="1595"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1410"/>
|
||||
<view key="contentView" wantsLayer="YES" misplaced="YES" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="453" height="151"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ySx-qg-WbT">
|
||||
<rect key="frame" x="20" y="62" width="50" height="50"/>
|
||||
<rect key="frame" x="20" y="66" width="50" height="50"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="50" id="LlV-kM-gHE"/>
|
||||
<constraint firstAttribute="height" constant="50" id="MjL-TR-9ey"/>
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="accountCloudKit" id="9RZ-J3-ioX"/>
|
||||
</imageView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80D-3X-rL2">
|
||||
<rect key="frame" x="76" y="96" width="359" height="16"/>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80D-3X-rL2">
|
||||
<rect key="frame" x="76" y="100" width="359" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Use your iCloud account" id="1d2-Mx-TKe">
|
||||
<font key="font" metaFont="systemBold"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Kj-Cl-FJQ">
|
||||
<rect key="frame" x="76" y="56" width="359" height="32"/>
|
||||
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Kj-Cl-FJQ">
|
||||
<rect key="frame" x="76" y="60" width="359" height="32"/>
|
||||
<textFieldCell key="cell" selectable="YES" allowsUndo="NO" title="NetNewsWire will use your iCloud account to sync your feeds across your Mac and iOS devices." id="wfr-Dv-UIF">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -48,7 +47,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xqo-gP-MPl">
|
||||
<rect key="frame" x="340" y="13" width="100" height="40"/>
|
||||
<rect key="frame" x="343" y="20" width="90" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Use iCloud" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oih-6c-KbS">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -61,7 +60,7 @@ DQ
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9eG-vV-s8c">
|
||||
<rect key="frame" x="242" y="17" width="100" height="32"/>
|
||||
<rect key="frame" x="241" y="24" width="90" height="24"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iVd-bO-4LN">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -19,7 +18,7 @@
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="398" height="205"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1536" height="935"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1410"/>
|
||||
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="398" height="205"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
@@ -28,13 +27,10 @@
|
||||
<rect key="frame" x="199" y="151" width="0.0" height="102"/>
|
||||
</stackView>
|
||||
<stackView distribution="fill" orientation="horizontal" alignment="firstBaseline" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6Q7-nI-h5u">
|
||||
<rect key="frame" x="199" y="95" width="0.0" height="21"/>
|
||||
<rect key="frame" x="199" y="92" width="0.0" height="24"/>
|
||||
</stackView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xqo-gP-MPl">
|
||||
<rect key="frame" x="309" y="13" width="76" height="32"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="62" id="i5E-OP-URn"/>
|
||||
</constraints>
|
||||
<rect key="frame" x="316" y="20" width="62" height="24"/>
|
||||
<buttonCell key="cell" type="push" title="Create" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oih-6c-KbS">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -42,12 +38,15 @@
|
||||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="62" id="i5E-OP-URn"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<action selector="create:" target="-2" id="jgg-n6-VVy"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9eG-vV-s8c">
|
||||
<rect key="frame" x="235" y="13" width="76" height="32"/>
|
||||
<rect key="frame" x="242" y="20" width="62" height="24"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iVd-bO-4LN">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -59,7 +58,7 @@ Gw
|
||||
<action selector="cancel:" target="-2" id="uDi-hX-dXu"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80D-3X-rL2">
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80D-3X-rL2">
|
||||
<rect key="frame" x="87" y="169" width="293" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Create a local account on your Mac." id="1d2-Mx-TKe">
|
||||
<font key="font" textStyle="headline" name=".SFNS-Bold"/>
|
||||
@@ -75,16 +74,16 @@ Gw
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="accountLocal" id="9RZ-J3-ioX"/>
|
||||
</imageView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MWg-UL-xtj">
|
||||
<rect key="frame" x="87" y="98" width="44" height="16"/>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MWg-UL-xtj">
|
||||
<rect key="frame" x="87" y="96" width="44" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Name:" id="AVh-ns-LEN">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f9b-FM-i8Q">
|
||||
<rect key="frame" x="137" y="95" width="200" height="21"/>
|
||||
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f9b-FM-i8Q">
|
||||
<rect key="frame" x="137" y="92" width="200" height="24"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="200" id="iff-tN-Gkx"/>
|
||||
</constraints>
|
||||
@@ -94,7 +93,7 @@ Gw
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Kj-Cl-FJQ">
|
||||
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Kj-Cl-FJQ">
|
||||
<rect key="frame" x="87" y="129" width="293" height="32"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="32" id="CaZ-mY-r4X"/>
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="AccountsDetailViewController" customModule="NetNewsWire" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="activeButton" destination="wxB-dX-nGt" id="ALS-GI-sb5"/>
|
||||
<outlet property="credentialsButton" destination="gLh-gl-ZGQ" id="ee9-t8-lUg"/>
|
||||
<outlet property="nameTextField" destination="TT0-Kf-YTC" id="oMG-jn-Qn0"/>
|
||||
<outlet property="typeLabel" destination="XYX-iz-hnq" id="SKM-et-3h3"/>
|
||||
<outlet property="view" destination="3ki-rg-6yb" id="ttM-4E-OLN"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<tabView id="3ki-rg-6yb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="346" height="300"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<tabViewItems>
|
||||
<tabViewItem label="Account" identifier="" id="35c-I3-wfs">
|
||||
<view key="view" id="ft2-Mb-5LD">
|
||||
<rect key="frame" x="10" y="33" width="326" height="254"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<gridView xPlacement="fill" yPlacement="center" rowAlignment="none" rowSpacing="9" translatesAutoresizingMaskIntoConstraints="NO" id="nVy-H3-bFO">
|
||||
<rect key="frame" x="20" y="90" width="286" height="144"/>
|
||||
<rows>
|
||||
<gridRow id="yLs-SL-a1b"/>
|
||||
<gridRow yPlacement="top" id="etw-2m-nWZ"/>
|
||||
<gridRow id="3IT-3r-gEK"/>
|
||||
<gridRow id="Y4C-5M-ySp"/>
|
||||
</rows>
|
||||
<columns>
|
||||
<gridColumn id="sMM-Ds-SKX"/>
|
||||
<gridColumn xPlacement="leading" id="Fhf-h9-g0O"/>
|
||||
</columns>
|
||||
<gridCells>
|
||||
<gridCell row="yLs-SL-a1b" column="sMM-Ds-SKX" id="3ea-DE-T3i">
|
||||
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jiQ-KJ-SS0">
|
||||
<rect key="frame" x="-2" y="128" width="44" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="Type:" id="tC5-Vt-gBc">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</gridCell>
|
||||
<gridCell row="yLs-SL-a1b" column="Fhf-h9-g0O" id="baI-Kp-tKF">
|
||||
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XYX-iz-hnq">
|
||||
<rect key="frame" x="44" y="128" width="73" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="On My Mac" id="6yI-bV-1Sh">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</gridCell>
|
||||
<gridCell row="etw-2m-nWZ" column="sMM-Ds-SKX" id="htf-Ca-Hpv"/>
|
||||
<gridCell row="etw-2m-nWZ" column="Fhf-h9-g0O" id="NrD-vV-1Y1">
|
||||
<button key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mgt-uY-fuq">
|
||||
<rect key="frame" x="44" y="102" width="64" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Active" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="wxB-dX-nGt">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<connections>
|
||||
<action selector="active:" target="-2" id="XgX-JM-UyU"/>
|
||||
</connections>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</gridCell>
|
||||
<gridCell row="3IT-3r-gEK" column="sMM-Ds-SKX" id="2yP-oZ-A6S">
|
||||
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ted-jN-oYR">
|
||||
<rect key="frame" x="-2" y="76" width="44" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="Name:" id="uyQ-Zi-QCr">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</gridCell>
|
||||
<gridCell row="3IT-3r-gEK" column="Fhf-h9-g0O" id="nCq-02-YVv">
|
||||
<textField key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TT0-Kf-YTC">
|
||||
<rect key="frame" x="46" y="73" width="100" height="21"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="7Vp-Hq-j6n">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</gridCell>
|
||||
<gridCell row="Y4C-5M-ySp" column="sMM-Ds-SKX" id="dON-E7-yd2"/>
|
||||
<gridCell row="Y4C-5M-ySp" column="Fhf-h9-g0O" id="i7Y-4k-5TF">
|
||||
<textField key="contentView" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="xp5-wk-PKc">
|
||||
<rect key="frame" x="44" y="0.0" width="244" height="64"/>
|
||||
<textFieldCell key="cell" selectable="YES" id="MW0-mH-Gaa">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<string key="title">The name appears in the sidebar. It can be anything you want. You can even use emoji. 🎸
|
||||
</string>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</gridCell>
|
||||
</gridCells>
|
||||
</gridView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gLh-gl-ZGQ">
|
||||
<rect key="frame" x="112" y="55" width="103" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Credentials" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="vYg-ZC-o4W">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<connections>
|
||||
<action selector="credentials:" target="-2" id="KS2-fM-QKK"/>
|
||||
</connections>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="nVy-H3-bFO" firstAttribute="leading" secondItem="ft2-Mb-5LD" secondAttribute="leading" constant="20" symbolic="YES" id="SQe-pg-1hl"/>
|
||||
<constraint firstAttribute="trailing" secondItem="nVy-H3-bFO" secondAttribute="trailing" constant="20" symbolic="YES" id="Wsq-ar-poP"/>
|
||||
<constraint firstItem="gLh-gl-ZGQ" firstAttribute="top" secondItem="nVy-H3-bFO" secondAttribute="bottom" constant="8" id="a0S-2S-3dR"/>
|
||||
<constraint firstItem="gLh-gl-ZGQ" firstAttribute="centerX" secondItem="ft2-Mb-5LD" secondAttribute="centerX" id="cW8-YT-BEn"/>
|
||||
<constraint firstItem="nVy-H3-bFO" firstAttribute="top" secondItem="ft2-Mb-5LD" secondAttribute="top" constant="20" symbolic="YES" id="sy2-s4-iEW"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</tabViewItem>
|
||||
</tabViewItems>
|
||||
<point key="canvasLocation" x="-195" y="110"/>
|
||||
</tabView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// AccountsDetailView.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Brent Simmons on 3/19/26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
struct AccountsDetailView: View {
|
||||
|
||||
let account: Account
|
||||
var onCredentials: (() -> Void)?
|
||||
|
||||
@State private var accountName: String
|
||||
@State private var isActive: Bool
|
||||
@State private var syncUnreadContent: Bool
|
||||
|
||||
init(account: Account, onCredentials: (() -> Void)? = nil) {
|
||||
self.account = account
|
||||
self.onCredentials = onCredentials
|
||||
_accountName = State(initialValue: account.name ?? "")
|
||||
_isActive = State(initialValue: account.isActive)
|
||||
_syncUnreadContent = State(initialValue: UserDefaults.standard.bool(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey))
|
||||
}
|
||||
|
||||
private var showCredentialsButton: Bool {
|
||||
switch account.type {
|
||||
case .onMyMac, .cloudKit, .feedly:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Grid(alignment: .leading, verticalSpacing: 0) {
|
||||
GridRow(alignment: .firstTextBaseline) {
|
||||
Text("Type:")
|
||||
.gridColumnAlignment(.trailing)
|
||||
Text(account.defaultName)
|
||||
}
|
||||
|
||||
GridRow {
|
||||
Color.clear
|
||||
.gridCellUnsizedAxes([.horizontal, .vertical])
|
||||
Toggle("Active", isOn: $isActive)
|
||||
.onChange(of: isActive) {
|
||||
account.isActive = isActive
|
||||
}
|
||||
.padding(.top, 9)
|
||||
}
|
||||
|
||||
GridRow(alignment: .firstTextBaseline) {
|
||||
Text("Name:")
|
||||
TextField("", text: $accountName)
|
||||
.frame(width: 150)
|
||||
.onSubmit {
|
||||
commitName()
|
||||
}
|
||||
.onChange(of: accountName) {
|
||||
commitName()
|
||||
}
|
||||
}
|
||||
.padding(.top, 14)
|
||||
|
||||
GridRow {
|
||||
Color.clear
|
||||
.gridCellUnsizedAxes([.horizontal, .vertical])
|
||||
Text("The name can be anything you want. You can even use emoji. 🎸")
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.padding(.top, 1)
|
||||
}
|
||||
|
||||
if showCredentialsButton {
|
||||
GridRow {
|
||||
Color.clear
|
||||
.gridCellUnsizedAxes([.horizontal, .vertical])
|
||||
Button("Credentials") {
|
||||
onCredentials?()
|
||||
}
|
||||
.padding(.top, 12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if account.type == .cloudKit {
|
||||
Toggle("Sync content of unread articles", isOn: $syncUnreadContent)
|
||||
.onChange(of: syncUnreadContent) {
|
||||
UserDefaults.standard.set(syncUnreadContent, forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey)
|
||||
}
|
||||
.padding(.top, 12)
|
||||
|
||||
Text("Syncing article content increases iCloud storage use, sync time, and battery use.\n\nArticle status and the content of starred articles are always synced.")
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.padding(.top, 4)
|
||||
.padding(.leading, 21)
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
|
||||
private func commitName() {
|
||||
if accountName.isEmpty {
|
||||
account.name = nil
|
||||
} else {
|
||||
account.name = accountName
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,64 +7,32 @@
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate {
|
||||
@IBOutlet var typeLabel: NSTextField!
|
||||
@IBOutlet var nameTextField: NSTextField!
|
||||
@IBOutlet var activeButton: NSButtonCell!
|
||||
@IBOutlet var credentialsButton: NSButton!
|
||||
final class AccountsDetailViewController: NSViewController {
|
||||
|
||||
private let account: Account
|
||||
private var accountsWindowController: NSWindowController?
|
||||
private var account: Account?
|
||||
|
||||
init(account: Account) {
|
||||
super.init(nibName: "AccountsDetail", bundle: nil)
|
||||
self.account = account
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
fatalError("AccountsDetailViewController does not support init(coder:)")
|
||||
}
|
||||
|
||||
private var hidesCredentialsButton: Bool {
|
||||
guard let account = account else {
|
||||
return true
|
||||
}
|
||||
switch account.type {
|
||||
case .onMyMac, .cloudKit, .feedly:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
override func loadView() {
|
||||
let detailView = AccountsDetailView(account: account) { [weak self] in
|
||||
self?.showCredentials()
|
||||
}
|
||||
let hostingView = NSHostingView(rootView: detailView)
|
||||
self.view = hostingView
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
nameTextField.delegate = self
|
||||
typeLabel.stringValue = account?.defaultName ?? ""
|
||||
nameTextField.stringValue = account?.name ?? ""
|
||||
activeButton.state = account?.isActive ?? false ? .on : .off
|
||||
credentialsButton.isHidden = hidesCredentialsButton
|
||||
}
|
||||
|
||||
func controlTextDidEndEditing(_ obj: Notification) {
|
||||
if !nameTextField.stringValue.isEmpty {
|
||||
account?.name = nameTextField.stringValue
|
||||
} else {
|
||||
account?.name = nil
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func active(_ sender: NSButtonCell) {
|
||||
account?.isActive = sender.state == .on ? true : false
|
||||
}
|
||||
|
||||
@IBAction func credentials(_ sender: Any) {
|
||||
guard let account else {
|
||||
return
|
||||
}
|
||||
private func showCredentials() {
|
||||
guard let window = view.window else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ public enum FetchType {
|
||||
public static let syncErrors = "syncErrors" // AccountsDidFailToSyncWithErrors
|
||||
}
|
||||
|
||||
public static let iCloudSyncArticleContentForUnreadArticlesKey = "iCloudSyncArticleContentForUnreadArticles"
|
||||
|
||||
public var isDeleted = false
|
||||
|
||||
public var containerID: ContainerIdentifier? {
|
||||
|
||||
@@ -123,6 +123,8 @@ import ErrorLog
|
||||
accountsDictionary[defaultAccount.accountID] = defaultAccount
|
||||
|
||||
readAccountsFromDisk()
|
||||
|
||||
CloudKitAccountDelegate.migrateiCloudSyncArticleContentForUnreadArticlesSetting(hasiCloudAccount: hasiCloudAccount)
|
||||
}
|
||||
|
||||
public func start() {
|
||||
|
||||
@@ -76,6 +76,15 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
static var syncArticleContentForUnreadArticles: Bool {
|
||||
get {
|
||||
UserDefaults.standard.bool(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey)
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey)
|
||||
}
|
||||
}
|
||||
|
||||
init(dataFolder: String) {
|
||||
Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public)")
|
||||
self.accountZone = CloudKitAccountZone(container: container)
|
||||
@@ -86,12 +95,22 @@ enum CloudKitAccountDelegateError: LocalizedError, Sendable {
|
||||
|
||||
self.refresher = LocalAccountRefresher()
|
||||
self.refresher.delegate = self
|
||||
self.articlesZone.settings = self
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(refreshProgressDidChange(_:)), name: .progressInfoDidChange, object: refresher)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(syncProgressDidChange(_:)), name: .progressInfoDidChange, object: syncProgress)
|
||||
Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public) did complete")
|
||||
}
|
||||
|
||||
static func migrateiCloudSyncArticleContentForUnreadArticlesSetting(hasiCloudAccount: Bool) {
|
||||
// iCloudSyncArticleContentForUnreadArticles should be set to false unless
|
||||
// the user already has an iCloud account.
|
||||
guard UserDefaults.standard.object(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey) == nil else {
|
||||
return
|
||||
}
|
||||
syncArticleContentForUnreadArticles = hasiCloudAccount
|
||||
}
|
||||
|
||||
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable: Any]) async {
|
||||
Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public)")
|
||||
await withCheckedContinuation { continuation in
|
||||
@@ -766,7 +785,8 @@ private extension CloudKitAccountDelegate {
|
||||
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
|
||||
let op = CloudKitSendStatusOperation(account: account,
|
||||
articlesZone: articlesZone,
|
||||
database: syncDatabase)
|
||||
database: syncDatabase,
|
||||
settings: self)
|
||||
op.completionBlock = { mainThreadOperation in
|
||||
Self.logger.debug("CloudKitAccountDelegate: \(#function, privacy: .public) did complete")
|
||||
if mainThreadOperation.isCanceled {
|
||||
|
||||
@@ -22,11 +22,13 @@ struct CloudKitArticleStatusUpdate {
|
||||
var articleID: String
|
||||
var statuses: [SyncStatus]
|
||||
var article: Article?
|
||||
var settings: any CloudKitSettings
|
||||
|
||||
init?(articleID: String, statuses: [SyncStatus], article: Article?) {
|
||||
init?(articleID: String, statuses: [SyncStatus], article: Article?, settings: any CloudKitSettings) {
|
||||
self.articleID = articleID
|
||||
self.statuses = statuses
|
||||
self.article = article
|
||||
self.settings = settings
|
||||
|
||||
let rec = record
|
||||
// This is an invalid status update. The article is required for new and all
|
||||
@@ -44,8 +46,11 @@ struct CloudKitArticleStatusUpdate {
|
||||
return .new
|
||||
}
|
||||
|
||||
if let article = article {
|
||||
if article.status.read == false || article.status.starred == true {
|
||||
if let article {
|
||||
if article.status.starred {
|
||||
return .all
|
||||
}
|
||||
if !article.status.read && settings.syncArticleContentForUnreadArticles {
|
||||
return .all
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import SyncDatabase
|
||||
import CloudKitSync
|
||||
|
||||
final class CloudKitArticlesZone: CloudKitZone {
|
||||
|
||||
private static let logger = cloudKitLogger
|
||||
var zoneID: CKRecordZone.ID
|
||||
|
||||
weak var container: CKContainer?
|
||||
@@ -55,6 +57,8 @@ final class CloudKitArticlesZone: CloudKitZone {
|
||||
}
|
||||
}
|
||||
|
||||
var settings: (any CloudKitSettings)!
|
||||
|
||||
init(container: CKContainer) {
|
||||
self.container = container
|
||||
self.database = container.privateCloudDatabase
|
||||
@@ -82,10 +86,21 @@ final class CloudKitArticlesZone: CloudKitZone {
|
||||
|
||||
var records = [CKRecord]()
|
||||
|
||||
let saveArticles = articles.filter { $0.status.read == false || $0.status.starred == true }
|
||||
for saveArticle in saveArticles {
|
||||
records.append(makeStatusRecord(saveArticle))
|
||||
records.append(makeArticleRecord(saveArticle))
|
||||
let syncUnreadContent = settings.syncArticleContentForUnreadArticles
|
||||
Self.logger.info("CloudKitArticlesZone: saveNewArticles syncUnreadContent: \(syncUnreadContent, privacy: .public)")
|
||||
|
||||
for article in articles {
|
||||
if article.status.starred {
|
||||
records.append(makeStatusRecord(article))
|
||||
records.append(makeArticleRecord(article))
|
||||
} else if !article.status.read {
|
||||
records.append(makeStatusRecord(article))
|
||||
if syncUnreadContent {
|
||||
records.append(makeArticleRecord(article))
|
||||
} else {
|
||||
Self.logger.debug("CloudKitArticlesZone: saveNewArticles skipping content for unread article \(article.articleID, privacy: .public)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let compressedRecords = await Task.detached(priority: .userInitiated) {
|
||||
@@ -109,6 +124,9 @@ final class CloudKitArticlesZone: CloudKitZone {
|
||||
var newRecords = [CKRecord]()
|
||||
var deleteRecordIDs = [CKRecord.ID]()
|
||||
|
||||
let syncUnreadContent = settings.syncArticleContentForUnreadArticles
|
||||
Self.logger.info("CloudKitArticlesZone: modifyArticles syncUnreadContent: \(syncUnreadContent, privacy: .public)")
|
||||
|
||||
for statusUpdate in statusUpdates {
|
||||
switch statusUpdate.record {
|
||||
case .all:
|
||||
@@ -116,7 +134,11 @@ final class CloudKitArticlesZone: CloudKitZone {
|
||||
modifyRecords.append(self.makeArticleRecord(statusUpdate.article!))
|
||||
case .new:
|
||||
newRecords.append(self.makeStatusRecord(statusUpdate))
|
||||
newRecords.append(self.makeArticleRecord(statusUpdate.article!))
|
||||
if statusUpdate.article!.status.starred || syncUnreadContent {
|
||||
newRecords.append(self.makeArticleRecord(statusUpdate.article!))
|
||||
} else {
|
||||
Self.logger.debug("CloudKitArticlesZone: modifyArticles skipping content for unread article \(statusUpdate.articleID, privacy: .public)")
|
||||
}
|
||||
case .delete:
|
||||
deleteRecordIDs.append(CKRecord.ID(recordName: self.statusID(statusUpdate.articleID), zoneID: zoneID))
|
||||
case .statusOnly:
|
||||
|
||||
@@ -19,12 +19,14 @@ final class CloudKitSendStatusOperation: MainThreadOperation, @unchecked Sendabl
|
||||
private weak var account: Account?
|
||||
private weak var articlesZone: CloudKitArticlesZone?
|
||||
private var syncDatabase: SyncDatabase
|
||||
private let settings: any CloudKitSettings
|
||||
private static let logger = cloudKitLogger
|
||||
|
||||
init(account: Account, articlesZone: CloudKitArticlesZone, database: SyncDatabase) {
|
||||
init(account: Account, articlesZone: CloudKitArticlesZone, database: SyncDatabase, settings: any CloudKitSettings) {
|
||||
self.account = account
|
||||
self.articlesZone = articlesZone
|
||||
self.syncDatabase = database
|
||||
self.settings = settings
|
||||
super.init(name: "CloudKitSendStatusOperation")
|
||||
}
|
||||
|
||||
@@ -81,7 +83,7 @@ final class CloudKitSendStatusOperation: MainThreadOperation, @unchecked Sendabl
|
||||
result[article.articleID] = article
|
||||
}
|
||||
let statusUpdates = syncStatusesDict.compactMap { (key, value) in
|
||||
CloudKitArticleStatusUpdate(articleID: key, statuses: value, article: articlesDict[key])
|
||||
CloudKitArticleStatusUpdate(articleID: key, statuses: value, article: articlesDict[key], settings: self.settings)
|
||||
}
|
||||
|
||||
// If this happens, we have somehow gotten into a state where we have new status records
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// CloudKitSettings.swift
|
||||
// Account
|
||||
//
|
||||
// Created by Brent Simmons on 3/18/26.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol CloudKitSettings {
|
||||
var syncArticleContentForUnreadArticles: Bool { get }
|
||||
}
|
||||
|
||||
extension CloudKitAccountDelegate: CloudKitSettings {
|
||||
|
||||
var syncArticleContentForUnreadArticles: Bool {
|
||||
CloudKitAccountDelegate.syncArticleContentForUnreadArticles
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ final class AccountInspectorViewController: UITableViewController {
|
||||
@IBOutlet var nameTextField: UITextField!
|
||||
@IBOutlet var activeSwitch: UISwitch!
|
||||
@IBOutlet var deleteAccountButton: VibrantButton!
|
||||
@IBOutlet var syncContentSwitch: UISwitch!
|
||||
@IBOutlet var limitationsAndSolutionsButton: UIButton!
|
||||
|
||||
var isModal = false
|
||||
@@ -31,6 +32,7 @@ final class AccountInspectorViewController: UITableViewController {
|
||||
nameTextField.text = account.name
|
||||
nameTextField.delegate = self
|
||||
activeSwitch.isOn = account.isActive
|
||||
syncContentSwitch.isOn = UserDefaults.standard.bool(forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey)
|
||||
|
||||
navigationItem.title = account.nameForDisplay
|
||||
|
||||
@@ -56,6 +58,10 @@ final class AccountInspectorViewController: UITableViewController {
|
||||
account?.isActive = activeSwitch.isOn
|
||||
}
|
||||
|
||||
@IBAction func syncContentSwitchDidChange(_ sender: UISwitch) {
|
||||
UserDefaults.standard.set(sender.isOn, forKey: Account.iCloudSyncArticleContentForUnreadArticlesKey)
|
||||
}
|
||||
|
||||
@objc func done() {
|
||||
dismiss(animated: true)
|
||||
}
|
||||
@@ -131,12 +137,24 @@ final class AccountInspectorViewController: UITableViewController {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Table View
|
||||
// MARK: - Table View
|
||||
|
||||
extension AccountInspectorViewController {
|
||||
|
||||
/// Sections as laid out in the storyboard.
|
||||
enum StoryboardSection: Int {
|
||||
case nameAndActive = 0
|
||||
case credentials = 1
|
||||
case deleteAccount = 2
|
||||
case syncContent = 3
|
||||
}
|
||||
|
||||
var isCloudKitAccount: Bool {
|
||||
account?.type == .cloudKit
|
||||
}
|
||||
|
||||
var hidesCredentialsSection: Bool {
|
||||
guard let account = account else {
|
||||
guard let account else {
|
||||
return true
|
||||
}
|
||||
switch account.type {
|
||||
@@ -147,44 +165,69 @@ extension AccountInspectorViewController {
|
||||
}
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
guard let account = account else { return 0 }
|
||||
|
||||
if account == AccountManager.shared.defaultAccount {
|
||||
return 1
|
||||
} else if hidesCredentialsSection {
|
||||
return 2
|
||||
} else {
|
||||
return super.numberOfSections(in: tableView)
|
||||
/// The storyboard sections to display, in order, for the current account type.
|
||||
///
|
||||
/// - Default account: name/active only
|
||||
/// - cloudKit: name/active, sync content, delete
|
||||
/// - Other hidden-credentials: name/active, delete
|
||||
/// - All others: name/active, credentials, delete
|
||||
var displayedSections: [StoryboardSection] {
|
||||
guard let account else {
|
||||
return []
|
||||
}
|
||||
if account == AccountManager.shared.defaultAccount {
|
||||
return [.nameAndActive]
|
||||
}
|
||||
if isCloudKitAccount {
|
||||
return [.nameAndActive, .syncContent, .deleteAccount]
|
||||
}
|
||||
if hidesCredentialsSection {
|
||||
return [.nameAndActive, .deleteAccount]
|
||||
}
|
||||
return [.nameAndActive, .credentials, .deleteAccount]
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
displayedSections.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
let storyboardIndex = displayedSections[section].rawValue
|
||||
return super.tableView(tableView, numberOfRowsInSection: storyboardIndex)
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: section)
|
||||
if displayedSections[section] == .nameAndActive {
|
||||
return ImageHeaderView.rowHeight
|
||||
}
|
||||
let storyboardIndex = displayedSections[section].rawValue
|
||||
return super.tableView(tableView, heightForHeaderInSection: storyboardIndex)
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
guard let account = account else { return nil }
|
||||
|
||||
if section == 0 {
|
||||
guard let account else {
|
||||
return nil
|
||||
}
|
||||
if displayedSections[section] == .nameAndActive {
|
||||
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
||||
headerView.imageView.image = Assets.accountImage(account.type)
|
||||
return headerView
|
||||
} else {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
}
|
||||
let storyboardIndex = displayedSections[section].rawValue
|
||||
return super.tableView(tableView, viewForHeaderInSection: storyboardIndex)
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell: UITableViewCell
|
||||
let storyboardIndex = displayedSections[indexPath.section].rawValue
|
||||
return super.tableView(tableView, cellForRowAt: IndexPath(row: indexPath.row, section: storyboardIndex))
|
||||
}
|
||||
|
||||
if indexPath.section == 1, hidesCredentialsSection {
|
||||
cell = super.tableView(tableView, cellForRowAt: IndexPath(row: 0, section: 2))
|
||||
} else {
|
||||
cell = super.tableView(tableView, cellForRowAt: indexPath)
|
||||
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
||||
if displayedSections[section] == .syncContent {
|
||||
return "Syncing article content increases iCloud storage use, sync time, and battery use.\n\nArticle status and the content of starred articles are always synced."
|
||||
}
|
||||
|
||||
return cell
|
||||
let storyboardIndex = displayedSections[section].rawValue
|
||||
return super.tableView(tableView, titleForFooterInSection: storyboardIndex)
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24412" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24405"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24504"/>
|
||||
<capability name="Named colors" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<view key="tableFooterView" contentMode="scaleToFill" id="3V2-Cm-ezj">
|
||||
<rect key="frame" x="0.0" y="312" width="414" height="44"/>
|
||||
<rect key="frame" x="0.0" y="399" width="414" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dgD-uX-vcx">
|
||||
@@ -163,6 +163,39 @@
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection id="syncContent-section-id">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="syncContent-cell-id" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
|
||||
<rect key="frame" x="20" y="330" width="374" height="51"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="syncContent-cell-id" id="syncContent-content-id">
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="51"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sync Content of Unread Articles" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="syncContent-label-id">
|
||||
<rect key="frame" x="20" y="15.5" width="245" height="20.5"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="syncContent-switch-id">
|
||||
<rect key="frame" x="293" y="11.5" width="63" height="28"/>
|
||||
<color key="onTintColor" name="primaryAccentColor"/>
|
||||
<connections>
|
||||
<action selector="syncContentSwitchDidChange:" destination="1m3-fZ-n7g" eventType="valueChanged" id="syncContent-action-id"/>
|
||||
</connections>
|
||||
</switch>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="syncContent-label-id" firstAttribute="centerY" secondItem="syncContent-content-id" secondAttribute="centerY" id="syncContent-labelCenterY-id"/>
|
||||
<constraint firstItem="syncContent-label-id" firstAttribute="leading" secondItem="syncContent-content-id" secondAttribute="leading" constant="20" symbolic="YES" id="syncContent-leading-id"/>
|
||||
<constraint firstItem="syncContent-switch-id" firstAttribute="centerY" secondItem="syncContent-content-id" secondAttribute="centerY" id="syncContent-switchCenterY-id"/>
|
||||
<constraint firstAttribute="trailing" secondItem="syncContent-switch-id" secondAttribute="trailing" constant="20" symbolic="YES" id="syncContent-trailing-id"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="1m3-fZ-n7g" id="eTZ-Uy-P3l"/>
|
||||
@@ -175,6 +208,7 @@
|
||||
<outlet property="deleteAccountButton" destination="obv-a5-Pl6" id="idW-gm-BIJ"/>
|
||||
<outlet property="limitationsAndSolutionsButton" destination="dgD-uX-vcx" id="5ti-AM-xms"/>
|
||||
<outlet property="nameTextField" destination="LUW-uv-piz" id="e2P-Hq-guh"/>
|
||||
<outlet property="syncContentSwitch" destination="syncContent-switch-id" id="syncContent-outlet-id"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="zcI-Zg-28D" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
@@ -357,11 +391,11 @@
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<connections>
|
||||
<outlet property="readerViewAlwaysEnabledSwitch" destination="fUd-JB-UMK" id="kUh-ob-Ego"/>
|
||||
<outlet property="feedURLLabel" destination="rOV-XS-bNW" id="mPv-yb-H4I"/>
|
||||
<outlet property="homePageLabel" destination="HUP-Cu-FGT" id="EDm-vt-2r0"/>
|
||||
<outlet property="nameTextField" destination="ZdA-rl-9eP" id="GzR-uc-fpV"/>
|
||||
<outlet property="newArticleNotificationsEnabledSwitch" destination="g39-wK-xUs" id="ahS-ZK-6xN"/>
|
||||
<outlet property="readerViewAlwaysEnabledSwitch" destination="fUd-JB-UMK" id="kUh-ob-Ego"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="qKF-0N-vfa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
|
||||
Reference in new issue
Block a user