mirror of
https://github.com/logseq/logseq.git
synced 2026-05-24 20:54:09 +00:00
fix: keep search visible on iOS tabs
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import Foundation
|
||||
import Capacitor
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
import WebKit
|
||||
|
||||
@objc(LiquidTabsPlugin)
|
||||
public class LiquidTabsPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
// So SwiftUI can notify JS
|
||||
static weak var shared: LiquidTabsPlugin?
|
||||
private static let maxPhoneContentTabs = 4
|
||||
|
||||
private let store = LiquidTabsStore.shared
|
||||
private var keyboardHackScriptInstalled = false
|
||||
@@ -28,6 +30,14 @@ public class LiquidTabsPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
installKeyboardHackScript()
|
||||
}
|
||||
|
||||
private static func visibleContentTabs(_ tabs: [LiquidTab]) -> [LiquidTab] {
|
||||
guard UIDevice.current.userInterfaceIdiom == .phone else {
|
||||
return tabs
|
||||
}
|
||||
|
||||
return Array(tabs.prefix(maxPhoneContentTabs))
|
||||
}
|
||||
|
||||
// MARK: - Methods from JS
|
||||
|
||||
/// Configure tabs from JS.
|
||||
@@ -63,12 +73,13 @@ public class LiquidTabsPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
let selectedId = self.store.selectedId
|
||||
self.store.tabs = tabs
|
||||
let visibleTabs = Self.visibleContentTabs(tabs)
|
||||
self.store.tabs = visibleTabs
|
||||
if let selectedId = selectedId,
|
||||
selectedId == "search" || tabs.contains(where: { $0.id == selectedId }) {
|
||||
selectedId == "search" || visibleTabs.contains(where: { $0.id == selectedId }) {
|
||||
self.store.selectedId = selectedId
|
||||
} else {
|
||||
self.store.selectedId = tabs.first?.id
|
||||
self.store.selectedId = visibleTabs.first?.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,11 @@
|
||||
(let [width (.-width js/screen)
|
||||
height (.-height js/screen)
|
||||
landscape? (> width height)
|
||||
[width height] (if landscape? [height width] [width height])]
|
||||
[width height] (if landscape? [height width] [width height])
|
||||
fallback-model (if (and (<= 320 width 600)
|
||||
(<= 568 height 1000))
|
||||
"iPhone"
|
||||
"Not a known Apple device!")]
|
||||
[(case [width height]
|
||||
;; The following list is from:
|
||||
;; - https://useyourloaf.com/blog/ipad-2024-screen-sizes/
|
||||
@@ -121,7 +125,7 @@
|
||||
[1024 1366] "iPadPro12.9"
|
||||
[1032 1376] "iPadPro13(M4)"
|
||||
[834 1210] "iPadPro11(M4)"
|
||||
"Not a known Apple device!")
|
||||
fallback-model)
|
||||
landscape?])))
|
||||
|
||||
(defn native-iphone-without-notch?
|
||||
|
||||
Reference in New Issue
Block a user