From b3b9d566b7fc98f2b7b41e7977d0a7d22f5c10af Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 4 Jun 2019 13:31:05 -0400 Subject: [PATCH] iOS 13 Dark Mode Support --- Tusker.xcodeproj/project.pbxproj | 8 ++--- Tusker/Base.lproj/LaunchScreen.storyboard | 11 ++++--- .../Screens/Compose/ComposeViewController.xib | 32 ++++++++----------- .../Compose/Drafts/DraftTableViewCell.swift | 2 ++ .../Compose/Drafts/DraftTableViewCell.xib | 30 ++++++++--------- .../Drafts/DraftsTableViewController.xib | 10 +++--- .../ConversationTableViewController.swift | 9 ++++-- .../NotificationsTableViewController.swift | 9 ++++-- .../Onboarding/OnboardingViewController.xib | 22 ++++++------- .../MyProfileTableViewController.swift | 4 ++- .../Profile/ProfileTableViewController.swift | 9 ++++-- .../TimelineTableViewController.swift | 9 ++++-- .../EnhancedTableViewController.swift | 3 +- Tusker/Screens/Utilities/Previewing.swift | 2 +- .../Views/Compose Media/ComposeMediaView.xib | 21 ++++++------ Tusker/Views/ContentLabel.swift | 2 +- Tusker/Views/LinkLabel.swift | 6 +++- .../ActionNotificationTableViewCell.swift | 17 ++-------- .../ActionNotificationTableViewCell.xib | 18 +++++------ .../FollowNotificationTableViewCell.xib | 18 +++++------ .../ProfileHeaderTableViewCell.xib | 10 +++--- .../ConversationMainStatusTableViewCell.xib | 19 ++++++----- Tusker/Views/Status/StatusTableViewCell.xib | 17 +++++----- 23 files changed, 140 insertions(+), 148 deletions(-) diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 908c0a95..b2487b76 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -1754,7 +1754,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -1810,7 +1810,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -1829,7 +1829,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = D9LRWNKC29; INFOPLIST_FILE = Tusker/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1851,7 +1851,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = D9LRWNKC29; INFOPLIST_FILE = Tusker/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Tusker/Base.lproj/LaunchScreen.storyboard b/Tusker/Base.lproj/LaunchScreen.storyboard index bfa36129..8ca47856 100644 --- a/Tusker/Base.lproj/LaunchScreen.storyboard +++ b/Tusker/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - - + + + - + @@ -11,9 +12,9 @@ - + - + diff --git a/Tusker/Screens/Compose/ComposeViewController.xib b/Tusker/Screens/Compose/ComposeViewController.xib index 66afb10d..13adcc77 100644 --- a/Tusker/Screens/Compose/ComposeViewController.xib +++ b/Tusker/Screens/Compose/ComposeViewController.xib @@ -1,12 +1,11 @@ - - - - + + - + + @@ -32,7 +31,7 @@ - + @@ -45,7 +44,6 @@ - - @@ -69,15 +66,14 @@ + - - @@ -90,7 +86,7 @@ - + @@ -104,7 +100,6 @@ - @@ -122,14 +117,14 @@ - + - + @@ -142,14 +137,13 @@ - + - @@ -168,7 +162,6 @@ - @@ -185,11 +178,11 @@ - + - + @@ -201,6 +194,7 @@ + diff --git a/Tusker/Screens/Compose/Drafts/DraftTableViewCell.swift b/Tusker/Screens/Compose/Drafts/DraftTableViewCell.swift index c8b4f85e..d09de621 100644 --- a/Tusker/Screens/Compose/Drafts/DraftTableViewCell.swift +++ b/Tusker/Screens/Compose/Drafts/DraftTableViewCell.swift @@ -29,9 +29,11 @@ class DraftTableViewCell: UITableViewCell { let size = CGSize(width: 50, height: 50) let imageView = UIImageView(frame: CGRect(origin: .zero, size: size)) + imageView.contentMode = .scaleAspectFill imageView.layer.masksToBounds = true imageView.layer.cornerRadius = 5 attachmentsStackView.addArrangedSubview(imageView) + imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor).isActive = true PHImageManager.default().requestImage(for: asset, targetSize: size, contentMode: .aspectFill, options: nil) { (image, _) in imageView.image = image diff --git a/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib b/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib index 906ed45d..993cd726 100644 --- a/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib +++ b/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib @@ -1,11 +1,10 @@ - - - - + + - + + @@ -14,29 +13,28 @@ - + - + - + - @@ -47,16 +45,15 @@ - + - + - @@ -64,6 +61,9 @@ + + + diff --git a/Tusker/Screens/Compose/Drafts/DraftsTableViewController.xib b/Tusker/Screens/Compose/Drafts/DraftsTableViewController.xib index 056a9daa..612670fe 100644 --- a/Tusker/Screens/Compose/Drafts/DraftsTableViewController.xib +++ b/Tusker/Screens/Compose/Drafts/DraftsTableViewController.xib @@ -1,10 +1,8 @@ - - - - + + - + @@ -17,7 +15,7 @@ - + diff --git a/Tusker/Screens/Conversation/ConversationTableViewController.swift b/Tusker/Screens/Conversation/ConversationTableViewController.swift index d26d5f14..d50a4b46 100644 --- a/Tusker/Screens/Conversation/ConversationTableViewController.swift +++ b/Tusker/Screens/Conversation/ConversationTableViewController.swift @@ -135,15 +135,18 @@ class ConversationTableViewController: EnhancedTableViewController { } override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { - return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider +// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider + return false } override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() +// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() + return nil } override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() +// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() + return nil } } diff --git a/Tusker/Screens/Notifications/NotificationsTableViewController.swift b/Tusker/Screens/Notifications/NotificationsTableViewController.swift index cadc7a9a..6deb2a0f 100644 --- a/Tusker/Screens/Notifications/NotificationsTableViewController.swift +++ b/Tusker/Screens/Notifications/NotificationsTableViewController.swift @@ -120,15 +120,18 @@ class NotificationsTableViewController: EnhancedTableViewController { } override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { - return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider +// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider + return false } override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() +// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() + return nil } override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() +// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() + return nil } @objc func refreshNotifications(_ sender: Any) { diff --git a/Tusker/Screens/Onboarding/OnboardingViewController.xib b/Tusker/Screens/Onboarding/OnboardingViewController.xib index 628c9e08..2f746a76 100644 --- a/Tusker/Screens/Onboarding/OnboardingViewController.xib +++ b/Tusker/Screens/Onboarding/OnboardingViewController.xib @@ -1,12 +1,11 @@ - - - - + + - + + @@ -21,7 +20,7 @@ - + - - + + - - + + @@ -43,20 +42,20 @@ - - + + - + diff --git a/Tusker/Views/ContentLabel.swift b/Tusker/Views/ContentLabel.swift index 1a6639ed..dcd7b55d 100644 --- a/Tusker/Views/ContentLabel.swift +++ b/Tusker/Views/ContentLabel.swift @@ -91,7 +91,7 @@ class ContentLabel: LinkLabel { self.links = [] let linkAttributes: [NSAttributedString.Key: Any] = [ - .foregroundColor: UIColor.blue, + .foregroundColor: UIColor.systemBlue, ] for (range, url) in links { mutAttrString.addAttributes(linkAttributes, range: range) diff --git a/Tusker/Views/LinkLabel.swift b/Tusker/Views/LinkLabel.swift index 543bdeb9..aff52783 100644 --- a/Tusker/Views/LinkLabel.swift +++ b/Tusker/Views/LinkLabel.swift @@ -19,7 +19,8 @@ class LinkLabel: UILabel { var links = [Link]() var selectedLinkAttributes: [NSAttributedString.Key: Any] = [ - .backgroundColor: UIColor(hue: 0, saturation: 0, brightness: 0.9, alpha: 1) +// .backgroundColor: UIColor(hue: 0, saturation: 0, brightness: 0.9, alpha: 1) + .backgroundColor: UIColor.secondarySystemBackground ] var selectedLinkRange: NSRange? { @@ -36,6 +37,9 @@ class LinkLabel: UILabel { override var attributedText: NSAttributedString? { didSet { guard let attributedText = attributedText else { return } + + textStorage?.removeLayoutManager(layoutManager) + textStorage = NSTextStorage(attributedString: attributedText) textStorage.addLayoutManager(layoutManager) } diff --git a/Tusker/Views/Notifications/ActionNotificationTableViewCell.swift b/Tusker/Views/Notifications/ActionNotificationTableViewCell.swift index 0e8b8112..d2d50f21 100644 --- a/Tusker/Views/Notifications/ActionNotificationTableViewCell.swift +++ b/Tusker/Views/Notifications/ActionNotificationTableViewCell.swift @@ -102,7 +102,7 @@ class ActionNotificationTableViewCell: UITableViewCell, PreferencesAdaptive { for attachment in attachments { let url = attachment.textURL ?? attachment.url let label = UILabel() - label.textColor = .darkGray + label.textColor = .secondaryLabel let textAttachment = InlineTextAttachment() textAttachment.image = UIImage(named: "Link")! @@ -112,21 +112,9 @@ class ActionNotificationTableViewCell: UITableViewCell, PreferencesAdaptive { let text = NSMutableAttributedString(string: " ") text.append(attachmentStr) text.append(NSAttributedString(string: " ")) -// text.addAttribute(.font, value: UIFont.systemFont(ofSize: 0), range: NSRange(location: 0, length: text.length)) text.append(NSAttributedString(string: "\(url.lastPathComponent)")) - text.addAttribute(.foregroundColor, value: UIColor.red, range: NSRange(location: 0, length: 2)) - - - -// let text = NSMutableAttributedString(string: " \(url.lastPathComponent)") -// let imageAttachment = InlineTextAttachment() -// imageAttachment.image = UIImage(named: "Link")! -// imageAttachment.bounds = CGRect(x: 0, y: 0, width: label.font.pointSize, height: label.font.pointSize) -// imageAttachment.fontDescender = label.font.descender -// let imageStr = NSMutableAttributedString(attachment: imageAttachment) -// imageStr.setAttributes([.foregroundColor: UIColor.darkGray], range: ) -// text.insert(imageStr, at: 0) + text.addAttribute(.foregroundColor, value: UIColor.systemBlue, range: NSRange(location: 0, length: 2)) label.attributedText = text attachmentsView.addArrangedSubview(label) @@ -135,7 +123,6 @@ class ActionNotificationTableViewCell: UITableViewCell, PreferencesAdaptive { attachmentsView.isHidden = true } -// contentLabel.statusID = status.id contentLabel.setTextFromHtml(status.content) } diff --git a/Tusker/Views/Notifications/ActionNotificationTableViewCell.xib b/Tusker/Views/Notifications/ActionNotificationTableViewCell.xib index 3eec22ce..f2b48f3a 100644 --- a/Tusker/Views/Notifications/ActionNotificationTableViewCell.xib +++ b/Tusker/Views/Notifications/ActionNotificationTableViewCell.xib @@ -1,12 +1,11 @@ - - - - + + - + + @@ -21,7 +20,7 @@ @@ -46,7 +45,6 @@ - @@ -73,13 +71,13 @@ - + @@ -111,7 +109,7 @@ - + diff --git a/Tusker/Views/Notifications/FollowNotificationTableViewCell.xib b/Tusker/Views/Notifications/FollowNotificationTableViewCell.xib index 1742c73f..4ecbe568 100644 --- a/Tusker/Views/Notifications/FollowNotificationTableViewCell.xib +++ b/Tusker/Views/Notifications/FollowNotificationTableViewCell.xib @@ -1,12 +1,11 @@ - - - - + + - + + @@ -24,13 +23,13 @@ @@ -54,11 +53,10 @@ - @@ -72,7 +70,7 @@ - + diff --git a/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.xib b/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.xib index c99e2c66..98eb1c1c 100644 --- a/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.xib +++ b/Tusker/Views/Profile Header/ProfileHeaderTableViewCell.xib @@ -1,10 +1,8 @@ - - - - + + - + @@ -33,7 +31,7 @@ - + diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib b/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib index 37a485c9..c3fc8dd0 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib @@ -1,12 +1,11 @@ - - - - + + - + + @@ -37,7 +36,7 @@ @@ -81,7 +80,7 @@