diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 67965f7bf..23285aede 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -117,6 +117,7 @@ 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */; }; 51E595A5228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E595A4228CC36500FCC42B /* ArticleStatusSyncTimer.swift */; }; 51E595A6228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E595A4228CC36500FCC42B /* ArticleStatusSyncTimer.swift */; }; + 51E595AB228DF94C00FCC42B /* SettingsTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51E595AA228DF94C00FCC42B /* SettingsTableViewCell.xib */; }; 51EC114C2149FE3300B296E3 /* FolderTreeMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EC114B2149FE3300B296E3 /* FolderTreeMenu.swift */; }; 51EF0F77227716200050506E /* FaviconGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F76227716200050506E /* FaviconGenerator.swift */; }; 51EF0F79227716380050506E /* ColorHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F78227716380050506E /* ColorHash.swift */; }; @@ -705,6 +706,7 @@ 51C452B32265141B00C03939 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; }; 51C452B72265178500C03939 /* styleSheet.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = styleSheet.css; sourceTree = ""; }; 51E595A4228CC36500FCC42B /* ArticleStatusSyncTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleStatusSyncTimer.swift; sourceTree = ""; }; + 51E595AA228DF94C00FCC42B /* SettingsTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingsTableViewCell.xib; sourceTree = ""; }; 51EC114B2149FE3300B296E3 /* FolderTreeMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FolderTreeMenu.swift; path = AddFeed/FolderTreeMenu.swift; sourceTree = ""; }; 51EF0F76227716200050506E /* FaviconGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconGenerator.swift; sourceTree = ""; }; 51EF0F78227716380050506E /* ColorHash.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorHash.swift; sourceTree = ""; }; @@ -1031,6 +1033,7 @@ isa = PBXGroup; children = ( 5183CCEC22711DCE0010922C /* Settings.storyboard */, + 51E595AA228DF94C00FCC42B /* SettingsTableViewCell.xib */, 5183CCEE227125970010922C /* SettingsViewController.swift */, 51F85BE6227245FC00C787DC /* AboutViewController.swift */, 51F85BDB2272162F00C787DC /* RefreshIntervalViewController.swift */, @@ -2189,6 +2192,7 @@ 51C452AB22650DC600C03939 /* template.html in Resources */, 51F85BF12272524100C787DC /* Credits.rtf in Resources */, 84A3EE61223B667F00557320 /* DefaultFeeds.opml in Resources */, + 51E595AB228DF94C00FCC42B /* SettingsTableViewCell.xib in Resources */, 51F85BEF2272520B00C787DC /* Thanks.rtf in Resources */, 84C9FC9D2262A1A900D921D6 /* Assets.xcassets in Resources */, 51C452B82265178500C03939 /* styleSheet.css in Resources */, diff --git a/iOS/Settings/AboutViewController.swift b/iOS/Settings/AboutViewController.swift index b935a753a..31da63e9e 100644 --- a/iOS/Settings/AboutViewController.swift +++ b/iOS/Settings/AboutViewController.swift @@ -26,7 +26,7 @@ class AboutViewController: UITableViewController { configureCell(file: "Thanks", textView: thanksTextView) configureCell(file: "Dedication", textView: dedicationTextView) - let buildLabel = UILabel(frame: CGRect(x: 20.0, y: 0.0, width: 0.0, height: 0.0)) + let buildLabel = NonIntrinsicLabel(frame: CGRect(x: 20.0, y: 0.0, width: 0.0, height: 0.0)) buildLabel.font = UIFont.systemFont(ofSize: 11.0) buildLabel.textColor = UIColor.gray buildLabel.text = NSLocalizedString("Copyright © 2002-2019 Ranchero Software", comment: "Copyright") diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index b8a53bd15..8ba42e9fb 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -18,10 +18,10 @@ - + - + @@ -39,10 +39,10 @@ - + - + @@ -59,7 +59,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -128,10 +128,10 @@ - + - + @@ -152,7 +152,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -210,7 +210,7 @@ - + @@ -234,7 +234,7 @@ - + @@ -251,7 +251,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -336,7 +336,7 @@ - + @@ -366,7 +366,7 @@ - + @@ -546,7 +546,7 @@ - + diff --git a/iOS/Settings/SettingsTableViewCell.xib b/iOS/Settings/SettingsTableViewCell.xib new file mode 100644 index 000000000..aca59947e --- /dev/null +++ b/iOS/Settings/SettingsTableViewCell.xib @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index 7eeea308f..08ce1e85b 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -21,6 +21,9 @@ class SettingsViewController: UITableViewController { // This hack mostly works around a bug in static tables with dynamic type. See: https://spin.atomicobject.com/2018/10/15/dynamic-type-static-uitableview/ NotificationCenter.default.removeObserver(tableView!, name: UIContentSizeCategory.didChangeNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil) + + tableView.register(UINib(nibName: "SettingsTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsTableViewCell") + } override func viewWillAppear(_ animated: Bool) { @@ -37,7 +40,7 @@ class SettingsViewController: UITableViewController { let numberOfLinesText = NSLocalizedString(" lines", comment: "Lines") timelineNumberOfLinesLabel.text = "\(AppDefaults.timelineNumberOfLines)" + numberOfLinesText - let buildLabel = UILabel(frame: CGRect(x: 20.0, y: 0.0, width: 0.0, height: 0.0)) + let buildLabel = NonIntrinsicLabel(frame: CGRect(x: 20.0, y: 0.0, width: 0.0, height: 0.0)) buildLabel.font = UIFont.systemFont(ofSize: 11.0) buildLabel.textColor = UIColor.gray buildLabel.text = "\(Bundle.main.appName) v \(Bundle.main.versionNumber) (Build \(Bundle.main.buildNumber))" @@ -47,12 +50,44 @@ class SettingsViewController: UITableViewController { } + // MARK: UITableView + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + case 0: + return AccountManager.shared.accounts.count + 1 + default: + return super.tableView(tableView, numberOfRowsInSection: section) + } + } + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = super.tableView(tableView, cellForRowAt: indexPath) + + let cell: UITableViewCell + switch indexPath.section { + case 0: + + cell = tableView.dequeueReusableCell(withIdentifier: "SettingsTableViewCell", for: indexPath) + cell.textLabel?.adjustsFontForContentSizeCategory = true + + let sortedAccounts = AccountManager.shared.sortedAccounts + if indexPath.row == sortedAccounts.count { + cell.textLabel?.text = NSLocalizedString("Add Account", comment: "Accounts") + } else { + cell.textLabel?.text = sortedAccounts[indexPath.row].nameForDisplay + } + + default: + + cell = super.tableView(tableView, cellForRowAt: indexPath) + + } + let bgView = UIView() bgView.backgroundColor = AppAssets.selectionBackgroundColor cell.selectedBackgroundView = bgView return cell + } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { @@ -100,7 +135,37 @@ class SettingsViewController: UITableViewController { tableView.selectRow(at: nil, animated: true, scrollPosition: .none) } + + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + return false + } + + override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + return false + } + override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { + return .none + } + + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.section == 0 { + return super.tableView(tableView, heightForRowAt: IndexPath(row: 0, section: 0)) + } else { + return super.tableView(tableView, heightForRowAt: indexPath) + } + } + + override func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int { + if indexPath.section == 0 { + return super.tableView(tableView, indentationLevelForRowAt: IndexPath(row: 0, section: 0)) + } else { + return super.tableView(tableView, indentationLevelForRowAt: indexPath) + } + } + + // MARK: Actions + @IBAction func done(_ sender: Any) { dismiss(animated: true) }