Add account add UI

This commit is contained in:
Maurice Parker 2019-05-01 10:28:13 -05:00
parent a845a96274
commit fe8e825c0d
8 changed files with 266 additions and 18 deletions

View File

@ -12,8 +12,8 @@ import Articles
let AccountsDidChangeNotification = "AccountsDidChangeNotification"
private let localAccountFolderName = "OnMyMac"
private let localAccountIdentifier = "OnMyMac"
private let defaultAccountFolderName = "OnMyMac"
private let defaultAccountIdentifier = "OnMyMac"
public final class AccountManager: UnreadCountProvider {
@ -74,7 +74,7 @@ public final class AccountManager: UnreadCountProvider {
abort()
}
defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: localAccountIdentifier)!
defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: defaultAccountIdentifier)!
accountsDictionary[defaultAccount.accountID] = defaultAccount
readNonLocalAccountsFromDisk()
@ -164,7 +164,7 @@ public final class AccountManager: UnreadCountProvider {
filenames?.forEach { (oneFilename) in
guard oneFilename != localAccountFolderName else {
guard oneFilename != defaultAccountFolderName else {
return
}
if let oneAccount = createAccount(oneFilename) {

View File

@ -32,4 +32,10 @@ struct AppImages {
return image
}()
static var accountFeedbin: RSImage! = {
let image = RSImage(named: "accountFeedbin")
image?.isTemplate = true
return image
}()
}

View File

@ -345,6 +345,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="addAccount:" target="z5c-Js-Up9" id="owK-WR-Xd7"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9qe-g9-RR3">
<rect key="frame" x="51" y="19" width="32" height="26"/>
@ -352,6 +355,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="removeAccount:" target="z5c-Js-Up9" id="APC-9C-TC7"/>
</connections>
</button>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="1gP-iQ-hAV" customClass="AccountsControlsBackgroundView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="83" y="20" width="67" height="24"/>

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccountAddViewController" customModule="NetNewsWire" customModuleProvider="target">
<connections>
<outlet property="tableView" destination="YWY-HH-lRy" id="BaW-PN-aD4"/>
<outlet property="view" destination="c22-O7-iKe" id="wFV-1Z-hFh"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="42" horizontalPageScroll="10" verticalLineScroll="42" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aV5-XD-qtI">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<clipView key="contentView" id="UDd-jz-Pwe">
<rect key="frame" x="1" y="1" width="478" height="270"/>
<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="40" rowSizeStyle="automatic" viewBased="YES" id="YWY-HH-lRy">
<rect key="frame" x="0.0" y="0.0" width="478" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<tableViewGridLines key="gridStyleMask" horizontal="YES"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="475" minWidth="40" maxWidth="1000" id="aZS-IU-bl6">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="lLv-gy-cGn">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="Cell" id="wVK-qI-WAx" customClass="AccountAddTableCellView" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="1" y="1" width="475" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="centerY" spacing="17" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xsr-pQ-ts2">
<rect key="frame" x="151" y="8" width="173" height="24"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="cjk-vg-Vn6">
<rect key="frame" x="0.0" y="0.0" width="24" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="EcV-jK-0Zb"/>
<constraint firstAttribute="height" constant="24" id="hGY-vc-lAm"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="ros-80-3xn"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="5ut-F4-bRA">
<rect key="frame" x="39" y="0.0" width="136" height="24"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="2mk-0x-ly6">
<font key="font" metaFont="system" size="20"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="xsr-pQ-ts2" firstAttribute="centerX" secondItem="wVK-qI-WAx" secondAttribute="centerX" id="NyC-iA-yed"/>
<constraint firstItem="xsr-pQ-ts2" firstAttribute="centerY" secondItem="wVK-qI-WAx" secondAttribute="centerY" id="lQw-mm-Vnb"/>
</constraints>
<connections>
<outlet property="accountImageView" destination="cjk-vg-Vn6" id="laA-LX-gYz"/>
<outlet property="accountNameLabel" destination="5ut-F4-bRA" id="jiR-YI-QBk"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="V4D-fs-sIt">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="a6y-yE-P0S">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="aV5-XD-qtI" secondAttribute="bottom" id="OR8-mp-jGq"/>
<constraint firstAttribute="trailing" secondItem="aV5-XD-qtI" secondAttribute="trailing" id="djx-Hq-MmE"/>
<constraint firstItem="aV5-XD-qtI" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="hrT-XK-tRk"/>
<constraint firstItem="aV5-XD-qtI" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="oGe-X8-oCz"/>
</constraints>
</customView>
</objects>
</document>

View File

@ -0,0 +1,16 @@
//
// AccountAddTableCellView.swift
// NetNewsWire
//
// Created by Maurice Parker on 5/1/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import Cocoa
class AccountAddTableCellView: NSTableCellView {
@IBOutlet weak var accountImageView: NSImageView?
@IBOutlet weak var accountNameLabel: NSTextField?
}

View File

@ -0,0 +1,85 @@
//
// AccountAddViewController.swift
// NetNewsWire
//
// Created by Maurice Parker on 5/1/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import Cocoa
class AccountAddViewController: NSViewController {
@IBOutlet weak var tableView: NSTableView!
init() {
super.init(nibName: "AccountAdd", bundle: nil)
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
}
}
// MARK: - NSTableViewDataSource
extension AccountAddViewController: NSTableViewDataSource {
func numberOfRows(in tableView: NSTableView) -> Int {
return 2
}
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
return nil
}
}
// MARK: - NSTableViewDelegate
extension AccountAddViewController: NSTableViewDelegate {
private static let cellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "AccountCell")
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountAddTableCellView {
switch row {
case 0:
cell.accountNameLabel?.stringValue = NSLocalizedString("Local", comment: "Local")
cell.accountImageView?.image = AppImages.accountLocal
case 1:
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
cell.accountImageView?.image = AppImages.accountFeedbin
default:
break
}
return cell
}
return nil
}
func tableViewSelectionDidChange(_ notification: Notification) {
// let selectedRow = tableView.selectedRow
// guard selectedRow != -1 else {
// return
// }
//
// let account = sortedAccounts[selectedRow]
//
// let controller = AccountDetailViewController(account: account)
// addChild(controller)
// controller.view.translatesAutoresizingMaskIntoConstraints = false
// detailView.addSubview(controller.view)
// detailView.rs_addFullSizeConstraints(forSubview: controller.view)
}
}

View File

@ -18,20 +18,25 @@ final class AccountsPreferencesViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
}
override func viewWillAppear() {
updateSortedAccounts()
tableView.reloadData()
tableView.delegate = self
tableView.dataSource = self
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
showController(AccountAddViewController())
}
override func viewWillDisappear() {
super.viewWillDisappear()
resetContainerView()
@IBAction func addAccount(_ sender: Any) {
showController(AccountAddViewController())
}
@IBAction func removeAccount(_ sender: Any) {
}
@objc func displayNameDidChange(_ note: Notification) {
updateSortedAccounts()
tableView.reloadData()
}
@ -83,11 +88,8 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
let account = sortedAccounts[selectedRow]
let controller = AccountDetailViewController(account: account)
addChild(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = false
detailView.addSubview(controller.view)
detailView.rs_addFullSizeConstraints(forSubview: controller.view)
showController(controller)
}
}
@ -100,11 +102,18 @@ private extension AccountsPreferencesViewController {
sortedAccounts = AccountManager.shared.sortedAccounts
}
func resetContainerView() {
func showController(_ controller: NSViewController) {
if let controller = children.first {
children.removeAll()
controller.view.removeFromSuperview()
}
addChild(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = false
detailView.addSubview(controller.view)
detailView.rs_addFullSizeConstraints(forSubview: controller.view)
}
}

View File

@ -113,6 +113,9 @@
51EF0F7E2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F7D2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift */; };
51EF0F802277A8330050506E /* MasterTimelineCellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F7F2277A8330050506E /* MasterTimelineCellLayout.swift */; };
51EF0F8C2279BEEB0050506E /* AccountDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F8B2279BEEB0050506E /* AccountDetailViewController.swift */; };
51EF0F8E2279C9260050506E /* AccountAdd.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51EF0F8D2279C9260050506E /* AccountAdd.xib */; };
51EF0F902279C9500050506E /* AccountAddViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F8F2279C9500050506E /* AccountAddViewController.swift */; };
51EF0F922279CA620050506E /* AccountAddTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F912279CA620050506E /* AccountAddTableCellView.swift */; };
51F85BE5227217D000C787DC /* RefreshIntervalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BDB2272162F00C787DC /* RefreshIntervalViewController.swift */; };
51F85BE7227245FC00C787DC /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BE6227245FC00C787DC /* AboutViewController.swift */; };
51F85BEB22724CB600C787DC /* About.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 51F85BEA22724CB600C787DC /* About.rtf */; };
@ -673,6 +676,9 @@
51EF0F7D2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineAccessibilityCellLayout.swift; sourceTree = "<group>"; };
51EF0F7F2277A8330050506E /* MasterTimelineCellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineCellLayout.swift; sourceTree = "<group>"; };
51EF0F8B2279BEEB0050506E /* AccountDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountDetailViewController.swift; sourceTree = "<group>"; };
51EF0F8D2279C9260050506E /* AccountAdd.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountAdd.xib; sourceTree = "<group>"; };
51EF0F8F2279C9500050506E /* AccountAddViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountAddViewController.swift; sourceTree = "<group>"; };
51EF0F912279CA620050506E /* AccountAddTableCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountAddTableCellView.swift; sourceTree = "<group>"; };
51F85BDB2272162F00C787DC /* RefreshIntervalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshIntervalViewController.swift; sourceTree = "<group>"; };
51F85BE6227245FC00C787DC /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
51F85BEA22724CB600C787DC /* About.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = About.rtf; sourceTree = "<group>"; };
@ -1559,6 +1565,9 @@
84C9FC7022629E1200D921D6 /* AccountsTableViewBackgroundView.swift */,
84C9FC7122629E1200D921D6 /* AccountsControlsBackgroundView.swift */,
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */,
51EF0F8D2279C9260050506E /* AccountAdd.xib */,
51EF0F8F2279C9500050506E /* AccountAddViewController.swift */,
51EF0F912279CA620050506E /* AccountAddTableCellView.swift */,
84C9FC7422629E1200D921D6 /* AccountDetail.xib */,
51EF0F8B2279BEEB0050506E /* AccountDetailViewController.swift */,
);
@ -2153,6 +2162,7 @@
845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */,
848362FF2262A30E00DA1D35 /* template.html in Resources */,
848363082262A3DD00DA1D35 /* Main.storyboard in Resources */,
51EF0F8E2279C9260050506E /* AccountAdd.xib in Resources */,
84C9FC8F22629E8F00D921D6 /* NetNewsWire.sdef in Resources */,
84C9FC7D22629E1200D921D6 /* AccountDetail.xib in Resources */,
84C9FC8C22629E8F00D921D6 /* KeyboardShortcuts.html in Resources */,
@ -2348,6 +2358,7 @@
8405DD9922153B6B008CE1BF /* TimelineContainerView.swift in Sources */,
D5A2678C20130ECF00A8D3C0 /* Author+Scriptability.swift in Sources */,
84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */,
51EF0F902279C9500050506E /* AccountAddViewController.swift in Sources */,
D57BE6E0204CD35F00D11AAC /* NSScriptCommand+NetNewsWire.swift in Sources */,
D553738B20186C20006D8857 /* Article+Scriptability.swift in Sources */,
845EE7C11FC2488C00854A1F /* SmartFeed.swift in Sources */,
@ -2399,6 +2410,7 @@
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */,
845213231FCA5B11003B6E93 /* ImageDownloader.swift in Sources */,
51EF0F8C2279BEEB0050506E /* AccountDetailViewController.swift in Sources */,
51EF0F922279CA620050506E /* AccountAddTableCellView.swift in Sources */,
849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */,
8405DDA522168C62008CE1BF /* TimelineContainerViewController.swift in Sources */,
844B5B671FEA18E300C7C76A /* MainWIndowKeyboardHandler.swift in Sources */,