Skip to content

Commit 5877d50

Browse files
fix(mobile): the iPhone Duo's search field and composer line up with its tab bar
UIKit floats the Duo's tab bar 24pt above the bottom edge, below the 34pt safe area. The list's search field sat on the safe area, 10pt higher, and the composer added its 6pt gutter on top, 16pt higher, so the three bottoms differed. The layout metrics observer now also reports UIKit's bar layout region for a 48pt bar on the bottom edge (iOS 27.1), measured in each column. On the Duo the search field and the composer pill end on it, level with the tab bar, and the workspace list keeps its last row clear of the field. Other devices keep their safe-area placement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2b3f7fb commit 5877d50

7 files changed

Lines changed: 39 additions & 8 deletions

File tree

‎apps/mobile/modules/t3-native-controls/ios/T3LayoutMetricsView.swift‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ final class T3LayoutMetricsView: ExpoView {
6969
}
7070
var verticalBarEdge = "none"
7171
var regions: [[String: Any]] = []
72+
var bottomBarInset: CGFloat?
7273
#if canImport(UIKit, _version: 9127.0.85)
7374
if #available(iOS 27.1, *) {
7475
let rtl = effectiveUserInterfaceLayoutDirection == .rightToLeft
@@ -77,6 +78,8 @@ final class T3LayoutMetricsView: ExpoView {
7778
case .trailing: verticalBarEdge = rtl ? "left" : "right"
7879
default: break
7980
}
81+
// Where UIKit floats a bar as tall as the app's bottom controls, level with its tab bar.
82+
bottomBarInset = edgeInsets(for: .bar(onEdge: UIRectEdge.bottom, extent: 48)).bottom
8083
for kind in [UIView.ReservedRegion.Kind.division, .occlusion] {
8184
for region in reservedRegions(kind: kind) where region.isActive {
8285
let frame = region.frame.intersection(bounds)
@@ -90,7 +93,7 @@ final class T3LayoutMetricsView: ExpoView {
9093
}
9194
}
9295
#endif
93-
let metrics: [String: Any] = [
96+
var metrics: [String: Any] = [
9497
"width": bounds.width, "height": bounds.height,
9598
"hasHinge": hasHinge,
9699
"horizontalSizeClass": traitCollection.horizontalSizeClass == .regular ? "regular" : "compact",
@@ -101,6 +104,7 @@ final class T3LayoutMetricsView: ExpoView {
101104
],
102105
"reservedRegions": regions,
103106
]
107+
metrics["bottomBarInset"] = bottomBarInset
104108
let next = metrics as NSDictionary
105109
guard lastMetrics?.isEqual(next) != true else { return }
106110
lastMetrics = next

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ export function ComposerSurface(props: {
349349
);
350350
}
351351

352+
/** Space below the composer pill, inside the bottom inset it is given. */
353+
export const THREAD_COMPOSER_BOTTOM_GUTTER = 6;
354+
352355
export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps) {
353356
const project = useProject(scopeProjectRef(props.environmentId, props.selectedThread.projectId));
354357
const { themeVariables: materialTheme } = useAppearancePreferences();
@@ -804,7 +807,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
804807
className="px-[12px]"
805808
style={{
806809
paddingTop: usesCard ? 8 : 6,
807-
paddingBottom: (props.bottomInset ?? 0) + (usesCard ? 8 : 6),
810+
paddingBottom: (props.bottomInset ?? 0) + (usesCard ? 8 : THREAD_COMPOSER_BOTTOM_GUTTER),
808811
backgroundColor:
809812
Platform.OS === "android" ? themeColorWithAlpha(composerPanel, 1) : undefined,
810813
}}

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ import Animated, {
102102
import { useSafeAreaInsets } from "react-native-safe-area-context";
103103
import { useWorkspaceContentWidth } from "../layout/workspace-content-width";
104104
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
105-
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
105+
import {
106+
useDuoBottomBarInset,
107+
useNativeColumnLayoutMetrics,
108+
} from "../../native/native-layout-metrics";
106109
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
107110
import { collectProviderUsageLimits } from "@t3tools/shared/usageLimits";
108111
import type { ComposerEditorHandle } from "../../components/ComposerEditor";
@@ -159,6 +162,7 @@ import {
159162
COMPOSER_EXPANDED_CHROME,
160163
COMPOSER_LAYOUT_TRANSITION,
161164
COMPOSER_TRANSITION_DURATION_MS,
165+
THREAD_COMPOSER_BOTTOM_GUTTER,
162166
ThreadComposer,
163167
} from "./ThreadComposer";
164168
import { ComposerPopoverHost } from "./ComposerPopoverHost";
@@ -536,10 +540,13 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
536540
const [endFollowEnabled, setEndFollowEnabled] = useState(true);
537541
// Android Back hides the keyboard without blurring. Keep its safe-area padding
538542
// fixed through the animation and cancel it with matching composer/list offsets.
543+
const bottomBarInset = useDuoBottomBarInset();
539544
const composerBottomInset =
540545
Platform.OS === "ios" && (composerExpanded || composerFocused)
541546
? 0
542-
: Math.max(insets.bottom, 12);
547+
: bottomBarInset !== undefined
548+
? bottomBarInset - THREAD_COMPOSER_BOTTOM_GUTTER
549+
: Math.max(insets.bottom, 12);
543550
const composerKeyboardOffset = Platform.OS === "android" ? composerBottomInset : 0;
544551
const contentPresentationKind = props.contentPresentation.kind;
545552
const realThreadSyncLabel = (() => {

‎apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { NativeStackScreenOptions } from "../../native/StackHeader";
1111
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
1212
import {
1313
useDeviceType,
14+
useDuoBottomBarInset,
1415
useNativeColumnLayoutMetrics,
1516
useNativeLayoutMetrics,
1617
} from "../../native/native-layout-metrics";
@@ -70,6 +71,7 @@ function WorkspaceRootContent() {
7071
(nativeMetrics !== null && nativeMetrics.verticalBarEdge !== "none"));
7172
const width = columnMetrics?.width ?? windowWidth;
7273
const insets = useSafeAreaInsets();
74+
const bottomBarInset = useDuoBottomBarInset();
7375
const keyboardHeight = useKeyboardState((keyboard) => keyboard.height);
7476
const workspace = useWorkspaceTabs()!;
7577
const { state } = workspace;
@@ -90,7 +92,9 @@ function WorkspaceRootContent() {
9092
const tab = state.tabs[state.selectedTab];
9193
const bottomClearance =
9294
Platform.OS === "ios" && isDuoDevice(deviceType)
93-
? Math.max(insets.bottom, 12, keyboardHeight + 8) + WORKSPACE_TOOLBAR.height + 16
95+
? Math.max(bottomBarInset ?? Math.max(insets.bottom, 12), keyboardHeight + 8) +
96+
WORKSPACE_TOOLBAR.height +
97+
16
9498
: Platform.OS === "ios"
9599
? Math.max(insets.bottom, keyboardHeight) +
96100
(systemTabBar || sidebarTabs || tab.searchMode !== "resting"

‎apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller
66
import Animated, { useAnimatedStyle } from "react-native-reanimated";
77
import { useSafeAreaInsets } from "react-native-safe-area-context";
88
import { isDuoDevice } from "../../lib/device-type";
9-
import { useDeviceType } from "../../native/native-layout-metrics";
9+
import { useDeviceType, useDuoBottomBarInset } from "../../native/native-layout-metrics";
1010
import type { SearchBarCommands } from "react-native-screens";
1111

1212
import { SymbolView } from "../../components/ui/AppSymbol";
@@ -75,6 +75,7 @@ export function WorkspaceToolbar(props: {
7575
// each fold replaces the search field.
7676
const listSearch = isDuoDevice(deviceType);
7777
const insets = useSafeAreaInsets();
78+
const bottomBarInset = useDuoBottomBarInset();
7879
const { isTabActive } = workspace;
7980
const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
8081
const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
@@ -216,7 +217,7 @@ export function WorkspaceToolbar(props: {
216217
) : null}
217218
</Toolbar>
218219
{listSearch ? (
219-
<AboveKeyboard bottom={Math.max(insets.bottom, 12)}>
220+
<AboveKeyboard bottom={bottomBarInset ?? Math.max(insets.bottom, 12)}>
220221
<WorkspaceSearchField
221222
ref={fieldRef}
222223
tab={selectedTab}

‎apps/mobile/src/lib/reserved-regions.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface NativeLayoutMetrics {
1919
readonly right: number;
2020
};
2121
readonly reservedRegions: ReadonlyArray<ReservedRegion>;
22+
/** How far above the bottom edge UIKit floats a 48pt bottom bar, level with its tab bar. iOS 27.1+. */
23+
readonly bottomBarInset?: number;
2224
}
2325

2426
export function deriveBottomControlInsets(metrics: NativeLayoutMetrics | null) {

‎apps/mobile/src/native/native-layout-metrics.tsx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createContext, use, useState, type ReactNode } from "react";
22
import { Platform } from "react-native";
3-
import { deriveDeviceType, type DeviceType } from "../lib/device-type";
3+
import { deriveDeviceType, isDuoDevice, type DeviceType } from "../lib/device-type";
44
import type { NativeLayoutMetrics } from "../lib/reserved-regions";
55
import { NativeLayoutObserver } from "./NativeLayoutObserver";
66

@@ -38,3 +38,13 @@ export function useNativeColumnLayoutMetrics() {
3838
export function useDeviceType() {
3939
return use(DeviceTypeContext);
4040
}
41+
42+
/**
43+
* Where the Duo's floating bottom controls end in this column. Its tab bar floats below the safe
44+
* area, and the controls beside it sit on the same line.
45+
*/
46+
export function useDuoBottomBarInset() {
47+
const deviceType = useDeviceType();
48+
const inset = use(NativeColumnLayoutMetricsContext)?.bottomBarInset;
49+
return isDuoDevice(deviceType) ? inset : undefined;
50+
}

0 commit comments

Comments
 (0)