From 622dba7c14c6302777ca23e4c58028f74e84f228 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 17 Sep 2019 10:34:54 -0500 Subject: [PATCH] Implement Settings About View --- NetNewsWire.xcodeproj/project.pbxproj | 20 +++--- iOS/Resources/About.rtf | 11 ++-- iOS/Resources/Acknowledgments.rtf | 8 +-- iOS/Resources/Credits.rtf | 6 +- iOS/Resources/Dedication.rtf | 6 +- iOS/Resources/Thanks.rtf | 8 +-- iOS/Settings/SettingsAboutView.swift | 65 +++++++++++++++++++ iOS/Settings/SettingsView.swift | 9 ++- .../AttributedStringView.swift | 31 +++++++++ .../NNWTableViewCell.swift | 0 10 files changed, 134 insertions(+), 30 deletions(-) create mode 100644 iOS/Settings/SettingsAboutView.swift create mode 100644 iOS/SwiftUI Extensions/AttributedStringView.swift rename iOS/{Views => UIKit Extensions}/NNWTableViewCell.swift (100%) diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index d0f3224d9..d6abca2cd 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -29,6 +29,8 @@ 5132285B232FF2C40033D4ED /* SettingsRefreshSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */; }; 513228FB233037630033D4ED /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513228F2233037620033D4ED /* Reachability.swift */; }; 513228FC233037630033D4ED /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513228F2233037620033D4ED /* Reachability.swift */; }; + 513229312330523F0033D4ED /* AttributedStringView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513229302330523F0033D4ED /* AttributedStringView.swift */; }; + 5132293B23305D4C0033D4ED /* SettingsAboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5132293A23305D4C0033D4ED /* SettingsAboutView.swift */; }; 513C5CE9232571C2003D4054 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513C5CE8232571C2003D4054 /* ShareViewController.swift */; }; 513C5CEC232571C2003D4054 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 513C5CEA232571C2003D4054 /* MainInterface.storyboard */; }; 513C5CF0232571C2003D4054 /* NetNewsWire iOS Share Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 513C5CE6232571C2003D4054 /* NetNewsWire iOS Share Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -771,6 +773,8 @@ 51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantButtonStyle.swift; sourceTree = ""; }; 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRefreshSelectionView.swift; sourceTree = ""; }; 513228F2233037620033D4ED /* Reachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = ""; }; + 513229302330523F0033D4ED /* AttributedStringView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedStringView.swift; sourceTree = ""; }; + 5132293A23305D4C0033D4ED /* SettingsAboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAboutView.swift; sourceTree = ""; }; 513C5CE6232571C2003D4054 /* NetNewsWire iOS Share Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "NetNewsWire iOS Share Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 513C5CE8232571C2003D4054 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; 513C5CEB232571C2003D4054 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; @@ -1236,6 +1240,7 @@ isa = PBXGroup; children = ( 51F35D0822AFD4760003CE1B /* SettingsView.swift */, + 5132293A23305D4C0033D4ED /* SettingsAboutView.swift */, 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */, 5194B5F122B69FCC00144881 /* SettingsSubscriptionsExportDocumentPickerView.swift */, 5194B5ED22B6965300144881 /* SettingsSubscriptionsImportDocumentPickerView.swift */, @@ -1258,9 +1263,10 @@ 5194B5E222B693EC00144881 /* SwiftUI Extensions */ = { isa = PBXGroup; children = ( + 513229302330523F0033D4ED /* AttributedStringView.swift */, DF999FF622B5AEFA0064B687 /* SafariView.swift */, - 51322854232EED360033D4ED /* VibrantSelectAction.swift */, 51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */, + 51322854232EED360033D4ED /* VibrantSelectAction.swift */, ); path = "SwiftUI Extensions"; sourceTree = ""; @@ -1279,6 +1285,7 @@ children = ( 51F85BFA2275D85000C787DC /* Array-Extensions.swift */, 51F85BF42273625800C787DC /* Bundle-Extensions.swift */, + 5F323808231DF9F000706F6B /* NNWTableViewCell.swift */, 51EAED95231363EF00A9EEE3 /* NonIntrinsicButton.swift */, 5183CCD9226E31A50010922C /* NonIntrinsicImageView.swift */, 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */, @@ -1405,14 +1412,6 @@ path = UIKit; sourceTree = ""; }; - 5F3237FF231DF9D000706F6B /* Views */ = { - isa = PBXGroup; - children = ( - 5F323808231DF9F000706F6B /* NNWTableViewCell.swift */, - ); - path = Views; - sourceTree = ""; - }; 6581C73620CED60100F4AD34 /* SafariExtension */ = { isa = PBXGroup; children = ( @@ -1934,7 +1933,6 @@ 51C452802265093600C03939 /* Add */, 5183CCEB227117C70010922C /* Settings */, 5183CCDB226F1EEB0010922C /* Progress */, - 5F3237FF231DF9D000706F6B /* Views */, 519D740423243C68008BB345 /* Model Extensions */, 5194B5E222B693EC00144881 /* SwiftUI Extensions */, 51C45245226506C800C03939 /* UIKit Extensions */, @@ -2672,6 +2670,7 @@ 51C452852265093600C03939 /* FlattenedAccountFolderPickerData.swift in Sources */, 51C4526B226508F600C03939 /* MasterFeedViewController.swift in Sources */, 5126EE97226CB48A00C22AFC /* SceneCoordinator.swift in Sources */, + 5132293B23305D4C0033D4ED /* SettingsAboutView.swift in Sources */, 84CAFCB022BC8C35007694F0 /* FetchRequestOperation.swift in Sources */, 51EF0F77227716200050506E /* FaviconGenerator.swift in Sources */, 51938DF3231AFC660055A1A0 /* SearchTimelineFeedDelegate.swift in Sources */, @@ -2741,6 +2740,7 @@ 519D73FB2323FF35008BB345 /* SettingsView.swift in Sources */, 511D4419231FC02D00FB1562 /* KeyboardManager.swift in Sources */, 51C45293226509C800C03939 /* StarredFeedDelegate.swift in Sources */, + 513229312330523F0033D4ED /* AttributedStringView.swift in Sources */, 51D6A5BC23199C85001C27D8 /* MasterTimelineDataSource.swift in Sources */, 51934CCB230F599B006127BE /* ThemedNavigationController.swift in Sources */, ); diff --git a/iOS/Resources/About.rtf b/iOS/Resources/About.rtf index d1351c2f6..810ed8e40 100644 --- a/iOS/Resources/About.rtf +++ b/iOS/Resources/About.rtf @@ -1,11 +1,12 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf400 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande-Bold;} +{\rtf1\ansi\ansicpg1252\cocoartf2507 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande-Bold;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} -\margl1440\margr1440\vieww9000\viewh8400\viewkind0 -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\sl360\slmult1\pardirnatural\partightenfactor0 +\margl1440\margr1440\vieww11860\viewh9620\viewkind0 +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0 \f0\b\fs28 \cf2 By Brent Simmons \fs22 \ +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://inessential.com/"}}{\fldrslt -\fs28 inessential.com}}} \ No newline at end of file +\fs28 \cf2 inessential.com}}} \ No newline at end of file diff --git a/iOS/Resources/Acknowledgments.rtf b/iOS/Resources/Acknowledgments.rtf index fdfda021a..5c97b7be4 100644 --- a/iOS/Resources/Acknowledgments.rtf +++ b/iOS/Resources/Acknowledgments.rtf @@ -1,10 +1,10 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf400 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} +{\rtf1\ansi\ansicpg1252\cocoartf2507 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 -\pard\pardeftab720\li360\sa60\partightenfactor0 +\pard\pardeftab720\li82\fi-83\sa60\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/ccgus/fmdb"}}{\fldrslt \f0\fs28 \cf2 FMDB}} -\f0\fs28 \cf2 (greatest SQLite wrapper ever in history) is by {\field{\*\fldinst{HYPERLINK "http://flyingmeat.com/"}}{\fldrslt \cf2 Flying Meat Software}}.} \ No newline at end of file +\f0\fs28 \cf2 (greatest SQLite wrapper ever in history) is by {\field{\*\fldinst{HYPERLINK "http://flyingmeat.com/"}}{\fldrslt Flying Meat Software}}.} \ No newline at end of file diff --git a/iOS/Resources/Credits.rtf b/iOS/Resources/Credits.rtf index 485b07abb..d89fe1e5e 100644 --- a/iOS/Resources/Credits.rtf +++ b/iOS/Resources/Credits.rtf @@ -1,10 +1,10 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf400 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} +{\rtf1\ansi\ansicpg1252\cocoartf2507 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 -\pard\pardeftab720\li360\sa60\partightenfactor0 +\pard\pardeftab720\sa60\partightenfactor0 \f0\fs28 \cf2 App icon and most other icons: {\field{\*\fldinst{HYPERLINK "https://twitter.com/BradEllis"}}{\fldrslt Brad Ellis}}\ Major code contributors: {\field{\*\fldinst{HYPERLINK "https://github.com/olofhellman"}}{\fldrslt Olof Hellman}}, {\field{\*\fldinst{HYPERLINK "https://github.com/vincode-io"}}{\fldrslt Maurice Parker}}, and {\field{\*\fldinst{HYPERLINK "https://github.com/danielpunkass"}}{\fldrslt Daniel Jalkut}}} \ No newline at end of file diff --git a/iOS/Resources/Dedication.rtf b/iOS/Resources/Dedication.rtf index d5861fdf3..a0c26ac3e 100644 --- a/iOS/Resources/Dedication.rtf +++ b/iOS/Resources/Dedication.rtf @@ -1,9 +1,9 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf400 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} +{\rtf1\ansi\ansicpg1252\cocoartf2507 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 -\pard\pardeftab720\li360\sa60\partightenfactor0 +\pard\pardeftab720\sa60\partightenfactor0 \f0\fs28 \cf2 NetNewsWire 5.0 is dedicated to Aaron Swartz, Derek Miller, and Alex King, who helped with earlier versions of NetNewsWire, who I miss.} \ No newline at end of file diff --git a/iOS/Resources/Thanks.rtf b/iOS/Resources/Thanks.rtf index 1d6c6249f..bfd228524 100644 --- a/iOS/Resources/Thanks.rtf +++ b/iOS/Resources/Thanks.rtf @@ -1,9 +1,9 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf400 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} +{\rtf1\ansi\ansicpg1252\cocoartf2507 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 -\pard\pardeftab720\li360\sa60\partightenfactor0 +\pard\pardeftab720\sa60\partightenfactor0 -\f0\fs28 \cf2 Thanks to Sheila and my family; thanks to my friends in Seattle and around the globe; thanks to my co-workers and friends at {\field{\*\fldinst{HYPERLINK "https://www.omnigroup.com/"}}{\fldrslt \cf2 The Omni Group}}; thanks to the ever-patient and ever-awesome NetNewsWire beta testers.} \ No newline at end of file +\f0\fs28 \cf2 Thanks to Sheila and my family; thanks to my friends in Seattle and around the globe; thanks to my co-workers and friends at {\field{\*\fldinst{HYPERLINK "https://www.omnigroup.com/"}}{\fldrslt The Omni Group}}; thanks to the ever-patient and ever-awesome NetNewsWire beta testers.} \ No newline at end of file diff --git a/iOS/Settings/SettingsAboutView.swift b/iOS/Settings/SettingsAboutView.swift new file mode 100644 index 000000000..45dc6d2ea --- /dev/null +++ b/iOS/Settings/SettingsAboutView.swift @@ -0,0 +1,65 @@ +// +// SettingsAboutView.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 9/16/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Combine + +struct SettingsAboutView: View { + + @ObservedObject var viewModel: ViewModel + + var body: some View { + Form { + Text("NetNewsWire 5").font(.largeTitle) + AttributedStringView(string: viewModel.about).frame(height: 54) + Section(header: Text("CREDITS")) { + AttributedStringView(string: viewModel.credits).frame(height: 81) + } + Section(header: Text("ACKNOWLEDGEMENTS")) { + AttributedStringView(string: viewModel.acknowledgements).frame(height: 54) + } + Section(header: Text("THANKS")) { + AttributedStringView(string: viewModel.thanks).frame(height: 135) + } + Section(header: Text("DEDICATION"), footer: Text("Copyright © 2002-2019 Ranchero Software").font(.footnote)) { + AttributedStringView(string: viewModel.dedication).frame(height: 108) + } + } + } + + class ViewModel: ObservableObject { + let objectWillChange = ObservableObjectPublisher() + + var about: NSAttributedString + var credits: NSAttributedString + var acknowledgements: NSAttributedString + var thanks: NSAttributedString + var dedication: NSAttributedString + + init() { + about = ViewModel.loadResource("About") + credits = ViewModel.loadResource("Credits") + acknowledgements = ViewModel.loadResource("Acknowledgments") + thanks = ViewModel.loadResource("Thanks") + dedication = ViewModel.loadResource("Dedication") + } + + private static func loadResource(_ resource: String) -> NSAttributedString { + let url = Bundle.main.url(forResource: resource, withExtension: "rtf")! + return try! NSAttributedString(url: url, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.rtf], documentAttributes: nil) + + } + + } +} + +struct SettingsAboutView_Previews: PreviewProvider { + static var previews: some View { + SettingsAboutView(viewModel: SettingsAboutView.ViewModel()) + } +} diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index 8def382fa..83b4c847d 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -19,6 +19,7 @@ struct SettingsView : View { @State private var accountAction: Int? = nil @State private var refreshAction: Int? = nil + @State private var aboutAction: Int? = nil @State private var isWebsitePresented: Bool = false @State private var website: String? = nil @@ -120,7 +121,13 @@ struct SettingsView : View { func buildAboutSection() -> some View { Section(header: Text("ABOUT"), footer: buildFooter()) { - Text("About NetNewsWire") + + NavigationLink(destination: SettingsAboutView(viewModel: SettingsAboutView.ViewModel()), tag: 1, selection: $aboutAction) { + Text("About NetNewsWire") + } + .modifier(VibrantSelectAction(action: { + self.aboutAction = 1 + })) Button(action: { self.isWebsitePresented.toggle() diff --git a/iOS/SwiftUI Extensions/AttributedStringView.swift b/iOS/SwiftUI Extensions/AttributedStringView.swift new file mode 100644 index 000000000..f6e7a325e --- /dev/null +++ b/iOS/SwiftUI Extensions/AttributedStringView.swift @@ -0,0 +1,31 @@ +// +// RichTextView.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 9/16/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import SwiftUI + +struct AttributedStringView: UIViewRepresentable { + + let string: NSAttributedString + + func makeUIView(context: Context) -> UITextView { + + let textView = UITextView() + textView.attributedText = string + textView.adjustsFontForContentSizeCategory = true + textView.translatesAutoresizingMaskIntoConstraints = false + textView.font = .preferredFont(forTextStyle: .body) + textView.textColor = UIColor.label + textView.backgroundColor = UIColor.secondarySystemGroupedBackground + + return textView + } + + func updateUIView(_ textView: UITextView, context: Context) { + } + +} diff --git a/iOS/Views/NNWTableViewCell.swift b/iOS/UIKit Extensions/NNWTableViewCell.swift similarity index 100% rename from iOS/Views/NNWTableViewCell.swift rename to iOS/UIKit Extensions/NNWTableViewCell.swift