diff --git a/ios/App/App/LiquidTabsPlugin.swift b/ios/App/App/LiquidTabsPlugin.swift index 92e7aec585..dfee3a5d34 100644 --- a/ios/App/App/LiquidTabsPlugin.swift +++ b/ios/App/App/LiquidTabsPlugin.swift @@ -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 } } diff --git a/src/main/frontend/mobile/util.cljs b/src/main/frontend/mobile/util.cljs index ed1e4e0cfd..0245200198 100644 --- a/src/main/frontend/mobile/util.cljs +++ b/src/main/frontend/mobile/util.cljs @@ -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?