Updated all iOS references to default local account new to be device specific

This commit is contained in:
Phil Viso 2019-05-19 16:52:21 -05:00
parent 890c146c7e
commit bce45d28e4
7 changed files with 62 additions and 16 deletions

View File

@ -67,6 +67,21 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
public static let feeds = "feeds" // AccountDidDownloadArticles, StatusesDidChange
}
public static let defaultLocalAccountName: String = {
let defaultName: String
#if os(macOS)
defaultName = NSLocalizedString("On My Mac", comment: "Account name")
#else
if UIDevice.current.userInterfaceIdiom == .pad {
defaultName = NSLocalizedString("On My iPad", comment: "Account name")
} else {
defaultName = NSLocalizedString("On My iPhone", comment: "Account name")
}
#endif
return defaultName
}()
public let accountID: String
public let type: AccountType
public var nameForDisplay: String {
@ -220,15 +235,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
switch type {
case .onMyMac:
#if os(macOS)
defaultName = NSLocalizedString("On My Mac", comment: "Account name")
#else
if UIDevice.current.userInterfaceIdiom == .pad {
defaultName = NSLocalizedString("On My iPad", comment: "Account name")
} else {
defaultName = NSLocalizedString("On My iPhone", comment: "Account name")
}
#endif
defaultName = Account.defaultLocalAccountName
case .feedly:
defaultName = "Feedly"
case .feedbin:

View File

@ -7,6 +7,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccountsAddLocalWindowController" customModule="NetNewsWire" customModuleProvider="target">
<connections>
<outlet property="localAccountNameTextField" destination="80D-3X-rL2" id="B6t-AS-hDh"/>
<outlet property="nameTextField" destination="f9b-FM-i8Q" id="TJl-Uc-PNg"/>
<outlet property="window" destination="QvC-M9-y7g" id="ENN-6Q-J5m"/>
</connections>
@ -17,13 +18,13 @@
<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="2560" height="1417"/>
<rect key="screenRect" x="0.0" y="0.0" width="2048" height="1129"/>
<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"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="19" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uDK-ji-zlT">
<rect key="frame" x="93" y="150" width="213" height="39"/>
<rect key="frame" x="95" y="150" width="209" height="39"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ySx-qg-WbT">
<rect key="frame" x="0.0" y="0.0" width="36" height="36"/>
@ -34,7 +35,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="accountLocal" id="9RZ-J3-ioX"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80D-3X-rL2">
<rect key="frame" x="53" y="0.0" width="162" height="39"/>
<rect key="frame" x="53" y="0.0" width="158" height="39"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="On My Mac" id="1d2-Mx-TKe">
<font key="font" metaFont="system" size="32"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>

View File

@ -11,14 +11,21 @@ import Account
class AccountsAddLocalWindowController: NSWindowController {
@IBOutlet weak var nameTextField: NSTextField!
@IBOutlet private weak var nameTextField: NSTextField!
@IBOutlet private weak var localAccountNameTextField: NSTextField!
private weak var hostWindow: NSWindow?
convenience init() {
self.init(windowNibName: NSNib.Name("AccountsAddLocal"))
}
override func windowDidLoad() {
super.windowDidLoad()
localAccountNameTextField.stringValue = Account.defaultLocalAccountName
}
// MARK: API
func runSheetOnWindow(_ hostWindow: NSWindow) {

View File

@ -7,6 +7,7 @@
//
import AppKit
import Account
class AccountsAddViewController: NSViewController {
@ -57,7 +58,7 @@ extension AccountsAddViewController: NSTableViewDelegate {
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountsAddTableCellView {
switch row {
case 0:
cell.accountNameLabel?.stringValue = NSLocalizedString("On My Mac", comment: "Local")
cell.accountNameLabel?.stringValue = Account.defaultLocalAccountName
cell.accountImageView?.image = AppImages.accountLocal
case 1:
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")

View File

@ -6,10 +6,19 @@
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import Account
import UIKit
class AddAccountViewController: UITableViewController {
@IBOutlet private weak var localAccountNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
localAccountNameLabel.text = Account.defaultLocalAccountName
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0:

View File

@ -11,8 +11,16 @@ import Account
class AddLocalAccountViewController: UIViewController {
@IBOutlet private weak var localAccountNameLabel: UILabel!
@IBOutlet weak var nameTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
localAccountNameLabel.text = Account.defaultLocalAccountName
nameTextField.delegate = self
}
@IBAction func cancel(_ sender: Any) {
dismiss(animated: true)
}
@ -24,3 +32,12 @@ class AddLocalAccountViewController: UIViewController {
}
}
extension AddLocalAccountViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
}

View File

@ -484,6 +484,9 @@
<outlet property="delegate" destination="b00-4A-bV6" id="FKM-rN-deu"/>
</connections>
</tableView>
<connections>
<outlet property="localAccountNameLabel" destination="116-rt-msI" id="h6M-5V-392"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="kmn-Q7-rga" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
@ -548,6 +551,7 @@
</barButtonItem>
</navigationItem>
<connections>
<outlet property="localAccountNameLabel" destination="Tdm-Ge-uc6" id="48O-IT-xXw"/>
<outlet property="nameTextField" destination="2dx-hK-hxL" id="t5V-3x-3vu"/>
</connections>
</viewController>