From 490e78295657cdaec4006359a1528ef133543393 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 20 Oct 2019 14:01:13 -0500 Subject: [PATCH] Improve About page layout --- NetNewsWire.xcodeproj/project.pbxproj | 8 ++-- iOS/Resources/About.rtf | 8 ++-- iOS/Resources/Acknowledgments.rtf | 11 +++--- iOS/Resources/Thanks.rtf | 5 ++- iOS/Settings/SettingsAboutView.swift | 30 ++++++++------- .../SettingsAttributedStringView.swift | 34 ----------------- .../AttributedStringView.swift | 37 +++++++++++++++++++ 7 files changed, 69 insertions(+), 64 deletions(-) delete mode 100644 iOS/Settings/SettingsAttributedStringView.swift create mode 100644 iOS/SwiftUI Extensions/AttributedStringView.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 736bfa8c6..cfb318ad1 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -50,7 +50,7 @@ 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 /* SettingsAttributedStringView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513229302330523F0033D4ED /* SettingsAttributedStringView.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 */; }; @@ -760,7 +760,7 @@ 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 /* SettingsAttributedStringView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAttributedStringView.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 = ""; }; @@ -1302,7 +1302,6 @@ children = ( 51F35D0822AFD4760003CE1B /* SettingsView.swift */, 5132293A23305D4C0033D4ED /* SettingsAboutView.swift */, - 513229302330523F0033D4ED /* SettingsAttributedStringView.swift */, 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */, 51314717235C89ED00387FDC /* SettingsSubscriptionsExportAccountPickerView.swift */, 5194B5F122B69FCC00144881 /* SettingsSubscriptionsExportDocumentPickerView.swift */, @@ -1336,6 +1335,7 @@ 5194B5E222B693EC00144881 /* SwiftUI Extensions */ = { isa = PBXGroup; children = ( + 513229302330523F0033D4ED /* AttributedStringView.swift */, DF999FF622B5AEFA0064B687 /* SafariView.swift */, 51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */, 51322854232EED360033D4ED /* VibrantSelectAction.swift */, @@ -3028,7 +3028,7 @@ 519D73FB2323FF35008BB345 /* SettingsView.swift in Sources */, 511D4419231FC02D00FB1562 /* KeyboardManager.swift in Sources */, 51C45293226509C800C03939 /* StarredFeedDelegate.swift in Sources */, - 513229312330523F0033D4ED /* SettingsAttributedStringView.swift in Sources */, + 513229312330523F0033D4ED /* AttributedStringView.swift in Sources */, 51D6A5BC23199C85001C27D8 /* MasterTimelineDataSource.swift in Sources */, 51934CCB230F599B006127BE /* ThemedNavigationController.swift in Sources */, 51314716235C862200387FDC /* SettingsSubscriptionsImportAccountPickerView.swift in Sources */, diff --git a/iOS/Resources/About.rtf b/iOS/Resources/About.rtf index 810ed8e40..881fea1f3 100644 --- a/iOS/Resources/About.rtf +++ b/iOS/Resources/About.rtf @@ -1,7 +1,7 @@ -{\rtf1\ansi\ansicpg1252\cocoartf2507 +{\rtf1\ansi\ansicpg1252\cocoartf2509 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande-Bold;} -{\colortbl;\red255\green255\blue255;\red0\green0\blue0;} -{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red10\green96\blue255;} +{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;\cssrgb\c0\c47843\c100000\cname systemBlueColor;} \margl1440\margr1440\vieww11860\viewh9620\viewkind0 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0 @@ -9,4 +9,4 @@ \fs22 \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0 {\field{\*\fldinst{HYPERLINK "http://inessential.com/"}}{\fldrslt -\fs28 \cf2 inessential.com}}} \ No newline at end of file +\fs28 \cf3 inessential.com}}} \ No newline at end of file diff --git a/iOS/Resources/Acknowledgments.rtf b/iOS/Resources/Acknowledgments.rtf index 7f9f3d50f..5f8b59acd 100644 --- a/iOS/Resources/Acknowledgments.rtf +++ b/iOS/Resources/Acknowledgments.rtf @@ -1,13 +1,12 @@ -{\rtf1\ansi\ansicpg1252\cocoartf2507 +{\rtf1\ansi\ansicpg1252\cocoartf2509 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0\cname textColor;} -\margl1440\margr1440\vieww9000\viewh8400\viewkind0 +\margl1440\margr1440\vieww8960\viewh8160\viewkind0 \deftab720 -\pard\pardeftab720\li360\fi-360\sa60\partightenfactor0 +\pard\tx0\pardeftab720\sa60\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://github.com/ccgus/fmdb"}}{\fldrslt \f0\fs22 \cf2 FMDB}} -\f0\fs22 \cf2 (greatest SQLite wrapper ever in\ -history) is by {\field{\*\fldinst{HYPERLINK "http://flyingmeat.com/"}}{\fldrslt Flying Meat Software}}.\ -\pard\pardeftab720\li360\fi-360\sa60\partightenfactor0 +\f0\fs22 \cf2 (greatest SQLite wrapper ever in history) is by {\field{\*\fldinst{HYPERLINK "http://flyingmeat.com/"}}{\fldrslt Flying Meat Software}}.\ +\pard\pardeftab720\sa60\partightenfactor0 {\field{\*\fldinst{HYPERLINK "https://sparkle-project.org/"}}{\fldrslt \cf2 Sparkle}} is by Sparkle Project.} \ No newline at end of file diff --git a/iOS/Resources/Thanks.rtf b/iOS/Resources/Thanks.rtf index 039738f66..a9365cfd9 100644 --- a/iOS/Resources/Thanks.rtf +++ b/iOS/Resources/Thanks.rtf @@ -1,4 +1,4 @@ -{\rtf1\ansi\ansicpg1252\cocoartf2507 +{\rtf1\ansi\ansicpg1252\cocoartf2509 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0\cname textColor;} @@ -6,4 +6,5 @@ \deftab720 \pard\pardeftab720\sa60\partightenfactor0 -\f0\fs22 \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. Thanks to {\field{\*\fldinst{HYPERLINK "https://github.com/"}}{\fldrslt GitHub}}, {\field{\*\fldinst{HYPERLINK "https://slack.com/"}}{\fldrslt Slack}}, and {\field{\*\fldinst{HYPERLINK "https://circleci.com/"}}{\fldrslt CircleCI}} for making open source collaboration easy and fun.} \ No newline at end of file +\f0\fs22 \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. \ +Thanks to {\field{\*\fldinst{HYPERLINK "https://github.com"}}{\fldrslt GitHub}} and {\field{\*\fldinst{HYPERLINK "https://slack.com"}}{\fldrslt Slack}} for making open source collaboration easy and fun.} \ No newline at end of file diff --git a/iOS/Settings/SettingsAboutView.swift b/iOS/Settings/SettingsAboutView.swift index 1549f2d7d..a5147b16a 100644 --- a/iOS/Settings/SettingsAboutView.swift +++ b/iOS/Settings/SettingsAboutView.swift @@ -14,20 +14,22 @@ struct SettingsAboutView: View { @ObservedObject var viewModel: ViewModel var body: some View { - Form { - Text("NetNewsWire").font(.largeTitle) - SettingsAttributedStringView(string: viewModel.about).frame(height: 54) - Section(header: Text("CREDITS")) { - SettingsAttributedStringView(string: viewModel.credits).frame(height: 135) - } - Section(header: Text("ACKNOWLEDGEMENTS")) { - SettingsAttributedStringView(string: viewModel.acknowledgements).frame(height: 81) - } - Section(header: Text("THANKS")) { - SettingsAttributedStringView(string: viewModel.thanks).frame(height: 189) - } - Section(header: Text("DEDICATION"), footer: Text("Copyright © 2002-2019 Ranchero Software").font(.footnote)) { - SettingsAttributedStringView(string: viewModel.dedication).frame(height: 108) + GeometryReader { geometry in + List { + Text("NetNewsWire").font(.largeTitle) + AttributedStringView(string: self.viewModel.about, preferredMaxLayoutWidth: geometry.size.width - 40) + Section(header: Text("CREDITS")) { + AttributedStringView(string: self.viewModel.credits, preferredMaxLayoutWidth: geometry.size.width - 40) + } + Section(header: Text("ACKNOWLEDGEMENTS")) { + AttributedStringView(string: self.viewModel.acknowledgements, preferredMaxLayoutWidth: geometry.size.width - 40) + } + Section(header: Text("THANKS")) { + AttributedStringView(string: self.viewModel.thanks, preferredMaxLayoutWidth: geometry.size.width - 40) + } + Section(header: Text("DEDICATION"), footer: Text("Copyright © 2002-2019 Ranchero Software").font(.footnote)) { + AttributedStringView(string: self.viewModel.dedication, preferredMaxLayoutWidth: geometry.size.width - 40) + } } } } diff --git a/iOS/Settings/SettingsAttributedStringView.swift b/iOS/Settings/SettingsAttributedStringView.swift deleted file mode 100644 index 21f9d1186..000000000 --- a/iOS/Settings/SettingsAttributedStringView.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// SettingsAttributedStringView.swift -// NetNewsWire-iOS -// -// Created by Maurice Parker on 9/16/19. -// Copyright © 2019 Ranchero Software. All rights reserved. -// - -import SwiftUI - -struct SettingsAttributedStringView: UIViewRepresentable { - - let string: NSAttributedString - - func makeUIView(context: Context) -> UITextView { - let textView = UITextView() - - textView.attributedText = string - textView.translatesAutoresizingMaskIntoConstraints = false - textView.isEditable = false - - textView.adjustsFontForContentSizeCategory = true - textView.font = .preferredFont(forTextStyle: .body) - textView.textColor = UIColor.label - textView.tintColor = AppAssets.secondaryAccentColor - textView.backgroundColor = UIColor.secondarySystemGroupedBackground - - return textView - } - - func updateUIView(_ textView: UITextView, context: Context) { - } - -} diff --git a/iOS/SwiftUI Extensions/AttributedStringView.swift b/iOS/SwiftUI Extensions/AttributedStringView.swift new file mode 100644 index 000000000..272b8b4f3 --- /dev/null +++ b/iOS/SwiftUI Extensions/AttributedStringView.swift @@ -0,0 +1,37 @@ +// +// AttributedStringView.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 + let preferredMaxLayoutWidth: CGFloat + + func makeUIView(context: Context) -> UILabel { + return UILabel() + } + + func updateUIView(_ view: UILabel, context: Context) { + view.attributedText = string + + view.numberOfLines = 0 + view.lineBreakMode = .byWordWrapping + view.preferredMaxLayoutWidth = preferredMaxLayoutWidth + + view.adjustsFontForContentSizeCategory = true + view.font = .preferredFont(forTextStyle: .body) + view.textColor = UIColor.label + view.tintColor = AppAssets.secondaryAccentColor + view.backgroundColor = UIColor.secondarySystemGroupedBackground + + view.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + view.setContentCompressionResistancePriority(.required, for: .vertical) + } + +}