Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,20 @@ extension WPStyleGuide {

/// Style `UITableView` in the app
class func configureTableViewAppearance() {
if #available(iOS 15.0, *) {
UITableView.appearance().sectionHeaderTopPadding = 0
}
UITableView.appearance().sectionHeaderTopPadding = 0
}

/// Style the tab bar using Muriel colors
class func configureTabBarAppearance() {
UITabBar.appearance().tintColor = .tabSelected
UITabBar.appearance().unselectedItemTintColor = .tabUnselected

if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .systemBackground
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .systemBackground

UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
}
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
}

/// Style the `LightNavigationController` UINavigationBar and BarButtonItems
Expand Down Expand Up @@ -114,10 +110,7 @@ extension WPStyleGuide {
appearance.configureWithDefaultBackground()

UIToolbar.appearance().standardAppearance = appearance

if #available(iOS 15.0, *) {
UIToolbar.appearance().scrollEdgeAppearance = appearance
}
UIToolbar.appearance().scrollEdgeAppearance = appearance
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ public extension NSAttributedString {
for (value, image) in unwrappedEmbeds {
let imageAttachment = NSTextAttachment()
let gifType = UTType.gif.identifier
var displayAnimatedGifs = false

// Check to see if the animated gif view provider is registered
if #available(iOS 15.0, *) {
displayAnimatedGifs = NSTextAttachment.textAttachmentViewProviderClass(forFileType: gifType) == AnimatedGifAttachmentViewProvider.self
}
let displayAnimatedGifs = NSTextAttachment.textAttachmentViewProviderClass(forFileType: gifType) == AnimatedGifAttachmentViewProvider.self

// When displaying an animated gif pass the gif data instead of the image
if
Expand Down
10 changes: 3 additions & 7 deletions WordPress/Classes/Extensions/UIApplication+mainWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import UIKit

extension UIApplication {
@objc var mainWindow: UIWindow? {
if #available(iOS 15, *) {
return connectedScenes
.compactMap { ($0 as? UIWindowScene)?.keyWindow }
.first
} else {
return windows.filter { $0.isKeyWindow }.first
}
connectedScenes
.compactMap { ($0 as? UIWindowScene)?.keyWindow }
.first
}

@objc var currentStatusBarFrame: CGRect {
Expand Down
5 changes: 1 addition & 4 deletions WordPress/Classes/Utility/WebKitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,7 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable {
appearance.backgroundColor = UIColor(light: .white, dark: .appBarBackground)

toolBar.standardAppearance = appearance

if #available(iOS 15.0, *) {
toolBar.scrollEdgeAppearance = appearance
}
toolBar.scrollEdgeAppearance = appearance

fixBarButtonsColorForBoldText(on: toolBar)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ final class BlazeOverlayViewController: UIViewController {
navigationItem.standardAppearance = appearance
navigationItem.compactAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = appearance
}
navigationItem.compactScrollEdgeAppearance = appearance
}

private func setupView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ class BlazeWebViewController: UIViewController, BlazeWebView {
navigationItem.standardAppearance = appearance
navigationItem.compactAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = appearance
}
navigationItem.compactScrollEdgeAppearance = appearance
}

// MARK: Reachability Helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,6 @@ extension BlogDashboardViewController {
}
}

// MARK: - UI Popover Delegate

/// This view controller may host a `DashboardPromptsCardCell` that requires presenting a `MenuSheetViewController`,
/// a fallback implementation of `UIMenu` for iOS 13. For more details, see the docs on `MenuSheetViewController`.
///
/// NOTE: This should be removed once we drop support for iOS 13.
///
extension BlogDashboardViewController: UIPopoverPresentationControllerDelegate {
// Force popover views to be presented as a popover (instead of being presented as a form sheet on iPhones).
public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .none
}
}

// MARK: - Helper functions

private extension Collection where Element == DashboardCardModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,14 @@ class DashboardPageCreationCell: UITableViewCell {
button.addTarget(self, action: #selector(createPageButtonTapped), for: .touchUpInside)
let font = WPStyleGuide.fontForTextStyle(.callout, fontWeight: .bold)

if #available(iOS 15.0, *) {
var buttonConfig: UIButton.Configuration = .plain()
buttonConfig.contentInsets = Metrics.createPageButtonContentInsets
buttonConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer({ incoming in
var outgoing = incoming
outgoing.font = font
return outgoing
})
button.configuration = buttonConfig
} else {
button.titleLabel?.font = font
button.setTitleColor(.jetpackGreen, for: .normal)
button.contentEdgeInsets = Metrics.createPageButtonContentEdgeInsets
button.flipInsetsForRightToLeftLayoutDirection()
}
var buttonConfig: UIButton.Configuration = .plain()
buttonConfig.contentInsets = Metrics.createPageButtonContentInsets
buttonConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer({ incoming in
var outgoing = incoming
outgoing.font = font
return outgoing
})
button.configuration = buttonConfig

return button
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,11 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
frameView.translatesAutoresizingMaskIntoConstraints = false
frameView.setTitle(Strings.cardFrameTitle)

// NOTE: Remove the logic when support for iOS 14 is dropped
if #available (iOS 15.0, *) {
// assign an empty closure so the button appears.
frameView.onEllipsisButtonTap = {
BlogDashboardAnalytics.trackContextualMenuAccessed(for: .prompts)
}
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
frameView.ellipsisButton.menu = contextMenu
} else {
// Show a fallback implementation using `MenuSheetViewController`.
// iOS 13 doesn't support showing UIMenu programmatically.
// iOS 14 doesn't support `UIDeferredMenuElement.uncached`.
frameView.onEllipsisButtonTap = { [weak self] in
BlogDashboardAnalytics.trackContextualMenuAccessed(for: .prompts)
self?.showMenuSheet()
}
frameView.onEllipsisButtonTap = {
BlogDashboardAnalytics.trackContextualMenuAccessed(for: .prompts)
}
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
frameView.ellipsisButton.menu = contextMenu

return frameView
}()
Expand Down Expand Up @@ -313,7 +301,6 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
return [defaultItems, [.learnMore(learnMoreTapped)]]
}

@available(iOS 15.0, *)
private var contextMenu: UIMenu {
return .init(title: String(), options: .displayInline, children: contextMenuItems.map { menuSection in
UIMenu(title: String(), options: .displayInline, children: [
Expand Down Expand Up @@ -526,27 +513,6 @@ private extension DashboardPromptsCardCell {
BloggingPromptsIntroductionPresenter(interactionType: .actionable(blog: blog)).present(from: presenterViewController)
}

// Fallback context menu implementation for iOS 13.
func showMenuSheet() {
guard let presenterViewController = presenterViewController else {
return
}
WPAnalytics.track(.promptsDashboardCardMenu)

let menuViewController = MenuSheetViewController(items: contextMenuItems.map { menuSection in
menuSection.map { $0.toMenuSheetItem }
})

menuViewController.modalPresentationStyle = .popover
if let popoverPresentationController = menuViewController.popoverPresentationController {
popoverPresentationController.delegate = presenterViewController
popoverPresentationController.sourceView = cardFrameView.ellipsisButton
popoverPresentationController.sourceRect = cardFrameView.ellipsisButton.bounds
}

presenterViewController.present(menuViewController, animated: true)
}

// MARK: Constants

struct Strings {
Expand Down Expand Up @@ -648,21 +614,6 @@ private extension DashboardPromptsCardCell {
}
}
}

var toMenuSheetItem: MenuSheetViewController.MenuItem {
switch self {
case .viewMore(let handler),
.skip(let handler),
.remove(let handler),
.learnMore(let handler):
return MenuSheetViewController.MenuItem(
title: title,
image: image,
destructive: menuAttributes.contains(.destructive),
handler: handler
)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ private extension QuickStartChecklistViewController {
navigationItem.standardAppearance = appearance
navigationItem.compactAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = appearance
}
navigationItem.compactScrollEdgeAppearance = appearance
}

func startObservingForQuickStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,6 @@ class CommentDetailViewController: UIViewController, NoResultsViewHost {
return appearance
}()

/// Convenience property that keeps track of whether the content has scrolled.
private var isContentScrolled: Bool = false {
didSet {
if isContentScrolled == oldValue {
return
}

// show blurred navigation bar when content is scrolled, or opaque style when the scroll position is at the top.
updateNavigationBarAppearance(isBlurred: isContentScrolled)
}
}

// MARK: Nav Bar Buttons

private(set) lazy var editBarButtonItem: UIBarButtonItem = {
Expand Down Expand Up @@ -380,26 +368,11 @@ private extension CommentDetailViewController {
}

func configureNavigationBar() {
if #available(iOS 15, *) {
// In iOS 15, to apply visual blur only when content is scrolled, keep the scrollEdgeAppearance unchanged as it applies to ALL navigation bars.
navigationItem.standardAppearance = blurredBarAppearance
} else {
// For iOS 14 and below, scrollEdgeAppearance only affects large title navigation bars. Therefore we need to manually detect if the content
// has been scrolled and change the appearance accordingly.
updateNavigationBarAppearance()
}

navigationItem.standardAppearance = blurredBarAppearance
navigationController?.navigationBar.isTranslucent = true
configureNavBarButton()
}

/// Updates the navigation bar style based on the `isBlurred` boolean parameter. The intent is to show a visual blur effect when the content is scrolled,
/// but reverts to opaque style when the scroll position is at the top. This method may be called multiple times since it's triggered by the `didSet`
/// property observer on the `isContentScrolled` property.
func updateNavigationBarAppearance(isBlurred: Bool = false) {
navigationItem.standardAppearance = isBlurred ? blurredBarAppearance : opaqueBarAppearance
}

func configureNavBarButton() {
var barItems: [UIBarButtonItem] = []
barItems.append(shareBarButtonItem)
Expand Down Expand Up @@ -1044,17 +1017,6 @@ extension CommentDetailViewController: UITableViewDelegate, UITableViewDataSourc
}

}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
// keep track of whether the content has scrolled or not. This is used to update the navigation bar style in iOS 14 and below.
// in iOS 15, we don't need to do this since it's been handled automatically; hence the early return.
if #available(iOS 15, *) {
return
}

isContentScrolled = scrollView.contentOffset.y > contentScrollThreshold
}

}

// MARK: - Reply Handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ struct DomainsDashboardView: View {

/// Builds the site address section for the given blog
private func makeSiteAddressSection(blog: Blog) -> some View {
Section(header: makeSiteAddressHeader(),
footer: Text(TextContent.primarySiteSectionFooter(blog.hasPaidPlan))) {
Section(footer: Text(TextContent.primarySiteSectionFooter(blog.hasPaidPlan))) {
VStack(alignment: .leading) {
Text(TextContent.siteAddressTitle)
Text(blog.freeSiteAddress)
Expand Down Expand Up @@ -129,13 +128,6 @@ struct DomainsDashboardView: View {
.foregroundColor(domain.domain.expirySoon || domain.domain.expired ? Color(UIColor.error) : Color(UIColor.textSubtle))
}

private func makeSiteAddressHeader() -> Divider? {
if #available(iOS 15, *) {
return nil
}
return Divider()
}

/// Instantiates the proper search depending if it's for claiming a free domain with a paid plan or purchasing a new one
private func makeDomainSearch(for blog: Blog, onDismiss: @escaping () -> Void) -> some View {
return DomainSuggestionViewControllerWrapper(
Expand Down
Loading