Merge pull request #2150 from stuartbreckenridge/swiftui

Adds Mac Preferences
This commit is contained in:
Maurice Parker 2020-06-29 08:12:40 -05:00 committed by GitHub
commit bbf1e3b2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 506 additions and 55 deletions

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="mPU-HG-I4u">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="mPU-HG-I4u">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16097"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17132"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -31,14 +32,14 @@
<objects>
<viewController title="General" storyboardIdentifier="General" id="iuH-lz-18x" customClass="GeneralPreferencesViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="WnV-px-wCT">
<rect key="frame" x="0.0" y="0.0" width="501" height="213"/>
<rect key="frame" x="0.0" y="0.0" width="501" height="217"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="Ut3-yd-q6G">
<rect key="frame" x="83" y="16" width="334" height="181"/>
<rect key="frame" x="80" y="16" width="340" height="185"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ucw-vG-yLt">
<rect key="frame" x="29" y="159" width="92" height="16"/>
<rect key="frame" x="29" y="162" width="92" height="16"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Refresh feeds:" id="F7c-lm-g97">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -46,13 +47,13 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SFF-mL-yc8">
<rect key="frame" x="125" y="153" width="212" height="25"/>
<rect key="frame" x="125" y="157" width="218" height="25"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="N1a-qV-4Os"/>
</constraints>
<popUpButtonCell key="cell" type="push" title="Every 30 minutes" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="3" imageScaling="proportionallyDown" inset="2" selectedItem="rZU-Tg-xwo" id="Jwn-HD-eP6">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="v0m-Z7-oG3">
<items>
<menuItem title="Manually only" tag="1" id="doa-Wq-4Uq"/>
@ -81,7 +82,7 @@
</popUpButtonCell>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rbK-cS-VQl">
<rect key="frame" x="-2" y="128" width="123" height="16"/>
<rect key="frame" x="-2" y="131" width="123" height="16"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Default RSS reader:" id="bUb-r3-SmS">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -89,10 +90,10 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cSu-T2-Jby">
<rect key="frame" x="125" y="122" width="212" height="25"/>
<rect key="frame" x="125" y="126" width="218" height="25"/>
<popUpButtonCell key="cell" type="push" title="NetNewsWire" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="bEy-Qx-Grl" id="Dyk-WN-XOo" userLabel="Popup">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="8PF-kj-u99">
<items>
<menuItem title="NetNewsWire" state="on" id="bEy-Qx-Grl"/>
@ -104,7 +105,7 @@
</connections>
</popUpButton>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="Ubm-Pk-l7x">
<rect key="frame" x="125" y="64" width="211" height="18"/>
<rect key="frame" x="125" y="67" width="215" height="18"/>
<buttonCell key="cell" type="check" title="Open in background in browser" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="t0a-LN-rCv">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -124,7 +125,7 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jVd-Ie-CGX">
<rect key="frame" x="53" y="3" width="68" height="16"/>
<rect key="frame" x="53" y="4" width="68" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Dock icon:" id="vFc-Nz-RFp">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -132,7 +133,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mwT-nY-TrX">
<rect key="frame" x="125" y="2" width="139" height="18"/>
<rect key="frame" x="125" y="3" width="143" height="18"/>
<buttonCell key="cell" type="check" title="Show unread count" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lh0-G6-9v4">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -153,18 +154,18 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="j0t-Wa-UTL">
<rect key="frame" x="145" y="30" width="191" height="28"/>
<rect key="frame" x="145" y="32" width="197" height="28"/>
<textFieldCell key="cell" controlSize="small" title="Hold the Shift key to invert this preference." id="EMq-9M-zTJ">
<font key="font" metaFont="toolTip"/>
<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>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ci4-fW-KjU">
<rect key="frame" x="125" y="91" width="212" height="25"/>
<rect key="frame" x="125" y="95" width="218" height="25"/>
<popUpButtonCell key="cell" type="push" title="Safari" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="ObP-qK-qDJ" id="hrm-aT-Rc2" userLabel="Popup">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="j1i-Ev-7rI">
<items>
<menuItem title="Safari" state="on" id="ObP-qK-qDJ"/>
@ -176,7 +177,7 @@
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wsb-Lr-8Q7">
<rect key="frame" x="45" y="97" width="76" height="16"/>
<rect key="frame" x="45" y="100" width="76" height="16"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Web pages:" id="CgU-dE-Qtb">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -242,14 +243,14 @@
<objects>
<viewController storyboardIdentifier="Advanced" id="GNh-Wp-giO" customClass="AdvancedPreferencesViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="Hij-7D-6Pw">
<rect key="frame" x="0.0" y="0.0" width="450" height="277"/>
<rect key="frame" x="0.0" y="0.0" width="450" height="278"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="uJD-OF-YVY">
<rect key="frame" x="60" y="20" width="330" height="237"/>
<rect key="frame" x="60" y="20" width="330" height="238"/>
<subviews>
<textField horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="EH5-aS-E55">
<rect key="frame" x="-2" y="221" width="87" height="16"/>
<rect key="frame" x="-2" y="222" width="87" height="16"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="App Updates:" id="zqG-X2-E9b">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -257,7 +258,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="T4A-0o-p2w">
<rect key="frame" x="89" y="220" width="145" height="18"/>
<rect key="frame" x="89" y="221" width="149" height="18"/>
<buttonCell key="cell" type="check" title="Check automatically" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="dm8-Xy-0Ba">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -275,7 +276,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QCu-J4-0yV">
<rect key="frame" x="90" y="193" width="110" height="18"/>
<rect key="frame" x="89" y="193" width="114" height="18"/>
<buttonCell key="cell" type="radio" title="Release builds" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="F8M-rS-und">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -285,7 +286,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CeE-AE-hRG">
<rect key="frame" x="90" y="171" width="88" height="18"/>
<rect key="frame" x="89" y="171" width="92" height="18"/>
<buttonCell key="cell" type="radio" title="Test builds" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Fuf-rU-D6M">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -306,7 +307,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TKI-a9-bRX">
<rect key="frame" x="85" y="80" width="154" height="32"/>
<rect key="frame" x="84" y="81" width="160" height="32"/>
<buttonCell key="cell" type="push" title="Check for Updates" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="AaA-Rr-UYD">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@ -324,7 +325,7 @@
</textFieldCell>
</textField>
<button horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="UHg-1l-FlD">
<rect key="frame" x="89" y="39" width="138" height="18"/>
<rect key="frame" x="89" y="39" width="142" height="18"/>
<buttonCell key="cell" type="check" title="Send automatically" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="jnc-C5-4oI">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -344,7 +345,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uuc-f2-OFX">
<rect key="frame" x="85" y="-7" width="154" height="32"/>
<rect key="frame" x="84" y="-7" width="160" height="32"/>
<buttonCell key="cell" type="push" title="Privacy Policy" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="kSv-Wu-NYx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@ -415,16 +416,16 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="7UM-iq-OLB" customClass="PreferencesTableViewBackgroundView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="44" width="160" height="213"/>
<rect key="frame" x="20" y="44" width="160" height="223"/>
<subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="26" horizontalPageScroll="10" verticalLineScroll="26" verticalPageScroll="10" hasHorizontalScroller="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="PaF-du-r3c">
<rect key="frame" x="1" y="0.0" width="158" height="212"/>
<rect key="frame" x="1" y="0.0" width="158" height="222"/>
<clipView key="contentView" id="cil-Gq-akO">
<rect key="frame" x="0.0" y="0.0" width="158" height="212"/>
<rect key="frame" x="0.0" y="0.0" width="158" height="222"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" viewBased="YES" id="aTp-KR-y6b">
<rect key="frame" x="0.0" y="0.0" width="159" height="212"/>
<rect key="frame" x="0.0" y="0.0" width="188" height="222"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -443,7 +444,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="Cell" id="h2e-5a-qNO">
<rect key="frame" x="1" y="1" width="156" height="17"/>
<rect key="frame" x="11" y="1" width="165" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="27f-p8-Wnt">
@ -455,7 +456,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSActionTemplate" id="lKA-xK-bHU"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hR2-bm-0wE">
<rect key="frame" x="26" y="1" width="126" height="16"/>
<rect key="frame" x="26" y="1" width="135" height="16"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="CcS-BO-sdv">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -531,7 +532,7 @@
<rect key="frame" x="83" y="20" width="97" height="24"/>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Y7D-xQ-wep">
<rect key="frame" x="188" y="20" width="242" height="237"/>
<rect key="frame" x="188" y="20" width="242" height="247"/>
</customView>
</subviews>
<constraints>
@ -586,16 +587,16 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="pjs-G4-byk" customClass="PreferencesTableViewBackgroundView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="44" width="160" height="206"/>
<rect key="frame" x="20" y="44" width="160" height="216"/>
<subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="26" horizontalPageScroll="10" verticalLineScroll="26" verticalPageScroll="10" hasHorizontalScroller="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="29T-r2-ckC">
<rect key="frame" x="1" y="0.0" width="158" height="205"/>
<rect key="frame" x="1" y="0.0" width="158" height="215"/>
<clipView key="contentView" id="dXw-GY-TP8">
<rect key="frame" x="0.0" y="0.0" width="158" height="205"/>
<rect key="frame" x="0.0" y="0.0" width="158" height="215"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" viewBased="YES" id="dfn-Vn-oDp">
<rect key="frame" x="0.0" y="0.0" width="159" height="205"/>
<rect key="frame" x="0.0" y="0.0" width="188" height="215"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -614,7 +615,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="Cell" id="xQs-6E-Kpy">
<rect key="frame" x="1" y="1" width="156" height="17"/>
<rect key="frame" x="11" y="1" width="165" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kmG-vw-CbN">
@ -626,7 +627,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSActionTemplate" id="OVD-Jo-TXU"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6cr-cB-qAN">
<rect key="frame" x="26" y="1" width="126" height="16"/>
<rect key="frame" x="26" y="1" width="135" height="16"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="goO-QG-kk7">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -698,7 +699,7 @@
<rect key="frame" x="83" y="20" width="97" height="24"/>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="N1N-pE-gBL">
<rect key="frame" x="188" y="20" width="242" height="230"/>
<rect key="frame" x="188" y="20" width="242" height="240"/>
</customView>
</subviews>
<constraints>
@ -733,8 +734,8 @@
</scene>
</scenes>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
<image name="NSAddTemplate" width="11" height="11"/>
<image name="NSRemoveTemplate" width="11" height="11"/>
<image name="NSActionTemplate" width="17" height="15"/>
<image name="NSAddTemplate" width="15" height="11"/>
<image name="NSRemoveTemplate" width="15" height="2"/>
</resources>
</document>

View File

@ -13,6 +13,7 @@ struct MainApp: App {
#if os(macOS)
@NSApplicationDelegateAdaptor(AppDelegate.self) private var delegate
let preferences = MacPreferences()
#endif
#if os(iOS)
@UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate
@ -72,6 +73,17 @@ struct MainApp: App {
})
}
.windowToolbarStyle(UnifiedWindowToolbarStyle())
// Mac Preferences
Settings {
MacPreferencesView()
.padding()
.frame(width: 500)
.navigationTitle("Preferences")
.environmentObject(preferences)
}
.windowToolbarStyle(UnifiedWindowToolbarStyle())
#endif
#if os(iOS)

View File

@ -0,0 +1,96 @@
//
// MacPreferences.swift
// macOS
//
// Created by Stuart Breckenridge on 27/6/20.
//
import SwiftUI
enum FontSize: Int {
case small = 0
case medium = 1
case large = 2
case veryLarge = 3
}
/// The `MacPreferences` object stores all macOS specific user preferences.
class MacPreferences: ObservableObject {
private struct AppKeys {
static let refreshInterval = "refreshInterval"
static let openInBackground = "openInBrowserInBackground"
static let showUnreadCountInDock = "showUnreadCountInDock"
static let checkForUpdatesAutomatically = "checkForAppUpdates"
static let downloadTestBuilds = "downloadTestBuilds"
static let sendCrashLogs = "sendCrashLogs"
}
// Refresh Interval
public let refreshIntervals:[String] = RefreshFrequencies.allCases.map({ $0.description })
@AppStorage(wrappedValue: 0, AppKeys.refreshInterval) var refreshFrequency {
didSet {
objectWillChange.send()
}
}
// Open in background
@AppStorage(wrappedValue: false, AppKeys.openInBackground) var openInBackground {
didSet {
objectWillChange.send()
}
}
// Unread Count in Dock
@AppStorage(wrappedValue: true, AppKeys.showUnreadCountInDock) var showUnreadCountInDock {
didSet {
objectWillChange.send()
}
}
// Check for App Updates
@AppStorage(wrappedValue: true, AppKeys.checkForUpdatesAutomatically) var checkForUpdatesAutomatically {
didSet {
objectWillChange.send()
}
}
// Test builds
@AppStorage(wrappedValue: false, AppKeys.downloadTestBuilds) var downloadTestBuilds {
didSet {
objectWillChange.send()
}
}
// Crash Logs
@AppStorage(wrappedValue: false, AppKeys.sendCrashLogs) var sendCrashLogs {
didSet {
objectWillChange.send()
}
}
}
enum RefreshFrequencies: CaseIterable, CustomStringConvertible {
case refreshEvery10Mins, refreshEvery20Mins, refreshHourly, refreshEvery2Hours, refreshEvery4Hours, refreshEvery8Hours, none
var description: String {
switch self {
case .refreshEvery10Mins:
return "Every 10 minutes"
case .refreshEvery20Mins:
return "Every 20 minutes"
case .refreshHourly:
return "Every hour"
case .refreshEvery2Hours:
return "Every 2 hours"
case .refreshEvery4Hours:
return "Every 4 hours"
case .refreshEvery8Hours:
return "Every 8 hours"
case .none:
return "Manually"
}
}
}

View File

@ -0,0 +1,127 @@
//
// AccountsPreferencesView.swift
// macOS
//
// Created by Stuart Breckenridge on 27/6/20.
//
import SwiftUI
struct AccountPreferencesViewModel {
let accountTypes = ["On My Mac", "FeedBin"]
var selectedAccount = Int?.none
}
struct AccountsPreferencesView: View {
@State private var viewModel = AccountPreferencesViewModel()
@State private var addAccountViewModel = AccountPreferencesViewModel()
@State private var showAddAccountView: Bool = false
var body: some View {
VStack {
HStack(alignment: .top, spacing: 10) {
VStack(alignment: .leading) {
List(selection: $viewModel.selectedAccount, content: {
ForEach(0..<viewModel.accountTypes.count, content: { i in
AccountDetailRow(imageName: "desktopcomputer", accountName: viewModel.accountTypes[i]).padding(.vertical, 8)
})
})
HStack {
Button("+", action: {
showAddAccountView.toggle()
})
Button("-", action: {})
.disabled(viewModel.selectedAccount == nil)
Spacer()
}
}.frame(width: 225, height: 300, alignment: .leading)
VStack(alignment: .leading) {
viewModel.selectedAccount == nil ? Text("Select Account") : Text(viewModel.accountTypes[viewModel.selectedAccount!])
Spacer()
}.frame(width: 225, height: 300, alignment: .leading)
}
Spacer()
}.sheet(isPresented: $showAddAccountView,
onDismiss: { showAddAccountView.toggle() },
content: {
AddAccountView()
})
}
}
struct AccountDetailRow: View {
var imageName: String
var accountName: String
var body: some View {
HStack {
Image(systemName: imageName).font(.headline)
Text(accountName).font(.headline)
}
}
}
struct AddAccountView: View {
@Environment(\.presentationMode) var presentationMode
let accountTypes = ["On My Mac", "FeedBin"]
@State var selectedAccount: Int = 0
@State private var userName: String = ""
@State private var password: String = ""
var body: some View {
VStack(alignment: .leading) {
Text("Add an Account").font(.headline)
Form {
Picker("Account Type",
selection: $selectedAccount,
content: {
ForEach(0..<accountTypes.count, content: {
AccountDetailRow(imageName: "desktopcomputer", accountName: accountTypes[$0])
})
})
if selectedAccount == 1 {
TextField("Email", text: $userName)
SecureField("Password", text: $password)
}
}
Spacer()
HStack {
Spacer()
Button(action: { presentationMode.wrappedValue.dismiss() }, label: {
Text("Cancel")
})
if selectedAccount == 0 {
Button("Add", action: {})
}
if selectedAccount != 0 {
Button("Create", action: {})
.disabled(userName.count == 0 || password.count == 0)
}
}
}.frame(width: 300, alignment: .top).padding()
}
}
class AddAccountModel: ObservableObject {
let accountTypes = ["On My Mac", "FeedBin"]
@Published var selectedAccount = Int?.none
}

View File

@ -0,0 +1,49 @@
//
// AdvancedPreferencesView.swift
// macOS
//
// Created by Stuart Breckenridge on 27/6/20.
//
import SwiftUI
struct AdvancedPreferencesView: View {
@StateObject var preferences: MacPreferences
var body: some View {
VStack {
Form {
Toggle("Check for app updates automatically", isOn: $preferences.checkForUpdatesAutomatically)
Toggle("Download Test Builds", isOn: $preferences.downloadTestBuilds)
HStack {
Spacer()
Text("If youre not sure, don't enable test builds. Test builds may have bugs, which may include crashing bugs and data loss.").foregroundColor(.secondary)
Spacer()
}
HStack {
Spacer()
Button("Check for Updates", action: {})
Spacer()
}.padding(.vertical, 12)
Toggle("Send Crash Logs Automatically", isOn: $preferences.sendCrashLogs)
Spacer()
HStack {
Spacer()
Button("Privacy Policy", action: {})
Spacer()
}.padding(.top, 12)
}
Spacer()
}.frame(width: 300, alignment: .center)
}
}

View File

@ -0,0 +1,33 @@
//
// GeneralPreferencesView.swift
// macOS
//
// Created by Stuart Breckenridge on 27/6/20.
//
import SwiftUI
struct GeneralPreferencesView: View {
@ObservedObject private var preferences = MacPreferences()
var body: some View {
VStack {
Form {
Picker("Refresh Feeds",
selection: $preferences.refreshFrequency,
content: {
ForEach(0..<preferences.refreshIntervals.count, content: {
Text(preferences.refreshIntervals[$0])
})
}).frame(width: 300, alignment: .center)
Toggle("Open webpages in background in browser", isOn: $preferences.openInBackground)
Toggle("Show Unread Count in Dock", isOn: $preferences.showUnreadCountInDock)
}
Spacer()
}.frame(width: 300, alignment: .center)
}
}

View File

@ -0,0 +1,89 @@
//
// MacPreferencesView.swift
// macOS
//
// Created by Stuart Breckenridge on 27/6/20.
//
import SwiftUI
struct MacPreferenceViewModel {
enum PreferencePane: Int, CaseIterable {
case general = 0
case accounts = 1
case advanced = 2
var description: String {
switch self {
case .general:
return "General"
case .accounts:
return "Accounts"
case .advanced:
return "Advanced"
}
}
}
var currentPreferencePane: PreferencePane = PreferencePane.general
}
struct MacPreferencesView: View {
@EnvironmentObject var preferences: MacPreferences
@State private var viewModel = MacPreferenceViewModel()
var body: some View {
VStack {
if viewModel.currentPreferencePane == .general {
AnyView(GeneralPreferencesView())
}
else if viewModel.currentPreferencePane == .accounts {
AnyView(AccountsPreferencesView())
}
else {
AnyView(AdvancedPreferencesView(preferences: preferences))
}
}
.toolbar {
ToolbarItem {
Button(action: {
viewModel.currentPreferencePane = .general
}, label: {
Image(systemName: "checkmark.rectangle")
Text("General")
})
}
ToolbarItem {
Button(action: {
viewModel.currentPreferencePane = .accounts
}, label: {
Image(systemName: "network")
Text("Accounts")
})
}
ToolbarItem {
Button(action: {
viewModel.currentPreferencePane = .advanced
}, label: {
Image(systemName: "gearshape.fill")
Text("Advanced")
})
}
}
.presentedWindowToolbarStyle(UnifiedCompactWindowToolbarStyle())
.presentedWindowStyle(TitleBarWindowStyle())
.navigationTitle(Text(viewModel.currentPreferencePane.description))
}
}
struct MacPreferencesView_Previews: PreviewProvider {
static var previews: some View {
MacPreferencesView()
}
}

View File

@ -7,6 +7,11 @@
objects = {
/* Begin PBXBuildFile section */
1729528E24AA1A4900D65E66 /* MacPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729526C24AA1A4900D65E66 /* MacPreferences.swift */; };
1729529324AA1CAA00D65E66 /* AccountsPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529024AA1CAA00D65E66 /* AccountsPreferencesView.swift */; };
1729529424AA1CAA00D65E66 /* AdvancedPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */; };
1729529524AA1CAA00D65E66 /* GeneralPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */; };
1729529724AA1CD000D65E66 /* MacPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529624AA1CD000D65E66 /* MacPreferencesView.swift */; };
179DB1DFBCF9177104B12E0F /* AccountsNewsBlurWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */; };
179DB3CE822BFCC2D774D9F4 /* AccountsNewsBlurWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */; };
3B3A32A5238B820900314204 /* FeedWranglerAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */; };
@ -1659,6 +1664,11 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1729526C24AA1A4900D65E66 /* MacPreferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacPreferences.swift; sourceTree = "<group>"; };
1729529024AA1CAA00D65E66 /* AccountsPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsPreferencesView.swift; sourceTree = "<group>"; };
1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvancedPreferencesView.swift; sourceTree = "<group>"; };
1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesView.swift; sourceTree = "<group>"; };
1729529624AA1CD000D65E66 /* MacPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacPreferencesView.swift; sourceTree = "<group>"; };
179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsNewsBlurWindowController.swift; sourceTree = "<group>"; };
3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerAccountViewController.swift; sourceTree = "<group>"; };
3B826DB02385C84800FC1ADB /* AccountsFeedWrangler.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AccountsFeedWrangler.xib; sourceTree = "<group>"; };
@ -2290,6 +2300,34 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
1729528F24AA1A4F00D65E66 /* Preferences */ = {
isa = PBXGroup;
children = (
1729529824AA1CD900D65E66 /* Model */,
1729529924AA1CE100D65E66 /* Views */,
);
path = Preferences;
sourceTree = "<group>";
};
1729529824AA1CD900D65E66 /* Model */ = {
isa = PBXGroup;
children = (
1729526C24AA1A4900D65E66 /* MacPreferences.swift */,
);
path = Model;
sourceTree = "<group>";
};
1729529924AA1CE100D65E66 /* Views */ = {
isa = PBXGroup;
children = (
1729529624AA1CD000D65E66 /* MacPreferencesView.swift */,
1729529024AA1CAA00D65E66 /* AccountsPreferencesView.swift */,
1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */,
1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */,
);
path = Views;
sourceTree = "<group>";
};
510289CE2451BA1E00426DDF /* Twitter */ = {
isa = PBXGroup;
children = (
@ -2564,6 +2602,7 @@
51C0519424A77E6D00194D5E /* macOS */ = {
isa = PBXGroup;
children = (
1729528F24AA1A4F00D65E66 /* Preferences */,
51C0514624A77DF800194D5E /* Info.plist */,
51C0514724A77DF800194D5E /* macOS.entitlements */,
51C051CD24A7A6DB00194D5E /* macOS-dev.entitlements */,
@ -3768,46 +3807,46 @@
TargetAttributes = {
51314636235A7BBE00387FDC = {
CreatedOnToolsVersion = 11.2;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
LastSwiftMigration = 1120;
ProvisioningStyle = Automatic;
};
513C5CE5232571C2003D4054 = {
CreatedOnToolsVersion = 11.0;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
};
518B2ED12351B3DD00400001 = {
CreatedOnToolsVersion = 11.2;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
TestTargetID = 840D617B2029031C009BC708;
};
51C0513C24A77DF800194D5E = {
CreatedOnToolsVersion = 12.0;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
};
51C0514324A77DF800194D5E = {
CreatedOnToolsVersion = 12.0;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
};
6581C73220CED60000F4AD34 = {
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
};
65ED3FA2235DEF6C0081F399 = {
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
};
65ED4090235DEF770081F399 = {
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
};
840D617B2029031C009BC708 = {
CreatedOnToolsVersion = 9.3;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
@ -3817,7 +3856,7 @@
};
849C645F1ED37A5D003D8FC0 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.HardenedRuntime = {
@ -3827,7 +3866,7 @@
};
849C64701ED37A5D003D8FC0 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = SHJK2V3AJG;
DevelopmentTeam = FQLBNX3GP7;
ProvisioningStyle = Automatic;
TestTargetID = 849C645F1ED37A5D003D8FC0;
};
@ -4691,7 +4730,9 @@
51E49A0124A91FC100B667CB /* SidebarView.swift in Sources */,
51E4995B24A875D500B667CB /* ArticlePasteboardWriter.swift in Sources */,
51E4993424A867E700B667CB /* UserInfoKey.swift in Sources */,
1729529724AA1CD000D65E66 /* MacPreferencesView.swift in Sources */,
51E4994C24A8734C00B667CB /* RedditFeedProvider-Extensions.swift in Sources */,
1729529324AA1CAA00D65E66 /* AccountsPreferencesView.swift in Sources */,
51E4994124A8713B00B667CB /* RefreshInterval.swift in Sources */,
51E498C924A8085D00B667CB /* PseudoFeed.swift in Sources */,
51E498FC24A808BA00B667CB /* FaviconURLFinder.swift in Sources */,
@ -4713,6 +4754,7 @@
51E4995A24A873F900B667CB /* ErrorHandler.swift in Sources */,
51E4991F24A8094300B667CB /* RSImage-AppIcons.swift in Sources */,
51E4991224A808FB00B667CB /* AddWebFeedDefaultContainer.swift in Sources */,
1729528E24AA1A4900D65E66 /* MacPreferences.swift in Sources */,
51E4993E24A870F900B667CB /* UserNotificationManager.swift in Sources */,
51E4992E24A8676300B667CB /* FetchRequestQueue.swift in Sources */,
51E498CF24A8085D00B667CB /* SmartFeed.swift in Sources */,
@ -4727,6 +4769,8 @@
51E498CD24A8085D00B667CB /* SearchTimelineFeedDelegate.swift in Sources */,
51E4996124A875F400B667CB /* ArticleRenderer.swift in Sources */,
51C0515F24A77DF800194D5E /* MainApp.swift in Sources */,
1729529524AA1CAA00D65E66 /* GeneralPreferencesView.swift in Sources */,
1729529424AA1CAA00D65E66 /* AdvancedPreferencesView.swift in Sources */,
51E4992D24A8676300B667CB /* FetchRequestOperation.swift in Sources */,
51E4992424A8098400B667CB /* SmartFeedPasteboardWriter.swift in Sources */,
51E4991424A808FF00B667CB /* ArticleStringFormatter.swift in Sources */,