diff --git a/Passepartout-iOS/Base.lproj/Main.storyboard b/Passepartout-iOS/Base.lproj/Main.storyboard index 2fc620a7..f9056474 100644 --- a/Passepartout-iOS/Base.lproj/Main.storyboard +++ b/Passepartout-iOS/Base.lproj/Main.storyboard @@ -398,43 +398,37 @@ - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/Passepartout-iOS/Scenes/DebugLogViewController.swift b/Passepartout-iOS/Scenes/DebugLogViewController.swift index 0721c13a..f9705529 100644 --- a/Passepartout-iOS/Scenes/DebugLogViewController.swift +++ b/Passepartout-iOS/Scenes/DebugLogViewController.swift @@ -30,8 +30,8 @@ import Passepartout_Core private let log = SwiftyBeaver.self class DebugLogViewController: UIViewController { - @IBOutlet private weak var textLog: UITextView! - + @IBOutlet private weak var textLog: UITextView? + private let vpn = VPN.shared deinit { @@ -44,11 +44,16 @@ class DebugLogViewController: UIViewController { applyDetailTitle(Theme.current) } + // MARK: UIViewController + override func viewDidLoad() { super.viewDidLoad() title = L10n.Service.Cells.DebugLog.caption - textLog.contentInsetAdjustmentBehavior = .never + textLog?.contentInsetAdjustmentBehavior = .never + + let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(toggleBars)) + textLog?.addGestureRecognizer(tapGestureRecognizer) NotificationCenter.default.addObserver(self, selector: #selector(vpnDidPrepare), name: .VPNDidPrepare, object: nil) if vpn.isPrepared { @@ -56,8 +61,29 @@ class DebugLogViewController: UIViewController { } } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + navigationController?.isToolbarHidden = false + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + + navigationController?.isToolbarHidden = true + } + + // MARK: Actions + + @objc private func toggleBars() { + let nav = navigationController + let isHidden = nav?.isToolbarHidden ?? true +// nav?.setNavigationBarHidden(!isHidden, animated: true) + nav?.setToolbarHidden(!isHidden, animated: true) + } + @IBAction private func share(_ sender: Any?) { - guard let raw = textLog.text, !raw.isEmpty else { + guard let raw = textLog?.text, !raw.isEmpty else { let alert = Macros.alert(title, L10n.DebugLog.Alerts.EmptyLog.message) alert.addCancelAction(L10n.Global.ok) present(alert, animated: true, completion: nil) @@ -82,19 +108,19 @@ class DebugLogViewController: UIViewController { } @IBAction private func previousSession() { - textLog.findPrevious(string: GroupConstants.VPN.sessionMarker) + textLog?.findPrevious(string: GroupConstants.VPN.sessionMarker) } @IBAction private func nextSession() { - textLog.findNext(string: GroupConstants.VPN.sessionMarker) + textLog?.findNext(string: GroupConstants.VPN.sessionMarker) } - + private func startRefreshingLog() { vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) { - self.textLog.text = $0 + self.textLog?.text = $0 DispatchQueue.main.async { - self.textLog.scrollToEnd() + self.textLog?.scrollToEnd() self.refreshLogInBackground() } } @@ -114,7 +140,7 @@ class DebugLogViewController: UIViewController { } vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) { - self.textLog.text = $0 + self.textLog?.text = $0 updateBlock() } }