Compare commits
No commits in common. "3990997e6ea45b21b727eb22c75893f22f24945b" and "73ab2136313a9b5eea23759ab4995c16c03607e1" have entirely different histories.
3990997e6e
...
73ab213631
|
@ -2,8 +2,6 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<true/>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.activate-account</string>
|
||||
|
|
|
@ -71,7 +71,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(updateAppearance), name: .appearanceChanged, object: nil)
|
||||
updateAppearance()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(logoutIfNecessary), name: .logoutAccount, object: nil)
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
|
@ -258,21 +257,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
syncFromServer()
|
||||
}
|
||||
|
||||
@objc private func logoutIfNecessary(_ notification: Notification) {
|
||||
guard let account = notification.object as? LocalData.Account else {
|
||||
return
|
||||
}
|
||||
if fervorController.account?.id == account.id {
|
||||
if let next = LocalData.mostRecentAccount() ?? LocalData.accounts.first {
|
||||
Task {
|
||||
await switchToAccount(next)
|
||||
}
|
||||
} else {
|
||||
createLoginUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension SceneDelegate: LoginViewControllerDelegate {
|
||||
|
@ -323,7 +307,3 @@ extension SceneDelegate: NSToolbarDelegate {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
extension Notification.Name {
|
||||
static let logoutAccount = Notification.Name("logoutAccount")
|
||||
}
|
||||
|
|
|
@ -13,14 +13,6 @@ class AppNavigationController: UINavigationController, UINavigationControllerDel
|
|||
|
||||
static let panRecognizerName = "AppNavPanRecognizer"
|
||||
|
||||
override var childForStatusBarHidden: UIViewController? {
|
||||
topViewController
|
||||
}
|
||||
|
||||
override var childForStatusBarStyle: UIViewController? {
|
||||
topViewController
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
@ -32,7 +24,6 @@ class AppNavigationController: UINavigationController, UINavigationControllerDel
|
|||
let recognizer = UIPanGestureRecognizer(target: self, action: #selector(panGestureRecognized))
|
||||
recognizer.allowedScrollTypesMask = .continuous
|
||||
recognizer.name = AppNavigationController.panRecognizerName
|
||||
recognizer.delegate = self
|
||||
view.addGestureRecognizer(recognizer)
|
||||
|
||||
isNavigationBarHidden = true
|
||||
|
@ -53,12 +44,7 @@ class AppNavigationController: UINavigationController, UINavigationControllerDel
|
|||
}
|
||||
|
||||
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
|
||||
statusBarBlockingView.layer.opacity = viewController.prefersStatusBarHidden ? 0 : 1
|
||||
}
|
||||
|
||||
override func setNeedsStatusBarAppearanceUpdate() {
|
||||
super.setNeedsStatusBarAppearanceUpdate()
|
||||
statusBarBlockingView?.layer.opacity = childForStatusBarHidden!.prefersStatusBarHidden ? 0 : 1
|
||||
statusBarBlockingView.isHidden = viewController.prefersStatusBarHidden
|
||||
}
|
||||
|
||||
private var poppingViewController: UIViewController?
|
||||
|
@ -141,13 +127,3 @@ class AppNavigationController: UINavigationController, UINavigationControllerDel
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
extension AppNavigationController: UIGestureRecognizerDelegate {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if String(describing: type(of: otherGestureRecognizer)) == "_UISwipeActionPanGestureRecognizer" {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,6 @@ class AppSplitViewController: UISplitViewController {
|
|||
|
||||
private var secondaryNav: UINavigationController!
|
||||
|
||||
override var childForStatusBarHidden: UIViewController? {
|
||||
if traitCollection.horizontalSizeClass == .compact {
|
||||
return viewController(for: .compact)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
init(fervorController: FervorController) {
|
||||
self.fervorController = fervorController
|
||||
|
||||
|
|
|
@ -306,21 +306,12 @@ extension HomeViewController: StretchyMenuInteractionDelegate {
|
|||
title += ":\(port)"
|
||||
}
|
||||
let subtitle = account.id == fervorController.account!.id ? "Currently logged in" : nil
|
||||
let menu = UIMenu(children: [
|
||||
UIAction(title: "Log Out", image: UIImage(systemName: "door.left.hand.open"), handler: { _ in
|
||||
guard let index = LocalData.accounts.firstIndex(where: { $0.id == account.id }) else {
|
||||
return
|
||||
}
|
||||
LocalData.accounts.remove(at: index)
|
||||
NotificationCenter.default.post(name: .logoutAccount, object: account)
|
||||
})
|
||||
])
|
||||
return StretchyMenuItem(title: title, subtitle: subtitle, menu: menu) { [unowned self] in
|
||||
return StretchyMenuItem(title: title, subtitle: subtitle) { [unowned self] in
|
||||
guard account.id != self.fervorController.account!.id else { return }
|
||||
self.delegate?.switchToAccount(account)
|
||||
}
|
||||
}
|
||||
items.append(StretchyMenuItem(title: "Add Account", action: { [unowned self] in
|
||||
items.append(StretchyMenuItem(title: "Add Account", subtitle: nil, action: { [unowned self] in
|
||||
let login = LoginViewController()
|
||||
login.delegate = self
|
||||
login.navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .cancel, primaryAction: UIAction(handler: { (_) in
|
||||
|
|
|
@ -30,14 +30,12 @@ class ReadViewController: UIViewController {
|
|||
|
||||
private var webView: WKWebView!
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private var itemReadObservation: NSKeyValueObservation?
|
||||
#endif
|
||||
|
||||
override var prefersStatusBarHidden: Bool {
|
||||
if navigationController?.isNavigationBarHidden == true,
|
||||
let webView,
|
||||
webView.scrollView.contentOffset.y > -webView.scrollView.safeAreaInsets.top {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
navigationController?.isNavigationBarHidden ?? false
|
||||
}
|
||||
|
||||
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
|
||||
|
@ -74,7 +72,10 @@ class ReadViewController: UIViewController {
|
|||
webView.isOpaque = false
|
||||
webView.backgroundColor = .clear
|
||||
if #available(iOS 16.0, *) {
|
||||
// TODO: Xcode 14 RC doesn't have the macOS 13 SDK, so we can't use this
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
webView.isFindInteractionEnabled = true
|
||||
#endif
|
||||
}
|
||||
if let content = itemContentHTML() {
|
||||
webView.loadHTMLString(content, baseURL: item.url)
|
||||
|
@ -97,18 +98,6 @@ class ReadViewController: UIViewController {
|
|||
activityItemsConfiguration = UIActivityItemsConfiguration(objects: [url as NSURL])
|
||||
}
|
||||
|
||||
webView.scrollView.publisher(for: \.contentOffset)
|
||||
.map { [unowned self] _ in
|
||||
self.prefersStatusBarHidden
|
||||
}
|
||||
.removeDuplicates()
|
||||
.sink { [unowned self] _ in
|
||||
UIView.animate(withDuration: 0.2, delay: 0) {
|
||||
self.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
scrollPositionChangedSubject
|
||||
.debounce(for: .milliseconds(500), scheduler: RunLoop.main)
|
||||
.sink { [unowned self] in
|
||||
|
@ -117,11 +106,9 @@ class ReadViewController: UIViewController {
|
|||
.store(in: &cancellables)
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
item.publisher(for: \.read)
|
||||
.sink { [unowned self] _ in
|
||||
self.updateToggleReadToolbarImage()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
itemReadObservation = item.observe(\.read) { [unowned self] _, _ in
|
||||
self.updateToggleReadToolbarImage()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -393,7 +380,7 @@ extension ReadViewController: StretchyMenuInteractionDelegate {
|
|||
return []
|
||||
}
|
||||
var items = [
|
||||
StretchyMenuItem(title: "Open in Safari", action: { [unowned self] in
|
||||
StretchyMenuItem(title: "Open in Safari", subtitle: nil, action: { [unowned self] in
|
||||
self.present(createSafariVC(url: url), animated: true)
|
||||
}),
|
||||
StretchyMenuItem(title: item.read ? "Mark as Unread" : "Mark as Read", subtitle: nil, action: { [unowned self] in
|
||||
|
@ -403,7 +390,7 @@ extension ReadViewController: StretchyMenuInteractionDelegate {
|
|||
}),
|
||||
]
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
items.insert(StretchyMenuItem(title: "Share", action: { [unowned self] in
|
||||
items.insert(StretchyMenuItem(title: "Share", subtitle: nil, action: { [unowned self] in
|
||||
self.present(UIActivityViewController(activityItems: [url], applicationActivities: nil), animated: true)
|
||||
}), at: 1)
|
||||
#endif
|
||||
|
|
|
@ -10,15 +10,7 @@ import UIKit
|
|||
struct StretchyMenuItem {
|
||||
let title: String
|
||||
let subtitle: String?
|
||||
let menu: UIMenu?
|
||||
let action: () -> Void
|
||||
|
||||
init(title: String, subtitle: String? = nil, menu: UIMenu? = nil, action: @escaping () -> Void) {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.menu = menu
|
||||
self.action = action
|
||||
}
|
||||
}
|
||||
|
||||
protocol StretchyMenuInteractionDelegate: AnyObject {
|
||||
|
@ -358,10 +350,6 @@ private class MenuItemView: UIView {
|
|||
])
|
||||
}
|
||||
|
||||
if item.menu != nil {
|
||||
addInteraction(UIContextMenuInteraction(delegate: self))
|
||||
}
|
||||
|
||||
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemTapped)))
|
||||
}
|
||||
|
||||
|
@ -415,11 +403,3 @@ private class MenuItemView: UIView {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
extension MenuItemView: UIContextMenuInteractionDelegate {
|
||||
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
|
||||
return UIContextMenuConfiguration(actionProvider: { [unowned self] _ in
|
||||
return self.item.menu!
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue