Implement the delete UI
This commit is contained in:
parent
133398c240
commit
1802f71572
|
@ -351,7 +351,7 @@
|
|||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9qe-g9-RR3">
|
||||
<rect key="frame" x="51" y="19" width="32" height="26"/>
|
||||
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Dvx-B8-wQy">
|
||||
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" enabled="NO" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Dvx-B8-wQy">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
|
@ -387,6 +387,7 @@
|
|||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="deleteButton" destination="9qe-g9-RR3" id="4qe-36-5d4"/>
|
||||
<outlet property="detailView" destination="Y7D-xQ-wep" id="7U0-LY-Xom"/>
|
||||
<outlet property="tableView" destination="aTp-KR-y6b" id="jTu-6a-Jno"/>
|
||||
</connections>
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?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="AccountsDeleteWindowController" customModule="NetNewsWire" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="deleteLabel" destination="Fce-kc-b0h" id="7ZU-DV-MZC"/>
|
||||
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
||||
<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="388" height="241"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<view key="contentView" id="se5-gp-TjO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="399" height="140"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fce-kc-b0h">
|
||||
<rect key="frame" x="18" y="81" width="215" height="39"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Delete Account" id="Avt-GJ-nM5">
|
||||
<font key="font" metaFont="system" size="32"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ATn-Px-oM3">
|
||||
<rect key="frame" x="18" y="39" width="363" height="34"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="34" id="TPx-9h-Nlb"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" lineBreakMode="charWrapping" id="g3o-wP-P50">
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="title">Are you sure you want to permanently delete this account?
|
||||
This cannot be undone.</string>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jaZ-f1-UDg">
|
||||
<rect key="frame" x="305" y="13" width="80" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Delete" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XJH-E2-zim">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Aw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="create:" target="-2" id="Kjr-mt-Yp3"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="v9D-u4-Ucr">
|
||||
<rect key="frame" x="223" y="13" width="82" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="tmJ-aM-Z1c">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="cancel:" target="-2" id="Zo3-sa-7b3"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="ATn-Px-oM3" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="2SQ-Jm-kaA"/>
|
||||
<constraint firstAttribute="bottom" secondItem="jaZ-f1-UDg" secondAttribute="bottom" constant="20" id="9GB-yz-aIT"/>
|
||||
<constraint firstItem="jaZ-f1-UDg" firstAttribute="leading" secondItem="v9D-u4-Ucr" secondAttribute="trailing" constant="12" symbolic="YES" id="BH5-Ed-OFG"/>
|
||||
<constraint firstItem="Fce-kc-b0h" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" id="Fxf-5F-l3D"/>
|
||||
<constraint firstItem="v9D-u4-Ucr" firstAttribute="centerY" secondItem="jaZ-f1-UDg" secondAttribute="centerY" id="IfR-SA-Uft"/>
|
||||
<constraint firstItem="Fce-kc-b0h" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="KeW-9F-SKj"/>
|
||||
<constraint firstAttribute="trailing" secondItem="jaZ-f1-UDg" secondAttribute="trailing" constant="20" id="LSF-4E-uzG"/>
|
||||
<constraint firstAttribute="trailing" secondItem="ATn-Px-oM3" secondAttribute="trailing" constant="20" id="eXh-HX-MTx"/>
|
||||
<constraint firstItem="jaZ-f1-UDg" firstAttribute="firstBaseline" secondItem="ATn-Px-oM3" secondAttribute="baseline" constant="16" id="gzw-C9-vLu"/>
|
||||
<constraint firstItem="ATn-Px-oM3" firstAttribute="top" secondItem="Fce-kc-b0h" secondAttribute="bottom" constant="8" id="mIu-3V-PcW"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="11" y="132.5"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// AccountsDeleteWindowController.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 5/1/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import Account
|
||||
|
||||
class AccountsDeleteWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet weak var deleteLabel: NSTextField!
|
||||
private weak var hostWindow: NSWindow?
|
||||
|
||||
var account: Account?
|
||||
|
||||
convenience init(account: Account) {
|
||||
self.init(windowNibName: NSNib.Name("AccountsDelete"))
|
||||
self.account = account
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
let deletePrompt = NSLocalizedString("Delete", comment: "Delete")
|
||||
deleteLabel.stringValue = "\(deletePrompt) \"\(account?.nameForDisplay ?? "")\"?"
|
||||
}
|
||||
|
||||
// MARK: API
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
self.hostWindow = hostWindow
|
||||
hostWindow.beginSheet(window!)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
|
||||
}
|
||||
|
||||
@IBAction func create(_ sender: Any) {
|
||||
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,9 @@ final class AccountsPreferencesViewController: NSViewController {
|
|||
|
||||
@IBOutlet weak var tableView: NSTableView!
|
||||
@IBOutlet weak var detailView: NSView!
|
||||
@IBOutlet weak var deleteButton: NSButton!
|
||||
|
||||
private var deleteController: AccountsDeleteWindowController?
|
||||
private var sortedAccounts = [Account]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
@ -36,6 +38,12 @@ final class AccountsPreferencesViewController: NSViewController {
|
|||
}
|
||||
|
||||
@IBAction func removeAccount(_ sender: Any) {
|
||||
guard tableView.selectedRow != -1 else {
|
||||
return
|
||||
}
|
||||
let account = sortedAccounts[tableView.selectedRow]
|
||||
deleteController = AccountsDeleteWindowController(account: account)
|
||||
deleteController!.runSheetOnWindow(view.window!)
|
||||
}
|
||||
|
||||
@objc func displayNameDidChange(_ note: Notification) {
|
||||
|
@ -89,11 +97,17 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
|
|||
func tableViewSelectionDidChange(_ notification: Notification) {
|
||||
|
||||
let selectedRow = tableView.selectedRow
|
||||
guard selectedRow != -1 else {
|
||||
if tableView.selectedRow == -1 {
|
||||
deleteButton.isEnabled = false
|
||||
return
|
||||
} else {
|
||||
deleteButton.isEnabled = true
|
||||
}
|
||||
|
||||
let account = sortedAccounts[selectedRow]
|
||||
if AccountManager.shared.defaultAccount == account {
|
||||
deleteButton.isEnabled = false
|
||||
}
|
||||
|
||||
let controller = AccountsDetailViewController(account: account)
|
||||
showController(controller)
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
5144EA3D227A37AF00D19003 /* ExportOPMLSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */; };
|
||||
5144EA40227A37EC00D19003 /* ImportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */; };
|
||||
5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */; };
|
||||
5144EA46227A5A8700D19003 /* AccountsDeleteWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */; };
|
||||
5144EA47227A5A8700D19003 /* AccountsDelete.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA45227A5A8700D19003 /* AccountsDelete.xib */; };
|
||||
5183CCD0226E1E880010922C /* NonIntrinsicLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */; };
|
||||
5183CCDA226E31A50010922C /* NonIntrinsicImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCD9226E31A50010922C /* NonIntrinsicImageView.swift */; };
|
||||
5183CCDD226F1F5C0010922C /* NavigationProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCDC226F1F5C0010922C /* NavigationProgressView.swift */; };
|
||||
|
@ -650,6 +652,8 @@
|
|||
5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExportOPMLSheet.xib; sourceTree = "<group>"; };
|
||||
5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportOPMLWindowController.swift; sourceTree = "<group>"; };
|
||||
5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportOPMLWindowController.swift; sourceTree = "<group>"; };
|
||||
5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsDeleteWindowController.swift; sourceTree = "<group>"; };
|
||||
5144EA45227A5A8700D19003 /* AccountsDelete.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsDelete.xib; sourceTree = "<group>"; };
|
||||
5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonIntrinsicLabel.swift; sourceTree = "<group>"; };
|
||||
5183CCD9226E31A50010922C /* NonIntrinsicImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonIntrinsicImageView.swift; sourceTree = "<group>"; };
|
||||
5183CCDC226F1F5C0010922C /* NavigationProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationProgressView.swift; sourceTree = "<group>"; };
|
||||
|
@ -1596,6 +1600,8 @@
|
|||
5144EA2E2279FAB600D19003 /* AccountsDetailViewController.swift */,
|
||||
5144EA352279FC3D00D19003 /* AccountsAddLocal.xib */,
|
||||
5144EA372279FC6200D19003 /* AccountsAddLocalWindowController.swift */,
|
||||
5144EA45227A5A8700D19003 /* AccountsDelete.xib */,
|
||||
5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */,
|
||||
);
|
||||
path = Accounts;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2189,6 +2195,7 @@
|
|||
848362FF2262A30E00DA1D35 /* template.html in Resources */,
|
||||
848363082262A3DD00DA1D35 /* Main.storyboard in Resources */,
|
||||
51EF0F8E2279C9260050506E /* AccountsAdd.xib in Resources */,
|
||||
5144EA47227A5A8700D19003 /* AccountsDelete.xib in Resources */,
|
||||
84C9FC8F22629E8F00D921D6 /* NetNewsWire.sdef in Resources */,
|
||||
84C9FC7D22629E1200D921D6 /* AccountsDetail.xib in Resources */,
|
||||
5144EA362279FC3D00D19003 /* AccountsAddLocal.xib in Resources */,
|
||||
|
@ -2412,6 +2419,7 @@
|
|||
84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */,
|
||||
5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */,
|
||||
842611A21FCB769D0086A189 /* RSHTMLMetadata+Extension.swift in Sources */,
|
||||
5144EA46227A5A8700D19003 /* AccountsDeleteWindowController.swift in Sources */,
|
||||
84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */,
|
||||
D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */,
|
||||
849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */,
|
||||
|
|
Loading…
Reference in New Issue