Repository: Automattic/pocket-casts-ios
File: podcasts/PodcastListViewController+Tip.swift (Swift)

Code before:
import SwiftUI
import PocketCastsUtils

extension PodcastListViewController: UIPopoverPresentationControllerDelegate {
    func showRecentlyPlayedSortingTipIfNeeded() {
        guard
            Settings.shouldShowRecentlyPlayedSortingTip,
            FeatureFlag.podcastsSortChanges.enabled,
            recentlyPlayedSortingTip == nil
        else {
            return
        }
        if let vc = showRecentlyPlayedSortingTip() {
            present(vc, animated: true) {
                Analytics.track(.episodeRecentlyPlayedSortOptionTooltipShown)
            }
            recentlyPlayedSortingTip = vc
        }
    }

    private func showRecentlyPlayedSortingTip() -> UIViewController? {
        guard let button = customRightBtn else {
            return nil
        }
        let vc = UIHostingController(rootView: AnyView (EmptyView()) )
        let idealSize = CGSizeMake(290, 100)
        let tipView = TipViewStatic(title: L10n.podcastsLibrarySortEpisodeRecentlyPlayedTipTitle,
                                    message: L10n.podcastsLibrarySortEpisodeRecentlyPlayedTipDescription,
                                    showClose: true,
                              onTap: { [weak self] in
            self?.dismissRecentlyPlayedSortingTip()
        })
            .frame(idealWidth: idealSize.width, minHeight: idealSize.height)
            .setupDefaultEnvironment()
        vc.rootView = AnyView(tipView)
        vc.view.backgroundColor = .clear
        vc.view.clipsToBounds = false
        vc.modalPresentationStyle = .popover
        if #available(iOS 16.0, *) {
            vc.sizingOptions = [.preferredContentSize]
        } else {
            vc.preferredContentSize = idealSize
        }
        if let popoverPresentationController = vc.popoverPresentationController {
            popoverPresentationController.delegate = self
            popoverPresentationController.permittedArrowDirections = [.up]
            if #available(iOS 16.0, *) {
                popoverPresentationController.sourceItem = button
            } else {
                popoverPresentationController.barButtonItem = button
            }

Review comment (suggestion):
⛏️ Could use the swiftier `CGSize` here:
```suggestion
        let idealSize = CGSize(290, 100)
```

Code after:
import SwiftUI
import PocketCastsUtils

extension PodcastListViewController: UIPopoverPresentationControllerDelegate {
    func showRecentlyPlayedSortingTipIfNeeded() {
        guard
            Settings.shouldShowRecentlyPlayedSortingTip,
            FeatureFlag.podcastsSortChanges.enabled,
            recentlyPlayedSortingTip == nil
        else {
            return
        }
        if let vc = showRecentlyPlayedSortingTip() {
            present(vc, animated: true) {
                Analytics.track(.episodeRecentlyPlayedSortOptionTooltipShown)
            }
            recentlyPlayedSortingTip = vc
        }
    }

    private func showRecentlyPlayedSortingTip() -> UIViewController? {
        guard let button = customRightBtn else {
            return nil
        }
        let idealSize = CGSize(width: 300, height: 120)
        let tipView = TipViewStatic(title: L10n.podcastsLibrarySortEpisodeRecentlyPlayedTipTitle,
                                    message: L10n.podcastsLibrarySortEpisodeRecentlyPlayedTipDescription,
                                    showClose: true,
                              onTap: { [weak self] in
            self?.dismissRecentlyPlayedSortingTip()
        })
            .frame(maxWidth: idealSize.width, minHeight: idealSize.height)
            .setupDefaultEnvironment()
        let vc = UIHostingController(rootView: tipView)
        vc.view.backgroundColor = .clear
        vc.view.clipsToBounds = false
        vc.modalPresentationStyle = .popover
        if #available(iOS 16.0, *) {
            vc.sizingOptions = [.preferredContentSize]
        } else {
            vc.preferredContentSize = idealSize
        }
        if let popoverPresentationController = vc.popoverPresentationController {
            popoverPresentationController.delegate = self
            popoverPresentationController.permittedArrowDirections = [.up]
            if #available(iOS 16.0, *) {
                popoverPresentationController.sourceItem = button
            } else {
                popoverPresentationController.barButtonItem = button
            }
            popoverPresentationController.backgroundColor = ThemeColor.primaryUi01()