Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
let statusRowMode = self.determineStatusRowMode()

updateBannerAndHUDandStatusRows(statusRowMode: statusRowMode, newSize: currentContext.newSize, animated: animated)
tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: ActionTabBarMetrics.tableContentInset, right: 0)
updateTableBottomContentInset()

redrawCharts()

Expand Down Expand Up @@ -777,6 +777,17 @@ final class StatusTableViewController: LoopChartsTableViewController {

override func viewDidLayoutSubviews() {
updateStatusBar()
updateTableBottomContentInset()
}

private func updateTableBottomContentInset() {
let bottomInset = ActionTabBarMetrics.tableContentInset(
isLandscape: view.bounds.width > view.bounds.height,
bottomSafeAreaInset: view.safeAreaInsets.bottom
)
if tableView.contentInset.bottom != bottomInset {
tableView.contentInset.bottom = bottomInset
}
}

private func updateBannerRow(animated: Bool) {
Expand Down
54 changes: 18 additions & 36 deletions Loop/Views/StatusTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ struct ActionTabBar: UIViewRepresentable {
tag: idx
)
}
uiView.setNeedsLayout()
}

func makeCoordinator() -> Coordinator { Coordinator() }
Expand Down Expand Up @@ -259,24 +260,8 @@ enum ActionTabBarMetrics {

static let barHeight: CGFloat = 49

static var bottomSafeAreaInset: CGFloat {
UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first { $0.isKeyWindow }?
.safeAreaInsets.bottom ?? 0
}

static var interfaceOrientation: UIInterfaceOrientation {
let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
let scene = scenes.first { $0.windows.contains { $0.isKeyWindow } }
?? scenes.first { $0.activationState == .foregroundActive }
?? scenes.first
return scene?.interfaceOrientation ?? .portrait
}

static var tableContentInset: CGFloat {
guard !interfaceOrientation.isLandscape else { return 0 }
static func tableContentInset(isLandscape: Bool, bottomSafeAreaInset: CGFloat) -> CGFloat {
guard !isLandscape else { return 0 }
if #available(iOS 26.0, *), bottomSafeAreaInset == 0 {
return barHeight + 40
}
Expand All @@ -287,13 +272,14 @@ enum ActionTabBarMetrics {
struct LegacyTabBarBackground: ViewModifier {

var isVisible: Bool = true
var bottomSafeAreaInset: CGFloat = 0

func body(content: Content) -> some View {
if !isVisible {
content
.frame(height: 0)
} else if #available(iOS 26.0, *) {
if ActionTabBarMetrics.bottomSafeAreaInset == 0 {
if bottomSafeAreaInset == 0 {
content
.frame(height: ActionTabBarMetrics.barHeight)
.padding(.bottom, 16)
Expand All @@ -315,7 +301,7 @@ struct LegacyTabBarBackground: ViewModifier {

struct ActionTabView<Content: View>: View {

@State private var orientation: UIInterfaceOrientation
@Environment(\.verticalSizeClass) private var verticalSizeClass

private let content: Content
private let tabs: [ActionTab]
Expand All @@ -326,24 +312,20 @@ struct ActionTabView<Content: View>: View {
) {
self.content = content()
self.tabs = tabs()
self.orientation = ActionTabBarMetrics.interfaceOrientation
}

var body: some View {
content
.safeAreaInset(edge: .bottom, spacing: 0) {
ActionTabBar(items: tabs, isHidden: !orientation.isPortrait)
.modifier(LegacyTabBarBackground(isVisible: orientation.isPortrait))
}
.onAppear {
UIDevice.current.beginGeneratingDeviceOrientationNotifications()
orientation = ActionTabBarMetrics.interfaceOrientation
}
.onDisappear {
UIDevice.current.endGeneratingDeviceOrientationNotifications()
}
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
orientation = ActionTabBarMetrics.interfaceOrientation
}
let isPortrait = verticalSizeClass != .compact
return GeometryReader { geometry in
content
.safeAreaInset(edge: .bottom, spacing: 0) {
ActionTabBar(items: tabs, isHidden: !isPortrait)
.modifier(LegacyTabBarBackground(
isVisible: isPortrait,
bottomSafeAreaInset: geometry.safeAreaInsets.bottom
))
}
}
.ignoresSafeArea(.keyboard)
}
}